فهرست منبع

avcodec/cbs: add a flush callback to CodedBitstreamType

Used to reset the codec's private internal state.

Signed-off-by: James Almer <jamrial@gmail.com>
James Almer 5 سال پیش
والد
کامیت
515b6419ca
3فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 6 0
      libavcodec/cbs.c
  2. 5 0
      libavcodec/cbs.h
  3. 3 0
      libavcodec/cbs_internal.h

+ 6 - 0
libavcodec/cbs.c

@@ -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;

+ 5 - 0
libavcodec/cbs.h

@@ -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.
  */

+ 3 - 0
libavcodec/cbs_internal.h

@@ -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;