comparison g726.c @ 7050:ecb7071103af libavcodec

Correct validity checks.
author michael
date Mon, 16 Jun 2008 23:23:56 +0000
parents bb24d15211a4
children 4f1331b0d428
comparison
equal deleted inserted replaced
7049:bb24d15211a4 7050:ecb7071103af
322 static av_cold int g726_init(AVCodecContext * avctx) 322 static av_cold int g726_init(AVCodecContext * avctx)
323 { 323 {
324 AVG726Context* c = (AVG726Context*)avctx->priv_data; 324 AVG726Context* c = (AVG726Context*)avctx->priv_data;
325 unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2; 325 unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2;
326 326
327 if ( 327 if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) {
328 (avctx->bit_rate != 16000 && avctx->bit_rate != 24000 && 328 av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");
329 avctx->bit_rate != 32000 && avctx->bit_rate != 40000)) {
330 av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n");
331 return -1;
332 }
333 if (avctx->sample_rate != 8000 && avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL) {
334 av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n");
335 return -1; 329 return -1;
336 } 330 }
337 if(avctx->channels != 1){ 331 if(avctx->channels != 1){
338 av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n"); 332 av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
339 return -1; 333 return -1;