aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-10-05 20:08:46 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-26 11:50:16 -0400
commite5e4f92b5c9e013adf3e8be0128ed7b3d5b02ad0 (patch)
treedcfbb7238ccf9990ddfcb6e2d226d09500c21b1f /libavcodec
parentdcaa83a0fccb3bd63eb71c48d70c1adfc97e4102 (diff)
downloadffmpeg-e5e4f92b5c9e013adf3e8be0128ed7b3d5b02ad0.tar.gz
alacdec: allocate per-channel buffers based on channel count.
reduces memory usage when the stream has fewer than MAX_CHANNELS
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/alac.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index d4926e848f..d784b4f4c5 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -88,7 +88,7 @@ typedef struct {
static void allocate_buffers(ALACContext *alac)
{
int chan;
- for (chan = 0; chan < MAX_CHANNELS; chan++) {
+ for (chan = 0; chan < alac->numchannels; chan++) {
alac->predicterror_buffer[chan] =
av_malloc(alac->setinfo_max_samples_per_frame * 4);
@@ -125,8 +125,6 @@ static int alac_set_info(ALACContext *alac)
bytestream_get_be32(&ptr); /* bitrate ? */
bytestream_get_be32(&ptr); /* samplerate */
- allocate_buffers(alac);
-
return 0;
}
@@ -670,6 +668,8 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
return AVERROR_PATCHWELCOME;
}
+ allocate_buffers(alac);
+
return 0;
}
@@ -678,7 +678,7 @@ static av_cold int alac_decode_close(AVCodecContext *avctx)
ALACContext *alac = avctx->priv_data;
int chan;
- for (chan = 0; chan < MAX_CHANNELS; chan++) {
+ for (chan = 0; chan < alac->numchannels; chan++) {
av_freep(&alac->predicterror_buffer[chan]);
av_freep(&alac->outputsamples_buffer[chan]);
av_freep(&alac->wasted_bits_buffer[chan]);