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

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

Issue 742233002: Implement |pic_order_cnt| computation for VTVideoDecode accelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vt_reorder
Patch Set: Casting Created 6 years, 1 month 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/files/file_path.h"
6 #include "base/files/memory_mapped_file.h"
7 #include "media/base/test_data_util.h"
8 #include "media/filters/h264_parser.h"
9 #include "media/video/h264_poc.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace media {
13
14 class H264POCTest: public testing::Test {
15 public:
16 H264POCTest() {
17 sps_.log2_max_frame_num_minus4 = 0;
DaleCurtis 2014/11/21 23:39:57 If the zeros aren't really adding to the readabili
sandersd (OOO until July 31) 2014/11/21 23:44:20 Done.
18 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0;
19 sps_.pic_order_cnt_type = 0;
20 sps_.num_ref_frames_in_pic_order_cnt_cycle = 4;
21 sps_.expected_delta_per_pic_order_cnt_cycle = 8;
22 sps_.offset_for_ref_frame[0] = 0;
23 sps_.offset_for_ref_frame[1] = 0;
24 sps_.offset_for_ref_frame[2] = 0;
25 sps_.offset_for_ref_frame[3] = 0;
26 sps_.offset_for_non_ref_pic = 0;
27 sps_.offset_for_top_to_bottom_field = 1;
28
29 slice_hdr_.field_pic_flag = false; // Not interlaced
30 slice_hdr_.frame_num = 0;
31 slice_hdr_.idr_pic_flag = true; // Start with an IDR.
32 slice_hdr_.pic_order_cnt_lsb = 0;
33 slice_hdr_.delta_pic_order_cnt_bottom = 0; // Entirely ignore fields.
34 slice_hdr_.nal_ref_idc = 1; // Set as a reference frame.
35 slice_hdr_.delta_pic_order_cnt[0] = 0;
36 slice_hdr_.delta_pic_order_cnt[1] = 0;
37 slice_hdr_.adaptive_ref_pic_marking_mode_flag = false;
38 }
39
40 protected:
41 bool ComputePOC() {
42 return h264_poc_.ComputePicOrderCnt(&sps_, slice_hdr_, &poc_);
43 }
44
45 // Also sets as a reference frame and unsets IDR, which is required for
46 // memory management control operations to be parsed.
47 void SetMMCO5() {
48 slice_hdr_.nal_ref_idc = 1; // Anything nonzero.
49 slice_hdr_.idr_pic_flag = false;
50 slice_hdr_.adaptive_ref_pic_marking_mode_flag = true;
51 slice_hdr_.ref_pic_marking[0].memory_mgmnt_control_operation = 6;
52 slice_hdr_.ref_pic_marking[1].memory_mgmnt_control_operation = 5;
53 slice_hdr_.ref_pic_marking[2].memory_mgmnt_control_operation = 0;
54 }
55
56 int32_t poc_;
57
58 H264SPS sps_;
59 H264SliceHeader slice_hdr_;
60 H264POC h264_poc_;
61
62 DISALLOW_COPY_AND_ASSIGN(H264POCTest);
63 };
64
65 TEST_F(H264POCTest, PicOrderCntType0) {
66 sps_.pic_order_cnt_type = 0;
67 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16
68
69 // Initial IDR with POC 0.
70 ASSERT_TRUE(ComputePOC());
71 ASSERT_EQ(0, poc_);
72
73 // Ref frame with POC lsb 8.
74 slice_hdr_.idr_pic_flag = false;
75 slice_hdr_.pic_order_cnt_lsb = 8;
76 ASSERT_TRUE(ComputePOC());
77 ASSERT_EQ(8, poc_);
78
79 // Ref frame with POC lsb 0. This should be detected as wrapping, as the
80 // (negative) gap is at least half the maximum.
81 slice_hdr_.pic_order_cnt_lsb = 0;
82 ASSERT_TRUE(ComputePOC());
83 ASSERT_EQ(16, poc_);
84
85 // Ref frame with POC lsb 9. This should be detected as negative wrapping,
86 // as the (positive) gap is more than half the maximum.
87 slice_hdr_.pic_order_cnt_lsb = 9;
88 ASSERT_TRUE(ComputePOC());
89 ASSERT_EQ(9, poc_);
90 }
91
92 TEST_F(H264POCTest, PicOrderCntType0_WithMMCO5) {
93 sps_.pic_order_cnt_type = 0;
94 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16
95
96 // Initial IDR with POC 0.
97 ASSERT_TRUE(ComputePOC());
98 ASSERT_EQ(0, poc_);
99
100 // Skip ahead.
101 slice_hdr_.idr_pic_flag = false;
102 slice_hdr_.pic_order_cnt_lsb = 8;
103 ASSERT_TRUE(ComputePOC());
104 ASSERT_EQ(8, poc_);
105
106 slice_hdr_.pic_order_cnt_lsb = 0;
107 ASSERT_TRUE(ComputePOC());
108 ASSERT_EQ(16, poc_);
109
110 slice_hdr_.pic_order_cnt_lsb = 8;
111 ASSERT_TRUE(ComputePOC());
112 ASSERT_EQ(24, poc_);
113
114 SetMMCO5();
115 slice_hdr_.pic_order_cnt_lsb = 0;
116 ASSERT_TRUE(ComputePOC());
117 ASSERT_EQ(32, poc_);
118
119 // Due to the MMCO5 above, this is relative to 0, but also detected as
120 // positive wrapping.
121 slice_hdr_.pic_order_cnt_lsb = 8;
122 ASSERT_TRUE(ComputePOC());
123 ASSERT_EQ(24, poc_);
124 }
125
126 TEST_F(H264POCTest, PicOrderCntType1) {
127 sps_.pic_order_cnt_type = 1;
128 sps_.log2_max_frame_num_minus4 = 0; // 16
129 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2;
130 sps_.expected_delta_per_pic_order_cnt_cycle = 3;
131 sps_.offset_for_ref_frame[0] = 1;
132 sps_.offset_for_ref_frame[1] = 2;
133
134 // Initial IDR with POC 0.
135 slice_hdr_.frame_num = 0;
136 ASSERT_TRUE(ComputePOC());
137 ASSERT_EQ(0, poc_);
138
139 // Ref frame.
140 slice_hdr_.idr_pic_flag = false;
141 slice_hdr_.frame_num = 1;
142 ASSERT_TRUE(ComputePOC());
143 ASSERT_EQ(1, poc_);
144
145 // Ref frame.
146 slice_hdr_.frame_num = 2;
147 ASSERT_TRUE(ComputePOC());
148 ASSERT_EQ(3, poc_);
149
150 // Ref frame.
151 slice_hdr_.frame_num = 3;
152 ASSERT_TRUE(ComputePOC());
153 ASSERT_EQ(4, poc_);
154
155 // Ref frame.
156 slice_hdr_.frame_num = 4;
157 ASSERT_TRUE(ComputePOC());
158 ASSERT_EQ(6, poc_);
159
160 // Ref frame, detected as wrapping (ie, this is frame 16).
161 slice_hdr_.frame_num = 0;
162 ASSERT_TRUE(ComputePOC());
163 ASSERT_EQ(24, poc_);
164 }
165
166 TEST_F(H264POCTest, PicOrderCntType1_WithMMCO5) {
167 sps_.pic_order_cnt_type = 1;
168 sps_.log2_max_frame_num_minus4 = 0; // 16
169 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2;
170 sps_.expected_delta_per_pic_order_cnt_cycle = 3;
171 sps_.offset_for_ref_frame[0] = 1;
172 sps_.offset_for_ref_frame[1] = 2;
173
174 // Initial IDR with POC 0.
175 slice_hdr_.frame_num = 0;
176 ASSERT_TRUE(ComputePOC());
177 ASSERT_EQ(0, poc_);
178
179 // Ref frame.
180 slice_hdr_.idr_pic_flag = false;
181 slice_hdr_.frame_num = 1;
182 ASSERT_TRUE(ComputePOC());
183 ASSERT_EQ(1, poc_);
184
185 // Ref frame, detected as wrapping.
186 SetMMCO5();
187 slice_hdr_.frame_num = 0;
188 ASSERT_TRUE(ComputePOC());
189 ASSERT_EQ(24, poc_);
190
191 // Ref frame, wrapping from before has been cleared.
192 slice_hdr_.frame_num = 1;
193 ASSERT_TRUE(ComputePOC());
194 ASSERT_EQ(1, poc_);
195 }
196
197 TEST_F(H264POCTest, PicOrderCntType2) {
198 sps_.pic_order_cnt_type = 2;
199
200 // Initial IDR with POC 0.
201 slice_hdr_.frame_num = 0;
202 ASSERT_TRUE(ComputePOC());
203 ASSERT_EQ(0, poc_);
204
205 // Ref frame.
206 slice_hdr_.idr_pic_flag = false;
207 slice_hdr_.frame_num = 1;
208 ASSERT_TRUE(ComputePOC());
209 ASSERT_EQ(2, poc_);
210
211 // Ref frame.
212 slice_hdr_.frame_num = 2;
213 ASSERT_TRUE(ComputePOC());
214 ASSERT_EQ(4, poc_);
215
216 // Ref frame.
217 slice_hdr_.frame_num = 3;
218 ASSERT_TRUE(ComputePOC());
219 ASSERT_EQ(6, poc_);
220
221 // Ref frame.
222 slice_hdr_.frame_num = 4;
223 ASSERT_TRUE(ComputePOC());
224 ASSERT_EQ(8, poc_);
225
226 // Ref frame, detected as wrapping (ie, this is frame 16).
227 slice_hdr_.frame_num = 0;
228 ASSERT_TRUE(ComputePOC());
229 ASSERT_EQ(32, poc_);
230 }
231
232 TEST_F(H264POCTest, PicOrderCntType2_WithMMCO5) {
233 sps_.pic_order_cnt_type = 2;
234
235 // Initial IDR with POC 0.
236 slice_hdr_.frame_num = 0;
237 ASSERT_TRUE(ComputePOC());
238 ASSERT_EQ(0, poc_);
239
240 // Ref frame.
241 slice_hdr_.idr_pic_flag = false;
242 slice_hdr_.frame_num = 1;
243 ASSERT_TRUE(ComputePOC());
244 ASSERT_EQ(2, poc_);
245
246 // Ref frame, detected as wrapping.
247 SetMMCO5();
248 slice_hdr_.frame_num = 0;
249 ASSERT_TRUE(ComputePOC());
250 ASSERT_EQ(32, poc_);
251
252 // Ref frame, wrapping from before has been cleared.
253 slice_hdr_.frame_num = 1;
254 ASSERT_TRUE(ComputePOC());
255 ASSERT_EQ(2, poc_);
256 }
257
258 } // 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