Mercurial > libavcodec.hg
comparison g726.c @ 7774:a570a1e80400 libavcodec
Prevent a division by 0 in the g726 decoder when the configured samplerate is 0.
patch by Laurent Aimar, fenrir via.ecp fr
author | diego |
---|---|
date | Tue, 02 Sep 2008 23:09:14 +0000 |
parents | 85ab7655ad4d |
children | 6efb15a24e91 |
comparison
equal
deleted
inserted
replaced
7773:272a13ae94c0 | 7774:a570a1e80400 |
---|---|
299 /* Interfacing to the libavcodec */ | 299 /* Interfacing to the libavcodec */ |
300 | 300 |
301 static av_cold int g726_init(AVCodecContext * avctx) | 301 static av_cold int g726_init(AVCodecContext * avctx) |
302 { | 302 { |
303 G726Context* c = avctx->priv_data; | 303 G726Context* c = avctx->priv_data; |
304 unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2; | 304 unsigned int index; |
305 | |
306 if (avctx->sample_rate <= 0) { | |
307 av_log(avctx, AV_LOG_ERROR, "Samplerate is invalid\n"); | |
308 return -1; | |
309 } | |
310 | |
311 index = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2; | |
305 | 312 |
306 if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) { | 313 if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) { |
307 av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n"); | 314 av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n"); |
308 return -1; | 315 return -1; |
309 } | 316 } |