2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
15 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
16 #include "test/codec_factory.h"
17 #include "test/encode_test_driver.h"
18 #include "test/i420_video_source.h"
19 #include "test/util.h"
20 #include "test/md5_helper.h"
21 #include "aom_mem/aom_mem.h"
24 class TileIndependenceTest
25 : public ::libaom_test::CodecTestWith2Params
<int, int>,
26 public ::libaom_test::EncoderTest
{
28 TileIndependenceTest()
29 : EncoderTest(GET_PARAM(0)), md5_fw_order_(), md5_inv_order_(),
30 n_tile_cols_(GET_PARAM(1)), n_tile_rows_(GET_PARAM(2)) {
31 init_flags_
= AOM_CODEC_USE_PSNR
;
32 aom_codec_dec_cfg_t cfg
= aom_codec_dec_cfg_t();
36 cfg
.allow_lowbitdepth
= 1;
37 fw_dec_
= codec_
->CreateDecoder(cfg
, 0);
38 inv_dec_
= codec_
->CreateDecoder(cfg
, 0);
39 inv_dec_
->Control(AV1_INVERT_TILE_DECODE_ORDER
, 1);
42 if (fw_dec_
->IsAV1() && inv_dec_
->IsAV1()) {
43 fw_dec_
->Control(AV1_SET_DECODE_TILE_ROW
, -1);
44 fw_dec_
->Control(AV1_SET_DECODE_TILE_COL
, -1);
45 inv_dec_
->Control(AV1_SET_DECODE_TILE_ROW
, -1);
46 inv_dec_
->Control(AV1_SET_DECODE_TILE_COL
, -1);
51 virtual ~TileIndependenceTest() {
56 virtual void SetUp() {
58 SetMode(libaom_test::kTwoPassGood
);
61 virtual void PreEncodeFrameHook(libaom_test::VideoSource
*video
,
62 libaom_test::Encoder
*encoder
) {
63 if (video
->frame() == 1) {
64 encoder
->Control(AV1E_SET_TILE_COLUMNS
, n_tile_cols_
);
65 encoder
->Control(AV1E_SET_TILE_ROWS
, n_tile_rows_
);
66 #if CONFIG_LOOPFILTERING_ACROSS_TILES
67 #if CONFIG_LOOPFILTERING_ACROSS_TILES_EXT
68 encoder
->Control(AV1E_SET_TILE_LOOPFILTER_V
, 0);
69 encoder
->Control(AV1E_SET_TILE_LOOPFILTER_H
, 0);
71 encoder
->Control(AV1E_SET_TILE_LOOPFILTER
, 0);
72 #endif // CONFIG_LOOPFILTERING_ACROSS_TILES_EXT
73 #endif // CONFIG_LOOPFILTERING_ACROSS_TILES
78 virtual void SetCpuUsed(libaom_test::Encoder
*encoder
) {
79 static const int kCpuUsed
= 3;
80 encoder
->Control(AOME_SET_CPUUSED
, kCpuUsed
);
83 void UpdateMD5(::libaom_test::Decoder
*dec
, const aom_codec_cx_pkt_t
*pkt
,
84 ::libaom_test::MD5
*md5
) {
85 const aom_codec_err_t res
= dec
->DecodeFrame(
86 reinterpret_cast<uint8_t *>(pkt
->data
.frame
.buf
), pkt
->data
.frame
.sz
);
87 if (res
!= AOM_CODEC_OK
) {
89 ASSERT_EQ(AOM_CODEC_OK
, res
);
91 const aom_image_t
*img
= dec
->GetDxData().Next();
95 virtual void FramePktHook(const aom_codec_cx_pkt_t
*pkt
) {
96 UpdateMD5(fw_dec_
, pkt
, &md5_fw_order_
);
97 UpdateMD5(inv_dec_
, pkt
, &md5_inv_order_
);
101 const aom_rational timebase
= { 33333333, 1000000000 };
102 cfg_
.g_timebase
= timebase
;
103 cfg_
.rc_target_bitrate
= 500;
104 cfg_
.g_lag_in_frames
= 12;
105 cfg_
.rc_end_usage
= AOM_VBR
;
107 libaom_test::I420VideoSource
video("hantro_collage_w352h288.yuv", 704, 576,
108 timebase
.den
, timebase
.num
, 0, 5);
109 ASSERT_NO_FATAL_FAILURE(RunLoop(&video
));
111 const char *md5_fw_str
= md5_fw_order_
.Get();
112 const char *md5_inv_str
= md5_inv_order_
.Get();
113 ASSERT_STREQ(md5_fw_str
, md5_inv_str
);
116 ::libaom_test::MD5 md5_fw_order_
, md5_inv_order_
;
117 ::libaom_test::Decoder
*fw_dec_
, *inv_dec_
;
124 // run an encode with 2 or 4 tiles, and do the decode both in normal and
125 // inverted tile ordering. Ensure that the MD5 of the output in both cases
126 // is identical. If so, tiles are considered independent and the test passes.
127 TEST_P(TileIndependenceTest
, MD5Match
) {
129 cfg_
.large_scale_tile
= 0;
130 #endif // CONFIG_EXT_TILE
134 class TileIndependenceTestLarge
: public TileIndependenceTest
{
135 virtual void SetCpuUsed(libaom_test::Encoder
*encoder
) {
136 static const int kCpuUsed
= 0;
137 encoder
->Control(AOME_SET_CPUUSED
, kCpuUsed
);
141 TEST_P(TileIndependenceTestLarge
, MD5Match
) {
143 cfg_
.large_scale_tile
= 0;
144 #endif // CONFIG_EXT_TILE
148 AV1_INSTANTIATE_TEST_CASE(TileIndependenceTest
, ::testing::Values(0, 1),
149 ::testing::Values(0, 1));
150 AV1_INSTANTIATE_TEST_CASE(TileIndependenceTestLarge
, ::testing::Values(0, 1),
151 ::testing::Values(0, 1));
154 class TileIndependenceLSTest
: public TileIndependenceTest
{};
156 TEST_P(TileIndependenceLSTest
, MD5Match
) {
157 cfg_
.large_scale_tile
= 1;
161 class TileIndependenceLSTestLarge
: public TileIndependenceTestLarge
{};
163 TEST_P(TileIndependenceLSTestLarge
, MD5Match
) {
164 cfg_
.large_scale_tile
= 1;
168 AV1_INSTANTIATE_TEST_CASE(TileIndependenceLSTest
, ::testing::Values(1, 2, 32),
169 ::testing::Values(1, 2, 32));
170 AV1_INSTANTIATE_TEST_CASE(TileIndependenceLSTestLarge
,
171 ::testing::Values(1, 2, 32),
172 ::testing::Values(1, 2, 32));
173 #endif // CONFIG_EXT_TILE