[FFmpeg-devel] [PATCH] Move CPU detection to libavutil and cleanup

Michael Niedermayer michaelni
Wed Sep 8 15:15:11 CEST 2010


On Wed, Sep 08, 2010 at 01:14:03PM +0200, Stefano Sabatini wrote:
[...]
> +#include "cpu.h"
> +#include "config.h"
> +
> +#if   ARCH_ARM
> +#   include "arm/cpu.h"
> +#elif ARCH_PPC
> +#   include "ppc/cpu.h"
> +#elif ARCH_X86
> +#   include "x86/cpu.h"
> +#else
> +int av_get_cpu_flags(void)
> +{
> +    return 0;
> +}
> +#endif
> +
> +#ifdef TEST
> +
> +#undef printf
> +
> +int main(void)
> +{
> +    int cpu_flags = av_get_cpu_flags();
> +
> +    printf("cpu_flags = 0x%08X\n", cpu_flags);
> +    printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s\n",
> +#if    ARCH_ARM
> +           cpu_flags & AV_CPU_FLAG_IWMMXT   ? "IWMMXT "     : "",
> +#elsif ARCH_PPC
> +           cpu_flags & AV_CPU_FLAG_ALTIVEC  ? "ALTIVEC "    : "",
> +#else
> +           cpu_flags & AV_CPU_FLAG_MMX      ? "MMX "        : "",
> +#endif
> +           cpu_flags & AV_CPU_FLAG_MMX2     ? "MMX2 "       : "",
> +           cpu_flags & AV_CPU_FLAG_SSE      ? "SSE "        : "",
> +           cpu_flags & AV_CPU_FLAG_SSE2     ? "SSE2 "       : "",
> +           cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "",
> +           cpu_flags & AV_CPU_FLAG_SSE3     ? "SSE3 "       : "",
> +           cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "",
> +           cpu_flags & AV_CPU_FLAG_SSSE3    ? "SSSE3 "      : "",
> +           cpu_flags & AV_CPU_FLAG_SSE4     ? "SSE4.1 "     : "",
> +           cpu_flags & AV_CPU_FLAG_SSE42    ? "SSE4.2 "     : "",
> +           cpu_flags & AV_CPU_FLAG_3DNOW    ? "3DNow "      : "",
> +           cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt "   : "");

the rest of the x86 flags should be under that ifdef too or be defined to 0

patch should be ok otherwise if tested 

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100908/0f1bb49b/attachment.pgp>



More information about the ffmpeg-devel mailing list