You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
alacdec: allocate per-channel buffers based on channel count.
reduces memory usage when the stream has fewer than MAX_CHANNELS
This commit is contained in:
@@ -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]);
|
||||
|
Reference in New Issue
Block a user