Commit 6fdfdb23 authored by Justin Ruggles's avatar Justin Ruggles

gsm: decode directly to the user-provided AVFrame

parent cb7b47a6
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
static av_cold int gsm_init(AVCodecContext *avctx) static av_cold int gsm_init(AVCodecContext *avctx)
{ {
GSMContext *s = avctx->priv_data;
avctx->channels = 1; avctx->channels = 1;
avctx->channel_layout = AV_CH_LAYOUT_MONO; avctx->channel_layout = AV_CH_LAYOUT_MONO;
avctx->sample_rate = 8000; avctx->sample_rate = 8000;
...@@ -51,16 +49,13 @@ static av_cold int gsm_init(AVCodecContext *avctx) ...@@ -51,16 +49,13 @@ static av_cold int gsm_init(AVCodecContext *avctx)
avctx->block_align = GSM_MS_BLOCK_SIZE; avctx->block_align = GSM_MS_BLOCK_SIZE;
} }
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0; return 0;
} }
static int gsm_decode_frame(AVCodecContext *avctx, void *data, static int gsm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt) int *got_frame_ptr, AVPacket *avpkt)
{ {
GSMContext *s = avctx->priv_data; AVFrame *frame = data;
int res; int res;
GetBitContext gb; GetBitContext gb;
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
...@@ -73,12 +68,12 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data, ...@@ -73,12 +68,12 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
} }
/* get output buffer */ /* get output buffer */
s->frame.nb_samples = avctx->frame_size; frame->nb_samples = avctx->frame_size;
if ((res = ff_get_buffer(avctx, &s->frame)) < 0) { if ((res = ff_get_buffer(avctx, frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return res; return res;
} }
samples = (int16_t *)s->frame.data[0]; samples = (int16_t *)frame->data[0];
switch (avctx->codec_id) { switch (avctx->codec_id) {
case AV_CODEC_ID_GSM: case AV_CODEC_ID_GSM:
...@@ -96,7 +91,6 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data, ...@@ -96,7 +91,6 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
} }
*got_frame_ptr = 1; *got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return avctx->block_align; return avctx->block_align;
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "avcodec.h" #include "avcodec.h"
typedef struct GSMContext { typedef struct GSMContext {
AVFrame frame;
// Contains first 120 elements from the previous frame // Contains first 120 elements from the previous frame
// (used by long_term_synth according to the "lag"), // (used by long_term_synth according to the "lag"),
// then in the following 160 elements the current // then in the following 160 elements the current
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment