comparison alsdec.c @ 10860:c9fb5b89e47a libavcodec

Replace variable length array with an allocated buffer in the context to increase compatibility.
author thilo.borgmann
date Tue, 12 Jan 2010 20:35:22 +0000
parents d87e8f2c5c91
children 61bf5a551856
comparison
equal deleted inserted replaced
10859:762e6bb0ba40 10860:c9fb5b89e47a
178 int *ltp_gain_buffer; ///< contains all gain values for ltp 5-tap filter 178 int *ltp_gain_buffer; ///< contains all gain values for ltp 5-tap filter
179 int32_t **quant_cof; ///< quantized parcor coefficients for a channel 179 int32_t **quant_cof; ///< quantized parcor coefficients for a channel
180 int32_t *quant_cof_buffer; ///< contains all quantized parcor coefficients 180 int32_t *quant_cof_buffer; ///< contains all quantized parcor coefficients
181 int32_t **lpc_cof; ///< coefficients of the direct form prediction filter for a channel 181 int32_t **lpc_cof; ///< coefficients of the direct form prediction filter for a channel
182 int32_t *lpc_cof_buffer; ///< contains all coefficients of the direct form prediction filter 182 int32_t *lpc_cof_buffer; ///< contains all coefficients of the direct form prediction filter
183 int32_t *lpc_cof_reversed_buffer; ///< temporary buffer to set up a reversed versio of lpc_cof_buffer
183 ALSChannelData **chan_data; ///< channel data for multi-channel correlation 184 ALSChannelData **chan_data; ///< channel data for multi-channel correlation
184 ALSChannelData *chan_data_buffer; ///< contains channel data for all channels 185 ALSChannelData *chan_data_buffer; ///< contains channel data for all channels
185 int *reverted_channels; ///< stores a flag for each reverted channel 186 int *reverted_channels; ///< stores a flag for each reverted channel
186 int32_t *prev_raw_samples; ///< contains unshifted raw samples from the previous block 187 int32_t *prev_raw_samples; ///< contains unshifted raw samples from the previous block
187 int32_t **raw_samples; ///< decoded raw samples for each channel 188 int32_t **raw_samples; ///< decoded raw samples for each channel
729 int64_t y; 730 int64_t y;
730 int32_t *quant_cof = bd->quant_cof; 731 int32_t *quant_cof = bd->quant_cof;
731 int32_t *lpc_cof = bd->lpc_cof; 732 int32_t *lpc_cof = bd->lpc_cof;
732 int32_t *raw_samples = bd->raw_samples; 733 int32_t *raw_samples = bd->raw_samples;
733 int32_t *raw_samples_end = bd->raw_samples + bd->block_length; 734 int32_t *raw_samples_end = bd->raw_samples + bd->block_length;
734 int32_t lpc_cof_reversed[opt_order]; 735 int32_t *lpc_cof_reversed = ctx->lpc_cof_reversed_buffer;
735 736
736 // reverse long-term prediction 737 // reverse long-term prediction
737 if (*bd->use_ltp) { 738 if (*bd->use_ltp) {
738 int ltp_smp; 739 int ltp_smp;
739 740
1357 av_freep(&ctx->ltp_gain_buffer); 1358 av_freep(&ctx->ltp_gain_buffer);
1358 av_freep(&ctx->quant_cof); 1359 av_freep(&ctx->quant_cof);
1359 av_freep(&ctx->lpc_cof); 1360 av_freep(&ctx->lpc_cof);
1360 av_freep(&ctx->quant_cof_buffer); 1361 av_freep(&ctx->quant_cof_buffer);
1361 av_freep(&ctx->lpc_cof_buffer); 1362 av_freep(&ctx->lpc_cof_buffer);
1363 av_freep(&ctx->lpc_cof_reversed_buffer);
1362 av_freep(&ctx->prev_raw_samples); 1364 av_freep(&ctx->prev_raw_samples);
1363 av_freep(&ctx->raw_samples); 1365 av_freep(&ctx->raw_samples);
1364 av_freep(&ctx->raw_buffer); 1366 av_freep(&ctx->raw_buffer);
1365 av_freep(&ctx->chan_data); 1367 av_freep(&ctx->chan_data);
1366 av_freep(&ctx->chan_data_buffer); 1368 av_freep(&ctx->chan_data_buffer);
1417 ctx->lpc_cof = av_malloc(sizeof(*ctx->lpc_cof) * num_buffers); 1419 ctx->lpc_cof = av_malloc(sizeof(*ctx->lpc_cof) * num_buffers);
1418 ctx->quant_cof_buffer = av_malloc(sizeof(*ctx->quant_cof_buffer) * 1420 ctx->quant_cof_buffer = av_malloc(sizeof(*ctx->quant_cof_buffer) *
1419 num_buffers * sconf->max_order); 1421 num_buffers * sconf->max_order);
1420 ctx->lpc_cof_buffer = av_malloc(sizeof(*ctx->lpc_cof_buffer) * 1422 ctx->lpc_cof_buffer = av_malloc(sizeof(*ctx->lpc_cof_buffer) *
1421 num_buffers * sconf->max_order); 1423 num_buffers * sconf->max_order);
1424 ctx->lpc_cof_reversed_buffer = av_malloc(sizeof(*ctx->lpc_cof_buffer) *
1425 sconf->max_order);
1422 1426
1423 if (!ctx->quant_cof || !ctx->lpc_cof || 1427 if (!ctx->quant_cof || !ctx->lpc_cof ||
1424 !ctx->quant_cof_buffer || !ctx->lpc_cof_buffer) { 1428 !ctx->quant_cof_buffer || !ctx->lpc_cof_buffer ||
1429 !ctx->lpc_cof_reversed_buffer) {
1425 av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); 1430 av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
1426 return AVERROR(ENOMEM); 1431 return AVERROR(ENOMEM);
1427 } 1432 }
1428 1433
1429 // assign quantized parcor coefficient buffers 1434 // assign quantized parcor coefficient buffers