[FFmpeg-devel] [PATCH] Arithmetic decoding in ALS

Thilo Borgmann thilo.borgmann
Tue Jan 19 16:38:59 CET 2010


Am 19.01.10 00:21, schrieb Thilo Borgmann:
> Am 18.01.10 23:38, schrieb Michael Niedermayer:
>> On Thu, Jan 14, 2010 at 03:20:04PM +0100, Thilo Borgmann wrote:
>>> Am 13.01.10 00:00, schrieb Michael Niedermayer:
>>>> On Tue, Jan 12, 2010 at 08:50:27PM +0100, Thilo Borgmann wrote:
>>>>> Am 12.01.10 00:33, schrieb Michael Niedermayer:
>>>>>> On Mon, Jan 11, 2010 at 09:15:05PM +0100, Thilo Borgmann wrote:
>>>>>>> ...
> 
>>> +/** Initializes a given lookup table using a given delta
>>> + */
>>> +static void bgmc_lut_fill(unsigned int lut, unsigned int delta)
>>> +{
>>> +    unsigned int sx, i;
>>> +
>>> +    for (sx = 0; sx < 16; sx++)
>>> +        for (i = 0; i < LUT_SIZE; i++) {
>>> +            unsigned int target = (i + 1) << (FREQ_BITS - LUT_BITS);
>>> +            unsigned int symbol = 1 << delta;
>>> +
>>> +            while (cf_table[sx][symbol] > target)
>>> +                symbol += 1 << delta;
>>> +
>>> +            cf_lut[lut][sx][i] = symbol;
>>> +        }
>>> +
>>> +    cf_lut_status[lut] = delta;
>>> +}
>>> +
>>> +
>>> +/** Retunes the index of a suitable lookup table for a given delta
>>> + */
>>> +static unsigned int bgmc_lut_get(unsigned int delta)
>>> +{
>>> +    unsigned int lut = delta < LUT_BUFF ? delta : LUT_BUFF;
>>> +
>>> +    if (cf_lut_status[lut] != delta)
>>> +        bgmc_lut_fill(lut, delta);
>>
>> this doesnt look thread safe
> 
> I agree for delta >= LUT_BUFF. To be sure, I don't see that for the
> other ones, right?
> 
> So whether all cases or just the delta >= LUT_BUFF cases affected, do
> return a new malloc'd buffer and free it at the end of bgmc_decode()?
> Otherwise just locking comes into my mind which is for sure worse...

Still unanswered and thought about again. Either a malloc'd buffer for
delta >= LUT_BUFF or just making cf_lut[_status] non-static is still in
my mind. What about that?

-Thilo



More information about the ffmpeg-devel mailing list