[FFmpeg-devel] Dirac Golomb decoder [PATCH]

Marco Gerards mgerards
Wed Aug 15 14:48:31 CEST 2007


Michael Niedermayer <michaelni at gmx.at> writes:

Hi,

[...]

>> @@ -75,7 +76,7 @@
>>  
>>  static inline int svq3_get_ue_golomb(GetBitContext *gb){
>>      uint32_t buf;
>> -    int log;
>> +    int ret = 1;
>>  
>>      OPEN_READER(re, gb);
>>      UPDATE_CACHE(re, gb);
>> @@ -88,21 +89,22 @@
>>  
>>          return ff_interleaved_ue_golomb_vlc_code[buf];
>>      }else{
>
> the int ret = 1; can be moved here, which might avoid an uneeded =1 in the
> if() case with some (crappy) compilers

I changed this.

> [...]
>
>> @@ -192,6 +194,49 @@
>>      }
>>  }
>>  
>> +static inline int dirac_get_se_golomb(GetBitContext *gb){
>> +    uint32_t buf;
>> +    uint32_t ret = 1;
>> +
>> +    OPEN_READER(re, gb);
>> +    UPDATE_CACHE(re, gb);
>> +    buf=GET_CACHE(re, gb);
>> +
>> +    if(buf&0xAA800000){
>> +        buf >>= 32 - 8;
>> +        LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
>> +        CLOSE_READER(re, gb);
>> +
>> +        ret = ff_interleaved_ue_golomb_vlc_code[buf];
>> +    } else {
>> +        while (1) {
>> +            buf >>= 32 - 8;
>> +            LAST_SKIP_BITS(re, gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
>> +
>> +            if (ff_interleaved_golomb_vlc_len[buf] != 9){
>> +                ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
>> +                ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
>> +                break;
>> +            }
>> +            ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
>> +            UPDATE_CACHE(re, gb);
>> +            buf = GET_CACHE(re, gb);
>> +        }
>> +        ret--;
>> +    }
>
> if this part is identical to svq3_get_ue_golomb() then simply calling it
> might be worth a try, though it might be a little slower due to the
> extra OPEN_READER/UPDATE_CACHE
> but it does not seem the se code is used in any speed critical parts of
> dirac?


No, at the moment it is called about 1-8 times per frame.

>> +
>> +    if (ret) {
>> +        UPDATE_CACHE(re, gb);
>
>> +        buf = SHOW_UBITS(re, gb, 1);
>> +        LAST_SKIP_BITS(re, gb, 1);
>> +        if (buf)
>> +            ret = -ret;
>
> buf = SHOW_SBITS(re, gb, 1);
> LAST_SKIP_BITS(re, gb, 1);
> ret = (ret^buf)-buf;
>
> (possibly avoids a conditional branch which is quite slow on moderns CPUs)

Changed.

> with these changes iam fine with the patch, you can commit it 
> and if you dont have write access then complain to diego

Ok, great!  I included the patch to be sure, so it can be checked in
by someone else, if it takes a while before I will get write
access. :-)

--
Marco

-------------- next part --------------
A non-text attachment was scrubbed...
Name: golomb.diff
Type: text/x-diff
Size: 3334 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070815/8e536d4a/attachment.diff>



More information about the ffmpeg-devel mailing list