[FFmpeg-cvslog] avcodec: move avcodec_flush_buffers from decode.c to utils.c

James Almer git at videolan.org
Sun May 24 19:50:09 EEST 2020


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sat May 16 19:17:13 2020 -0300| [c7c8f141ebd95b73baebf4b5013d3c6389cbe2c6] | committer: James Almer

avcodec: move avcodec_flush_buffers from decode.c to utils.c

It's not a decoding exclusive function anymore.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7c8f141ebd95b73baebf4b5013d3c6389cbe2c6
---

 libavcodec/decode.c | 44 --------------------------------------------
 libavcodec/utils.c  | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index f3327d74af..e438135b53 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1961,47 +1961,3 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
         av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
     return ret;
 }
-
-void avcodec_flush_buffers(AVCodecContext *avctx)
-{
-    AVCodecInternal *avci = avctx->internal;
-
-    if (av_codec_is_encoder(avctx->codec)) {
-        int caps = avctx->codec->capabilities;
-
-        if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
-            // Only encoders that explicitly declare support for it can be
-            // flushed. Otherwise, this is a no-op.
-            av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
-                   "that doesn't support it\n");
-            return;
-        }
-
-        // We haven't implemented flushing for frame-threaded encoders.
-        av_assert0(!(caps & AV_CODEC_CAP_FRAME_THREADS));
-    }
-
-    avci->draining      = 0;
-    avci->draining_done = 0;
-    avci->nb_draining_errors = 0;
-    av_frame_unref(avci->buffer_frame);
-    av_frame_unref(avci->compat_decode_frame);
-    av_packet_unref(avci->buffer_pkt);
-    avci->buffer_pkt_valid = 0;
-
-    av_packet_unref(avci->ds.in_pkt);
-
-    if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
-        ff_thread_flush(avctx);
-    else if (avctx->codec->flush)
-        avctx->codec->flush(avctx);
-
-    avctx->pts_correction_last_pts =
-    avctx->pts_correction_last_dts = INT64_MIN;
-
-    if (av_codec_is_decoder(avctx->codec))
-        av_bsf_flush(avci->bsf);
-
-    if (!avctx->refcounted_frames)
-        av_frame_unref(avci->to_free);
-}
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 3255679550..3899a13b99 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1055,6 +1055,50 @@ FF_ENABLE_DEPRECATION_WARNINGS
     goto end;
 }
 
+void avcodec_flush_buffers(AVCodecContext *avctx)
+{
+    AVCodecInternal *avci = avctx->internal;
+
+    if (av_codec_is_encoder(avctx->codec)) {
+        int caps = avctx->codec->capabilities;
+
+        if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
+            // Only encoders that explicitly declare support for it can be
+            // flushed. Otherwise, this is a no-op.
+            av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
+                   "that doesn't support it\n");
+            return;
+        }
+
+        // We haven't implemented flushing for frame-threaded encoders.
+        av_assert0(!(caps & AV_CODEC_CAP_FRAME_THREADS));
+    }
+
+    avci->draining      = 0;
+    avci->draining_done = 0;
+    avci->nb_draining_errors = 0;
+    av_frame_unref(avci->buffer_frame);
+    av_frame_unref(avci->compat_decode_frame);
+    av_packet_unref(avci->buffer_pkt);
+    avci->buffer_pkt_valid = 0;
+
+    av_packet_unref(avci->ds.in_pkt);
+
+    if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
+        ff_thread_flush(avctx);
+    else if (avctx->codec->flush)
+        avctx->codec->flush(avctx);
+
+    avctx->pts_correction_last_pts =
+    avctx->pts_correction_last_dts = INT64_MIN;
+
+    if (av_codec_is_decoder(avctx->codec))
+        av_bsf_flush(avci->bsf);
+
+    if (!avctx->refcounted_frames)
+        av_frame_unref(avci->to_free);
+}
+
 void avsubtitle_free(AVSubtitle *sub)
 {
     int i;



More information about the ffmpeg-cvslog mailing list