[x264-devel] commit: Convert to a unified "pixel" type for pixel data (Oskar Arvidsson )

Håkan Hjort hakan.hjort at gmail.com
Thu Jun 3 21:20:27 CEST 2010


On Thu, Jun 3, 2010 at 19:15, avcoder <ffmpeg at gmail.com> wrote:
> It seems that the following code breaks on non-16 bytes stack such as MSVC++
> +static void ALWAYS_INLINE pixel_memset( pixel *dst, int value, int size )
> +{
> +    for( int i = 0; i < size; i++ )
> +        dst[i] = value;
> +}
>
> because: <compiled by gcc 4.4.4>
>
-snip
>
> please check:
>
>  372:   0f 57 c9                xorps  %xmm1,%xmm1
>  375:   0f b6 f8                movzbl %al,%edi
>  378:   89 7c 24 30             mov    %edi,0x30(%esp)
>  37c:   89 fd                   mov    %edi,%ebp
>  37e:   0f 29 4c 24 10          movaps %xmm1,0x10(%esp)
>
>
> %esp is not aligned on 16
>

This either due to something else (specifying an alignment) or a GCC
bug, I think.


> I just use the following patch:
>
> diff --git a/common/frame.c b/common/frame.c
> index 9d630f8..2209683 100644
> --- a/common/frame.c
> +++ b/common/frame.c
> @@ -255,8 +255,7 @@ int x264_frame_copy_picture( x264_t *h,
> x264_frame_t *dst, x264_picture_t *src )
>
>  static void ALWAYS_INLINE pixel_memset( pixel *dst, int value, int size )
>  {
> -    for( int i = 0; i < size; i++ )
> -        dst[i] = value;
> +    memset(dst, value, size);
>  }
>

That won't be correct when pixel is some other size than 'sizeof char'.
Which, I guess, is the hole point of the initial patch.

(Or well, it will only for values where all char sized sub parts
should get the same bit pattern.)

Regards,
Håkan


More information about the x264-devel mailing list