1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

libgsm: decode directly to the user-provided AVFrame

This commit is contained in:
Justin Ruggles 2012-12-23 18:40:50 -05:00
parent a8ea936a0a
commit 4f69612d3e

View File

@ -148,7 +148,6 @@ AVCodec ff_libgsm_ms_encoder = {
}; };
typedef struct LibGSMDecodeContext { typedef struct LibGSMDecodeContext {
AVFrame frame;
struct gsm_state *state; struct gsm_state *state;
} LibGSMDecodeContext; } LibGSMDecodeContext;
@ -175,9 +174,6 @@ static av_cold int libgsm_decode_init(AVCodecContext *avctx) {
} }
} }
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0; return 0;
} }
@ -194,6 +190,7 @@ static int libgsm_decode_frame(AVCodecContext *avctx, void *data,
{ {
int i, ret; int i, ret;
LibGSMDecodeContext *s = avctx->priv_data; LibGSMDecodeContext *s = avctx->priv_data;
AVFrame *frame = data;
uint8_t *buf = avpkt->data; uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
int16_t *samples; int16_t *samples;
@ -204,12 +201,12 @@ static int libgsm_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 ((ret = ff_get_buffer(avctx, &s->frame)) < 0) { if ((ret = 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 ret; return ret;
} }
samples = (int16_t *)s->frame.data[0]; samples = (int16_t *)frame->data[0];
for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) { for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
if ((ret = gsm_decode(s->state, buf, samples)) < 0) if ((ret = gsm_decode(s->state, buf, samples)) < 0)
@ -218,8 +215,7 @@ static int libgsm_decode_frame(AVCodecContext *avctx, void *data,
samples += GSM_FRAME_SIZE; samples += GSM_FRAME_SIZE;
} }
*got_frame_ptr = 1; *got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return avctx->block_align; return avctx->block_align;
} }