diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-10-13 16:39:47 +0300 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-10-18 14:57:43 +0300 |
commit | 9f9bf8703b919dad486cb3a009eba5db6fa756a9 (patch) | |
tree | 3c826d709f78d741bd84eac1ac7faa5918235074 /fftools | |
parent | ee0a900e5817148c8343f8f95e7b811b069704f4 (diff) |
fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux
Bitstream filtering is done as a part of muxing, so this is the more
proper place for this.
Diffstat (limited to 'fftools')
-rw-r--r-- | fftools/ffmpeg.c | 36 | ||||
-rw-r--r-- | fftools/ffmpeg_mux.c | 38 |
2 files changed, 38 insertions, 36 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9bb877fb34..46d2912d07 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2651,35 +2651,6 @@ static int compare_int64(const void *a, const void *b) return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b); } -static int init_output_bsfs(OutputStream *ost) -{ - AVBSFContext *ctx = ost->bsf_ctx; - int ret; - - if (!ctx) - return 0; - - ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar); - if (ret < 0) - return ret; - - ctx->time_base_in = ost->st->time_base; - - ret = av_bsf_init(ctx); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n", - ctx->filter->name); - return ret; - } - - ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out); - if (ret < 0) - return ret; - ost->st->time_base = ctx->time_base_out; - - return 0; -} - static int init_output_stream_streamcopy(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; @@ -3212,13 +3183,6 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return ret; } - /* initialize bitstream filters for the output stream - * needs to be done here, because the codec id for streamcopy is not - * known until now */ - ret = init_output_bsfs(ost); - if (ret < 0) - return ret; - ret = of_stream_init(output_files[ost->file_index], ost); if (ret < 0) return ret; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 652628185e..5418cd3000 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -536,12 +536,50 @@ int mux_check_init(Muxer *mux) return 0; } +static int bsf_init(OutputStream *ost) +{ + AVBSFContext *ctx = ost->bsf_ctx; + int ret; + + if (!ctx) + return 0; + + ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar); + if (ret < 0) + return ret; + + ctx->time_base_in = ost->st->time_base; + + ret = av_bsf_init(ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n", + ctx->filter->name); + return ret; + } + + ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out); + if (ret < 0) + return ret; + ost->st->time_base = ctx->time_base_out; + + return 0; +} + int of_stream_init(OutputFile *of, OutputStream *ost) { Muxer *mux = mux_from_of(of); + int ret; + if (ost->sq_idx_mux >= 0) sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase); + /* initialize bitstream filters for the output stream + * needs to be done here, because the codec id for streamcopy is not + * known until now */ + ret = bsf_init(ost); + if (ret < 0) + return ret; + ost->initialized = 1; return mux_check_init(mux); |