[FFmpeg-devel] [PATCH 2/5] Add dot_product function for use by the G.723.1 decoder

Michael Niedermayer michaelni at gmx.at
Fri Apr 8 12:34:41 CEST 2011


On Mon, Mar 21, 2011 at 08:48:59PM +0100, Vitor Sessak wrote:
> On 03/17/2011 11:56 PM, banan at ludd.ltu.se wrote:
>> From: Mohamed Naufal Basheer<naufal11 at gmail.com>
>>
>> ---
>>   libavcodec/celp_math.c |   12 ++++++++++++
>>   libavcodec/celp_math.h |   11 +++++++++++
>>   2 files changed, 23 insertions(+), 0 deletions(-)
>>
>> diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
>> index 09111da..b78edd1 100644
>> --- a/libavcodec/celp_math.c
>> +++ b/libavcodec/celp_math.c
>> @@ -25,6 +25,7 @@
>>   #include<assert.h>
>>
>>   #include "avcodec.h"
>> +#include "mathops.h"
>>   #include "celp_math.h"
>>
>>   #ifdef G729_BITEXACT
>> @@ -196,6 +197,17 @@ int ff_log2(uint32_t value)
>>       return (power_int<<  15) + value;
>>   }
>>
>> +int ff_dot_product(const int16_t *a, const int16_t *b, int length, int shift)
>> +{
>> +    int i, sum = 0;
>> +
>> +    for (i = 0; i<  length; i++) {
>> +        int64_t prod = av_clipl_int32(MUL64(a[i], b[i])<<  shift);
>> +        sum = av_clipl_int32(sum + prod);
>> +    }
>> +    return sum;
>> +}
>
> Hmm... I don't understand why this is not implemented like

probably spec written by idiots :)
but ive not checked


>
> int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
> {
>     int i;
>     int64_t sum = 0;
>
>     for (i = 0; i < length; i++)
>         sum += MUL16(a[i], b[i]);
>
>     return sum;
> }
>
> and then
>
> av_clipl_int32(ff_dot_product(a, b, len) << shift);
> ?
>
> Is the reason that clipping as in your code necessary for the decoder to  
> be bitexact? IMHO, if it is so, I think this function is too much G723.1  
> specific to be in common code...

agree, can you or someone test if the mathematically cleaner code
works too?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110408/899092b1/attachment.asc>


More information about the ffmpeg-devel mailing list