@@ -2054,8 +2054,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ff_thread_flush(avctx);
- else if (avctx->codec->flush)
+ else if (avctx->codec->flush) {
+ avctx->internal->need_flush = 0;
avctx->codec->flush(avctx);
+ }
avctx->pts_correction_last_pts =
avctx->pts_correction_last_dts = INT64_MIN;
@@ -233,6 +233,9 @@ typedef struct AVCodecInternal {
int initial_sample_rate;
int initial_channels;
uint64_t initial_channel_layout;
+
+ /* used for preserving a frame at the last PTS */
+ int need_flush;
} AVCodecInternal;
struct AVCodecDefault {
@@ -864,6 +864,7 @@ void ff_thread_flush(AVCodecContext *avctx)
release_delayed_buffers(p);
+ avctx->internal->need_flush = 0;
if (avctx->codec->flush)
avctx->codec->flush(p->avctx);
}
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/decode.c | 4 +++- libavcodec/internal.h | 3 +++ libavcodec/pthread_frame.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-)