diff mbox series

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

Message ID 20200530160541.29517-2-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/36] avcodec/vp9_superframe_bsf: Check for existence of data before reading it
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 30, 2020, 4:05 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/vp9_superframe_bsf.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
diff mbox series

Patch

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;