avcodec/mpeg4videodec: duplicate the last decoded frame when the last coded frame was skipped

This ensures the video stream duration is not lost after decoding.

Signed-off-by: James Almer <jamrial@gmail.com>
pull/388/head
James Almer 2 years ago
parent 69ac78da9b
commit 261cd929e0
  1. 13
      libavcodec/h263dec.c
  2. 1
      libavcodec/mpegvideo.h

@ -430,6 +430,18 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
return ret;
s->next_picture_ptr = NULL;
*got_frame = 1;
} else if (s->skipped_last_frame && s->current_picture_ptr) {
/* Output the last picture we decoded again if the stream ended with
* an NVOP */
if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
/* Copy props from the last input packet. Otherwise, props from the last
* returned picture would be reused */
if ((ret = ff_decode_frame_props(avctx, pict)) < 0)
return ret;
s->current_picture_ptr = NULL;
*got_frame = 1;
}
@ -500,6 +512,7 @@ retry:
s->extradata_parsed = 1;
}
ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0);
s->skipped_last_frame = (ret == FRAME_SKIPPED);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {

@ -175,6 +175,7 @@ typedef struct MpegEncContext {
Picture *last_picture_ptr; ///< pointer to the previous picture.
Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred)
Picture *current_picture_ptr; ///< pointer to the current picture
int skipped_last_frame;
int last_dc[3]; ///< last DC values for MPEG-1
int16_t *dc_val_base;
int16_t *dc_val[3]; ///< used for MPEG-4 DC prediction, all 3 arrays must be continuous

Loading…
Cancel
Save