diff options
author | James Almer <jamrial@gmail.com> | 2018-07-27 13:18:29 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-08-17 14:06:21 -0300 |
commit | e1e1e8dbb204085443d95a05f91a5c33574792ce (patch) | |
tree | 20005e4ab4583fc4207549048deefdea2cc8467c /libavcodec | |
parent | 6a9c00c09d2bc50c0ea64ba092b2f4afc46aa978 (diff) | |
download | ffmpeg-e1e1e8dbb204085443d95a05f91a5c33574792ce.tar.gz |
bsf: add a flushing mechanism to AVBSFContext
Meant to reset the internal bsf state without the need to reinitialize it.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 6 | ||||
-rw-r--r-- | libavcodec/bsf.c | 10 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index eb234a40d6..fb8e34e7d5 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -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 @@ -5030,6 +5031,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. */ diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 284c7c8044..05cad546de 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -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) { diff --git a/libavcodec/version.h b/libavcodec/version.h index 36a014959e..32486a83c1 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -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, \ |