aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Voznytsa <andrew.voznytsa@gmail.com>2006-10-28 09:30:43 +0000
committerDiego Biurrun <diego@biurrun.de>2006-10-28 09:30:43 +0000
commitb500cc2a4696758c7e6dbfbc53c92321066cb2b4 (patch)
tree87f6796d6f64508562e24d13862848058db48fdb
parent72523c7a2025cee0858ee03b8bca6b9824e023e3 (diff)
downloadffmpeg-b500cc2a4696758c7e6dbfbc53c92321066cb2b4.tar.gz
sample rate fix
patch by Andrew Voznytsa andrew.voznytsa gmail com Originally committed as revision 6820 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/amr.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libavcodec/amr.c b/libavcodec/amr.c
index d84bc677ed..d24c8fe7db 100644
--- a/libavcodec/amr.c
+++ b/libavcodec/amr.c
@@ -109,6 +109,23 @@ static enum Mode getBitrateMode(int bitrate)
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 @@ static int amr_nb_decode_init(AVCodecContext * avctx)
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 @@ static int amr_nb_decode_init(AVCodecContext * avctx)
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 @@ static int amr_wb_decode_init(AVCodecContext * avctx)
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;
}