aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_refs.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-05-09 14:25:56 +0200
committerAnton Khirnov <anton@khirnov.net>2016-06-12 20:27:53 +0200
commitbec993381cfec72051b0d9f12ac9d9bb9c750983 (patch)
tree4f7585caa0abcc3dcede2b8a7320b772094db291 /libavcodec/h264_refs.c
parent2d410ebbaa1e760d6837cb434a6d1d4c3c6f0d85 (diff)
downloadffmpeg-bec993381cfec72051b0d9f12ac9d9bb9c750983.tar.gz
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().
Diffstat (limited to 'libavcodec/h264_refs.c')
-rw-r--r--libavcodec/h264_refs.c33
1 files changed, 16 insertions, 17 deletions
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;
}