Dynamic evaluation of the processor flags passed to libpostproc.
authorCrystalP <CrystalP@xbmc.org>
Sun, 31 Jul 2011 18:05:55 +0000 (14:05 -0400)
committerCrystalP <CrystalP@xbmc.org>
Sun, 31 Jul 2011 18:06:13 +0000 (14:06 -0400)
Similar to the work done for swscale. Benefits 3DNow and Altivec users, as the optimizations were not turned on for them.

lib/DllPostProc.h
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp

index cb46300..b09a3f6 100644 (file)
@@ -55,6 +55,25 @@ extern "C" {
 #endif
 }
 
+#include "utils/CPUInfo.h"
+
+inline int PPCPUFlags()
+{
+  unsigned int cpuFeatures = g_cpuInfo.GetCPUFeatures();
+  int flags = 0;
+
+  if (cpuFeatures & CPU_FEATURE_MMX)
+    flags |= PP_CPU_CAPS_MMX;
+  if (cpuFeatures & CPU_FEATURE_MMX2)
+    flags |= PP_CPU_CAPS_MMX2;
+  if (cpuFeatures & CPU_FEATURE_3DNOW)
+    flags |= PP_CPU_CAPS_3DNOW;
+  if (cpuFeatures & CPU_FEATURE_ALTIVEC)
+    flags |= PP_CPU_CAPS_ALTIVEC;
+
+  return flags;
+}
+
 class DllPostProcInterface
 {
 public:
index a118c59..a111e3c 100644 (file)
@@ -78,7 +78,7 @@ bool CDVDVideoPPFFmpeg::CheckInit(int iWidth, int iHeight)
       Dispose();
     }
 
-    m_pContext = m_dll.pp_get_context(m_pSource->iWidth, m_pSource->iHeight, PP_CPU_CAPS_MMX | PP_CPU_CAPS_MMX2 | PP_FORMAT_420);
+    m_pContext = m_dll.pp_get_context(m_pSource->iWidth, m_pSource->iHeight, PPCPUFlags() | PP_FORMAT_420);
 
     m_iInitWidth = m_pSource->iWidth;
     m_iInitHeight = m_pSource->iHeight;