[FFmpeg-cvslog] libgsm: simplify decoding by using a loop

Justin Ruggles git at videolan.org
Thu Nov 3 02:23:11 CET 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Fri Oct 28 10:28:41 2011 -0400| [480324e7ca0b87105fd7ee168292a0d5692af128] | committer: Justin Ruggles

libgsm: simplify decoding by using a loop

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=480324e7ca0b87105fd7ee168292a0d5692af128
---

 libavcodec/libgsm.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c
index 1b12ca4..bca7bfb 100644
--- a/libavcodec/libgsm.c
+++ b/libavcodec/libgsm.c
@@ -166,8 +166,11 @@ static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
 static int libgsm_decode_frame(AVCodecContext *avctx,
                                void *data, int *data_size,
                                AVPacket *avpkt) {
+    int i, ret;
+    struct gsm_state *s = avctx->priv_data;
     uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
+    int16_t *samples = data;
     int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt);
 
     if (*data_size < out_size) {
@@ -180,13 +183,11 @@ static int libgsm_decode_frame(AVCodecContext *avctx,
         return AVERROR_INVALIDDATA;
     }
 
-    switch(avctx->codec_id) {
-    case CODEC_ID_GSM:
-        if(gsm_decode(avctx->priv_data,buf,data)) return -1;
-        break;
-    case CODEC_ID_GSM_MS:
-        if(gsm_decode(avctx->priv_data,buf,data) ||
-           gsm_decode(avctx->priv_data,buf+33,((int16_t*)data)+GSM_FRAME_SIZE)) return -1;
+    for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
+        if ((ret = gsm_decode(s, buf, samples)) < 0)
+            return -1;
+        buf     += GSM_BLOCK_SIZE;
+        samples += GSM_FRAME_SIZE;
     }
 
     *data_size = out_size;



More information about the ffmpeg-cvslog mailing list