]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cbs: add a flush callback to CodedBitstreamType
authorJames Almer <jamrial@gmail.com>
Thu, 24 Sep 2020 20:57:42 +0000 (17:57 -0300)
committerJames Almer <jamrial@gmail.com>
Wed, 30 Sep 2020 00:38:27 +0000 (21:38 -0300)
Used to reset the codec's private internal state.

Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/cbs.c
libavcodec/cbs.h
libavcodec/cbs_internal.h

index 7c1aa005c212f5c9d9ef69cb81cdf1f7bf5a5e26..c8c526ab123e3cc4e23b1e8ca329cfae2a8660f2 100644 (file)
@@ -112,6 +112,12 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
     return 0;
 }
 
+void ff_cbs_flush(CodedBitstreamContext *ctx)
+{
+    if (ctx->codec && ctx->codec->flush)
+        ctx->codec->flush(ctx);
+}
+
 void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
 {
     CodedBitstreamContext *ctx = *ctx_ptr;
index 3a054aa8f3360c23168c0d2d56e10152ce1e45b9..635921b11ed99a1ac63774dcf13e1078074112ec 100644 (file)
@@ -236,6 +236,11 @@ extern const enum AVCodecID ff_cbs_all_codec_ids[];
 int ff_cbs_init(CodedBitstreamContext **ctx,
                 enum AVCodecID codec_id, void *log_ctx);
 
+/**
+ * Reset all internal state in a context.
+ */
+void ff_cbs_flush(CodedBitstreamContext *ctx);
+
 /**
  * Close a context and free all internal state.
  */
index d991e1eedfc8095f1c616c14af362bdc908fb9cc..faa847aad36f4991a2d95bbcaf826a581b52f536 100644 (file)
@@ -117,6 +117,9 @@ typedef struct CodedBitstreamType {
     int (*assemble_fragment)(CodedBitstreamContext *ctx,
                              CodedBitstreamFragment *frag);
 
+    // Reset the codec internal state.
+    void (*flush)(CodedBitstreamContext *ctx);
+
     // Free the codec internal state.
     void (*close)(CodedBitstreamContext *ctx);
 } CodedBitstreamType;