diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-12-23 16:56:17 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2013-02-12 12:21:21 -0500 |
commit | 5cd597f22ff5b1587e005153ad5bd33ecf6907c8 (patch) | |
tree | 5316268dd794d7009b4da7226c339cc31ad5b8da /libavcodec/alac.c | |
parent | bae4f47938bbc63b7ab567edce9a5e778a37a3bf (diff) | |
download | ffmpeg-5cd597f22ff5b1587e005153ad5bd33ecf6907c8.tar.gz |
alac: decode directly to the user-provided AVFrame
Diffstat (limited to 'libavcodec/alac.c')
-rw-r--r-- | libavcodec/alac.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 1a3f769513..0c5bdd3e45 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -58,7 +58,6 @@ typedef struct { AVCodecContext *avctx; - AVFrame frame; GetBitContext gb; int channels; @@ -248,7 +247,7 @@ static void append_extra_bits(int32_t *buffer[2], int32_t *extra_bits_buffer[2], buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i]; } -static int decode_element(AVCodecContext *avctx, void *data, int ch_index, +static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index, int channels) { ALACContext *alac = avctx->priv_data; @@ -283,8 +282,8 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index, } if (!alac->nb_samples) { /* get output buffer */ - alac->frame.nb_samples = output_samples; - if ((ret = ff_get_buffer(avctx, &alac->frame)) < 0) { + frame->nb_samples = output_samples; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } @@ -296,7 +295,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index, alac->nb_samples = output_samples; if (alac->sample_size > 16) { for (ch = 0; ch < channels; ch++) - alac->output_samples_buffer[ch] = (int32_t *)alac->frame.extended_data[ch_index + ch]; + alac->output_samples_buffer[ch] = (int32_t *)frame->extended_data[ch_index + ch]; } if (is_compressed) { @@ -377,7 +376,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index, switch(alac->sample_size) { case 16: { for (ch = 0; ch < channels; ch++) { - int16_t *outbuffer = (int16_t *)alac->frame.extended_data[ch_index + ch]; + int16_t *outbuffer = (int16_t *)frame->extended_data[ch_index + ch]; for (i = 0; i < alac->nb_samples; i++) *outbuffer++ = alac->output_samples_buffer[ch][i]; }} @@ -397,6 +396,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { ALACContext *alac = avctx->priv_data; + AVFrame *frame = data; enum AlacRawDataBlockType element; int channels; int ch, ret, got_end; @@ -423,7 +423,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - ret = decode_element(avctx, data, + ret = decode_element(avctx, frame, ff_alac_channel_layout_offsets[alac->channels - 1][ch], channels); if (ret < 0 && get_bits_left(&alac->gb)) @@ -441,8 +441,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, avpkt->size * 8 - get_bits_count(&alac->gb)); } - *got_frame_ptr = 1; - *(AVFrame *)data = alac->frame; + *got_frame_ptr = 1; return avpkt->size; } @@ -563,9 +562,6 @@ static av_cold int alac_decode_init(AVCodecContext * avctx) return ret; } - avcodec_get_frame_defaults(&alac->frame); - avctx->coded_frame = &alac->frame; - return 0; } |