[FFmpeg-devel] [PATCH 4/5] Add the G723.1 demuxer and decoder

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


On Sat, Mar 19, 2011 at 03:02:32PM +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>
[...]
>> +static int scale_vector(int16_t *vector, int length)
>> +{
>> +    int bits, scale, max = 0;
>> +    int i;
>> +
>> +    const int16_t shift_table[16] = {
>> +        0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
>> +        0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x7fff
>> +    };
>> +
>> +    for (i = 0; i<  length; i++)
>> +        max = FFMAX(max, FFABS(vector[i]));
>> +
>> +    bits  = normalize_bits(max, 0);
>> +    scale = shift_table[bits];
>> +
>> +    for (i = 0; i<  length; i++)
>> +        vector[i] = (int16_t)(av_clipl_int32(vector[i] * scale<<  1)>>  4);
>
> What is the point of clipping a 32-bit value to 32-bits?

this code is not well written

it should be, assuming the original is correct: (bit exact)
vector[i] = (vector[i] * scale) >> 3;


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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- 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/c7a83e6c/attachment.asc>


More information about the ffmpeg-devel mailing list