mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 16:52:31 +00:00
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:
parent
ee0a900e58
commit
9f9bf8703b
@ -2651,35 +2651,6 @@ static int compare_int64(const void *a, const void *b)
|
|||||||
return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)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)
|
static int init_output_stream_streamcopy(OutputStream *ost)
|
||||||
{
|
{
|
||||||
OutputFile *of = output_files[ost->file_index];
|
OutputFile *of = output_files[ost->file_index];
|
||||||
@ -3212,13 +3183,6 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
|
|||||||
return ret;
|
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);
|
ret = of_stream_init(output_files[ost->file_index], ost);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -536,12 +536,50 @@ int mux_check_init(Muxer *mux)
|
|||||||
return 0;
|
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)
|
int of_stream_init(OutputFile *of, OutputStream *ost)
|
||||||
{
|
{
|
||||||
Muxer *mux = mux_from_of(of);
|
Muxer *mux = mux_from_of(of);
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (ost->sq_idx_mux >= 0)
|
if (ost->sq_idx_mux >= 0)
|
||||||
sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
|
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;
|
ost->initialized = 1;
|
||||||
|
|
||||||
return mux_check_init(mux);
|
return mux_check_init(mux);
|
||||||
|
Loading…
Reference in New Issue
Block a user