]> git.sesse.net Git - ffmpeg/commitdiff
libgsmdec: always set channel layout and sample rate at initialization
authorJustin Ruggles <justin.ruggles@gmail.com>
Mon, 22 Oct 2012 19:43:59 +0000 (15:43 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 1 Nov 2012 15:29:16 +0000 (11:29 -0400)
Only mono 8kHz is supported.

libavcodec/libgsm.c

index e6d435ba0559daf0c5f4053633da663f5b226eba..afed7100a03a26274663ef5e83bc9f4ce354511b 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gsm/gsm.h>
 
+#include "libavutil/audioconvert.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "gsm.h"
@@ -149,19 +150,10 @@ typedef struct LibGSMDecodeContext {
 static av_cold int libgsm_decode_init(AVCodecContext *avctx) {
     LibGSMDecodeContext *s = avctx->priv_data;
 
-    if (avctx->channels > 1) {
-        av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n",
-               avctx->channels);
-        return -1;
-    }
-
-    if (!avctx->channels)
-        avctx->channels = 1;
-
-    if (!avctx->sample_rate)
-        avctx->sample_rate = 8000;
-
-    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+    avctx->channels       = 1;
+    avctx->channel_layout = AV_CH_LAYOUT_MONO;
+    avctx->sample_rate    = 8000;
+    avctx->sample_fmt     = AV_SAMPLE_FMT_S16;
 
     s->state = gsm_create();