[FFmpeg-devel] [PATCH 7/9] sbrdsp: unroll and use integer operations

Michael Niedermayer michaelni at gmx.at
Fri Apr 5 06:04:25 CEST 2013


On Thu, Apr 04, 2013 at 07:45:51PM +0000, Christophe Gisquet wrote:
> This patch can be controversial, by assuming floats are IEEE-754 and
> particular behaviour of the FPU will get in the way.
> Timing on Arrandale and Win32 (thus, x87 FPU is used in the reference).
> 
> sbr_qmf_pre_shuffle_c: 115 to 76
> sbr_neg_odd_64_c: 84 to 55
> sbr_qmf_post_shuffle_c: 112 to 83
> ---
>  libavcodec/sbrdsp.c | 33 +++++++++++++++++++++++----------
>  1 file changed, 23 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/sbrdsp.c b/libavcodec/sbrdsp.c
> index e2280cc..49c2107 100644
> --- a/libavcodec/sbrdsp.c
> +++ b/libavcodec/sbrdsp.c
> @@ -51,28 +51,41 @@ static float sbr_sum_square_c(float (*x)[2], int n)
>  
>  static void sbr_neg_odd_64_c(float *x)
>  {
> +    uint32_t *xi = (uint32_t*)x;
>      int i;
> -    for (i = 1; i < 64; i += 2)
> -        x[i] = -x[i];
> +    for (i = 1; i < 64; i += 4)
> +    {
> +        xi[i+0] ^= 1U<<31;
> +        xi[i+2] ^= 1U<<31;

casting  *float to *int32 and dereferencing is a strict aliassing
violation, you have to use
AV_RN32() or av_float2int() or some pointer to a union of float+int32
or something else along thouse lines

otherwise the patch should be ok

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- 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/20130405/d706d4db/attachment.asc>


More information about the ffmpeg-devel mailing list