2 * Copyright (c) 2021, 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.
14 #include "test/codec_factory.h"
15 #include "test/decode_test_driver.h"
16 #include "test/ivf_video_source.h"
17 #include "test/util.h"
18 #include "test/video_source.h"
19 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
23 struct ObuExtensionHeader
{
30 const ObuExtensionHeader
*headers
;
34 std::ostream
&operator<<(std::ostream
&os
, const DecodeParam
&dp
) {
35 return os
<< "file: " << dp
.filename
;
38 class DecodeScalabilityTest
39 : public ::libaom_test::DecoderTest
,
40 public ::libaom_test::CodecTestWithParam
<DecodeParam
> {
42 DecodeScalabilityTest()
43 : DecoderTest(GET_PARAM(0)), headers_(GET_PARAM(1).headers
),
44 num_headers_(GET_PARAM(1).num_headers
) {}
46 ~DecodeScalabilityTest() override
{}
48 void PreDecodeFrameHook(const libaom_test::CompressedVideoSource
&video
,
49 libaom_test::Decoder
*decoder
) override
{
50 if (video
.frame_number() == 0)
51 decoder
->Control(AV1D_SET_OUTPUT_ALL_LAYERS
, 1);
54 void DecompressedFrameHook(const aom_image_t
&img
,
55 const unsigned int /*frame_number*/) override
{
56 const ObuExtensionHeader
&header
= headers_
[header_index_
];
57 EXPECT_EQ(img
.temporal_id
, header
.temporal_id
);
58 EXPECT_EQ(img
.spatial_id
, header
.spatial_id
);
59 header_index_
= (header_index_
+ 1) % num_headers_
;
63 const DecodeParam input
= GET_PARAM(1);
64 aom_codec_dec_cfg_t cfg
= { 1, 0, 0, !FORCE_HIGHBITDEPTH_DECODING
};
65 libaom_test::IVFVideoSource
decode_video(input
.filename
);
68 ASSERT_NO_FATAL_FAILURE(RunLoop(&decode_video
, cfg
));
72 const ObuExtensionHeader
*const headers_
;
73 const size_t num_headers_
;
74 size_t header_index_
= 0;
77 TEST_P(DecodeScalabilityTest
, ObuExtensionHeader
) { RunTest(); }
79 // For all test files, we have:
81 // OperatingPointIdc = operating_point_idc[ 0 ]
83 // av1-1-b8-01-size-16x16.ivf:
84 // operating_points_cnt_minus_1 = 0
85 // operating_point_idc[ 0 ] = 0x0
86 const ObuExtensionHeader kSize16x16Headers
[1] = { { 0, 0 } };
88 #if !CONFIG_REALTIME_ONLY
89 // av1-1-b8-22-svc-L1T2.ivf:
90 // operating_points_cnt_minus_1 = 1
91 // operating_point_idc[ 0 ] = 0x103
92 // operating_point_idc[ 1 ] = 0x101
93 const ObuExtensionHeader kL1T2Headers
[2] = { { 0, 0 }, { 1, 0 } };
95 // av1-1-b8-22-svc-L2T1.ivf:
96 // operating_points_cnt_minus_1 = 1
97 // operating_point_idc[ 0 ] = 0x301
98 // operating_point_idc[ 1 ] = 0x101
99 const ObuExtensionHeader kL2T1Headers
[2] = { { 0, 0 }, { 0, 1 } };
101 // av1-1-b8-22-svc-L2T2.ivf:
102 // operating_points_cnt_minus_1 = 3
103 // operating_point_idc[ 0 ] = 0x303
104 // operating_point_idc[ 1 ] = 0x301
105 // operating_point_idc[ 2 ] = 0x103
106 // operating_point_idc[ 3 ] = 0x101
107 const ObuExtensionHeader kL2T2Headers
[4] = {
108 { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 }
110 #endif // !CONFIG_REALTIME_ONLY
112 const DecodeParam kAV1DecodeScalabilityTests
[] = {
113 // { filename, headers, num_headers }
114 { "av1-1-b8-01-size-16x16.ivf", kSize16x16Headers
, 1 },
115 #if !CONFIG_REALTIME_ONLY
116 // These test vectors use loop restoration, which is not supported in
117 // the CONFIG_REALTIME_ONLY builds.
118 { "av1-1-b8-22-svc-L1T2.ivf", kL1T2Headers
, 2 },
119 { "av1-1-b8-22-svc-L2T1.ivf", kL2T1Headers
, 2 },
120 { "av1-1-b8-22-svc-L2T2.ivf", kL2T2Headers
, 4 },
121 #endif // !CONFIG_REALTIME_ONLY
124 AV1_INSTANTIATE_TEST_SUITE(DecodeScalabilityTest
,
125 ::testing::ValuesIn(kAV1DecodeScalabilityTests
));