mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
lavc/encode: improve input sample rate validation
Reject zero sample rates in addition to negative ones and describe them as 'invalid' rather than 'unsupported'.
This commit is contained in:
parent
fc6c746aa1
commit
39206c5e58
@ -658,6 +658,11 @@ static int encode_preinit_audio(AVCodecContext *avctx)
|
||||
avctx->sample_fmt);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (avctx->sample_rate <= 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid audio sample rate: %d\n",
|
||||
avctx->sample_rate);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if (c->sample_fmts) {
|
||||
for (i = 0; c->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
|
||||
@ -686,11 +691,6 @@ static int encode_preinit_audio(AVCodecContext *avctx)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
if (avctx->sample_rate < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n",
|
||||
avctx->sample_rate);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (c->ch_layouts) {
|
||||
for (i = 0; c->ch_layouts[i].nb_channels; i++) {
|
||||
if (!av_channel_layout_compare(&avctx->ch_layout, &c->ch_layouts[i]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user