[FFmpeg-devel] [RFC] "Likely" and "Unlikely" macros

Jason Garrett-Glaser darkshikari
Tue Oct 7 23:11:36 CEST 2008


On Tue, Oct 7, 2008 at 2:07 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
> On Tue, Oct 7, 2008 at 6:03 PM, Jason Garrett-Glaser
> <darkshikari at gmail.com> wrote:
>> The following macros seem to provide great benefit in some critical
>> code sections, such as decode_cabac_residual, where I've shaved off a
>> few clocks experimenting with them:
>>
>> #define likely(x) __builtin_expect((x),1)
>> #define unlikely(x) __builtin_expect((x),0)
>>
>> This is probably due to gcc knowing which side of each if statement to inline.
>>
>> Is there any objection to using these in various critical code
>> sections in ffmpeg?
>
> http://article.gmane.org/gmane.comp.video.ffmpeg.devel/65056
>
> I just don't know the internals enough to try and shave cycles out of
> critical sections =)

Indeed, it seems I wasn't the first to consider this.

I'll return with a patch in a bit, and let Michael decide where the
macros should go.

Dark Shikari




More information about the ffmpeg-devel mailing list