Mercurial > libavcodec.hg
comparison amr.c @ 4094:f812a11be0b1 libavcodec
sample rate fix
patch by Andrew Voznytsa andrew.voznytsa gmail com
author | diego |
---|---|
date | Sat, 28 Oct 2006 09:30:43 +0000 |
parents | c8c591fe26f8 |
children | 4115a044e31d |
comparison
equal
deleted
inserted
replaced
4093:ca9b4b42ebf9 | 4094:f812a11be0b1 |
---|---|
107 } | 107 } |
108 /*Return highest possible*/ | 108 /*Return highest possible*/ |
109 return(MR122); | 109 return(MR122); |
110 } | 110 } |
111 | 111 |
112 static void amr_decode_fix_avctx(AVCodecContext * avctx) | |
113 { | |
114 const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB); | |
115 | |
116 if(avctx->sample_rate == 0) | |
117 { | |
118 avctx->sample_rate = 8000 * is_amr_wb; | |
119 } | |
120 | |
121 if(avctx->channels == 0) | |
122 { | |
123 avctx->channels = 1; | |
124 } | |
125 | |
126 avctx->frame_size = 160 * is_amr_wb; | |
127 } | |
128 | |
112 #ifdef CONFIG_AMR_NB_FIXED | 129 #ifdef CONFIG_AMR_NB_FIXED |
113 /* fixed point version*/ | 130 /* fixed point version*/ |
114 /* frame size in serial bitstream file (frame type + serial stream + flags) */ | 131 /* frame size in serial bitstream file (frame type + serial stream + flags) */ |
115 #define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5) | 132 #define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5) |
116 | 133 |
143 if(Speech_Decode_Frame_init(&s->speech_decoder_state, "Decoder")) | 160 if(Speech_Decode_Frame_init(&s->speech_decoder_state, "Decoder")) |
144 { | 161 { |
145 av_log(avctx, AV_LOG_ERROR, "Speech_Decode_Frame_init error\n"); | 162 av_log(avctx, AV_LOG_ERROR, "Speech_Decode_Frame_init error\n"); |
146 return -1; | 163 return -1; |
147 } | 164 } |
165 | |
166 amr_decode_fix_avctx(avctx); | |
167 | |
168 if(avctx->channels > 1) | |
169 { | |
170 av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); | |
171 return -1; | |
172 } | |
173 | |
148 return 0; | 174 return 0; |
149 } | 175 } |
150 | 176 |
151 static int amr_nb_encode_init(AVCodecContext * avctx) | 177 static int amr_nb_encode_init(AVCodecContext * avctx) |
152 { | 178 { |
345 if(!s->decState) | 371 if(!s->decState) |
346 { | 372 { |
347 av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n"); | 373 av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n"); |
348 return -1; | 374 return -1; |
349 } | 375 } |
376 | |
377 amr_decode_fix_avctx(avctx); | |
378 | |
379 if(avctx->channels > 1) | |
380 { | |
381 av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); | |
382 return -1; | |
383 } | |
384 | |
350 return 0; | 385 return 0; |
351 } | 386 } |
352 | 387 |
353 static int amr_nb_encode_init(AVCodecContext * avctx) | 388 static int amr_nb_encode_init(AVCodecContext * avctx) |
354 { | 389 { |
596 static int amr_wb_decode_init(AVCodecContext * avctx) | 631 static int amr_wb_decode_init(AVCodecContext * avctx) |
597 { | 632 { |
598 AMRWBContext *s = (AMRWBContext *)avctx->priv_data; | 633 AMRWBContext *s = (AMRWBContext *)avctx->priv_data; |
599 s->frameCount=0; | 634 s->frameCount=0; |
600 s->state = D_IF_init(); | 635 s->state = D_IF_init(); |
636 | |
637 amr_decode_fix_avctx(avctx); | |
638 | |
639 if(avctx->channels > 1) | |
640 { | |
641 av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n"); | |
642 return -1; | |
643 } | |
644 | |
601 return 0; | 645 return 0; |
602 } | 646 } |
603 | 647 |
604 extern const UWord8 block_size[]; | 648 extern const UWord8 block_size[]; |
605 | 649 |