1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-10-07 10:21:53 +02:00

cook: decode directly to the user-provided AVFrame

This commit is contained in:
Justin Ruggles 2012-12-23 17:41:31 -05:00
parent cddf8998f1
commit 7b78321597

View File

@ -123,7 +123,6 @@ typedef struct cook {
AVCodecContext* avctx; AVCodecContext* avctx;
DSPContext dsp; DSPContext dsp;
AVFrame frame;
GetBitContext gb; GetBitContext gb;
/* stream data */ /* stream data */
int num_vectors; int num_vectors;
@ -944,6 +943,7 @@ static int decode_subpacket(COOKContext *q, COOKSubpacket *p,
static int cook_decode_frame(AVCodecContext *avctx, void *data, static int cook_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;
COOKContext *q = avctx->priv_data; COOKContext *q = avctx->priv_data;
@ -957,12 +957,12 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data,
/* get output buffer */ /* get output buffer */
if (q->discarded_packets >= 2) { if (q->discarded_packets >= 2) {
q->frame.nb_samples = q->samples_per_channel; frame->nb_samples = q->samples_per_channel;
if ((ret = ff_get_buffer(avctx, &q->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 = (float **)q->frame.extended_data; samples = (float **)frame->extended_data;
} }
/* estimate subpacket sizes */ /* estimate subpacket sizes */
@ -1003,8 +1003,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data,
return avctx->block_align; return avctx->block_align;
} }
*got_frame_ptr = 1; *got_frame_ptr = 1;
*(AVFrame *) data = q->frame;
return avctx->block_align; return avctx->block_align;
} }
@ -1248,9 +1247,6 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
else else
avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avcodec_get_frame_defaults(&q->frame);
avctx->coded_frame = &q->frame;
#ifdef DEBUG #ifdef DEBUG
dump_cook_context(q); dump_cook_context(q);
#endif #endif