[MPlayer-dev-eng] shared liba52 and mm_accel macros

Guillaume Poirier gpoirier at mplayerhq.hu
Mon Apr 2 11:49:58 CEST 2007


Reimar Döffinger wrote:
> Hello,
> [...]
> On Mon, Apr 02, 2007 at 11:33:17AM +1000, Finn Thain wrote:

>>I had no idea that runtime detection was so difficult. As a Gentoo user, I 
>>compile everything tuned to my CPU. But I don't know how the binary 
>>distros handle altivec and all the other optimisations on other 
>>architectures. Maybe the API originally came from closed-source code...
> AFAIK only Altivec is so problematic, and actually only Altivec on
> Linux, OSX seems to have a special syscall to check for it IIRC.


For what it's worth, here's what's implemented in x264 to detect
Altivec capabilities on OSX:

uint32_t x264_cpu_detect( void )
    /* Thank you VLC */
    uint32_t cpu = 0;
    int      selectors[2] = { CTL_HW, HW_VECTORUNIT };
    int      has_altivec = 0;
    size_t   length = sizeof( has_altivec );
    int      error = sysctl( selectors, 2, &has_altivec, &length,
NULL, 0 );

    if( error == 0 && has_altivec != 0 )
        cpu |= X264_CPU_ALTIVEC;

    return cpu;

on Linux, it's much more hackish (trying to execute an altivec
instruction and trap SIGILL if it raises an exception.


More information about the MPlayer-dev-eng mailing list