From 34fe125f4bc8b6fba16140517c01424cba302499 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 20 Dec 2013 13:50:46 +0100 Subject: [PATCH] avcodec/mpegvideo_enc: fix frame skipping with intra only codecs Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo.c | 4 +++- libavcodec/mpegvideo_enc.c | 27 ++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 4c25845b8c..e96791af6b 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -2655,7 +2655,9 @@ FF_ENABLE_DEPRECATION_WARNINGS else if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) s->mbintra_table[mb_xy]=1; - if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc + if ( (s->flags&CODEC_FLAG_PSNR) + || s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor + || !(s->encoding && (s->intra_only || s->pict_type==AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc uint8_t *dest_y, *dest_cb, *dest_cr; int dct_linesize, dct_offset; op_pixels_func (*op_pix)[4]; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 2153fdac8f..6bf3e384c6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1300,6 +1300,20 @@ static int select_input_picture(MpegEncContext *s) /* set next picture type & ordering */ if (s->reordered_input_picture[0] == NULL && s->input_picture[0]) { + if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) { + if (s->picture_in_gop_number < s->gop_size && + s->next_picture_ptr && + skip_check(s, s->input_picture[0], s->next_picture_ptr)) { + // FIXME check that te gop check above is +-1 correct + av_frame_unref(&s->input_picture[0]->f); + + emms_c(); + ff_vbv_update(s, 0); + + goto no_output_pic; + } + } + if (/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr == NULL || s->intra_only) { s->reordered_input_picture[0] = s->input_picture[0]; @@ -1309,19 +1323,6 @@ static int select_input_picture(MpegEncContext *s) } else { int b_frames; - if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) { - if (s->picture_in_gop_number < s->gop_size && - skip_check(s, s->input_picture[0], s->next_picture_ptr)) { - // FIXME check that te gop check above is +-1 correct - av_frame_unref(&s->input_picture[0]->f); - - emms_c(); - ff_vbv_update(s, 0); - - goto no_output_pic; - } - } - if (s->flags & CODEC_FLAG_PASS2) { for (i = 0; i < s->max_b_frames + 1; i++) { int pict_num = s->input_picture[0]->f.display_picture_number + i;