]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libgsm.c
vc1dec: prevent v_edge_pos from becoming negative.
[ffmpeg] / libavcodec / libgsm.c
index 97f8abe10a51a529277ba244adadeb3ae0be6938..f3cfb91f17fc16e0c3da8941a8fee338f2ea441f 100644 (file)
 
 #include <gsm/gsm.h>
 
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "gsm.h"
-#include "libavutil/common.h"
 
 static av_cold int libgsm_encode_close(AVCodecContext *avctx) {
 #if FF_API_OLD_ENCODE_AUDIO
@@ -153,19 +154,11 @@ 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;
-
+    avctx->channels       = 1;
+    avctx->channel_layout = AV_CH_LAYOUT_MONO;
     if (!avctx->sample_rate)
         avctx->sample_rate = 8000;
-
-    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+    avctx->sample_fmt     = AV_SAMPLE_FMT_S16;
 
     s->state = gsm_create();
 
@@ -212,7 +205,7 @@ static int libgsm_decode_frame(AVCodecContext *avctx, void *data,
 
     /* get output buffer */
     s->frame.nb_samples = avctx->frame_size;
-    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
+    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
     }