OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 | |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 12 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
14 #include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h" | 13 #include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h" |
15 | 14 |
16 #include "vpx/vpx_encoder.h" | 15 #include "vpx/vpx_encoder.h" |
17 #include "vpx/vp8cx.h" | 16 #include "vpx/vp8cx.h" |
18 | 17 |
19 namespace webrtc { | 18 namespace webrtc { |
20 | 19 |
21 enum { | 20 enum { |
22 kTemporalUpdateLast = VP8_EFLAG_NO_UPD_GF | | 21 kTemporalUpdateLast = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | |
23 VP8_EFLAG_NO_UPD_ARF | | |
24 VP8_EFLAG_NO_REF_GF | | 22 VP8_EFLAG_NO_REF_GF | |
25 VP8_EFLAG_NO_REF_ARF, | 23 VP8_EFLAG_NO_REF_ARF, |
26 kTemporalUpdateGoldenWithoutDependency = VP8_EFLAG_NO_REF_GF | | 24 kTemporalUpdateGoldenWithoutDependency = |
27 VP8_EFLAG_NO_REF_ARF | | 25 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF | |
28 VP8_EFLAG_NO_UPD_ARF | | 26 VP8_EFLAG_NO_UPD_LAST, |
29 VP8_EFLAG_NO_UPD_LAST, | 27 kTemporalUpdateGolden = |
30 kTemporalUpdateGolden = VP8_EFLAG_NO_REF_ARF | | 28 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST, |
31 VP8_EFLAG_NO_UPD_ARF | | 29 kTemporalUpdateAltrefWithoutDependency = |
32 VP8_EFLAG_NO_UPD_LAST, | 30 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF | |
33 kTemporalUpdateAltrefWithoutDependency = VP8_EFLAG_NO_REF_ARF | | 31 VP8_EFLAG_NO_UPD_LAST, |
34 VP8_EFLAG_NO_REF_GF | | 32 kTemporalUpdateAltref = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST, |
35 VP8_EFLAG_NO_UPD_GF | | 33 kTemporalUpdateNone = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | |
36 VP8_EFLAG_NO_UPD_LAST, | |
37 kTemporalUpdateAltref = VP8_EFLAG_NO_UPD_GF | | |
38 VP8_EFLAG_NO_UPD_LAST, | |
39 kTemporalUpdateNone = VP8_EFLAG_NO_UPD_GF | | |
40 VP8_EFLAG_NO_UPD_ARF | | |
41 VP8_EFLAG_NO_UPD_LAST | | 34 VP8_EFLAG_NO_UPD_LAST | |
42 VP8_EFLAG_NO_UPD_ENTROPY, | 35 VP8_EFLAG_NO_UPD_ENTROPY, |
43 kTemporalUpdateNoneNoRefAltRef = VP8_EFLAG_NO_REF_ARF | | 36 kTemporalUpdateNoneNoRefAltRef = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | |
44 VP8_EFLAG_NO_UPD_GF | | |
45 VP8_EFLAG_NO_UPD_ARF | | 37 VP8_EFLAG_NO_UPD_ARF | |
46 VP8_EFLAG_NO_UPD_LAST | | 38 VP8_EFLAG_NO_UPD_LAST | |
47 VP8_EFLAG_NO_UPD_ENTROPY, | 39 VP8_EFLAG_NO_UPD_ENTROPY, |
48 kTemporalUpdateNoneNoRefGolden = VP8_EFLAG_NO_REF_GF | | 40 kTemporalUpdateNoneNoRefGolden = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF | |
49 VP8_EFLAG_NO_UPD_GF | | |
50 VP8_EFLAG_NO_UPD_ARF | | 41 VP8_EFLAG_NO_UPD_ARF | |
51 VP8_EFLAG_NO_UPD_LAST | | 42 VP8_EFLAG_NO_UPD_LAST | |
52 VP8_EFLAG_NO_UPD_ENTROPY, | 43 VP8_EFLAG_NO_UPD_ENTROPY, |
53 kTemporalUpdateGoldenWithoutDependencyRefAltRef = VP8_EFLAG_NO_REF_GF | | 44 kTemporalUpdateGoldenWithoutDependencyRefAltRef = |
54 VP8_EFLAG_NO_UPD_ARF | | 45 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST, |
55 VP8_EFLAG_NO_UPD_LAST, | 46 kTemporalUpdateGoldenRefAltRef = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST, |
56 kTemporalUpdateGoldenRefAltRef = VP8_EFLAG_NO_UPD_ARF | | 47 kTemporalUpdateLastRefAltRef = |
57 VP8_EFLAG_NO_UPD_LAST, | 48 VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF, |
58 kTemporalUpdateLastRefAltRef = VP8_EFLAG_NO_UPD_GF | | 49 kTemporalUpdateLastAndGoldenRefAltRef = |
59 VP8_EFLAG_NO_UPD_ARF | | 50 VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF, |
60 VP8_EFLAG_NO_REF_GF, | |
61 kTemporalUpdateLastAndGoldenRefAltRef = VP8_EFLAG_NO_UPD_ARF | | |
62 VP8_EFLAG_NO_REF_GF, | |
63 }; | 51 }; |
64 | 52 |
65 TEST(TemporalLayersTest, 2Layers) { | 53 TEST(TemporalLayersTest, 2Layers) { |
66 DefaultTemporalLayers tl(2, 0); | 54 DefaultTemporalLayers tl(2, 0); |
67 vpx_codec_enc_cfg_t cfg; | 55 vpx_codec_enc_cfg_t cfg; |
68 CodecSpecificInfoVP8 vp8_info; | 56 CodecSpecificInfoVP8 vp8_info; |
69 tl.ConfigureBitrates(500, 500, 30, &cfg); | 57 tl.ConfigureBitrates(500, 500, 30, &cfg); |
70 | 58 |
71 int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef, | 59 int expected_flags[16] = { |
72 kTemporalUpdateGoldenWithoutDependencyRefAltRef, | 60 kTemporalUpdateLastAndGoldenRefAltRef, |
73 kTemporalUpdateLastRefAltRef, | 61 kTemporalUpdateGoldenWithoutDependencyRefAltRef, |
74 kTemporalUpdateGoldenRefAltRef, | 62 kTemporalUpdateLastRefAltRef, |
75 kTemporalUpdateLastRefAltRef, | 63 kTemporalUpdateGoldenRefAltRef, |
76 kTemporalUpdateGoldenRefAltRef, | 64 kTemporalUpdateLastRefAltRef, |
77 kTemporalUpdateLastRefAltRef, | 65 kTemporalUpdateGoldenRefAltRef, |
78 kTemporalUpdateNone, | 66 kTemporalUpdateLastRefAltRef, |
79 kTemporalUpdateLastAndGoldenRefAltRef, | 67 kTemporalUpdateNone, |
80 kTemporalUpdateGoldenWithoutDependencyRefAltRef, | 68 kTemporalUpdateLastAndGoldenRefAltRef, |
81 kTemporalUpdateLastRefAltRef, | 69 kTemporalUpdateGoldenWithoutDependencyRefAltRef, |
82 kTemporalUpdateGoldenRefAltRef, | 70 kTemporalUpdateLastRefAltRef, |
83 kTemporalUpdateLastRefAltRef, | 71 kTemporalUpdateGoldenRefAltRef, |
84 kTemporalUpdateGoldenRefAltRef, | 72 kTemporalUpdateLastRefAltRef, |
85 kTemporalUpdateLastRefAltRef, | 73 kTemporalUpdateGoldenRefAltRef, |
86 kTemporalUpdateNone, | 74 kTemporalUpdateLastRefAltRef, |
87 }; | 75 kTemporalUpdateNone, |
88 int expected_temporal_idx[16] = | 76 }; |
89 { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; | 77 int expected_temporal_idx[16] = {0, 1, 0, 1, 0, 1, 0, 1, |
| 78 0, 1, 0, 1, 0, 1, 0, 1}; |
90 | 79 |
91 bool expected_layer_sync[16] = | 80 bool expected_layer_sync[16] = {false, true, false, false, false, false, |
92 { false, true, false, false, false, false, false, false, | 81 false, false, false, true, false, false, |
93 false, true, false, false, false, false, false, false }; | 82 false, false, false, false}; |
94 | 83 |
95 uint32_t timestamp = 0; | 84 uint32_t timestamp = 0; |
96 for (int i = 0; i < 16; ++i) { | 85 for (int i = 0; i < 16; ++i) { |
97 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 86 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); |
98 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 87 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
99 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 88 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
100 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); | 89 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); |
101 timestamp += 3000; | 90 timestamp += 3000; |
102 } | 91 } |
103 } | 92 } |
104 | 93 |
105 TEST(TemporalLayersTest, 3Layers) { | 94 TEST(TemporalLayersTest, 3Layers) { |
106 DefaultTemporalLayers tl(3, 0); | 95 DefaultTemporalLayers tl(3, 0); |
107 vpx_codec_enc_cfg_t cfg; | 96 vpx_codec_enc_cfg_t cfg; |
108 CodecSpecificInfoVP8 vp8_info; | 97 CodecSpecificInfoVP8 vp8_info; |
109 tl.ConfigureBitrates(500, 500, 30, &cfg); | 98 tl.ConfigureBitrates(500, 500, 30, &cfg); |
110 | 99 |
111 int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef, | 100 int expected_flags[16] = { |
112 kTemporalUpdateNoneNoRefGolden, | 101 kTemporalUpdateLastAndGoldenRefAltRef, |
113 kTemporalUpdateGoldenWithoutDependencyRefAltRef, | 102 kTemporalUpdateNoneNoRefGolden, |
114 kTemporalUpdateNone, | 103 kTemporalUpdateGoldenWithoutDependencyRefAltRef, |
115 kTemporalUpdateLastRefAltRef, | 104 kTemporalUpdateNone, |
116 kTemporalUpdateNone, | 105 kTemporalUpdateLastRefAltRef, |
117 kTemporalUpdateGoldenRefAltRef, | 106 kTemporalUpdateNone, |
118 kTemporalUpdateNone, | 107 kTemporalUpdateGoldenRefAltRef, |
119 kTemporalUpdateLastAndGoldenRefAltRef, | 108 kTemporalUpdateNone, |
120 kTemporalUpdateNoneNoRefGolden, | 109 kTemporalUpdateLastAndGoldenRefAltRef, |
121 kTemporalUpdateGoldenWithoutDependencyRefAltRef, | 110 kTemporalUpdateNoneNoRefGolden, |
122 kTemporalUpdateNone, | 111 kTemporalUpdateGoldenWithoutDependencyRefAltRef, |
123 kTemporalUpdateLastRefAltRef, | 112 kTemporalUpdateNone, |
124 kTemporalUpdateNone, | 113 kTemporalUpdateLastRefAltRef, |
125 kTemporalUpdateGoldenRefAltRef, | 114 kTemporalUpdateNone, |
126 kTemporalUpdateNone, | 115 kTemporalUpdateGoldenRefAltRef, |
| 116 kTemporalUpdateNone, |
127 }; | 117 }; |
128 int expected_temporal_idx[16] = | 118 int expected_temporal_idx[16] = {0, 2, 1, 2, 0, 2, 1, 2, |
129 { 0, 2, 1, 2, 0, 2, 1, 2, 0, 2, 1, 2, 0, 2, 1, 2 }; | 119 0, 2, 1, 2, 0, 2, 1, 2}; |
130 | 120 |
131 bool expected_layer_sync[16] = | 121 bool expected_layer_sync[16] = {false, true, true, false, false, false, |
132 { false, true, true, false, false, false, false, false, | 122 false, false, false, true, true, false, |
133 false, true, true, false, false, false, false, false }; | 123 false, false, false, false}; |
134 | 124 |
135 unsigned int timestamp = 0; | 125 unsigned int timestamp = 0; |
136 for (int i = 0; i < 16; ++i) { | 126 for (int i = 0; i < 16; ++i) { |
137 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 127 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); |
138 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 128 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
139 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 129 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
140 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); | 130 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); |
141 timestamp += 3000; | 131 timestamp += 3000; |
142 } | 132 } |
143 } | 133 } |
(...skipping 14 matching lines...) Expand all Loading... |
158 kTemporalUpdateNone, | 148 kTemporalUpdateNone, |
159 kTemporalUpdateLast, | 149 kTemporalUpdateLast, |
160 kTemporalUpdateNone, | 150 kTemporalUpdateNone, |
161 kTemporalUpdateAltref, | 151 kTemporalUpdateAltref, |
162 kTemporalUpdateNone, | 152 kTemporalUpdateNone, |
163 kTemporalUpdateGolden, | 153 kTemporalUpdateGolden, |
164 kTemporalUpdateNone, | 154 kTemporalUpdateNone, |
165 kTemporalUpdateAltref, | 155 kTemporalUpdateAltref, |
166 kTemporalUpdateNone, | 156 kTemporalUpdateNone, |
167 }; | 157 }; |
168 int expected_temporal_idx[16] = | 158 int expected_temporal_idx[16] = {0, 3, 2, 3, 1, 3, 2, 3, |
169 { 0, 3, 2, 3, 1, 3, 2, 3, 0, 3, 2, 3, 1, 3, 2, 3 }; | 159 0, 3, 2, 3, 1, 3, 2, 3}; |
170 | 160 |
171 bool expected_layer_sync[16] = | 161 bool expected_layer_sync[16] = {false, true, true, true, true, true, |
172 { false, true, true, true, true, true, false, true, | 162 false, true, false, true, false, true, |
173 false, true, false, true, false, true, false, true }; | 163 false, true, false, true}; |
174 | 164 |
175 uint32_t timestamp = 0; | 165 uint32_t timestamp = 0; |
176 for (int i = 0; i < 16; ++i) { | 166 for (int i = 0; i < 16; ++i) { |
177 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 167 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); |
178 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 168 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
179 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 169 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
180 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); | 170 EXPECT_EQ(expected_layer_sync[i], vp8_info.layerSync); |
181 timestamp += 3000; | 171 timestamp += 3000; |
182 } | 172 } |
183 } | 173 } |
184 | 174 |
185 TEST(TemporalLayersTest, KeyFrame) { | 175 TEST(TemporalLayersTest, KeyFrame) { |
186 DefaultTemporalLayers tl(3, 0); | 176 DefaultTemporalLayers tl(3, 0); |
187 vpx_codec_enc_cfg_t cfg; | 177 vpx_codec_enc_cfg_t cfg; |
188 CodecSpecificInfoVP8 vp8_info; | 178 CodecSpecificInfoVP8 vp8_info; |
189 tl.ConfigureBitrates(500, 500, 30, &cfg); | 179 tl.ConfigureBitrates(500, 500, 30, &cfg); |
190 | 180 |
191 int expected_flags[8] = { | 181 int expected_flags[8] = { |
192 kTemporalUpdateLastAndGoldenRefAltRef, | 182 kTemporalUpdateLastAndGoldenRefAltRef, |
193 kTemporalUpdateNoneNoRefGolden, | 183 kTemporalUpdateNoneNoRefGolden, |
194 kTemporalUpdateGoldenWithoutDependencyRefAltRef, | 184 kTemporalUpdateGoldenWithoutDependencyRefAltRef, |
195 kTemporalUpdateNone, | 185 kTemporalUpdateNone, |
196 kTemporalUpdateLastRefAltRef, | 186 kTemporalUpdateLastRefAltRef, |
197 kTemporalUpdateNone, | 187 kTemporalUpdateNone, |
198 kTemporalUpdateGoldenRefAltRef, | 188 kTemporalUpdateGoldenRefAltRef, |
199 kTemporalUpdateNone, | 189 kTemporalUpdateNone, |
200 }; | 190 }; |
201 int expected_temporal_idx[8] = | 191 int expected_temporal_idx[8] = {0, 0, 0, 0, 0, 0, 0, 2}; |
202 { 0, 0, 0, 0, 0, 0, 0, 2}; | |
203 | 192 |
204 uint32_t timestamp = 0; | 193 uint32_t timestamp = 0; |
205 for (int i = 0; i < 7; ++i) { | 194 for (int i = 0; i < 7; ++i) { |
206 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); | 195 EXPECT_EQ(expected_flags[i], tl.EncodeFlags(timestamp)); |
207 tl.PopulateCodecSpecific(true, &vp8_info, 0); | 196 tl.PopulateCodecSpecific(true, &vp8_info, 0); |
208 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); | 197 EXPECT_EQ(expected_temporal_idx[i], vp8_info.temporalIdx); |
209 EXPECT_EQ(true, vp8_info.layerSync); | 198 EXPECT_EQ(true, vp8_info.layerSync); |
210 timestamp += 3000; | 199 timestamp += 3000; |
211 } | 200 } |
212 EXPECT_EQ(expected_flags[7], tl.EncodeFlags(timestamp)); | 201 EXPECT_EQ(expected_flags[7], tl.EncodeFlags(timestamp)); |
213 tl.PopulateCodecSpecific(false, &vp8_info, 0); | 202 tl.PopulateCodecSpecific(false, &vp8_info, 0); |
214 EXPECT_EQ(expected_temporal_idx[7], vp8_info.temporalIdx); | 203 EXPECT_EQ(expected_temporal_idx[7], vp8_info.temporalIdx); |
215 EXPECT_EQ(true, vp8_info.layerSync); | 204 EXPECT_EQ(true, vp8_info.layerSync); |
216 } | 205 } |
217 } // namespace webrtc | 206 } // namespace webrtc |
OLD | NEW |