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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (slice_hdr.field_pic_flag) { | 60 if (slice_hdr.field_pic_flag) { |
61 DLOG(ERROR) << "Interlaced frames are not supported"; | 61 DLOG(ERROR) << "Interlaced frames are not supported"; |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 bool mmco5 = HasMMCO5(slice_hdr); | 65 bool mmco5 = HasMMCO5(slice_hdr); |
66 int32_t max_frame_num = 1 << (sps->log2_max_frame_num_minus4 + 4); | 66 int32_t max_frame_num = 1 << (sps->log2_max_frame_num_minus4 + 4); |
67 int32_t max_pic_order_cnt_lsb = | 67 int32_t max_pic_order_cnt_lsb = |
68 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4); | 68 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4); |
69 | 69 |
70 // Check for invalid (including duplicate) |frame_num| values. All cases are | 70 // Note: Duplicate frame numbers are ignored. They occur in many videos |
71 // treated as gaps, which is to say that nothing is done. (Gaps don't affect | 71 // despite appearing to be invalid according to the spec. |
72 // POC computation.) | 72 // TODO(sandersd): Check if these videos are using slices or have redundant |
73 if (!slice_hdr.idr_pic_flag && | 73 // streams. |
74 slice_hdr.frame_num != (prev_frame_num_ + 1) % max_frame_num) { | 74 |
75 if (!sps->gaps_in_frame_num_value_allowed_flag) | 75 // Note: Gaps in frame numbers are also ignored. They do not affect POC |
76 DLOG(WARNING) << "Invalid gap in frame_num"; | 76 // computation. |
77 } | |
78 | 77 |
79 // Based on T-REC-H.264 8.2.1, "Decoding process for picture order | 78 // Based on T-REC-H.264 8.2.1, "Decoding process for picture order |
80 // count", available from http://www.itu.int/rec/T-REC-H.264. | 79 // count", available from http://www.itu.int/rec/T-REC-H.264. |
81 // | 80 // |
82 // Reorganized slightly from spec pseudocode to handle MMCO5 when storing | 81 // Reorganized slightly from spec pseudocode to handle MMCO5 when storing |
83 // state instead of when loading it. | 82 // state instead of when loading it. |
84 switch (sps->pic_order_cnt_type) { | 83 switch (sps->pic_order_cnt_type) { |
85 case 0: { | 84 case 0: { |
86 int32_t prev_pic_order_cnt_msb = ref_pic_order_cnt_msb_; | 85 int32_t prev_pic_order_cnt_msb = ref_pic_order_cnt_msb_; |
87 int32_t prev_pic_order_cnt_lsb = ref_pic_order_cnt_lsb_; | 86 int32_t prev_pic_order_cnt_lsb = ref_pic_order_cnt_lsb_; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 221 |
223 default: | 222 default: |
224 DLOG(ERROR) << "Invalid pic_order_cnt_type: " << sps->pic_order_cnt_type; | 223 DLOG(ERROR) << "Invalid pic_order_cnt_type: " << sps->pic_order_cnt_type; |
225 return false; | 224 return false; |
226 } | 225 } |
227 | 226 |
228 return true; | 227 return true; |
229 } | 228 } |
230 | 229 |
231 } // namespace media | 230 } // namespace media |
OLD | NEW |