[FFmpeg-devel] [PATCH 07/12] lpc: remove VLA in ff_lpc_compute_autocorr
Måns Rullgård
mans
Wed Jun 23 23:18:51 CEST 2010
Justin Ruggles <justin.ruggles at gmail.com> writes:
> Mans Rullgard wrote:
>
>> ---
>> libavcodec/lpc.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
>> index 49e41d8..6b3cf01 100644
>> --- a/libavcodec/lpc.c
>> +++ b/libavcodec/lpc.c
>> @@ -59,7 +59,7 @@ void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
>> double *autoc)
>> {
>> int i, j;
>> - double tmp[len + lag + 1];
>> + double *tmp = av_malloc((len + lag + 1) * sizeof(*tmp));
>> double *data1= tmp + lag;
>>
>> apply_welch_window(data, len, data1);
>> @@ -86,6 +86,8 @@ void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
>> }
>> autoc[j] = sum;
>> }
>> +
>> + av_free(tmp);
>> }
>
> looks fine to me. But I think the sse2 version of this function also
> has the same VLA.
Yes, it does, as I noticed later. Requiring dsputil functions to
allocate unknown amounts of memory us generally a bad idea. Can we
think of a better solution? Make the caller pass a scratch buffer?
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list