OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/memory_mapped_file.h" | 8 #include "base/files/memory_mapped_file.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "media/base/test_data_util.h" | 10 #include "media/base/test_data_util.h" |
11 #include "media/filters/h264_parser.h" | 11 #include "media/filters/h264_parser.h" |
12 #include "media/video/h264_poc.h" | 12 #include "media/video/h264_poc.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 class H264POCTest : public testing::Test { | 17 class H264POCTest : public testing::Test { |
18 public: | 18 public: |
19 H264POCTest() : sps_(), slice_hdr_() { | 19 H264POCTest() : sps_(), slice_hdr_() { |
20 // Default every frame to be a reference frame. | 20 // Default every frame to be a reference frame. |
21 slice_hdr_.nal_ref_idc = 1; | 21 slice_hdr_.nal_ref_idc = 1; |
22 } | 22 } |
23 | 23 |
24 protected: | 24 protected: |
25 bool ComputePOC() { | 25 void ComputePOC() { |
26 bool result = h264_poc_.ComputePicOrderCnt(&sps_, slice_hdr_, &poc_); | 26 poc_ = h264_poc_.ComputePicOrderCnt(&sps_, slice_hdr_); |
27 | 27 |
28 // Clear MMCO5. | 28 // Clear MMCO5. |
29 slice_hdr_.adaptive_ref_pic_marking_mode_flag = false; | 29 slice_hdr_.adaptive_ref_pic_marking_mode_flag = false; |
30 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 0; | 30 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 0; |
31 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 0; | 31 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 0; |
32 slice_hdr_.ref_pic_marking[2].memory_mgmnt_control_operation = 0; | 32 slice_hdr_.ref_pic_marking[2].memory_mgmnt_control_operation = 0; |
33 | |
34 return result; | |
35 } | 33 } |
36 | 34 |
37 // Also sets as a reference frame and unsets IDR, which is required for | 35 // Also sets as a reference frame and unsets IDR, which is required for |
38 // memory management control operations to be parsed. | 36 // memory management control operations to be parsed. |
39 void SetMMCO5() { | 37 void SetMMCO5() { |
40 slice_hdr_.nal_ref_idc = 1; | 38 slice_hdr_.nal_ref_idc = 1; |
41 slice_hdr_.idr_pic_flag = false; | 39 slice_hdr_.idr_pic_flag = false; |
42 slice_hdr_.adaptive_ref_pic_marking_mode_flag = true; | 40 slice_hdr_.adaptive_ref_pic_marking_mode_flag = true; |
43 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 6; | 41 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 6; |
44 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 5; | 42 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 5; |
45 slice_hdr_.ref_pic_marking[2].memory_mgmnt_control_operation = 0; | 43 slice_hdr_.ref_pic_marking[2].memory_mgmnt_control_operation = 0; |
46 } | 44 } |
47 | 45 |
48 int32_t poc_; | 46 base::Optional<int32_t> poc_; |
49 | 47 |
50 H264SPS sps_; | 48 H264SPS sps_; |
51 H264SliceHeader slice_hdr_; | 49 H264SliceHeader slice_hdr_; |
52 H264POC h264_poc_; | 50 H264POC h264_poc_; |
53 | 51 |
54 DISALLOW_COPY_AND_ASSIGN(H264POCTest); | 52 DISALLOW_COPY_AND_ASSIGN(H264POCTest); |
55 }; | 53 }; |
56 | 54 |
57 TEST_F(H264POCTest, PicOrderCntType0) { | 55 TEST_F(H264POCTest, PicOrderCntType0) { |
58 sps_.pic_order_cnt_type = 0; | 56 sps_.pic_order_cnt_type = 0; |
59 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 | 57 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 |
60 | 58 |
61 // Initial IDR with POC 0. | 59 // Initial IDR with POC 0. |
62 slice_hdr_.idr_pic_flag = true; | 60 slice_hdr_.idr_pic_flag = true; |
63 slice_hdr_.frame_num = 0; | 61 slice_hdr_.frame_num = 0; |
64 ASSERT_TRUE(ComputePOC()); | 62 ComputePOC(); |
65 ASSERT_EQ(0, poc_); | 63 ASSERT_TRUE(poc_.has_value()); |
| 64 ASSERT_EQ(0, *poc_); |
66 | 65 |
67 // Ref frame with POC lsb 8. | 66 // Ref frame with POC lsb 8. |
68 slice_hdr_.idr_pic_flag = false; | 67 slice_hdr_.idr_pic_flag = false; |
69 slice_hdr_.frame_num = 1; | 68 slice_hdr_.frame_num = 1; |
70 slice_hdr_.pic_order_cnt_lsb = 8; | 69 slice_hdr_.pic_order_cnt_lsb = 8; |
71 ASSERT_TRUE(ComputePOC()); | 70 ComputePOC(); |
72 ASSERT_EQ(8, poc_); | 71 ASSERT_TRUE(poc_.has_value()); |
| 72 ASSERT_EQ(8, *poc_); |
73 | 73 |
74 // Ref frame with POC lsb 0. This should be detected as wrapping, as the | 74 // Ref frame with POC lsb 0. This should be detected as wrapping, as the |
75 // (negative) gap is at least half the maximum. | 75 // (negative) gap is at least half the maximum. |
76 slice_hdr_.pic_order_cnt_lsb = 0; | 76 slice_hdr_.pic_order_cnt_lsb = 0; |
77 slice_hdr_.frame_num = 2; | 77 slice_hdr_.frame_num = 2; |
78 ASSERT_TRUE(ComputePOC()); | 78 ComputePOC(); |
79 ASSERT_EQ(16, poc_); | 79 ASSERT_TRUE(poc_.has_value()); |
| 80 ASSERT_EQ(16, *poc_); |
80 | 81 |
81 // Ref frame with POC lsb 9. This should be detected as negative wrapping, | 82 // Ref frame with POC lsb 9. This should be detected as negative wrapping, |
82 // as the (positive) gap is more than half the maximum. | 83 // as the (positive) gap is more than half the maximum. |
83 slice_hdr_.pic_order_cnt_lsb = 9; | 84 slice_hdr_.pic_order_cnt_lsb = 9; |
84 slice_hdr_.frame_num = 3; | 85 slice_hdr_.frame_num = 3; |
85 ASSERT_TRUE(ComputePOC()); | 86 ComputePOC(); |
86 ASSERT_EQ(9, poc_); | 87 ASSERT_TRUE(poc_.has_value()); |
| 88 ASSERT_EQ(9, *poc_); |
87 } | 89 } |
88 | 90 |
89 TEST_F(H264POCTest, PicOrderCntType0_WithMMCO5) { | 91 TEST_F(H264POCTest, PicOrderCntType0_WithMMCO5) { |
90 sps_.pic_order_cnt_type = 0; | 92 sps_.pic_order_cnt_type = 0; |
91 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 | 93 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 |
92 | 94 |
93 // Initial IDR with POC 0. | 95 // Initial IDR with POC 0. |
94 slice_hdr_.idr_pic_flag = true; | 96 slice_hdr_.idr_pic_flag = true; |
95 slice_hdr_.frame_num = 0; | 97 slice_hdr_.frame_num = 0; |
96 ASSERT_TRUE(ComputePOC()); | 98 ComputePOC(); |
97 ASSERT_EQ(0, poc_); | 99 ASSERT_TRUE(poc_.has_value()); |
| 100 ASSERT_EQ(0, *poc_); |
98 | 101 |
99 // Skip ahead. | 102 // Skip ahead. |
100 slice_hdr_.idr_pic_flag = false; | 103 slice_hdr_.idr_pic_flag = false; |
101 slice_hdr_.frame_num = 1; | 104 slice_hdr_.frame_num = 1; |
102 slice_hdr_.pic_order_cnt_lsb = 8; | 105 slice_hdr_.pic_order_cnt_lsb = 8; |
103 ASSERT_TRUE(ComputePOC()); | 106 ComputePOC(); |
104 ASSERT_EQ(8, poc_); | 107 ASSERT_TRUE(poc_.has_value()); |
| 108 ASSERT_EQ(8, *poc_); |
105 | 109 |
106 slice_hdr_.frame_num = 2; | 110 slice_hdr_.frame_num = 2; |
107 slice_hdr_.pic_order_cnt_lsb = 0; | 111 slice_hdr_.pic_order_cnt_lsb = 0; |
108 ASSERT_TRUE(ComputePOC()); | 112 ComputePOC(); |
109 ASSERT_EQ(16, poc_); | 113 ASSERT_TRUE(poc_.has_value()); |
| 114 ASSERT_EQ(16, *poc_); |
110 | 115 |
111 slice_hdr_.frame_num = 3; | 116 slice_hdr_.frame_num = 3; |
112 slice_hdr_.pic_order_cnt_lsb = 8; | 117 slice_hdr_.pic_order_cnt_lsb = 8; |
113 ASSERT_TRUE(ComputePOC()); | 118 ComputePOC(); |
114 ASSERT_EQ(24, poc_); | 119 ASSERT_TRUE(poc_.has_value()); |
| 120 ASSERT_EQ(24, *poc_); |
115 | 121 |
116 // MMCO5 resets to 0. | 122 // MMCO5 resets to 0. |
117 slice_hdr_.frame_num = 4; | 123 slice_hdr_.frame_num = 4; |
118 slice_hdr_.pic_order_cnt_lsb = 0; | 124 slice_hdr_.pic_order_cnt_lsb = 0; |
119 SetMMCO5(); | 125 SetMMCO5(); |
120 ASSERT_TRUE(ComputePOC()); | 126 ComputePOC(); |
121 ASSERT_EQ(0, poc_); | 127 ASSERT_TRUE(poc_.has_value()); |
| 128 ASSERT_EQ(0, *poc_); |
122 | 129 |
123 // Still detected as positive wrapping. | 130 // Still detected as positive wrapping. |
124 slice_hdr_.frame_num = 5; | 131 slice_hdr_.frame_num = 5; |
125 slice_hdr_.pic_order_cnt_lsb = 8; | 132 slice_hdr_.pic_order_cnt_lsb = 8; |
126 ASSERT_TRUE(ComputePOC()); | 133 ComputePOC(); |
127 ASSERT_EQ(24, poc_); | 134 ASSERT_TRUE(poc_.has_value()); |
| 135 ASSERT_EQ(24, *poc_); |
128 } | 136 } |
129 | 137 |
130 TEST_F(H264POCTest, PicOrderCntType1) { | 138 TEST_F(H264POCTest, PicOrderCntType1) { |
131 sps_.pic_order_cnt_type = 1; | 139 sps_.pic_order_cnt_type = 1; |
132 sps_.log2_max_frame_num_minus4 = 0; // 16 | 140 sps_.log2_max_frame_num_minus4 = 0; // 16 |
133 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; | 141 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; |
134 sps_.expected_delta_per_pic_order_cnt_cycle = 3; | 142 sps_.expected_delta_per_pic_order_cnt_cycle = 3; |
135 sps_.offset_for_ref_frame[0] = 1; | 143 sps_.offset_for_ref_frame[0] = 1; |
136 sps_.offset_for_ref_frame[1] = 2; | 144 sps_.offset_for_ref_frame[1] = 2; |
137 | 145 |
138 // Initial IDR with POC 0. | 146 // Initial IDR with POC 0. |
139 slice_hdr_.idr_pic_flag = true; | 147 slice_hdr_.idr_pic_flag = true; |
140 slice_hdr_.frame_num = 0; | 148 slice_hdr_.frame_num = 0; |
141 ASSERT_TRUE(ComputePOC()); | 149 ComputePOC(); |
142 ASSERT_EQ(0, poc_); | 150 ASSERT_TRUE(poc_.has_value()); |
| 151 ASSERT_EQ(0, *poc_); |
143 | 152 |
144 // Ref frame. | 153 // Ref frame. |
145 slice_hdr_.idr_pic_flag = false; | 154 slice_hdr_.idr_pic_flag = false; |
146 slice_hdr_.frame_num = 1; | 155 slice_hdr_.frame_num = 1; |
147 ASSERT_TRUE(ComputePOC()); | 156 ComputePOC(); |
148 ASSERT_EQ(1, poc_); | 157 ASSERT_TRUE(poc_.has_value()); |
| 158 ASSERT_EQ(1, *poc_); |
149 | 159 |
150 // Ref frame. | 160 // Ref frame. |
151 slice_hdr_.frame_num = 2; | 161 slice_hdr_.frame_num = 2; |
152 ASSERT_TRUE(ComputePOC()); | 162 ComputePOC(); |
153 ASSERT_EQ(3, poc_); | 163 ASSERT_TRUE(poc_.has_value()); |
| 164 ASSERT_EQ(3, *poc_); |
154 | 165 |
155 // Ref frame. | 166 // Ref frame. |
156 slice_hdr_.frame_num = 3; | 167 slice_hdr_.frame_num = 3; |
157 ASSERT_TRUE(ComputePOC()); | 168 ComputePOC(); |
158 ASSERT_EQ(4, poc_); | 169 ASSERT_TRUE(poc_.has_value()); |
| 170 ASSERT_EQ(4, *poc_); |
159 | 171 |
160 // Ref frame. | 172 // Ref frame. |
161 slice_hdr_.frame_num = 4; | 173 slice_hdr_.frame_num = 4; |
162 ASSERT_TRUE(ComputePOC()); | 174 ComputePOC(); |
163 ASSERT_EQ(6, poc_); | 175 ASSERT_TRUE(poc_.has_value()); |
| 176 ASSERT_EQ(6, *poc_); |
164 | 177 |
165 // Ref frame, detected as wrapping (ie, this is frame 16). | 178 // Ref frame, detected as wrapping (ie, this is frame 16). |
166 slice_hdr_.frame_num = 0; | 179 slice_hdr_.frame_num = 0; |
167 ASSERT_TRUE(ComputePOC()); | 180 ComputePOC(); |
168 ASSERT_EQ(24, poc_); | 181 ASSERT_TRUE(poc_.has_value()); |
| 182 ASSERT_EQ(24, *poc_); |
169 } | 183 } |
170 | 184 |
171 TEST_F(H264POCTest, PicOrderCntType1_WithMMCO5) { | 185 TEST_F(H264POCTest, PicOrderCntType1_WithMMCO5) { |
172 sps_.pic_order_cnt_type = 1; | 186 sps_.pic_order_cnt_type = 1; |
173 sps_.log2_max_frame_num_minus4 = 0; // 16 | 187 sps_.log2_max_frame_num_minus4 = 0; // 16 |
174 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; | 188 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; |
175 sps_.expected_delta_per_pic_order_cnt_cycle = 3; | 189 sps_.expected_delta_per_pic_order_cnt_cycle = 3; |
176 sps_.offset_for_ref_frame[0] = 1; | 190 sps_.offset_for_ref_frame[0] = 1; |
177 sps_.offset_for_ref_frame[1] = 2; | 191 sps_.offset_for_ref_frame[1] = 2; |
178 | 192 |
179 // Initial IDR with POC 0. | 193 // Initial IDR with POC 0. |
180 slice_hdr_.idr_pic_flag = true; | 194 slice_hdr_.idr_pic_flag = true; |
181 slice_hdr_.frame_num = 0; | 195 slice_hdr_.frame_num = 0; |
182 ASSERT_TRUE(ComputePOC()); | 196 ComputePOC(); |
183 ASSERT_EQ(0, poc_); | 197 ASSERT_TRUE(poc_.has_value()); |
| 198 ASSERT_EQ(0, *poc_); |
184 | 199 |
185 // Ref frame. | 200 // Ref frame. |
186 slice_hdr_.idr_pic_flag = false; | 201 slice_hdr_.idr_pic_flag = false; |
187 slice_hdr_.frame_num = 1; | 202 slice_hdr_.frame_num = 1; |
188 ASSERT_TRUE(ComputePOC()); | 203 ComputePOC(); |
189 ASSERT_EQ(1, poc_); | 204 ASSERT_TRUE(poc_.has_value()); |
| 205 ASSERT_EQ(1, *poc_); |
190 | 206 |
191 // Ref frame, detected as wrapping. | 207 // Ref frame, detected as wrapping. |
192 SetMMCO5(); | 208 SetMMCO5(); |
193 slice_hdr_.frame_num = 0; | 209 slice_hdr_.frame_num = 0; |
194 ASSERT_TRUE(ComputePOC()); | 210 ComputePOC(); |
195 ASSERT_EQ(0, poc_); | 211 ASSERT_TRUE(poc_.has_value()); |
| 212 ASSERT_EQ(0, *poc_); |
196 | 213 |
197 // Ref frame, wrapping from before has been cleared. | 214 // Ref frame, wrapping from before has been cleared. |
198 slice_hdr_.frame_num = 1; | 215 slice_hdr_.frame_num = 1; |
199 ASSERT_TRUE(ComputePOC()); | 216 ComputePOC(); |
200 ASSERT_EQ(1, poc_); | 217 ASSERT_TRUE(poc_.has_value()); |
| 218 ASSERT_EQ(1, *poc_); |
201 } | 219 } |
202 | 220 |
203 // |frame_num| values may be duplicated by non-reference frames. | 221 // |frame_num| values may be duplicated by non-reference frames. |
204 TEST_F(H264POCTest, PicOrderCntType1_DupFrameNum) { | 222 TEST_F(H264POCTest, PicOrderCntType1_DupFrameNum) { |
205 sps_.pic_order_cnt_type = 1; | 223 sps_.pic_order_cnt_type = 1; |
206 sps_.log2_max_frame_num_minus4 = 0; // 16 | 224 sps_.log2_max_frame_num_minus4 = 0; // 16 |
207 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; | 225 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; |
208 sps_.expected_delta_per_pic_order_cnt_cycle = 3; | 226 sps_.expected_delta_per_pic_order_cnt_cycle = 3; |
209 sps_.offset_for_ref_frame[0] = 1; | 227 sps_.offset_for_ref_frame[0] = 1; |
210 sps_.offset_for_ref_frame[1] = 2; | 228 sps_.offset_for_ref_frame[1] = 2; |
211 | 229 |
212 // Initial IDR with POC 0. | 230 // Initial IDR with POC 0. |
213 slice_hdr_.idr_pic_flag = true; | 231 slice_hdr_.idr_pic_flag = true; |
214 slice_hdr_.frame_num = 0; | 232 slice_hdr_.frame_num = 0; |
215 ASSERT_TRUE(ComputePOC()); | 233 ComputePOC(); |
216 ASSERT_EQ(0, poc_); | 234 ASSERT_TRUE(poc_.has_value()); |
| 235 ASSERT_EQ(0, *poc_); |
217 | 236 |
218 // Ref frame. | 237 // Ref frame. |
219 slice_hdr_.idr_pic_flag = false; | 238 slice_hdr_.idr_pic_flag = false; |
220 slice_hdr_.frame_num = 1; | 239 slice_hdr_.frame_num = 1; |
221 ASSERT_TRUE(ComputePOC()); | 240 ComputePOC(); |
222 ASSERT_EQ(1, poc_); | 241 ASSERT_TRUE(poc_.has_value()); |
| 242 ASSERT_EQ(1, *poc_); |
223 | 243 |
224 // Duplicate |frame_num| frame. | 244 // Duplicate |frame_num| frame. |
225 slice_hdr_.nal_ref_idc = 0; | 245 slice_hdr_.nal_ref_idc = 0; |
226 slice_hdr_.frame_num = 1; | 246 slice_hdr_.frame_num = 1; |
227 slice_hdr_.delta_pic_order_cnt0 = 2; | 247 slice_hdr_.delta_pic_order_cnt0 = 2; |
228 ASSERT_TRUE(ComputePOC()); | 248 ComputePOC(); |
229 ASSERT_EQ(2, poc_); | 249 ASSERT_TRUE(poc_.has_value()); |
| 250 ASSERT_EQ(2, *poc_); |
230 } | 251 } |
231 | 252 |
232 TEST_F(H264POCTest, PicOrderCntType2) { | 253 TEST_F(H264POCTest, PicOrderCntType2) { |
233 sps_.pic_order_cnt_type = 2; | 254 sps_.pic_order_cnt_type = 2; |
234 | 255 |
235 // Initial IDR with POC 0. | 256 // Initial IDR with POC 0. |
236 slice_hdr_.idr_pic_flag = true; | 257 slice_hdr_.idr_pic_flag = true; |
237 slice_hdr_.frame_num = 0; | 258 slice_hdr_.frame_num = 0; |
238 ASSERT_TRUE(ComputePOC()); | 259 ComputePOC(); |
239 ASSERT_EQ(0, poc_); | 260 ASSERT_TRUE(poc_.has_value()); |
| 261 ASSERT_EQ(0, *poc_); |
240 | 262 |
241 // Ref frame. | 263 // Ref frame. |
242 slice_hdr_.idr_pic_flag = false; | 264 slice_hdr_.idr_pic_flag = false; |
243 slice_hdr_.frame_num = 1; | 265 slice_hdr_.frame_num = 1; |
244 ASSERT_TRUE(ComputePOC()); | 266 ComputePOC(); |
245 ASSERT_EQ(2, poc_); | 267 ASSERT_TRUE(poc_.has_value()); |
| 268 ASSERT_EQ(2, *poc_); |
246 | 269 |
247 // Ref frame. | 270 // Ref frame. |
248 slice_hdr_.frame_num = 2; | 271 slice_hdr_.frame_num = 2; |
249 ASSERT_TRUE(ComputePOC()); | 272 ComputePOC(); |
250 ASSERT_EQ(4, poc_); | 273 ASSERT_TRUE(poc_.has_value()); |
| 274 ASSERT_EQ(4, *poc_); |
251 | 275 |
252 // Ref frame. | 276 // Ref frame. |
253 slice_hdr_.frame_num = 3; | 277 slice_hdr_.frame_num = 3; |
254 ASSERT_TRUE(ComputePOC()); | 278 ComputePOC(); |
255 ASSERT_EQ(6, poc_); | 279 ASSERT_TRUE(poc_.has_value()); |
| 280 ASSERT_EQ(6, *poc_); |
256 | 281 |
257 // Ref frame. | 282 // Ref frame. |
258 slice_hdr_.frame_num = 4; | 283 slice_hdr_.frame_num = 4; |
259 ASSERT_TRUE(ComputePOC()); | 284 ComputePOC(); |
260 ASSERT_EQ(8, poc_); | 285 ASSERT_TRUE(poc_.has_value()); |
| 286 ASSERT_EQ(8, *poc_); |
261 | 287 |
262 // Ref frame, detected as wrapping (ie, this is frame 16). | 288 // Ref frame, detected as wrapping (ie, this is frame 16). |
263 slice_hdr_.frame_num = 0; | 289 slice_hdr_.frame_num = 0; |
264 ASSERT_TRUE(ComputePOC()); | 290 ComputePOC(); |
265 ASSERT_EQ(32, poc_); | 291 ASSERT_TRUE(poc_.has_value()); |
| 292 ASSERT_EQ(32, *poc_); |
266 } | 293 } |
267 | 294 |
268 TEST_F(H264POCTest, PicOrderCntType2_WithMMCO5) { | 295 TEST_F(H264POCTest, PicOrderCntType2_WithMMCO5) { |
269 sps_.pic_order_cnt_type = 2; | 296 sps_.pic_order_cnt_type = 2; |
270 | 297 |
271 // Initial IDR with POC 0. | 298 // Initial IDR with POC 0. |
272 slice_hdr_.idr_pic_flag = true; | 299 slice_hdr_.idr_pic_flag = true; |
273 slice_hdr_.frame_num = 0; | 300 slice_hdr_.frame_num = 0; |
274 ASSERT_TRUE(ComputePOC()); | 301 ComputePOC(); |
275 ASSERT_EQ(0, poc_); | 302 ASSERT_TRUE(poc_.has_value()); |
| 303 ASSERT_EQ(0, *poc_); |
276 | 304 |
277 // Ref frame. | 305 // Ref frame. |
278 slice_hdr_.idr_pic_flag = false; | 306 slice_hdr_.idr_pic_flag = false; |
279 slice_hdr_.frame_num = 1; | 307 slice_hdr_.frame_num = 1; |
280 ASSERT_TRUE(ComputePOC()); | 308 ComputePOC(); |
281 ASSERT_EQ(2, poc_); | 309 ASSERT_TRUE(poc_.has_value()); |
| 310 ASSERT_EQ(2, *poc_); |
282 | 311 |
283 // Ref frame, detected as wrapping. | 312 // Ref frame, detected as wrapping. |
284 SetMMCO5(); | 313 SetMMCO5(); |
285 slice_hdr_.frame_num = 0; | 314 slice_hdr_.frame_num = 0; |
286 ASSERT_TRUE(ComputePOC()); | 315 ComputePOC(); |
287 ASSERT_EQ(0, poc_); | 316 ASSERT_TRUE(poc_.has_value()); |
| 317 ASSERT_EQ(0, *poc_); |
288 | 318 |
289 // Ref frame, wrapping from before has been cleared. | 319 // Ref frame, wrapping from before has been cleared. |
290 slice_hdr_.frame_num = 1; | 320 slice_hdr_.frame_num = 1; |
291 ASSERT_TRUE(ComputePOC()); | 321 ComputePOC(); |
292 ASSERT_EQ(2, poc_); | 322 ASSERT_TRUE(poc_.has_value()); |
| 323 ASSERT_EQ(2, *poc_); |
293 } | 324 } |
294 | 325 |
295 } // namespace media | 326 } // namespace media |
OLD | NEW |