Commit 3997fef9 authored by Justin Ruggles's avatar Justin Ruggles

truespeech: decode directly to the user-provided AVFrame

parent 4a2b26fc
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
* TrueSpeech decoder context * TrueSpeech decoder context
*/ */
typedef struct { typedef struct {
AVFrame frame;
DSPContext dsp; DSPContext dsp;
/* input data */ /* input data */
DECLARE_ALIGNED(16, uint8_t, buffer)[32]; DECLARE_ALIGNED(16, uint8_t, buffer)[32];
...@@ -73,9 +72,6 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx) ...@@ -73,9 +72,6 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx)
ff_dsputil_init(&c->dsp, avctx); ff_dsputil_init(&c->dsp, avctx);
avcodec_get_frame_defaults(&c->frame);
avctx->coded_frame = &c->frame;
return 0; return 0;
} }
...@@ -310,6 +306,7 @@ static void truespeech_save_prevvec(TSContext *c) ...@@ -310,6 +306,7 @@ static void truespeech_save_prevvec(TSContext *c)
static int truespeech_decode_frame(AVCodecContext *avctx, void *data, static int truespeech_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt) int *got_frame_ptr, AVPacket *avpkt)
{ {
AVFrame *frame = data;
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
TSContext *c = avctx->priv_data; TSContext *c = avctx->priv_data;
...@@ -327,12 +324,12 @@ static int truespeech_decode_frame(AVCodecContext *avctx, void *data, ...@@ -327,12 +324,12 @@ static int truespeech_decode_frame(AVCodecContext *avctx, void *data,
} }
/* get output buffer */ /* get output buffer */
c->frame.nb_samples = iterations * 240; frame->nb_samples = iterations * 240;
if ((ret = ff_get_buffer(avctx, &c->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 *)c->frame.data[0]; samples = (int16_t *)frame->data[0];
memset(samples, 0, iterations * 240 * sizeof(*samples)); memset(samples, 0, iterations * 240 * sizeof(*samples));
...@@ -354,8 +351,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx, void *data, ...@@ -354,8 +351,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx, void *data,
truespeech_save_prevvec(c); truespeech_save_prevvec(c);
} }
*got_frame_ptr = 1; *got_frame_ptr = 1;
*(AVFrame *)data = c->frame;
return buf_size; return buf_size;
} }
......
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