[FFmpeg-cvslog] gsm: decode directly to the user-provided AVFrame

Justin Ruggles git at videolan.org
Wed Feb 13 12:12:26 CET 2013


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Sun Dec 23 18:00:01 2012 -0500| [6fdfdb23d36f369f27ef11e40547cedc3df0bfb1] | committer: Justin Ruggles

gsm: decode directly to the user-provided AVFrame

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

 libavcodec/gsmdec.c      |   16 +++++-----------
 libavcodec/gsmdec_data.h |    1 -
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c
index 4304723..e452be3 100644
--- a/libavcodec/gsmdec.c
+++ b/libavcodec/gsmdec.c
@@ -34,8 +34,6 @@
 
 static av_cold int gsm_init(AVCodecContext *avctx)
 {
-    GSMContext *s = avctx->priv_data;
-
     avctx->channels       = 1;
     avctx->channel_layout = AV_CH_LAYOUT_MONO;
     avctx->sample_rate    = 8000;
@@ -51,16 +49,13 @@ static av_cold int gsm_init(AVCodecContext *avctx)
         avctx->block_align = GSM_MS_BLOCK_SIZE;
     }
 
-    avcodec_get_frame_defaults(&s->frame);
-    avctx->coded_frame = &s->frame;
-
     return 0;
 }
 
 static int gsm_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
 {
-    GSMContext *s = avctx->priv_data;
+    AVFrame *frame = data;
     int res;
     GetBitContext gb;
     const uint8_t *buf = avpkt->data;
@@ -73,12 +68,12 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
     }
 
     /* get output buffer */
-    s->frame.nb_samples = avctx->frame_size;
-    if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
+    frame->nb_samples = avctx->frame_size;
+    if ((res = ff_get_buffer(avctx, frame)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return res;
     }
-    samples = (int16_t *)s->frame.data[0];
+    samples = (int16_t *)frame->data[0];
 
     switch (avctx->codec_id) {
     case AV_CODEC_ID_GSM:
@@ -95,8 +90,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
             return res;
     }
 
-    *got_frame_ptr   = 1;
-    *(AVFrame *)data = s->frame;
+    *got_frame_ptr = 1;
 
     return avctx->block_align;
 }
diff --git a/libavcodec/gsmdec_data.h b/libavcodec/gsmdec_data.h
index 2f3a2d2..7a81da9 100644
--- a/libavcodec/gsmdec_data.h
+++ b/libavcodec/gsmdec_data.h
@@ -26,7 +26,6 @@
 #include "avcodec.h"
 
 typedef struct GSMContext {
-    AVFrame frame;
     // Contains first 120 elements from the previous frame
     // (used by long_term_synth according to the "lag"),
     // then in the following 160 elements the current



More information about the ffmpeg-cvslog mailing list