]> git.sesse.net Git - ffmpeg/commitdiff
bsf: add a flushing mechanism to AVBSFContext
authorJames Almer <jamrial@gmail.com>
Fri, 27 Jul 2018 16:18:29 +0000 (13:18 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 17 Aug 2018 17:06:21 +0000 (14:06 -0300)
Meant to reset the internal bsf state without the need to reinitialize it.

Signed-off-by: James Almer <jamrial@gmail.com>
doc/APIchanges
libavcodec/avcodec.h
libavcodec/bsf.c
libavcodec/version.h

index d385d73b0c12d3dec4ff15b914fad4fd820300f7..9ba03648c563a12d43e77b1228da0adcfe807195 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2017-03-23
 
 API changes, most recent first:
 
+2018-xx-xx - xxxxxxx - lavc 58.10.0 - avcodec.h
+  Add av_bsf_flush().
+
 2018-02-xx - xxxxxxx - lavfi 7.1.0 - avfilter.h
   Add AVFilterContext.extra_hw_frames.
 
index eb234a40d6a59b94a72e5343e9d55f8115343407..fb8e34e7d5de3b389d78eb65dffb9e855c9825ee 100644 (file)
@@ -4927,6 +4927,7 @@ typedef struct AVBitStreamFilter {
     int (*init)(AVBSFContext *ctx);
     int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
     void (*close)(AVBSFContext *ctx);
+    void (*flush)(AVBSFContext *ctx);
 } AVBitStreamFilter;
 
 #if FF_API_OLD_BSF
@@ -5029,6 +5030,11 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
  */
 int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt);
 
+/**
+ * Reset the internal bitstream filter state / flush internal buffers.
+ */
+void av_bsf_flush(AVBSFContext *ctx);
+
 /**
  * Free a bitstream filter context and everything associated with it; write NULL
  * into the supplied pointer.
index 284c7c80441582e46589c9752cfb38417bd98a08..05cad546debd5ca420fd2fed7a64a03b24705f4a 100644 (file)
@@ -170,6 +170,16 @@ int av_bsf_init(AVBSFContext *ctx)
     return 0;
 }
 
+void av_bsf_flush(AVBSFContext *ctx)
+{
+    ctx->internal->eof = 0;
+
+    av_packet_unref(ctx->internal->buffer_pkt);
+
+    if (ctx->filter->flush)
+        ctx->filter->flush(ctx);
+}
+
 int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
 {
     if (!pkt || !pkt->data) {
index 36a014959e2f189f7e1f0ee21a54575b3dae2fc8..32486a83c1d7cc479689bcc2c10fe1053e15babd 100644 (file)
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 58
-#define LIBAVCODEC_VERSION_MINOR  9
+#define LIBAVCODEC_VERSION_MINOR 10
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \