1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Prevent a division by 0 in the g726 decoder when the configured samplerate is 0.

patch by Laurent Aimar, fenrir via.ecp fr

Originally committed as revision 15160 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Laurent Aimar 2008-09-02 23:09:14 +00:00 committed by Diego Biurrun
parent d1c2156bc6
commit bd10f6e149

View File

@ -301,7 +301,14 @@ static int16_t g726_encode(G726Context* c, int16_t sig)
static av_cold int g726_init(AVCodecContext * avctx) static av_cold int g726_init(AVCodecContext * avctx)
{ {
G726Context* c = avctx->priv_data; G726Context* c = avctx->priv_data;
unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2; unsigned int index;
if (avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR, "Samplerate is invalid\n");
return -1;
}
index = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2;
if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) { if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) {
av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n"); av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");