fftools/ffmpeg_filter: stop accessing encoder AVCodecContext
Pass all the necessary value through OutputFilterOptions. Will allow decoupling filtering from encoding in future commits.
This commit is contained in:
parent
17702c5f7b
commit
bc206ed1b3
|
@ -282,6 +282,13 @@ typedef struct OutputFilterOptions {
|
||||||
|
|
||||||
// A combination of OFilterFlags.
|
// A combination of OFilterFlags.
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
|
|
||||||
|
int format;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
int sample_rate;
|
||||||
|
AVChannelLayout ch_layout;
|
||||||
} OutputFilterOptions;
|
} OutputFilterOptions;
|
||||||
|
|
||||||
typedef struct InputFilter {
|
typedef struct InputFilter {
|
||||||
|
|
|
@ -782,12 +782,12 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||||
ofp->ts_offset = opts->ts_offset;
|
ofp->ts_offset = opts->ts_offset;
|
||||||
ofp->enc_timebase = opts->output_tb;
|
ofp->enc_timebase = opts->output_tb;
|
||||||
|
|
||||||
switch (ost->enc_ctx->codec_type) {
|
switch (ofilter->type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
ofp->width = ost->enc_ctx->width;
|
ofp->width = opts->width;
|
||||||
ofp->height = ost->enc_ctx->height;
|
ofp->height = opts->height;
|
||||||
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
|
if (opts->format != AV_PIX_FMT_NONE) {
|
||||||
ofp->format = ost->enc_ctx->pix_fmt;
|
ofp->format = opts->format;
|
||||||
} else if (opts->pix_fmts)
|
} else if (opts->pix_fmts)
|
||||||
ofp->formats = opts->pix_fmts;
|
ofp->formats = opts->pix_fmts;
|
||||||
else if (opts->enc)
|
else if (opts->enc)
|
||||||
|
@ -812,19 +812,19 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
|
if (opts->format != AV_SAMPLE_FMT_NONE) {
|
||||||
ofp->format = ost->enc_ctx->sample_fmt;
|
ofp->format = opts->format;
|
||||||
} else if (opts->enc) {
|
} else if (opts->enc) {
|
||||||
ofp->formats = opts->enc->sample_fmts;
|
ofp->formats = opts->enc->sample_fmts;
|
||||||
}
|
}
|
||||||
if (ost->enc_ctx->sample_rate) {
|
if (opts->sample_rate) {
|
||||||
ofp->sample_rate = ost->enc_ctx->sample_rate;
|
ofp->sample_rate = opts->sample_rate;
|
||||||
} else if (opts->enc) {
|
} else if (opts->enc) {
|
||||||
ofp->sample_rates = opts->enc->supported_samplerates;
|
ofp->sample_rates = opts->enc->supported_samplerates;
|
||||||
}
|
}
|
||||||
if (ost->enc_ctx->ch_layout.nb_channels) {
|
if (opts->ch_layout.nb_channels) {
|
||||||
int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL,
|
int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL,
|
||||||
&ost->enc_ctx->ch_layout);
|
&opts->ch_layout);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else if (opts->enc) {
|
} else if (opts->enc) {
|
||||||
|
|
|
@ -1378,6 +1378,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||||
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
||||||
OutputFilterOptions opts = {
|
OutputFilterOptions opts = {
|
||||||
.enc = enc,
|
.enc = enc,
|
||||||
|
.format = (type == AVMEDIA_TYPE_VIDEO) ?
|
||||||
|
ost->enc_ctx->pix_fmt : ost->enc_ctx->sample_fmt,
|
||||||
|
.width = ost->enc_ctx->width,
|
||||||
|
.height = ost->enc_ctx->height,
|
||||||
|
.sample_rate = ost->enc_ctx->sample_rate,
|
||||||
|
.ch_layout = ost->enc_ctx->ch_layout,
|
||||||
.output_tb = enc_tb,
|
.output_tb = enc_tb,
|
||||||
.ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
|
.ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
|
||||||
0 : mux->of.start_time,
|
0 : mux->of.start_time,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user