[FFmpeg-devel] [PATCH] QCELP decoder postfilter & final gain control
Kenan Gillet
kenan.gillet
Tue Apr 14 01:04:03 CEST 2009
Hi,
2009/4/12 M?ns Rullg?rd <mans at mansr.com>:
> "Reynaldo H. Verdejo Pinochet" <reynaldo at opendot.cl> writes:
>
>> Hello
>>
>> M?ns Rullg?rd wrote
>>>
>>> If filter_coeffs is pointing to the first element of an array, that
>>> subtraction *is* invalid.
>>
>> That's what I tried to argue yesterday's night at IRC but Baptiste
>> said (he might clarify this if he's reading) it wont matter as long
>> as the code itself isn't reading nor writing from there. I personally
>> don't like the 'trick' and I'm not sure its even guaranteed to work but
>> whenever I'm not sure I ask, and it being a 'non issue' has been the
>> answer so far.
>
> Merely calculating an address outside an array or dynamically
> allocated block might cause an overflow trap or similar. ?I have seen
> this happen in a real system, and it was not easy to track it down.
I benchmarked ff_celp_lp_synthesis_filterf both with and without the trick
(patch attached), on a Core Duo 2Ghz, gcc 4.2.1, and did not find any
noticeable difference.
-------------- next part --------------
Index: libavcodec/celp_filters.c
===================================================================
--- libavcodec/celp_filters.c (revision 18382)
+++ libavcodec/celp_filters.c (working copy)
@@ -61,15 +61,14 @@
{
int i,n;
- // These two lines are to avoid a -1 subtraction in the main loop
+ // This line is to avoid a +1 subtraction in the main loop.
filter_length++;
- filter_coeffs--;
for(n=0; n<buffer_length; n++)
{
int sum = rounder;
for(i=1; i<filter_length; i++)
- sum -= filter_coeffs[i] * out[n-i];
+ sum -= filter_coeffs[i-1] * out[n-i];
sum = (sum >> 12) + in[n];
@@ -94,14 +93,13 @@
{
int i,n;
- // These two lines are to avoid a -1 subtraction in the main loop
+ // This line is to avoid a +1 subtraction in the main loop
filter_length++;
- filter_coeffs--;
for(n=0; n<buffer_length; n++)
{
out[n] = in[n];
for(i=1; i<filter_length; i++)
- out[n] -= filter_coeffs[i] * out[n-i];
+ out[n] -= filter_coeffs[i-1] * out[n-i];
}
}
More information about the ffmpeg-devel
mailing list