[gst-cvs] gst-ffmpeg: Use orc instead of liboil for CPU feature detection

Sebastian Dröge slomo at kemper.freedesktop.org
Mon Jun 14 05:39:06 PDT 2010


Module: gst-ffmpeg
Branch: master
Commit: 899d2f0cecddf458b194b7492b4561d3ac296021
URL:    http://cgit.freedesktop.org/gstreamer/gst-ffmpeg/commit/?id=899d2f0cecddf458b194b7492b4561d3ac296021

Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date:   Mon Jun 14 14:38:44 2010 +0200

Use orc instead of liboil for CPU feature detection

---

 configure.ac                    |   18 ++++--------------
 ext/libpostproc/Makefile.am     |    4 ++--
 ext/libpostproc/gstpostproc.c   |   30 +++++++++++++++++++++---------
 ext/libswscale/Makefile.am      |    4 ++--
 ext/libswscale/gstffmpegscale.c |   29 ++++++++++++++++++++---------
 5 files changed, 49 insertions(+), 36 deletions(-)

diff --git a/configure.ac b/configure.ac
index dfb1793..79f5d04 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,8 +46,7 @@ AM_PROG_LIBTOOL
 
 dnl *** required versions of GStreamer stuff ***
 GST_REQ=0.10.22
-LIBOIL_MAJORMINOR=0.3
-LIBOIL_REQ=0.3.6
+ORC_REQ=0.4.5
 
 dnl *** autotools stuff ****
 
@@ -125,18 +124,8 @@ AM_CONDITIONAL(HAVE_GST_CHECK, test "x$HAVE_GST_CHECK" = "xyes")
 AC_MSG_NOTICE(Using GStreamer Core Plugins in $GST_PLUGINS_DIR)
 AC_MSG_NOTICE(Using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR)
 
-dnl liboil is required for cpu detection for libpostproc
-dnl FIXME : In theory we should be able to compile libpostproc with cpudetect
-dnl capabilities, which would enable us to get rid of this
-PKG_CHECK_MODULES(LIBOIL, liboil-$LIBOIL_MAJORMINOR >= $LIBOIL_REQ, HAVE_LIBOIL=yes, HAVE_LIBOIL=no)
-if test "x$HAVE_LIBOIL" != "xyes"
-then
-  AC_MSG_ERROR([liboil-$LIBOIL_REQ or later is required])
-  AC_ERROR
-fi
-
-AC_SUBST(LIBOIL_CFLAGS)
-AC_SUBST(LIBOIL_LIBS)
+dnl orc is required for cpu detection for libpostproc
+ORC_CHECK([$ORC_REQ])
 
 dnl *** set variables based on configure arguments ***
 
@@ -423,3 +412,4 @@ tests/files/Makefile
 )
 AC_OUTPUT
 
+ORC_OUTPUT
diff --git a/ext/libpostproc/Makefile.am b/ext/libpostproc/Makefile.am
index 80c31c2..1c4e7d8 100644
--- a/ext/libpostproc/Makefile.am
+++ b/ext/libpostproc/Makefile.am
@@ -2,11 +2,11 @@ plugin_LTLIBRARIES = libgstpostproc.la
 
 libgstpostproc_la_SOURCES = gstpostproc.c
 
-libgstpostproc_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(LIBOIL_CFLAGS) \
+libgstpostproc_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS) \
 	$(POSTPROC_CFLAGS)
 libgstpostproc_la_LIBADD = -lgstvideo- at GST_MAJORMINOR@ \
 	$(POSTPROC_LIBS) \
-	$(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(LIBOIL_LIBS)
+	$(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(ORC_LIBS)
 
 libgstpostproc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(DARWIN_LDFLAGS)
 libgstpostproc_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/ext/libpostproc/gstpostproc.c b/ext/libpostproc/gstpostproc.c
index 20694f5..903ae04 100644
--- a/ext/libpostproc/gstpostproc.c
+++ b/ext/libpostproc/gstpostproc.c
@@ -24,9 +24,10 @@
 #include <gst/gst.h>
 #include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
-#include <liboil/liboil.h>
-#include <liboil/liboilcpu.h>
-#include <liboil/liboilfunction.h>
+
+#if HAVE_ORC
+#include <orc/orc.h>
+#endif
 
 #ifdef HAVE_FFMPEG_UNINSTALLED
 #include <avcodec.h>
@@ -280,7 +281,8 @@ gst_ffmpeg_log_callback (void *ptr, int level, const char *fmt, va_list vl)
 static void
 change_context (GstPostProc * postproc, gint width, gint height)
 {
-  guint flags;
+  guint mmx_flags;
+  guint altivec_flags;
   gint ppflags;
 
   GST_DEBUG_OBJECT (postproc, "change_context, width:%d, height:%d",
@@ -289,11 +291,21 @@ change_context (GstPostProc * postproc, gint width, gint height)
   if ((width != postproc->width) && (height != postproc->height)) {
     if (postproc->context)
       pp_free_context (postproc->context);
-    flags = oil_cpu_get_flags ();
-    ppflags = (flags & OIL_IMPL_FLAG_MMX ? PP_CPU_CAPS_MMX : 0)
-        | (flags & OIL_IMPL_FLAG_MMXEXT ? PP_CPU_CAPS_MMX2 : 0)
-        | (flags & OIL_IMPL_FLAG_3DNOW ? PP_CPU_CAPS_3DNOW : 0)
-        | (flags & OIL_IMPL_FLAG_ALTIVEC ? PP_CPU_CAPS_ALTIVEC : 0);
+
+#ifdef HAVE_ORC
+    mmx_flags = orc_target_get_default_flags (orc_target_get_by_name ("mmx"));
+    altivec_flags =
+        orc_target_get_default_flags (orc_target_get_by_name ("altivec"));
+#else
+    mmx_flags = 0;
+    altivec_flags = 0;
+#endif
+
+    ppflags = (mmx_flags & ORC_TARGET_MMX_MMX ? PP_CPU_CAPS_MMX : 0)
+        | (mmx_flags & ORC_TARGET_MMX_MMXEXT ? PP_CPU_CAPS_MMX2 : 0)
+        | (mmx_flags & ORC_TARGET_MMX_3DNOW ? PP_CPU_CAPS_3DNOW : 0)
+        | (altivec_flags & ORC_TARGET_ALTIVEC_ALTIVEC ? PP_CPU_CAPS_ALTIVEC :
+        0);
     postproc->context = pp_get_context (width, height, PP_FORMAT_420 | ppflags);
     postproc->width = width;
     postproc->height = height;
diff --git a/ext/libswscale/Makefile.am b/ext/libswscale/Makefile.am
index d7204cc..9363a33 100644
--- a/ext/libswscale/Makefile.am
+++ b/ext/libswscale/Makefile.am
@@ -4,10 +4,10 @@ libgstffmpegscale_la_SOURCES = gstffmpegscale.c
 
 libgstffmpegscale_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
 	$(GST_PLUGINS_BASE_CFLAGS) \
-	 $(LIBOIL_CFLAGS) $(SWSCALE_CFLAGS)
+	$(ORC_CFLAGS) $(SWSCALE_CFLAGS)
 libgstffmpegscale_la_LIBADD = $(SWSCALE_LIBS) \
 	$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
-	$(GST_BASE_LIBS) $(LIBOIL_LIBS) $(LIBM) -lz
+	$(GST_BASE_LIBS) $(ORC_LIBS) $(LIBM) -lz
 libgstffmpegscale_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(DARWIN_LDFLAGS)
 libgstffmpegscale_la_LIBTOOLFLAGS = --tag=disable-static
 
diff --git a/ext/libswscale/gstffmpegscale.c b/ext/libswscale/gstffmpegscale.c
index 6521de8..0a52e00 100644
--- a/ext/libswscale/gstffmpegscale.c
+++ b/ext/libswscale/gstffmpegscale.c
@@ -32,9 +32,10 @@
 #include <gst/gst.h>
 #include <gst/base/gstbasetransform.h>
 #include <gst/video/video.h>
-#include <liboil/liboil.h>
-#include <liboil/liboilcpu.h>
-#include <liboil/liboilfunction.h>
+
+#if HAVE_ORC
+#include <orc/orc.h>
+#endif
 
 #include <string.h>
 
@@ -595,7 +596,8 @@ gst_ffmpegscale_set_caps (GstBaseTransform * trans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstFFMpegScale *scale = GST_FFMPEGSCALE (trans);
-  gint flags, swsflags;
+  guint mmx_flags, altivec_flags;
+  gint swsflags;
   GstVideoFormat in_format, out_format;
   gboolean ok;
 
@@ -629,11 +631,20 @@ gst_ffmpegscale_set_caps (GstBaseTransform * trans, GstCaps * incaps,
   gst_ffmpegscale_fill_info (scale, out_format, scale->out_width,
       scale->out_height, scale->out_stride, scale->out_offset);
 
-  flags = oil_cpu_get_flags ();
-  swsflags = (flags & OIL_IMPL_FLAG_MMX ? SWS_CPU_CAPS_MMX : 0)
-      | (flags & OIL_IMPL_FLAG_MMXEXT ? SWS_CPU_CAPS_MMX2 : 0)
-      | (flags & OIL_IMPL_FLAG_3DNOW ? SWS_CPU_CAPS_3DNOW : 0)
-      | (flags & OIL_IMPL_FLAG_ALTIVEC ? SWS_CPU_CAPS_ALTIVEC : 0);
+#ifdef HAVE_ORC
+  mmx_flags = orc_target_get_default_flags (orc_target_get_by_name ("mmx"));
+  altivec_flags =
+      orc_target_get_default_flags (orc_target_get_by_name ("altivec"));
+#else
+  mmx_flags = 0;
+  altivec_flags = 0;
+#endif
+
+  swsflags = (mmx_flags & ORC_TARGET_MMX_MMX ? SWS_CPU_CAPS_MMX : 0)
+      | (mmx_flags & ORC_TARGET_MMX_MMXEXT ? SWS_CPU_CAPS_MMX2 : 0)
+      | (mmx_flags & ORC_TARGET_MMX_3DNOW ? SWS_CPU_CAPS_3DNOW : 0)
+      | (altivec_flags & ORC_TARGET_ALTIVEC_ALTIVEC ? SWS_CPU_CAPS_ALTIVEC : 0);
+
   scale->ctx = sws_getContext (scale->in_width, scale->in_height,
       scale->in_pixfmt, scale->out_width, scale->out_height, scale->out_pixfmt,
       swsflags | gst_ffmpegscale_method_flags[scale->method], NULL, NULL, NULL);





More information about the Gstreamer-commits mailing list