2013-03-06 00:23:34 +04:00
|
|
|
/*
|
2016-09-02 00:32:49 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2013-03-06 00:23:34 +04:00
|
|
|
*
|
2016-09-02 00:32:49 +03:00
|
|
|
* This source code is subject to the terms of the BSD 2 Clause License and
|
|
|
|
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
|
|
|
* was not distributed with this source code in the LICENSE file, you can
|
|
|
|
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
|
|
|
* Media Patent License 1.0 was not distributed with this source code in the
|
|
|
|
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
|
|
|
*/
|
|
|
|
|
2013-03-06 00:23:34 +04:00
|
|
|
#include <climits>
|
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
|
|
|
#include "test/codec_factory.h"
|
|
|
|
#include "test/encode_test_driver.h"
|
|
|
|
#include "test/i420_video_source.h"
|
|
|
|
#include "test/util.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2015-10-21 17:24:49 +03:00
|
|
|
const int kTestMode = 0;
|
|
|
|
const int kSuperframeSyntax = 1;
|
2016-05-03 20:25:01 +03:00
|
|
|
const int kTileCols = 2;
|
|
|
|
const int kTileRows = 3;
|
2015-10-21 17:24:49 +03:00
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
typedef std::tr1::tuple<libaom_test::TestMode, int, int, int>
|
2016-08-12 03:46:05 +03:00
|
|
|
SuperframeTestParam;
|
2015-10-21 17:24:49 +03:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
class SuperframeTest
|
2016-08-23 02:08:15 +03:00
|
|
|
: public ::libaom_test::EncoderTest,
|
|
|
|
public ::libaom_test::CodecTestWithParam<SuperframeTestParam> {
|
2013-03-06 00:23:34 +04:00
|
|
|
protected:
|
2016-08-12 03:46:05 +03:00
|
|
|
SuperframeTest()
|
|
|
|
: EncoderTest(GET_PARAM(0)), modified_buf_(NULL), last_sf_pts_(0) {}
|
2014-03-13 01:51:42 +04:00
|
|
|
virtual ~SuperframeTest() {}
|
2013-03-06 00:23:34 +04:00
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
InitializeConfig();
|
2015-10-21 17:24:49 +03:00
|
|
|
const SuperframeTestParam input = GET_PARAM(1);
|
2016-08-23 02:08:15 +03:00
|
|
|
const libaom_test::TestMode mode = std::tr1::get<kTestMode>(input);
|
2015-10-21 17:24:49 +03:00
|
|
|
const int syntax = std::tr1::get<kSuperframeSyntax>(input);
|
|
|
|
SetMode(mode);
|
2013-03-06 00:23:34 +04:00
|
|
|
sf_count_ = 0;
|
|
|
|
sf_count_max_ = INT_MAX;
|
2016-08-31 00:01:10 +03:00
|
|
|
is_av1_style_superframe_ = syntax;
|
2016-05-03 20:25:01 +03:00
|
|
|
n_tile_cols_ = std::tr1::get<kTileCols>(input);
|
|
|
|
n_tile_rows_ = std::tr1::get<kTileRows>(input);
|
2013-03-06 00:23:34 +04:00
|
|
|
}
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
virtual void TearDown() { delete[] modified_buf_; }
|
2013-03-06 00:23:34 +04:00
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
virtual void PreEncodeFrameHook(libaom_test::VideoSource *video,
|
|
|
|
libaom_test::Encoder *encoder) {
|
2013-03-06 00:23:34 +04:00
|
|
|
if (video->frame() == 1) {
|
2016-08-31 00:01:10 +03:00
|
|
|
encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
|
|
|
|
encoder->Control(AOME_SET_CPUUSED, 2);
|
|
|
|
encoder->Control(AV1E_SET_TILE_COLUMNS, n_tile_cols_);
|
|
|
|
encoder->Control(AV1E_SET_TILE_ROWS, n_tile_rows_);
|
2013-03-06 00:23:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
virtual const aom_codec_cx_pkt_t *MutateEncoderOutputHook(
|
|
|
|
const aom_codec_cx_pkt_t *pkt) {
|
|
|
|
if (pkt->kind != AOM_CODEC_CX_FRAME_PKT) return pkt;
|
2013-03-06 00:23:34 +04:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
const uint8_t *buffer = reinterpret_cast<uint8_t *>(pkt->data.frame.buf);
|
2013-03-06 00:23:34 +04:00
|
|
|
const uint8_t marker = buffer[pkt->data.frame.sz - 1];
|
|
|
|
const int frames = (marker & 0x7) + 1;
|
|
|
|
const int mag = ((marker >> 3) & 3) + 1;
|
2016-08-31 00:01:10 +03:00
|
|
|
const unsigned int index_sz = 2 + mag * (frames - is_av1_style_superframe_);
|
2016-08-12 03:46:05 +03:00
|
|
|
if ((marker & 0xe0) == 0xc0 && pkt->data.frame.sz >= index_sz &&
|
2013-03-06 00:23:34 +04:00
|
|
|
buffer[pkt->data.frame.sz - index_sz] == marker) {
|
|
|
|
// frame is a superframe. strip off the index.
|
2016-08-12 03:46:05 +03:00
|
|
|
if (modified_buf_) delete[] modified_buf_;
|
2013-03-06 00:23:34 +04:00
|
|
|
modified_buf_ = new uint8_t[pkt->data.frame.sz - index_sz];
|
2016-08-12 03:46:05 +03:00
|
|
|
memcpy(modified_buf_, pkt->data.frame.buf, pkt->data.frame.sz - index_sz);
|
2013-03-06 00:23:34 +04:00
|
|
|
modified_pkt_ = *pkt;
|
|
|
|
modified_pkt_.data.frame.buf = modified_buf_;
|
|
|
|
modified_pkt_.data.frame.sz -= index_sz;
|
|
|
|
|
|
|
|
sf_count_++;
|
|
|
|
last_sf_pts_ = pkt->data.frame.pts;
|
|
|
|
return &modified_pkt_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we do a few frames after the last SF
|
2016-08-12 03:46:05 +03:00
|
|
|
abort_ |=
|
|
|
|
sf_count_ > sf_count_max_ && pkt->data.frame.pts - last_sf_pts_ >= 5;
|
2013-03-06 00:23:34 +04:00
|
|
|
return pkt;
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
int is_av1_style_superframe_;
|
2013-03-06 00:23:34 +04:00
|
|
|
int sf_count_;
|
|
|
|
int sf_count_max_;
|
2016-08-31 00:01:10 +03:00
|
|
|
aom_codec_cx_pkt_t modified_pkt_;
|
2013-03-06 00:23:34 +04:00
|
|
|
uint8_t *modified_buf_;
|
2016-08-31 00:01:10 +03:00
|
|
|
aom_codec_pts_t last_sf_pts_;
|
2016-05-03 20:25:01 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
int n_tile_cols_;
|
|
|
|
int n_tile_rows_;
|
2013-03-06 00:23:34 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(SuperframeTest, TestSuperframeIndexIsOptional) {
|
|
|
|
sf_count_max_ = 0; // early exit on successful test.
|
|
|
|
cfg_.g_lag_in_frames = 25;
|
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
|
2013-03-06 00:23:34 +04:00
|
|
|
30, 1, 0, 40);
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
2016-07-18 21:28:31 +03:00
|
|
|
#if CONFIG_EXT_REFS
|
2016-06-16 01:39:51 +03:00
|
|
|
// NOTE: The use of BWDREF_FRAME will enable the coding of more non-show
|
|
|
|
// frames besides ALTREF_FRAME.
|
|
|
|
EXPECT_GE(sf_count_, 1);
|
|
|
|
#else
|
2013-03-06 00:23:34 +04:00
|
|
|
EXPECT_EQ(sf_count_, 1);
|
2016-07-18 21:28:31 +03:00
|
|
|
#endif // CONFIG_EXT_REFS
|
2013-03-06 00:23:34 +04:00
|
|
|
}
|
|
|
|
|
2016-04-13 04:33:07 +03:00
|
|
|
// The superframe index is currently mandatory with ANS due to the decoder
|
|
|
|
// starting at the end of the buffer.
|
2016-05-03 20:25:01 +03:00
|
|
|
#if CONFIG_EXT_TILE
|
|
|
|
// Single tile does not work with ANS (see comment above).
|
|
|
|
#if CONFIG_ANS
|
|
|
|
const int tile_col_values[] = { 1, 2 };
|
|
|
|
#else
|
|
|
|
const int tile_col_values[] = { 1, 2, 32 };
|
|
|
|
#endif
|
|
|
|
const int tile_row_values[] = { 1, 2, 32 };
|
2016-08-31 00:01:10 +03:00
|
|
|
AV1_INSTANTIATE_TEST_CASE(
|
2016-08-12 03:46:05 +03:00
|
|
|
SuperframeTest,
|
2016-08-23 02:08:15 +03:00
|
|
|
::testing::Combine(::testing::Values(::libaom_test::kTwoPassGood),
|
2016-08-12 03:46:05 +03:00
|
|
|
::testing::Values(1),
|
|
|
|
::testing::ValuesIn(tile_col_values),
|
|
|
|
::testing::ValuesIn(tile_row_values)));
|
2016-05-03 20:25:01 +03:00
|
|
|
#else
|
2016-04-13 04:33:07 +03:00
|
|
|
#if !CONFIG_ANS
|
2016-08-31 00:01:10 +03:00
|
|
|
AV1_INSTANTIATE_TEST_CASE(
|
2016-08-12 03:46:05 +03:00
|
|
|
SuperframeTest,
|
2016-08-23 02:08:15 +03:00
|
|
|
::testing::Combine(::testing::Values(::libaom_test::kTwoPassGood),
|
2016-08-12 03:46:05 +03:00
|
|
|
::testing::Values(1), ::testing::Values(0),
|
|
|
|
::testing::Values(0)));
|
2016-05-03 20:25:01 +03:00
|
|
|
#endif // !CONFIG_ANS
|
|
|
|
#endif // CONFIG_EXT_TILE
|
2013-03-06 00:23:34 +04:00
|
|
|
} // namespace
|