| 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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(H264POCTest); | 46 DISALLOW_COPY_AND_ASSIGN(H264POCTest); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 TEST_F(H264POCTest, PicOrderCntType0) { | 49 TEST_F(H264POCTest, PicOrderCntType0) { |
| 50 sps_.pic_order_cnt_type = 0; | 50 sps_.pic_order_cnt_type = 0; |
| 51 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 | 51 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 |
| 52 | 52 |
| 53 // Initial IDR with POC 0. | 53 // Initial IDR with POC 0. |
| 54 slice_hdr_.idr_pic_flag = true; | 54 slice_hdr_.idr_pic_flag = true; |
| 55 slice_hdr_.frame_num = 0; |
| 55 ASSERT_TRUE(ComputePOC()); | 56 ASSERT_TRUE(ComputePOC()); |
| 56 ASSERT_EQ(0, poc_); | 57 ASSERT_EQ(0, poc_); |
| 57 | 58 |
| 58 // Ref frame with POC lsb 8. | 59 // Ref frame with POC lsb 8. |
| 59 slice_hdr_.idr_pic_flag = false; | 60 slice_hdr_.idr_pic_flag = false; |
| 61 slice_hdr_.frame_num = 1; |
| 60 slice_hdr_.pic_order_cnt_lsb = 8; | 62 slice_hdr_.pic_order_cnt_lsb = 8; |
| 61 ASSERT_TRUE(ComputePOC()); | 63 ASSERT_TRUE(ComputePOC()); |
| 62 ASSERT_EQ(8, poc_); | 64 ASSERT_EQ(8, poc_); |
| 63 | 65 |
| 64 // Ref frame with POC lsb 0. This should be detected as wrapping, as the | 66 // Ref frame with POC lsb 0. This should be detected as wrapping, as the |
| 65 // (negative) gap is at least half the maximum. | 67 // (negative) gap is at least half the maximum. |
| 66 slice_hdr_.pic_order_cnt_lsb = 0; | 68 slice_hdr_.pic_order_cnt_lsb = 0; |
| 69 slice_hdr_.frame_num = 2; |
| 67 ASSERT_TRUE(ComputePOC()); | 70 ASSERT_TRUE(ComputePOC()); |
| 68 ASSERT_EQ(16, poc_); | 71 ASSERT_EQ(16, poc_); |
| 69 | 72 |
| 70 // Ref frame with POC lsb 9. This should be detected as negative wrapping, | 73 // Ref frame with POC lsb 9. This should be detected as negative wrapping, |
| 71 // as the (positive) gap is more than half the maximum. | 74 // as the (positive) gap is more than half the maximum. |
| 72 slice_hdr_.pic_order_cnt_lsb = 9; | 75 slice_hdr_.pic_order_cnt_lsb = 9; |
| 76 slice_hdr_.frame_num = 3; |
| 73 ASSERT_TRUE(ComputePOC()); | 77 ASSERT_TRUE(ComputePOC()); |
| 74 ASSERT_EQ(9, poc_); | 78 ASSERT_EQ(9, poc_); |
| 75 } | 79 } |
| 76 | 80 |
| 77 TEST_F(H264POCTest, PicOrderCntType0_WithMMCO5) { | 81 TEST_F(H264POCTest, PicOrderCntType0_WithMMCO5) { |
| 78 sps_.pic_order_cnt_type = 0; | 82 sps_.pic_order_cnt_type = 0; |
| 79 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 | 83 sps_.log2_max_pic_order_cnt_lsb_minus4 = 0; // 16 |
| 80 | 84 |
| 81 // Initial IDR with POC 0. | 85 // Initial IDR with POC 0. |
| 82 slice_hdr_.idr_pic_flag = true; | 86 slice_hdr_.idr_pic_flag = true; |
| 87 slice_hdr_.frame_num = 0; |
| 83 ASSERT_TRUE(ComputePOC()); | 88 ASSERT_TRUE(ComputePOC()); |
| 84 ASSERT_EQ(0, poc_); | 89 ASSERT_EQ(0, poc_); |
| 85 | 90 |
| 86 // Skip ahead. | 91 // Skip ahead. |
| 87 slice_hdr_.idr_pic_flag = false; | 92 slice_hdr_.idr_pic_flag = false; |
| 93 slice_hdr_.frame_num = 1; |
| 88 slice_hdr_.pic_order_cnt_lsb = 8; | 94 slice_hdr_.pic_order_cnt_lsb = 8; |
| 89 ASSERT_TRUE(ComputePOC()); | 95 ASSERT_TRUE(ComputePOC()); |
| 90 ASSERT_EQ(8, poc_); | 96 ASSERT_EQ(8, poc_); |
| 91 | 97 |
| 98 slice_hdr_.frame_num = 2; |
| 92 slice_hdr_.pic_order_cnt_lsb = 0; | 99 slice_hdr_.pic_order_cnt_lsb = 0; |
| 93 ASSERT_TRUE(ComputePOC()); | 100 ASSERT_TRUE(ComputePOC()); |
| 94 ASSERT_EQ(16, poc_); | 101 ASSERT_EQ(16, poc_); |
| 95 | 102 |
| 103 slice_hdr_.frame_num = 3; |
| 96 slice_hdr_.pic_order_cnt_lsb = 8; | 104 slice_hdr_.pic_order_cnt_lsb = 8; |
| 97 ASSERT_TRUE(ComputePOC()); | 105 ASSERT_TRUE(ComputePOC()); |
| 98 ASSERT_EQ(24, poc_); | 106 ASSERT_EQ(24, poc_); |
| 99 | 107 |
| 108 slice_hdr_.frame_num = 4; |
| 109 slice_hdr_.pic_order_cnt_lsb = 0; |
| 100 SetMMCO5(); | 110 SetMMCO5(); |
| 101 slice_hdr_.pic_order_cnt_lsb = 0; | |
| 102 ASSERT_TRUE(ComputePOC()); | 111 ASSERT_TRUE(ComputePOC()); |
| 103 ASSERT_EQ(32, poc_); | 112 ASSERT_EQ(32, poc_); |
| 104 | 113 |
| 105 // Due to the MMCO5 above, this is relative to 0, but also detected as | 114 // Due to the MMCO5 above, this is relative to 0, but also detected as |
| 106 // positive wrapping. | 115 // positive wrapping. |
| 116 slice_hdr_.frame_num = 5; |
| 107 slice_hdr_.pic_order_cnt_lsb = 8; | 117 slice_hdr_.pic_order_cnt_lsb = 8; |
| 108 ASSERT_TRUE(ComputePOC()); | 118 ASSERT_TRUE(ComputePOC()); |
| 109 ASSERT_EQ(24, poc_); | 119 ASSERT_EQ(24, poc_); |
| 110 } | 120 } |
| 111 | 121 |
| 112 TEST_F(H264POCTest, PicOrderCntType1) { | 122 TEST_F(H264POCTest, PicOrderCntType1) { |
| 113 sps_.pic_order_cnt_type = 1; | 123 sps_.pic_order_cnt_type = 1; |
| 114 sps_.log2_max_frame_num_minus4 = 0; // 16 | 124 sps_.log2_max_frame_num_minus4 = 0; // 16 |
| 115 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; | 125 sps_.num_ref_frames_in_pic_order_cnt_cycle = 2; |
| 116 sps_.expected_delta_per_pic_order_cnt_cycle = 3; | 126 sps_.expected_delta_per_pic_order_cnt_cycle = 3; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 ASSERT_TRUE(ComputePOC()); | 249 ASSERT_TRUE(ComputePOC()); |
| 240 ASSERT_EQ(32, poc_); | 250 ASSERT_EQ(32, poc_); |
| 241 | 251 |
| 242 // Ref frame, wrapping from before has been cleared. | 252 // Ref frame, wrapping from before has been cleared. |
| 243 slice_hdr_.frame_num = 1; | 253 slice_hdr_.frame_num = 1; |
| 244 ASSERT_TRUE(ComputePOC()); | 254 ASSERT_TRUE(ComputePOC()); |
| 245 ASSERT_EQ(2, poc_); | 255 ASSERT_EQ(2, poc_); |
| 246 } | 256 } |
| 247 | 257 |
| 248 } // namespace media | 258 } // namespace media |
| OLD | NEW |