ffmpeg | branch: master | Clément Bœsch <clem...@stupeflix.com> | Thu Jun 30 10:24:03 2016 +0200| [f48aea66ddfef3998ee7aaf6c6567577ae481807] | committer: Clément Bœsch
Merge commit 'bec993381cfec72051b0d9f12ac9d9bb9c750983' * commit 'bec993381cfec72051b0d9f12ac9d9bb9c750983': h264: postpone generating the implicit MMCOs Merged-by: Clément Bœsch <clem...@stupeflix.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f48aea66ddfef3998ee7aaf6c6567577ae481807 --- libavcodec/h264.h | 6 +++--- libavcodec/h264_picture.c | 2 +- libavcodec/h264_refs.c | 33 ++++++++++++++++----------------- libavcodec/h264_slice.c | 12 ++++++------ 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 84cf59e..efca5ab 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -456,6 +456,7 @@ typedef struct H264SliceContext { MMCO mmco[MAX_MMCO_COUNT]; int nb_mmco; + int explicit_ref_marking; } H264SliceContext; /** @@ -603,6 +604,7 @@ typedef struct H264Context { MMCO mmco[MAX_MMCO_COUNT]; int nb_mmco; int mmco_reset; + int explicit_ref_marking; int long_ref_count; ///< number of actual long term references int short_ref_count; ///< number of actual short term references @@ -729,13 +731,11 @@ void ff_h264_remove_all_refs(H264Context *h); /** * Execute the reference picture marking (memory management control operations). */ -int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count); +int ff_h264_execute_ref_pic_marking(H264Context *h); int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl, GetBitContext *gb); -int ff_generate_sliding_window_mmcos(const H264Context *h, H264SliceContext *sl); - void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl); int ff_h264_decode_init(AVCodecContext *avctx); void ff_h264_decode_init_vlc(void); diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index 320bb0c..6426b54 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -164,7 +164,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) { if (!h->droppable) { - err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->nb_mmco); + err = ff_h264_execute_ref_pic_marking(h); h->poc.prev_poc_msb = h->poc.poc_msb; h->poc.prev_poc_lsb = h->poc.poc_lsb; } diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index c710012..5905276 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -601,11 +601,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; if (h->short_ref_count && h->long_ref_count + h->short_ref_count >= h->ps.sps->ref_frame_count && @@ -621,18 +620,22 @@ 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 pps_ref_count[2] = {0}; 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"); @@ -838,7 +841,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; @@ -849,8 +852,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); @@ -894,16 +899,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; } diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index cb52b77..10baf10 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -431,6 +431,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, memcpy(h->mmco, h1->mmco, sizeof(h->mmco)); h->nb_mmco = h1->nb_mmco; h->mmco_reset = h1->mmco_reset; + h->explicit_ref_marking = h1->explicit_ref_marking; h->long_ref_count = h1->long_ref_count; h->short_ref_count = h1->short_ref_count; @@ -445,7 +446,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, return 0; if (!h->droppable) { - err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->nb_mmco); + err = ff_h264_execute_ref_pic_marking(h); h->poc.prev_poc_msb = h->poc.poc_msb; h->poc.prev_poc_lsb = h->poc.poc_lsb; } @@ -1422,11 +1423,8 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl) ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0); ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1); - ret = ff_generate_sliding_window_mmcos(h, sl); - if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) - return ret; - - ret = ff_h264_execute_ref_pic_marking(h, sl->mmco, sl->nb_mmco); + h->explicit_ref_marking = 0; + ret = ff_h264_execute_ref_pic_marking(h); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) return ret; /* Error concealment: If a ref is missing, copy the previous ref @@ -1577,6 +1575,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl) ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count, sl->slice_type_nos, &sl->pwt, h->avctx); + sl->explicit_ref_marking = 0; if (h->nal_ref_idc) { ret = ff_h264_decode_ref_pic_marking(h, sl, &sl->gb); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) @@ -1675,6 +1674,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl) memcpy(h->mmco, sl->mmco, sl->nb_mmco * sizeof(*h->mmco)); h->nb_mmco = sl->nb_mmco; + h->explicit_ref_marking = sl->explicit_ref_marking; } ret = ff_h264_build_ref_list(h, sl); ====================================================================== diff --cc libavcodec/h264_refs.c index c710012,c4b33af..5905276 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@@ -601,14 -536,15 +601,13 @@@ static int check_opcodes(MMCO *mmco1, M 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); - if (h->short_ref_count && - h->long_ref_count + h->short_ref_count == h->ps.sps->ref_frame_count && + h->long_ref_count + h->short_ref_count >= h->ps.sps->ref_frame_count && !(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) { mmco[0].opcode = MMCO_SHORT2UNUSED; mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num; @@@ -621,15 -557,14 +620,15 @@@ } } - 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 pps_ref_count[2] = {0}; int current_ref_assigned = 0, err = 0; H264Picture *av_uninit(pic); diff --cc libavcodec/h264_slice.c index cb52b77,23f4343..10baf10 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@@ -1575,8 -1340,9 +1573,9 @@@ static int h264_slice_header_parse(H264 (pps->weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B)) ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count, - sl->slice_type_nos, &sl->pwt); + sl->slice_type_nos, &sl->pwt, h->avctx); + sl->explicit_ref_marking = 0; if (h->nal_ref_idc) { ret = ff_h264_decode_ref_pic_marking(h, sl, &sl->gb); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog