mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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
|
||||
const AVCodec *enc;
|
||||
// Overrides encoder pixel formats when set.
|
||||
const enum AVPixelFormat *pix_fmts;
|
||||
|
||||
int64_t trim_start_us;
|
||||
int64_t trim_duration_us;
|
||||
@ -311,6 +309,11 @@ typedef struct OutputFilterOptions {
|
||||
|
||||
int sample_rate;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
const int *formats;
|
||||
const int *sample_rates;
|
||||
const AVChannelLayout *ch_layouts;
|
||||
const AVRational *frame_rates;
|
||||
} OutputFilterOptions;
|
||||
|
||||
typedef struct InputFilter {
|
||||
|
@ -819,11 +819,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||
ofp->height = opts->height;
|
||||
if (opts->format != AV_PIX_FMT_NONE) {
|
||||
ofp->format = opts->format;
|
||||
} else if (opts->pix_fmts)
|
||||
ofp->formats = opts->pix_fmts;
|
||||
else if (opts->enc &&
|
||||
!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT))
|
||||
ofp->formats = opts->enc->pix_fmts;
|
||||
} else
|
||||
ofp->formats = opts->formats;
|
||||
|
||||
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_max = ost->max_frame_rate;
|
||||
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
|
||||
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:
|
||||
if (opts->format != AV_SAMPLE_FMT_NONE) {
|
||||
ofp->format = opts->format;
|
||||
} else if (opts->enc) {
|
||||
ofp->formats = opts->enc->sample_fmts;
|
||||
} else {
|
||||
ofp->formats = opts->formats;
|
||||
}
|
||||
if (opts->sample_rate) {
|
||||
ofp->sample_rate = opts->sample_rate;
|
||||
} else if (opts->enc) {
|
||||
ofp->sample_rates = opts->enc->supported_samplerates;
|
||||
}
|
||||
} else
|
||||
ofp->sample_rates = opts->sample_rates;
|
||||
if (opts->ch_layout.nb_channels) {
|
||||
int ret = set_channel_layout(ofp, opts->enc ? opts->enc->ch_layouts : NULL,
|
||||
&opts->ch_layout);
|
||||
int ret = set_channel_layout(ofp, opts->ch_layouts, &opts->ch_layout);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else if (opts->enc) {
|
||||
ofp->ch_layouts = opts->enc->ch_layouts;
|
||||
} else {
|
||||
ofp->ch_layouts = opts->ch_layouts;
|
||||
}
|
||||
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);
|
||||
|
||||
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,
|
||||
// but the full-range ones are experimental-only.
|
||||
// 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 };
|
||||
|
||||
if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
|
||||
opts.pix_fmts = mjpeg_formats;
|
||||
opts.formats = mjpeg_formats;
|
||||
}
|
||||
|
||||
if (threads_manual) {
|
||||
|
Loading…
Reference in New Issue
Block a user