Browse code

libopencore-amr: set channel layout for amr-nb or if not set by the user

Justin Ruggles authored on 2012/10/23 06:49:59
Showing 1 changed files
... ...
@@ -19,6 +19,7 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
+#include "libavutil/audioconvert.h"
22 23
 #include "avcodec.h"
23 24
 #include "libavutil/avstring.h"
24 25
 #include "libavutil/common.h"
... ...
@@ -30,13 +31,16 @@ static void amr_decode_fix_avctx(AVCodecContext *avctx)
30 30
 {
31 31
     const int is_amr_wb = 1 + (avctx->codec_id == AV_CODEC_ID_AMR_WB);
32 32
 
33
-    if (!avctx->sample_rate)
34
-        avctx->sample_rate = 8000 * is_amr_wb;
33
+    avctx->sample_rate = 8000 * is_amr_wb;
35 34
 
36
-    if (!avctx->channels)
37
-        avctx->channels = 1;
35
+    if (avctx->channels > 1) {
36
+        av_log_missing_feature(avctx, "multi-channel AMR", 0);
37
+        return AVERROR_PATCHWELCOME;
38
+    }
38 39
 
39
-    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
40
+    avctx->channels       = 1;
41
+    avctx->channel_layout = AV_CH_LAYOUT_MONO;
42
+    avctx->sample_fmt     = AV_SAMPLE_FMT_S16;
40 43
 }
41 44
 
42 45
 #if CONFIG_LIBOPENCORE_AMRNB