Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Frank Galligan | 38536f6 | 2013-12-12 08:36:34 -0800 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 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. |
| 10 | */ |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 11 | |
| 12 | #include <cstdio> |
| 13 | #include <cstdlib> |
| 14 | #include <string> |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 15 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 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" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 21 | #include "aom_mem/aom_mem.h" |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 22 | |
| 23 | namespace { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 24 | class TileIndependenceTest |
Sebastien Alaiwan | 4322bc1 | 2017-06-05 10:18:28 +0200 | [diff] [blame] | 25 | : public ::libaom_test::CodecTestWith2Params<int, int>, |
| 26 | public ::libaom_test::EncoderTest { |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 27 | protected: |
James Zern | bae3117 | 2013-07-18 14:37:53 -0700 | [diff] [blame] | 28 | TileIndependenceTest() |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 29 | : EncoderTest(GET_PARAM(0)), md5_fw_order_(), md5_inv_order_(), |
| 30 | n_tile_cols_(GET_PARAM(1)), n_tile_rows_(GET_PARAM(2)) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 31 | init_flags_ = AOM_CODEC_USE_PSNR; |
| 32 | aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t(); |
Ronald S. Bultje | f496f60 | 2013-02-06 15:30:21 -0800 | [diff] [blame] | 33 | cfg.w = 704; |
| 34 | cfg.h = 144; |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 35 | cfg.threads = 1; |
Sebastien Alaiwan | 8a65f9f | 2017-06-23 07:28:44 +0200 | [diff] [blame] | 36 | cfg.allow_lowbitdepth = 1; |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 37 | fw_dec_ = codec_->CreateDecoder(cfg, 0); |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 38 | inv_dec_ = codec_->CreateDecoder(cfg, 0); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 39 | inv_dec_->Control(AV1_INVERT_TILE_DECODE_ORDER, 1); |
Yunqing Wang | 8e5e338 | 2016-05-05 16:42:57 -0700 | [diff] [blame] | 40 | |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 41 | #if CONFIG_AV1 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 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); |
Yunqing Wang | 8e5e338 | 2016-05-05 16:42:57 -0700 | [diff] [blame] | 47 | } |
| 48 | #endif |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | virtual ~TileIndependenceTest() { |
| 52 | delete fw_dec_; |
| 53 | delete inv_dec_; |
| 54 | } |
| 55 | |
| 56 | virtual void SetUp() { |
| 57 | InitializeConfig(); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | SetMode(libaom_test::kTwoPassGood); |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 59 | } |
| 60 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 61 | virtual void PreEncodeFrameHook(libaom_test::VideoSource *video, |
| 62 | libaom_test::Encoder *encoder) { |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 63 | if (video->frame() == 1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 64 | encoder->Control(AV1E_SET_TILE_COLUMNS, n_tile_cols_); |
| 65 | encoder->Control(AV1E_SET_TILE_ROWS, n_tile_rows_); |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 66 | #if CONFIG_LOOPFILTERING_ACROSS_TILES |
Lei | 7bb501d | 2017-12-13 15:10:34 -0800 | [diff] [blame] | 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); |
| 70 | #else |
Ryan Lei | 7386eda | 2016-12-08 21:08:31 -0800 | [diff] [blame] | 71 | encoder->Control(AV1E_SET_TILE_LOOPFILTER, 0); |
Lei | 7bb501d | 2017-12-13 15:10:34 -0800 | [diff] [blame] | 72 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES_EXT |
Ryan Lei | 9b02b0e | 2017-01-30 15:52:20 -0800 | [diff] [blame] | 73 | #endif // CONFIG_LOOPFILTERING_ACROSS_TILES |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 74 | SetCpuUsed(encoder); |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 78 | virtual void SetCpuUsed(libaom_test::Encoder *encoder) { |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 79 | static const int kCpuUsed = 3; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 80 | encoder->Control(AOME_SET_CPUUSED, kCpuUsed); |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 83 | void UpdateMD5(::libaom_test::Decoder *dec, const aom_codec_cx_pkt_t *pkt, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 84 | ::libaom_test::MD5 *md5) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 85 | const aom_codec_err_t res = dec->DecodeFrame( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 86 | reinterpret_cast<uint8_t *>(pkt->data.frame.buf), pkt->data.frame.sz); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 87 | if (res != AOM_CODEC_OK) { |
James Zern | 2b1a0b6 | 2013-05-06 11:45:03 -0700 | [diff] [blame] | 88 | abort_ = true; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 89 | ASSERT_EQ(AOM_CODEC_OK, res); |
James Zern | 2b1a0b6 | 2013-05-06 11:45:03 -0700 | [diff] [blame] | 90 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 91 | const aom_image_t *img = dec->GetDxData().Next(); |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 92 | md5->Add(img); |
| 93 | } |
| 94 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 95 | virtual void FramePktHook(const aom_codec_cx_pkt_t *pkt) { |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 96 | UpdateMD5(fw_dec_, pkt, &md5_fw_order_); |
| 97 | UpdateMD5(inv_dec_, pkt, &md5_inv_order_); |
| 98 | } |
| 99 | |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 100 | void DoTest() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 101 | const aom_rational timebase = { 33333333, 1000000000 }; |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 102 | cfg_.g_timebase = timebase; |
| 103 | cfg_.rc_target_bitrate = 500; |
| 104 | cfg_.g_lag_in_frames = 12; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 105 | cfg_.rc_end_usage = AOM_VBR; |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 106 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 107 | libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 704, 576, |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 108 | timebase.den, timebase.num, 0, 5); |
| 109 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 110 | |
| 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); |
| 114 | } |
| 115 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 116 | ::libaom_test::MD5 md5_fw_order_, md5_inv_order_; |
| 117 | ::libaom_test::Decoder *fw_dec_, *inv_dec_; |
James Zern | bae3117 | 2013-07-18 14:37:53 -0700 | [diff] [blame] | 118 | |
| 119 | private: |
Geza Lore | 1982d67 | 2016-05-03 13:55:25 +0100 | [diff] [blame] | 120 | int n_tile_cols_; |
| 121 | int n_tile_rows_; |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 122 | }; |
| 123 | |
| 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. |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 127 | TEST_P(TileIndependenceTest, MD5Match) { |
| 128 | #if CONFIG_EXT_TILE |
| 129 | cfg_.large_scale_tile = 0; |
Yunqing Wang | 8ae64a9 | 2018-01-12 12:26:44 -0800 | [diff] [blame] | 130 | fw_dec_->Control(AV1_SET_TILE_MODE, 0); |
| 131 | inv_dec_->Control(AV1_SET_TILE_MODE, 0); |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 132 | #endif // CONFIG_EXT_TILE |
| 133 | DoTest(); |
| 134 | } |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 135 | |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 136 | class TileIndependenceTestLarge : public TileIndependenceTest { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 137 | virtual void SetCpuUsed(libaom_test::Encoder *encoder) { |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 138 | static const int kCpuUsed = 0; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 139 | encoder->Control(AOME_SET_CPUUSED, kCpuUsed); |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 140 | } |
| 141 | }; |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 142 | |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 143 | TEST_P(TileIndependenceTestLarge, MD5Match) { |
Geza Lore | 67a2ff7 | 2016-05-03 11:53:55 +0100 | [diff] [blame] | 144 | #if CONFIG_EXT_TILE |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 145 | cfg_.large_scale_tile = 0; |
Yunqing Wang | 8ae64a9 | 2018-01-12 12:26:44 -0800 | [diff] [blame] | 146 | fw_dec_->Control(AV1_SET_TILE_MODE, 0); |
| 147 | inv_dec_->Control(AV1_SET_TILE_MODE, 0); |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 148 | #endif // CONFIG_EXT_TILE |
| 149 | DoTest(); |
| 150 | } |
| 151 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 152 | AV1_INSTANTIATE_TEST_CASE(TileIndependenceTest, ::testing::Values(0, 1), |
| 153 | ::testing::Values(0, 1)); |
| 154 | AV1_INSTANTIATE_TEST_CASE(TileIndependenceTestLarge, ::testing::Values(0, 1), |
| 155 | ::testing::Values(0, 1)); |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 156 | |
| 157 | #if CONFIG_EXT_TILE |
| 158 | class TileIndependenceLSTest : public TileIndependenceTest {}; |
| 159 | |
Yunqing Wang | ce796ed | 2018-01-17 10:16:33 -0800 | [diff] [blame] | 160 | TEST_P(TileIndependenceLSTest, DISABLED_MD5Match) { |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 161 | cfg_.large_scale_tile = 1; |
Yunqing Wang | 8ae64a9 | 2018-01-12 12:26:44 -0800 | [diff] [blame] | 162 | fw_dec_->Control(AV1_SET_TILE_MODE, 1); |
| 163 | inv_dec_->Control(AV1_SET_TILE_MODE, 1); |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 164 | DoTest(); |
| 165 | } |
| 166 | |
| 167 | class TileIndependenceLSTestLarge : public TileIndependenceTestLarge {}; |
| 168 | |
Yunqing Wang | ce796ed | 2018-01-17 10:16:33 -0800 | [diff] [blame] | 169 | TEST_P(TileIndependenceLSTestLarge, DISABLED_MD5Match) { |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 170 | cfg_.large_scale_tile = 1; |
Yunqing Wang | 8ae64a9 | 2018-01-12 12:26:44 -0800 | [diff] [blame] | 171 | fw_dec_->Control(AV1_SET_TILE_MODE, 1); |
| 172 | inv_dec_->Control(AV1_SET_TILE_MODE, 1); |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 173 | DoTest(); |
| 174 | } |
| 175 | |
| 176 | AV1_INSTANTIATE_TEST_CASE(TileIndependenceLSTest, ::testing::Values(1, 2, 32), |
| 177 | ::testing::Values(1, 2, 32)); |
| 178 | AV1_INSTANTIATE_TEST_CASE(TileIndependenceLSTestLarge, |
| 179 | ::testing::Values(1, 2, 32), |
| 180 | ::testing::Values(1, 2, 32)); |
Geza Lore | 67a2ff7 | 2016-05-03 11:53:55 +0100 | [diff] [blame] | 181 | #endif // CONFIG_EXT_TILE |
Ronald S. Bultje | 1407bdc | 2013-02-01 09:35:28 -0800 | [diff] [blame] | 182 | } // namespace |