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.
This commit is contained in:
Anton Khirnov 2022-10-13 15:39:47 +02:00
parent ee0a900e58
commit 9f9bf8703b
2 changed files with 38 additions and 36 deletions

View File

@ -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;

View File

@ -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);