vp9_superframe_bsf: implement a AVBSFContext.flush() callback
authorJames Almer <jamrial@gmail.com>
Fri, 27 Jul 2018 16:23:44 +0000 (13:23 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 17 Aug 2018 17:33:43 +0000 (14:33 -0300)
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/vp9_superframe_bsf.c

index ad66cb5..04b158f 100644 (file)
@@ -191,6 +191,17 @@ 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;
@@ -210,6 +221,7 @@ const AVBitStreamFilter ff_vp9_superframe_bsf = {
     .priv_data_size = sizeof(VP9BSFContext),
     .filter         = vp9_superframe_filter,
     .init           = vp9_superframe_init,
+    .flush          = vp9_superframe_flush,
     .close          = vp9_superframe_close,
     .codec_ids      = codec_ids,
 };