aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/alac.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-13 11:36:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-13 11:39:05 +0100
commitd13f434dbb55348b3ed761e4f4c2ff9c7be4ea4b (patch)
tree6591e3d29559c2dacdea43049b128790993be84c /libavcodec/alac.c
parent4789955ec4260f9e8f99b8d774ada2ad679d5630 (diff)
parente3db34291f4401a16f6ac92721617a9f33cd4c31 (diff)
downloadffmpeg-d13f434dbb55348b3ed761e4f4c2ff9c7be4ea4b.tar.gz
Merge commit 'e3db34291f4401a16f6ac92721617a9f33cd4c31'
* commit 'e3db34291f4401a16f6ac92721617a9f33cd4c31': amrnb: decode directly to the user-provided AVFrame als: decode directly to the user-provided AVFrame alac: decode directly to the user-provided AVFrame adxenc: alloc/free coded_frame instead of keeping it in the ADXContext adx: decode directly to the user-provided AVFrame Conflicts: libavcodec/alsdec.c libavcodec/amrnbdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/alac.c')
-rw-r--r--libavcodec/alac.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 180ef53105..f8ac560cb8 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -58,7 +58,6 @@
typedef struct {
AVCodecContext *avctx;
- AVFrame frame;
GetBitContext gb;
int channels;
@@ -254,7 +253,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;
@@ -289,8 +288,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;
}
@@ -302,7 +301,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
alac->nb_samples = output_samples;
if (alac->direct_output) {
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) {
@@ -390,7 +389,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];
}}
@@ -405,7 +404,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
}else{
switch(alac->sample_size) {
case 16: {
- int16_t *outbuffer = ((int16_t *)alac->frame.extended_data[0]) + ch_index;
+ int16_t *outbuffer = ((int16_t *)frame->extended_data[0]) + ch_index;
for (i = 0; i < alac->nb_samples; i++) {
for (ch = 0; ch < channels; ch++)
*outbuffer++ = alac->output_samples_buffer[ch][i];
@@ -414,7 +413,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
}
break;
case 24: {
- int32_t *outbuffer = ((int32_t *)alac->frame.extended_data[0]) + ch_index;
+ int32_t *outbuffer = ((int32_t *)frame->extended_data[0]) + ch_index;
for (i = 0; i < alac->nb_samples; i++) {
for (ch = 0; ch < channels; ch++)
*outbuffer++ = alac->output_samples_buffer[ch][i] << 8;
@@ -423,7 +422,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
}
break;
case 32: {
- int32_t *outbuffer = ((int32_t *)alac->frame.extended_data[0]) + ch_index;
+ int32_t *outbuffer = ((int32_t *)frame->extended_data[0]) + ch_index;
for (i = 0; i < alac->nb_samples; i++) {
for (ch = 0; ch < channels; ch++)
*outbuffer++ = alac->output_samples_buffer[ch][i];
@@ -441,6 +440,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;
@@ -469,7 +469,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))
@@ -487,8 +487,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;
}
@@ -616,9 +615,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;
}