[FFmpeg-devel] [PATCH 4/6] avcodec/internal: Add need_flush, simplify the next 2 commits

Michael Niedermayer michael at niedermayer.cc
Sat Aug 24 21:18:27 EEST 2019


Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/decode.c        | 4 +++-
 libavcodec/internal.h      | 3 +++
 libavcodec/pthread_frame.c | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 72482e2168..a757249f93 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -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;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 15ef0bbefc..4bb1b1af36 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -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 {
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 36ac0ac1e5..4556b2101e 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -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);
     }
-- 
2.23.0



More information about the ffmpeg-devel mailing list