# HG changeset patch # User diego # Date 1162027843 0 # Node ID f812a11be0b158995d765af154dfcf254eae5faa # Parent ca9b4b42ebf9acb14a691d637b6a115063758b4f sample rate fix patch by Andrew Voznytsa andrew.voznytsa gmail com diff -r ca9b4b42ebf9 -r f812a11be0b1 amr.c --- a/amr.c Sat Oct 28 08:03:30 2006 +0000 +++ b/amr.c Sat Oct 28 09:30:43 2006 +0000 @@ -109,6 +109,23 @@ return(MR122); } +static void amr_decode_fix_avctx(AVCodecContext * avctx) +{ + const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB); + + if(avctx->sample_rate == 0) + { + avctx->sample_rate = 8000 * is_amr_wb; + } + + if(avctx->channels == 0) + { + avctx->channels = 1; + } + + avctx->frame_size = 160 * is_amr_wb; +} + #ifdef CONFIG_AMR_NB_FIXED /* fixed point version*/ /* frame size in serial bitstream file (frame type + serial stream + flags) */ @@ -145,6 +162,15 @@ av_log(avctx, AV_LOG_ERROR, "Speech_Decode_Frame_init error\n"); return -1; } + + amr_decode_fix_avctx(avctx); + + if(avctx->channels > 1) + { + av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); + return -1; + } + return 0; } @@ -347,6 +373,15 @@ av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n"); return -1; } + + amr_decode_fix_avctx(avctx); + + if(avctx->channels > 1) + { + av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); + return -1; + } + return 0; } @@ -598,6 +633,15 @@ AMRWBContext *s = (AMRWBContext *)avctx->priv_data; s->frameCount=0; s->state = D_IF_init(); + + amr_decode_fix_avctx(avctx); + + if(avctx->channels > 1) + { + av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n"); + return -1; + } + return 0; }