[FFmpeg-devel] [PATCH] Avoid a branch in MP2 decoder

Måns Rullgård mans
Sat Jun 26 20:11:35 CEST 2010


Vitor Sessak <vitor1001 at gmail.com> writes:

> $subj.
>
> -Vitor
>
> Index: libavcodec/mpegaudiodec.c
> ===================================================================
> --- libavcodec/mpegaudiodec.c	(revision 23792)
> +++ libavcodec/mpegaudiodec.c	(working copy)
> @@ -202,9 +202,7 @@
>  
>      val = (mant - (steps >> 1)) * scale_factor_mult2[steps >> 2][mod];
>      /* NOTE: at this point, 0 <= shift <= 21 */
> -    if (shift > 0)
> -        val = (val + (1 << (shift - 1))) >> shift;
> -    return val;
> +    return ((val << 1) + (1 << shift)) >> (shift+1);
>  }

This assumes the MSB of val is zero.  Is this always the case?

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list