aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-06 18:16:49 +0200
committerAnton Khirnov <anton@khirnov.net>2023-07-11 19:28:18 +0200
commit39206c5e581f5020fe47adf463a759b0f39186d8 (patch)
tree05c2b7f86ad503eef8653927a05400a3ad6bbdb5
parentfc6c746aa17fd4434cf81f045c4644ded02b0912 (diff)
downloadffmpeg-39206c5e581f5020fe47adf463a759b0f39186d8.tar.gz
lavc/encode: improve input sample rate validation
Reject zero sample rates in addition to negative ones and describe them as 'invalid' rather than 'unsupported'.
-rw-r--r--libavcodec/encode.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index f443f07e15..0d009a26cc 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -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]))