| Index: media/video/h264_poc.cc
|
| diff --git a/media/video/h264_poc.cc b/media/video/h264_poc.cc
|
| index 164d704f13dd51eee5759fe65fd7bb0f03abea3e..88a4a9063e569c508f4beca9be6804dde23f9ee4 100644
|
| --- a/media/video/h264_poc.cc
|
| +++ b/media/video/h264_poc.cc
|
| @@ -27,6 +27,7 @@ void H264POC::Reset() {
|
| ref_pic_order_cnt_lsb_ = 0;
|
| prev_frame_num_ = 0;
|
| prev_frame_num_offset_ = 0;
|
| + prev_poc_ = 0;
|
| }
|
|
|
| // Check if a slice includes memory management control operation 5, which
|
| @@ -62,10 +63,10 @@ bool H264POC::ComputePicOrderCnt(
|
| return false;
|
| }
|
|
|
| - // TODO(sandersd): Handle |gaps_in_frame_num_value|.
|
| - if (prev_frame_num_ > 0 && prev_frame_num_ < slice_hdr.frame_num - 1) {
|
| - DLOG(ERROR) << "Gaps in frame_num are not supported";
|
| - return false;
|
| + if (!slice_hdr.idr_pic_flag && slice_hdr.frame_num == prev_frame_num_) {
|
| + DLOG(WARNING) << "Redundant picture passed to H264POC";
|
| + *pic_order_cnt = prev_poc_;
|
| + return true;
|
| }
|
|
|
| bool mmco5 = HasMMCO5(slice_hdr);
|
| @@ -73,11 +74,21 @@ bool H264POC::ComputePicOrderCnt(
|
| int32_t max_pic_order_cnt_lsb =
|
| 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4);
|
|
|
| + if (!slice_hdr.idr_pic_flag &&
|
| + slice_hdr.frame_num != (prev_frame_num_ + 1) % max_frame_num) {
|
| + // We don't do any special handling of gaps in |frame_num|, because the
|
| + // computations below are unaffected by them. In particular, wrapping is
|
| + // handled the same whether we simulate the missing frames or not.
|
| + if (!sps->gaps_in_frame_num_value_allowed_flag)
|
| + DLOG(WARNING) << "Invalid gap in frame_num";
|
| + }
|
| +
|
| // Based on T-REC-H.264 8.2.1, "Decoding process for picture order
|
| // count", available from http://www.itu.int/rec/T-REC-H.264.
|
| //
|
| // Reorganized slightly from spec pseudocode to handle MMCO5 when storing
|
| // state instead of when loading it.
|
| + int32_t poc;
|
| switch (sps->pic_order_cnt_type) {
|
| case 0: {
|
| int32_t prev_pic_order_cnt_msb = ref_pic_order_cnt_msb_;
|
| @@ -109,7 +120,7 @@ bool H264POC::ComputePicOrderCnt(
|
| // (assuming no interlacing).
|
| int32_t top_foc = pic_order_cnt_msb + slice_hdr.pic_order_cnt_lsb;
|
| int32_t bottom_foc = top_foc + slice_hdr.delta_pic_order_cnt_bottom;
|
| - *pic_order_cnt = std::min(top_foc, bottom_foc);
|
| + poc = std::min(top_foc, bottom_foc);
|
|
|
| // Store state.
|
| prev_frame_num_ = slice_hdr.frame_num;
|
| @@ -178,7 +189,7 @@ bool H264POC::ComputePicOrderCnt(
|
| int32_t top_foc = expected_pic_order_cnt + slice_hdr.delta_pic_order_cnt0;
|
| int32_t bottom_foc = top_foc + sps->offset_for_top_to_bottom_field +
|
| slice_hdr.delta_pic_order_cnt1;
|
| - *pic_order_cnt = std::min(top_foc, bottom_foc);
|
| + poc = std::min(top_foc, bottom_foc);
|
|
|
| // Store state.
|
| prev_frame_num_ = slice_hdr.frame_num;
|
| @@ -202,11 +213,11 @@ bool H264POC::ComputePicOrderCnt(
|
| // 8-12, 8-13. Derive |temp_pic_order_count| (it's always the
|
| // |pic_order_cnt|, regardless of interlacing).
|
| if (slice_hdr.idr_pic_flag)
|
| - *pic_order_cnt = 0;
|
| + poc = 0;
|
| else if (slice_hdr.nal_ref_idc == 0)
|
| - *pic_order_cnt = 2 * (frame_num_offset + slice_hdr.frame_num) - 1;
|
| + poc = 2 * (frame_num_offset + slice_hdr.frame_num) - 1;
|
| else
|
| - *pic_order_cnt = 2 * (frame_num_offset + slice_hdr.frame_num);
|
| + poc = 2 * (frame_num_offset + slice_hdr.frame_num);
|
|
|
| // Store state.
|
| prev_frame_num_ = slice_hdr.frame_num;
|
| @@ -222,6 +233,7 @@ bool H264POC::ComputePicOrderCnt(
|
| return false;
|
| }
|
|
|
| + *pic_order_cnt = prev_poc_ = poc;
|
| return true;
|
| }
|
|
|
|
|