diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-05-06 15:01:33 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-05-10 07:27:36 +0200 |
commit | 7547f135485623e00844d2ad40debb5b048e6b5d (patch) | |
tree | f8ea9c5a584452ce4cc0a0e89bda658fa50c3fe8 /libavformat/mux.c | |
parent | 5130bbb7efe1125c515eddedc0985fa9b6e5d731 (diff) | |
download | ffmpeg-7547f135485623e00844d2ad40debb5b048e6b5d.tar.gz |
avformat/utils: Move ff_stream_add_bitstream_filter to mux.c
It is muxing-only; in fact, it should be considered part of
the core muxing code.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r-- | libavformat/mux.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index 11b0cb1307..31361f9b46 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1304,6 +1304,49 @@ int av_get_output_timestamp(struct AVFormatContext *s, int stream, return 0; } +int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args) +{ + int ret; + const AVBitStreamFilter *bsf; + FFStream *const sti = ffstream(st); + AVBSFContext *bsfc; + + av_assert0(!sti->bsfc); + + if (!(bsf = av_bsf_get_by_name(name))) { + av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter '%s'\n", name); + return AVERROR_BSF_NOT_FOUND; + } + + if ((ret = av_bsf_alloc(bsf, &bsfc)) < 0) + return ret; + + bsfc->time_base_in = st->time_base; + if ((ret = avcodec_parameters_copy(bsfc->par_in, st->codecpar)) < 0) { + av_bsf_free(&bsfc); + return ret; + } + + if (args && bsfc->filter->priv_class) { + if ((ret = av_set_options_string(bsfc->priv_data, args, "=", ":")) < 0) { + av_bsf_free(&bsfc); + return ret; + } + } + + if ((ret = av_bsf_init(bsfc)) < 0) { + av_bsf_free(&bsfc); + return ret; + } + + sti->bsfc = bsfc; + + av_log(NULL, AV_LOG_VERBOSE, + "Automatically inserted bitstream filter '%s'; args='%s'\n", + name, args ? args : ""); + return 1; +} + int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt, AVFormatContext *src, int interleave) { |