$OpenBSD: patch-modules_codec_avcodec_cpu_c,v 1.2 2014/05/05 08:34:08 brad Exp $

Deal with newer FFmpeg API.

--- modules/codec/avcodec/cpu.c.orig	Thu Apr 10 21:09:43 2014
+++ modules/codec/avcodec/cpu.c	Thu Apr 10 21:22:54 2014
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * cpu.c: CPU capabilities for libavcodec
+ *****************************************************************************
+ * Copyright (C) 1999-2012 the VideoLAN team
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_cpu.h>
+
+#define HAVE_MMX 1
+#ifdef HAVE_LIBAVCODEC_AVCODEC_H
+# include <libavcodec/avcodec.h>
+#else
+# include <avcodec.h>
+#endif
+#include "avcodec.h"
+
+/**
+ * Maps CPU capabilities computed by VLC to libav DSP mask.
+ */
+unsigned GetVlcDspMask( void )
+{
+    unsigned mask = 0;
+
+#if defined (__i386__) || defined (__x86_64__)
+    unsigned i_cpu = vlc_CPU();
+    if( !(i_cpu & CPU_CAPABILITY_MMX) )
+        mask |= AV_CPU_FLAG_MMX;
+    if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
+        mask |= AV_CPU_FLAG_MMX2;
+    if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
+        mask |= AV_CPU_FLAG_3DNOW;
+    if( !(i_cpu & CPU_CAPABILITY_SSE) )
+        mask |= AV_CPU_FLAG_SSE;
+    if( !(i_cpu & CPU_CAPABILITY_SSE2) )
+        mask |= AV_CPU_FLAG_SSE2;
+# ifdef AV_CPU_FLAG_SSE3
+    if( !(i_cpu & CPU_CAPABILITY_SSE3) )
+        mask |= AV_CPU_FLAG_SSE3;
+# endif
+# ifdef AV_CPU_FLAG_SSSE3
+    if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
+        mask |= AV_CPU_FLAG_SSSE3;
+# endif
+# ifdef AV_CPU_FLAG_SSE4
+    if( !(i_cpu & CPU_CAPABILITY_SSE4_1) )
+        mask |= AV_CPU_FLAG_SSE4;
+# endif
+# ifdef AV_CPU_FLAG_SSE42
+    if( !(i_cpu & CPU_CAPABILITY_SSE4_2) )
+        mask |= AV_CPU_FLAG_SSE42;
+# endif
+    // TODO: AVX
+#endif
+
+#if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
+    unsigned i_cpu = vlc_CPU();
+    if( !(i_cpu & CPU_CAPABILITY_ALTIVEC) )
+        mask |= AV_CPU_FLAG_ALTIVEC;
+#endif
+
+    return mask;
+}
