Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: media/video/h264_poc_unittest.cc

Issue 2661423002: VTVDA: Optimize pic_order_cnt_type == 2. (Closed)
Patch Set: Update unit test. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/video/h264_poc.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 bool ComputePOC() {
26 return h264_poc_.ComputePicOrderCnt(&sps_, slice_hdr_, &poc_); 26 bool result = h264_poc_.ComputePicOrderCnt(&sps_, slice_hdr_, &poc_);
27
28 // Clear MMCO5.
29 slice_hdr_.adaptive_ref_pic_marking_mode_flag = false;
30 slice_hdr_.ref_pic_marking[0].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;
33
34 return result;
27 } 35 }
28 36
29 // Also sets as a reference frame and unsets IDR, which is required for 37 // Also sets as a reference frame and unsets IDR, which is required for
30 // memory management control operations to be parsed. 38 // memory management control operations to be parsed.
31 void SetMMCO5() { 39 void SetMMCO5() {
32 slice_hdr_.nal_ref_idc = 1; 40 slice_hdr_.nal_ref_idc = 1;
33 slice_hdr_.idr_pic_flag = false; 41 slice_hdr_.idr_pic_flag = false;
34 slice_hdr_.adaptive_ref_pic_marking_mode_flag = true; 42 slice_hdr_.adaptive_ref_pic_marking_mode_flag = true;
35 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 6; 43 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 6;
36 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 5; 44 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 5;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 slice_hdr_.frame_num = 2; 106 slice_hdr_.frame_num = 2;
99 slice_hdr_.pic_order_cnt_lsb = 0; 107 slice_hdr_.pic_order_cnt_lsb = 0;
100 ASSERT_TRUE(ComputePOC()); 108 ASSERT_TRUE(ComputePOC());
101 ASSERT_EQ(16, poc_); 109 ASSERT_EQ(16, poc_);
102 110
103 slice_hdr_.frame_num = 3; 111 slice_hdr_.frame_num = 3;
104 slice_hdr_.pic_order_cnt_lsb = 8; 112 slice_hdr_.pic_order_cnt_lsb = 8;
105 ASSERT_TRUE(ComputePOC()); 113 ASSERT_TRUE(ComputePOC());
106 ASSERT_EQ(24, poc_); 114 ASSERT_EQ(24, poc_);
107 115
116 // MMCO5 resets to 0.
108 slice_hdr_.frame_num = 4; 117 slice_hdr_.frame_num = 4;
109 slice_hdr_.pic_order_cnt_lsb = 0; 118 slice_hdr_.pic_order_cnt_lsb = 0;
110 SetMMCO5(); 119 SetMMCO5();
111 ASSERT_TRUE(ComputePOC()); 120 ASSERT_TRUE(ComputePOC());
112 ASSERT_EQ(32, poc_); 121 ASSERT_EQ(0, poc_);
113 122
114 // Due to the MMCO5 above, this is relative to 0, but also detected as 123 // Still detected as positive wrapping.
115 // positive wrapping.
116 slice_hdr_.frame_num = 5; 124 slice_hdr_.frame_num = 5;
117 slice_hdr_.pic_order_cnt_lsb = 8; 125 slice_hdr_.pic_order_cnt_lsb = 8;
118 ASSERT_TRUE(ComputePOC()); 126 ASSERT_TRUE(ComputePOC());
119 ASSERT_EQ(24, poc_); 127 ASSERT_EQ(24, poc_);
120 } 128 }
121 129
122 TEST_F(H264POCTest, PicOrderCntType1) { 130 TEST_F(H264POCTest, PicOrderCntType1) {
123 sps_.pic_order_cnt_type = 1; 131 sps_.pic_order_cnt_type = 1;
124 sps_.log2_max_frame_num_minus4 = 0; // 16 132 sps_.log2_max_frame_num_minus4 = 0; // 16
125 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; 133 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Ref frame. 185 // Ref frame.
178 slice_hdr_.idr_pic_flag = false; 186 slice_hdr_.idr_pic_flag = false;
179 slice_hdr_.frame_num = 1; 187 slice_hdr_.frame_num = 1;
180 ASSERT_TRUE(ComputePOC()); 188 ASSERT_TRUE(ComputePOC());
181 ASSERT_EQ(1, poc_); 189 ASSERT_EQ(1, poc_);
182 190
183 // Ref frame, detected as wrapping. 191 // Ref frame, detected as wrapping.
184 SetMMCO5(); 192 SetMMCO5();
185 slice_hdr_.frame_num = 0; 193 slice_hdr_.frame_num = 0;
186 ASSERT_TRUE(ComputePOC()); 194 ASSERT_TRUE(ComputePOC());
187 ASSERT_EQ(24, poc_); 195 ASSERT_EQ(0, poc_);
188 196
189 // Ref frame, wrapping from before has been cleared. 197 // Ref frame, wrapping from before has been cleared.
190 slice_hdr_.frame_num = 1; 198 slice_hdr_.frame_num = 1;
191 ASSERT_TRUE(ComputePOC()); 199 ASSERT_TRUE(ComputePOC());
192 ASSERT_EQ(1, poc_); 200 ASSERT_EQ(1, poc_);
193 } 201 }
194 202
195 // Despite being invalid, videos with duplicate non-keyframe |frame_num| values 203 // |frame_num| values may be duplicated by non-reference frames.
196 // are common. http://crbug.com/615289, http://crbug.com/616349.
197 TEST_F(H264POCTest, PicOrderCntType1_DupFrameNum) { 204 TEST_F(H264POCTest, PicOrderCntType1_DupFrameNum) {
198 sps_.pic_order_cnt_type = 1; 205 sps_.pic_order_cnt_type = 1;
199 sps_.log2_max_frame_num_minus4 = 0; // 16 206 sps_.log2_max_frame_num_minus4 = 0; // 16
200 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; 207 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2;
201 sps_.expected_delta_per_pic_order_cnt_cycle = 3; 208 sps_.expected_delta_per_pic_order_cnt_cycle = 3;
202 sps_.offset_for_ref_frame[0] = 1; 209 sps_.offset_for_ref_frame[0] = 1;
203 sps_.offset_for_ref_frame[1] = 2; 210 sps_.offset_for_ref_frame[1] = 2;
204 211
205 // Initial IDR with POC 0. 212 // Initial IDR with POC 0.
206 slice_hdr_.idr_pic_flag = true; 213 slice_hdr_.idr_pic_flag = true;
207 slice_hdr_.frame_num = 0; 214 slice_hdr_.frame_num = 0;
208 ASSERT_TRUE(ComputePOC()); 215 ASSERT_TRUE(ComputePOC());
209 ASSERT_EQ(0, poc_); 216 ASSERT_EQ(0, poc_);
210 217
211 // Ref frame. 218 // Ref frame.
212 slice_hdr_.idr_pic_flag = false; 219 slice_hdr_.idr_pic_flag = false;
213 slice_hdr_.frame_num = 1; 220 slice_hdr_.frame_num = 1;
214 ASSERT_TRUE(ComputePOC()); 221 ASSERT_TRUE(ComputePOC());
215 ASSERT_EQ(1, poc_); 222 ASSERT_EQ(1, poc_);
216 223
217 // Duplicate |frame_num| frame. 224 // Duplicate |frame_num| frame.
225 slice_hdr_.nal_ref_idc = 0;
218 slice_hdr_.frame_num = 1; 226 slice_hdr_.frame_num = 1;
219 slice_hdr_.delta_pic_order_cnt0 = 1; 227 slice_hdr_.delta_pic_order_cnt0 = 2;
220 ASSERT_TRUE(ComputePOC()); 228 ASSERT_TRUE(ComputePOC());
221 ASSERT_EQ(2, poc_); 229 ASSERT_EQ(2, poc_);
222 } 230 }
223 231
224 TEST_F(H264POCTest, PicOrderCntType2) { 232 TEST_F(H264POCTest, PicOrderCntType2) {
225 sps_.pic_order_cnt_type = 2; 233 sps_.pic_order_cnt_type = 2;
226 234
227 // Initial IDR with POC 0. 235 // Initial IDR with POC 0.
228 slice_hdr_.idr_pic_flag = true; 236 slice_hdr_.idr_pic_flag = true;
229 slice_hdr_.frame_num = 0; 237 slice_hdr_.frame_num = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // Ref frame. 277 // Ref frame.
270 slice_hdr_.idr_pic_flag = false; 278 slice_hdr_.idr_pic_flag = false;
271 slice_hdr_.frame_num = 1; 279 slice_hdr_.frame_num = 1;
272 ASSERT_TRUE(ComputePOC()); 280 ASSERT_TRUE(ComputePOC());
273 ASSERT_EQ(2, poc_); 281 ASSERT_EQ(2, poc_);
274 282
275 // Ref frame, detected as wrapping. 283 // Ref frame, detected as wrapping.
276 SetMMCO5(); 284 SetMMCO5();
277 slice_hdr_.frame_num = 0; 285 slice_hdr_.frame_num = 0;
278 ASSERT_TRUE(ComputePOC()); 286 ASSERT_TRUE(ComputePOC());
279 ASSERT_EQ(32, poc_); 287 ASSERT_EQ(0, poc_);
280 288
281 // Ref frame, wrapping from before has been cleared. 289 // Ref frame, wrapping from before has been cleared.
282 slice_hdr_.frame_num = 1; 290 slice_hdr_.frame_num = 1;
283 ASSERT_TRUE(ComputePOC()); 291 ASSERT_TRUE(ComputePOC());
284 ASSERT_EQ(2, poc_); 292 ASSERT_EQ(2, poc_);
285 } 293 }
286 294
287 } // namespace media 295 } // namespace media
OLDNEW
« no previous file with comments | « media/video/h264_poc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698