[FFmpeg-devel] [PATCH 02/36] avcodec/vp9_superframe_bsf: Reuse vp9_superframe_flush()

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat May 30 19:05:07 EEST 2020


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavcodec/vp9_superframe_bsf.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vp9_superframe_bsf.c b/libavcodec/vp9_superframe_bsf.c
index 34a47aa69e..d9c78c67f5 100644
--- a/libavcodec/vp9_superframe_bsf.c
+++ b/libavcodec/vp9_superframe_bsf.c
@@ -31,6 +31,16 @@ typedef struct VP9BSFContext {
     AVPacket *cache[MAX_CACHE];
 } VP9BSFContext;
 
+static void vp9_superframe_flush(AVBSFContext *ctx)
+{
+    VP9BSFContext *s = ctx->priv_data;
+
+    // unref cached data
+    for (int n = 0; n < s->n_cache; n++)
+        av_packet_unref(s->cache[n]);
+    s->n_cache = 0;
+}
+
 static void stats(AVPacket * const *in, int n_in,
                   unsigned *_max, unsigned *_sum)
 {
@@ -102,7 +112,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *pkt)
 {
     GetBitContext gb;
     VP9BSFContext *s = ctx->priv_data;
-    int res, invisible, profile, marker, uses_superframe_syntax = 0, n;
+    int res, invisible, profile, marker, uses_superframe_syntax = 0;
 
     res = ff_bsf_get_packet_ref(ctx, pkt);
     if (res < 0)
@@ -166,9 +176,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *pkt)
     if (res < 0)
         goto done;
 
-    for (n = 0; n < s->n_cache; n++)
-        av_packet_unref(s->cache[n]);
-    s->n_cache = 0;
+    vp9_superframe_flush(ctx);
 
 done:
     if (res < 0)
@@ -191,17 +199,6 @@ static int vp9_superframe_init(AVBSFContext *ctx)
     return 0;
 }
 
-static void vp9_superframe_flush(AVBSFContext *ctx)
-{
-    VP9BSFContext *s = ctx->priv_data;
-    int n;
-
-    // unref cached data
-    for (n = 0; n < s->n_cache; n++)
-        av_packet_unref(s->cache[n]);
-    s->n_cache = 0;
-}
-
 static void vp9_superframe_close(AVBSFContext *ctx)
 {
     VP9BSFContext *s = ctx->priv_data;
-- 
2.20.1



More information about the ffmpeg-devel mailing list