]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/bsf: add a flushing mechanism to AVBSFContext
authorJames Almer <jamrial@gmail.com>
Thu, 26 Jul 2018 23:32:13 +0000 (20:32 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 17 Aug 2018 02:43:10 +0000 (23:43 -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 efe15ba4e00ea924a6ec3c154dd50414af3f30bd..468cc122c7523ca499d65ec1c894c22b8d5c3b76 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-08-16 - xxxxxxxxxx - lavc 58.23.100 - avcodec.h
+  Add av_bsf_flush().
+
 2018-05-xx - xxxxxxxxxx - lavf 58.15.100 - avformat.h
   Add pmt_version field to AVProgram
 
index 1266879206fd423b6adcc2aa07e48412f5716a5b..56be65bd56dca52baef1bab14cfbd6cb40685088 100644 (file)
@@ -5769,6 +5769,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
@@ -5895,6 +5896,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 bd611ea16b0e7da1e675b40c046a87b488a35754..03841da682a729de8d8b5a0c2017fb1ea522a1bb 100644 (file)
@@ -172,6 +172,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)
 {
     int ret;
index 907c6fb111d48acb612a813d377974d58dbf0448..a91e5f01e607738c39de839511cad99ea43a5c26 100644 (file)
@@ -28,8 +28,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  22
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MINOR  23
+#define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \