From bec993381cfec72051b0d9f12ac9d9bb9c750983 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 9 May 2016 14:25:56 +0200 Subject: h264: postpone generating the implicit MMCOs Do it right before the MMCOs are applied to the DPB. This will allow moving the frame_start() call out of the slice header parsing, since generating the implicit MMCOs needs to be done after frame_start(). --- libavcodec/h264_refs.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'libavcodec/h264_refs.c') diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index dae5565eb8..c4b33afb15 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -536,11 +536,10 @@ static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos) return 0; } -int ff_generate_sliding_window_mmcos(const H264Context *h, - H264SliceContext *sl) +static void generate_sliding_window_mmcos(H264Context *h) { - MMCO *mmco = sl->mmco; - int nb_mmco = 0, i = 0; + MMCO *mmco = h->mmco; + int nb_mmco = 0; assert(h->long_ref_count + h->short_ref_count <= h->ps.sps->ref_frame_count); @@ -558,17 +557,21 @@ int ff_generate_sliding_window_mmcos(const H264Context *h, } } - sl->nb_mmco = nb_mmco; - - return 0; + h->nb_mmco = nb_mmco; } -int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count) +int ff_h264_execute_ref_pic_marking(H264Context *h) { + MMCO *mmco = h->mmco; + int mmco_count; int i, av_uninit(j); int current_ref_assigned = 0, err = 0; H264Picture *av_uninit(pic); + if (!h->explicit_ref_marking) + generate_sliding_window_mmcos(h); + mmco_count = h->nb_mmco; + if ((h->avctx->debug & FF_DEBUG_MMCO) && mmco_count == 0) av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n"); @@ -739,7 +742,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count) int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl, GetBitContext *gb) { - int i, ret; + int i; MMCO *mmco = sl->mmco; int nb_mmco = 0; @@ -750,8 +753,10 @@ int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl, mmco[0].long_arg = 0; nb_mmco = 1; } + sl->explicit_ref_marking = 1; } else { - if (get_bits1(gb)) { // adaptive_ref_pic_marking_mode_flag + sl->explicit_ref_marking = get_bits1(gb); + if (sl->explicit_ref_marking) { for (i = 0; i < MAX_MMCO_COUNT; i++) { MMCOOpcode opcode = get_ue_golomb_31(gb); @@ -795,16 +800,10 @@ int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl, break; } nb_mmco = i; - } else { - ret = ff_generate_sliding_window_mmcos(h, sl); - if (ret < 0 && h->avctx->err_recognition & AV_EF_EXPLODE) - return ret; - nb_mmco = -1; } } - if (nb_mmco != -1) - sl->nb_mmco = nb_mmco; + sl->nb_mmco = nb_mmco; return 0; } -- cgit v1.2.3