ffmpeg | branch: master | Clément Bœsch <u...@pkh.me> | Wed Jul 27 17:28:00 2016 +0200| [87d1f820591b87bec452f33f451dee4db142ee9a] | committer: Clément Bœsch
Merge commit 'f966498e433fead2f5e6b5b66fad2ac062146d22' * commit 'f966498e433fead2f5e6b5b66fad2ac062146d22': h264: decode the poc values from the slice header into the per-slice context Merged-by: Clément Bœsch <u...@pkh.me> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=87d1f820591b87bec452f33f451dee4db142ee9a --- libavcodec/h264.h | 5 +++++ libavcodec/h264_slice.c | 46 ++++++++++++++++++---------------------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index e106f00..ceec2c3 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -460,6 +460,11 @@ typedef struct H264SliceContext { MMCO mmco[MAX_MMCO_COUNT]; int nb_mmco; int explicit_ref_marking; + + int frame_num; + int poc_lsb; + int delta_poc_bottom; + int delta_poc[2]; } H264SliceContext; /** diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index f68dfc7..74e8118 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1150,6 +1150,12 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, h->droppable = (nal->ref_idc == 0); h->picture_structure = sl->picture_structure; + h->poc.frame_num = sl->frame_num; + h->poc.poc_lsb = sl->poc_lsb; + h->poc.delta_poc_bottom = sl->delta_poc_bottom; + h->poc.delta_poc[0] = sl->delta_poc[0]; + h->poc.delta_poc[1] = sl->delta_poc[1]; + /* Shorten frame num gaps so we don't have to allocate reference * frames just to throw them away */ if (h->poc.frame_num != h->poc.prev_frame_num) { @@ -1340,7 +1346,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl, unsigned int slice_type, tmp, i; int field_pic_flag, bottom_field_flag; int first_slice = sl == h->slice_ctx && !h->current_slice; - int frame_num, picture_structure; + int picture_structure; if (first_slice) av_assert0(!h->setup_finished); @@ -1390,18 +1396,15 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl, } sps = (const SPS*)h->ps.sps_list[pps->sps_id]->data; - frame_num = get_bits(&sl->gb, sps->log2_max_frame_num); + sl->frame_num = get_bits(&sl->gb, sps->log2_max_frame_num); if (!first_slice) { - if (h->poc.frame_num != frame_num) { + if (h->poc.frame_num != sl->frame_num) { av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n", - h->poc.frame_num, frame_num); + h->poc.frame_num, sl->frame_num); return AVERROR_INVALIDDATA; } } - if (!h->setup_finished) - h->poc.frame_num = frame_num; - sl->mb_mbaff = 0; if (sps->frame_mbs_only_flag) { @@ -1423,10 +1426,10 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl, sl->mb_field_decoding_flag = picture_structure != PICT_FRAME; if (picture_structure == PICT_FRAME) { - h->curr_pic_num = h->poc.frame_num; + h->curr_pic_num = sl->frame_num; h->max_pic_num = 1 << sps->log2_max_frame_num; } else { - h->curr_pic_num = 2 * h->poc.frame_num + 1; + h->curr_pic_num = 2 * sl->frame_num + 1; h->max_pic_num = 1 << (sps->log2_max_frame_num + 1); } @@ -1434,30 +1437,17 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl, get_ue_golomb_long(&sl->gb); /* idr_pic_id */ if (sps->poc_type == 0) { - int poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); + sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); - if (!h->setup_finished) - h->poc.poc_lsb = poc_lsb; - - if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) { - int delta_poc_bottom = get_se_golomb(&sl->gb); - if (!h->setup_finished) - h->poc.delta_poc_bottom = delta_poc_bottom; - } + if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) + sl->delta_poc_bottom = get_se_golomb(&sl->gb); } if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { - int delta_poc = get_se_golomb(&sl->gb); + sl->delta_poc[0] = get_se_golomb(&sl->gb); - if (!h->setup_finished) - h->poc.delta_poc[0] = delta_poc; - - if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) { - delta_poc = get_se_golomb(&sl->gb); - - if (!h->setup_finished) - h->poc.delta_poc[1] = delta_poc; - } + if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) + sl->delta_poc[1] = get_se_golomb(&sl->gb); } if (pps->redundant_pic_cnt_present) ====================================================================== diff --cc libavcodec/h264_slice.c index f68dfc7,be44e66..74e8118 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@@ -1339,13 -1181,9 +1345,13 @@@ static int h264_slice_header_parse(H264 int ret; unsigned int slice_type, tmp, i; int field_pic_flag, bottom_field_flag; - int droppable, picture_structure; + int first_slice = sl == h->slice_ctx && !h->current_slice; - int frame_num, picture_structure; ++ int picture_structure; + + if (first_slice) + av_assert0(!h->setup_finished); - sl->first_mb_addr = get_ue_golomb(&sl->gb); + sl->first_mb_addr = get_ue_golomb_long(&sl->gb); slice_type = get_ue_golomb_31(&sl->gb); if (slice_type > 9) { @@@ -1390,20 -1228,11 +1396,17 @@@ } sps = (const SPS*)h->ps.sps_list[pps->sps_id]->data; - frame_num = get_bits(&sl->gb, sps->log2_max_frame_num); + sl->frame_num = get_bits(&sl->gb, sps->log2_max_frame_num); + if (!first_slice) { - if (h->poc.frame_num != frame_num) { ++ if (h->poc.frame_num != sl->frame_num) { + av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n", - h->poc.frame_num, frame_num); ++ h->poc.frame_num, sl->frame_num); + return AVERROR_INVALIDDATA; + } + } - if (!h->setup_finished) - h->poc.frame_num = frame_num; - sl->mb_mbaff = 0; - droppable = nal->ref_idc == 0; if (sps->frame_mbs_only_flag) { picture_structure = PICT_FRAME; } else { @@@ -1431,19 -1256,13 +1434,13 @@@ } if (nal->type == NAL_IDR_SLICE) - get_ue_golomb(&sl->gb); /* idr_pic_id */ + get_ue_golomb_long(&sl->gb); /* idr_pic_id */ if (sps->poc_type == 0) { - int poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); + sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); - if (!h->setup_finished) - h->poc.poc_lsb = poc_lsb; - - if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) { - int delta_poc_bottom = get_se_golomb(&sl->gb); - if (!h->setup_finished) - h->poc.delta_poc_bottom = delta_poc_bottom; - } + if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) + sl->delta_poc_bottom = get_se_golomb(&sl->gb); } if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog