mirror of https://git.ffmpeg.org/ffmpeg.git
fftools/ffmpeg_filter: switch to avcodec_get_supported_config()
Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
parent
f3e265c690
commit
33d5a4ec4e
|
@ -283,8 +283,6 @@ typedef struct OutputFilterOptions {
|
||||||
|
|
||||||
// Codec used for encoding, may be NULL
|
// Codec used for encoding, may be NULL
|
||||||
const AVCodec *enc;
|
const AVCodec *enc;
|
||||||
// Overrides encoder pixel formats when set.
|
|
||||||
const enum AVPixelFormat *pix_fmts;
|
|
||||||
|
|
||||||
int64_t trim_start_us;
|
int64_t trim_start_us;
|
||||||
int64_t trim_duration_us;
|
int64_t trim_duration_us;
|
||||||
|
@ -311,6 +309,11 @@ typedef struct OutputFilterOptions {
|
||||||
|
|
||||||
int sample_rate;
|
int sample_rate;
|
||||||
AVChannelLayout ch_layout;
|
AVChannelLayout ch_layout;
|
||||||
|
|
||||||
|
const int *formats;
|
||||||
|
const int *sample_rates;
|
||||||
|
const AVChannelLayout *ch_layouts;
|
||||||
|
const AVRational *frame_rates;
|
||||||
} OutputFilterOptions;
|
} OutputFilterOptions;
|
||||||
|
|
||||||
typedef struct InputFilter {
|
typedef struct InputFilter {
|
||||||
|
|
|
@ -819,11 +819,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||||
ofp->height = opts->height;
|
ofp->height = opts->height;
|
||||||
if (opts->format != AV_PIX_FMT_NONE) {
|
if (opts->format != AV_PIX_FMT_NONE) {
|
||||||
ofp->format = opts->format;
|
ofp->format = opts->format;
|
||||||
} else if (opts->pix_fmts)
|
} else
|
||||||
ofp->formats = opts->pix_fmts;
|
ofp->formats = opts->formats;
|
||||||
else if (opts->enc &&
|
|
||||||
!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT))
|
|
||||||
ofp->formats = opts->enc->pix_fmts;
|
|
||||||
|
|
||||||
fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT);
|
fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT);
|
||||||
|
|
||||||
|
@ -835,7 +832,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||||
ofp->fps.framerate = ost->frame_rate;
|
ofp->fps.framerate = ost->frame_rate;
|
||||||
ofp->fps.framerate_max = ost->max_frame_rate;
|
ofp->fps.framerate_max = ost->max_frame_rate;
|
||||||
ofp->fps.framerate_supported = ost->force_fps || !opts->enc ?
|
ofp->fps.framerate_supported = ost->force_fps || !opts->enc ?
|
||||||
NULL : opts->enc->supported_framerates;
|
NULL : opts->frame_rates;
|
||||||
|
|
||||||
// reduce frame rate for mpeg4 to be within the spec limits
|
// reduce frame rate for mpeg4 to be within the spec limits
|
||||||
if (opts->enc && opts->enc->id == AV_CODEC_ID_MPEG4)
|
if (opts->enc && opts->enc->id == AV_CODEC_ID_MPEG4)
|
||||||
|
@ -847,21 +844,19 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
if (opts->format != AV_SAMPLE_FMT_NONE) {
|
if (opts->format != AV_SAMPLE_FMT_NONE) {
|
||||||
ofp->format = opts->format;
|
ofp->format = opts->format;
|
||||||
} else if (opts->enc) {
|
} else {
|
||||||
ofp->formats = opts->enc->sample_fmts;
|
ofp->formats = opts->formats;
|
||||||
}
|
}
|
||||||
if (opts->sample_rate) {
|
if (opts->sample_rate) {
|
||||||
ofp->sample_rate = opts->sample_rate;
|
ofp->sample_rate = opts->sample_rate;
|
||||||
} else if (opts->enc) {
|
} else
|
||||||
ofp->sample_rates = opts->enc->supported_samplerates;
|
ofp->sample_rates = opts->sample_rates;
|
||||||
}
|
|
||||||
if (opts->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->ch_layouts, &opts->ch_layout);
|
||||||
&opts->ch_layout);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else if (opts->enc) {
|
} else {
|
||||||
ofp->ch_layouts = opts->enc->ch_layouts;
|
ofp->ch_layouts = opts->ch_layouts;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,6 +952,39 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index);
|
snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index);
|
||||||
|
|
||||||
|
if (ost->type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
if (!keep_pix_fmt) {
|
||||||
|
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
||||||
|
AV_CODEC_CONFIG_PIX_FORMAT, 0,
|
||||||
|
(const void **) &opts.formats, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (!ost->force_fps) {
|
||||||
|
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
||||||
|
AV_CODEC_CONFIG_FRAME_RATE, 0,
|
||||||
|
(const void **) &opts.frame_rates, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
||||||
|
AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
|
||||||
|
(const void **) &opts.formats, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
||||||
|
AV_CODEC_CONFIG_SAMPLE_RATE, 0,
|
||||||
|
(const void **) &opts.sample_rates, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
||||||
|
AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0,
|
||||||
|
(const void **) &opts.ch_layouts, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// MJPEG encoder exports a full list of supported pixel formats,
|
// MJPEG encoder exports a full list of supported pixel formats,
|
||||||
// but the full-range ones are experimental-only.
|
// but the full-range ones are experimental-only.
|
||||||
// Restrict the auto-conversion list unless -strict experimental
|
// Restrict the auto-conversion list unless -strict experimental
|
||||||
|
@ -964,7 +997,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
||||||
AV_PIX_FMT_NONE };
|
AV_PIX_FMT_NONE };
|
||||||
|
|
||||||
if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
|
if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
|
||||||
opts.pix_fmts = mjpeg_formats;
|
opts.formats = mjpeg_formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threads_manual) {
|
if (threads_manual) {
|
||||||
|
|
Loading…
Reference in New Issue