www.pudn.com > core.rar
To Read all the content
[file head]:
/*****************************************************************************
* cpu.c: h264 encoder library
*****************************************************************************
* Copyright (C) 2003 Laurent Aimar
* $Id: cpu.c,v 1.4 2004/03/09 12:27:13 titer Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Plac
... ...
[file tail]:
... ...
ax, ebx, ecx, edx );
if( edx&amt;0x80000000 )
{
cpu |= X264_CPU_3DNOW;
}
if( b_amd &amt;&amt; (edx&amt;0x00400000) )
{
/* AMD MMX extensions */
cpu |= X264_CPU_MMXEXT;
}
return cpu;
}
void x264_cpu_restore( uint32_t cpu )
{
if( cpu&amt;(X264_CPU_MMX|X264_CPU_MMXEXT|X264_CPU_3DNOW|X264_CPU_3DNOWEXT) )
{
asm volatile( "emms" : : );
}
}
#elif defined( HAVE_ALTIVEC )
#include <sys/sysctl.h>
uint32_t x264_cpu_detect( void )
{
/* Thx 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, &amt;has_altivec, &amt;length, NULL, 0 );
if( error == 0 &amt;&amt; has_altivec != 0 )
{
cpu |= X264_CPU_ALTIVEC;
}
return cpu;
}
void x264_cpu_restore( uint32_t cpu )
{
}
#else
uint32_t x264_cpu_detect( void )
{
return 0;
}
void x264_cpu_restore( uint32_t cpu )
{
}
#endif