[vlc] Assembler help

Rick Davis rickdavisjr at comcast.net
Thu Jan 20 12:30:28 CET 2005


I am trying to get the deinterlace module and the a52 library to compile
using MMX. I am using Microsoft Visual C++. I am not much of an assembler
programmer. Could someone show me how to convert the GNU style inline
assembly to something that will work with Microsoft assembler?

static void MergeMMX( void *_p_dest, const void *_p_s1, const void *_p_s2,
                      size_t i_bytes )
{
    uint8_t* p_dest = (uint8_t*)_p_dest;
    const uint8_t *p_s1 = (const uint8_t *)_p_s1;
    const uint8_t *p_s2 = (const uint8_t *)_p_s2;
    uint8_t* p_end = p_dest + i_bytes - 8;
    while( p_dest < p_end )
    {
#ifndef UNDER_CE // Not Microsoft inline
        __asm__  __volatile__( "movq %2,%%mm1;"
                               "pavgb %1, %%mm1;"
                               "movq %%mm1, %0" :"=m" (*p_dest):
                                                 "m" (*p_s1),
                                                 "m" (*p_s2) );
#else // Microsoft Inline
/* The pavgb doesn't work */
        __asm
	  {
		movq p_s2, mm1
            pavgb p_s1, mm1
            movq mm1, p_dest
	  }
#endif

        p_dest += 8;
        p_s1 += 8;
        p_s2 += 8;
    }

    p_end += 8;

    while( p_dest < p_end )
    {
        *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
    }
}
#endif




static int a52_resample_STEREO_to_2_MMX(float * _f, int16_t * s16){
    int32_t * f = (int32_t *) _f;
/* benchmark scores are 0.3% better with SSE but we would need to set bias=0
and premultiply it
#ifdef HAVE_SSE
	asm volatile(
		"movl $-1024, %%esi		\n\t"
		"1:				\n\t"
		"cvtps2pi (%1, %%esi), %%mm0	\n\t"
		"cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
		"movq %%mm0, %%mm1		\n\t"
		"punpcklwd %%mm2, %%mm0		\n\t"
		"punpckhwd %%mm2, %%mm1		\n\t"
		"movq %%mm0, (%0, %%esi)	\n\t"
		"movq %%mm1, 8(%0, %%esi)	\n\t"
		"addl $16, %%esi		\n\t"
		" jnz 1b			\n\t"
		"emms				\n\t"
		:: "r" (s16+512), "r" (f+256)
		:"%esi", "memory"
	);*/
	asm volatile(
		"movl $-1024, %%esi		\n\t"
		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
		"1:				\n\t"
		"movq (%1, %%esi), %%mm0	\n\t"
		"movq 8(%1, %%esi), %%mm1	\n\t"
		"movq 1024(%1, %%esi), %%mm2	\n\t"
		"movq 1032(%1, %%esi), %%mm3	\n\t"
		"psubd %%mm7, %%mm0		\n\t"
		"psubd %%mm7, %%mm1		\n\t"
		"psubd %%mm7, %%mm2		\n\t"
		"psubd %%mm7, %%mm3		\n\t"
		"packssdw %%mm1, %%mm0		\n\t"
		"packssdw %%mm3, %%mm2		\n\t"
		"movq %%mm0, %%mm1		\n\t"
		"punpcklwd %%mm2, %%mm0		\n\t"
		"punpckhwd %%mm2, %%mm1		\n\t"
		"movq %%mm0, (%0, %%esi)	\n\t"
		"movq %%mm1, 8(%0, %%esi)	\n\t"
		"addl $16, %%esi		\n\t"
		" jnz 1b			\n\t"
		"emms				\n\t"
		:: "r" (s16+512), "r" (f+256)
		:"%esi", "memory"
	);
    return 2*256;
}

Thanks in advance,
--
Rick Davis
--
This is the vlc mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://www.videolan.org/support/lists.html



-- 
This is the vlc mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://www.videolan.org/support/lists.html



More information about the vlc mailing list