Use orc instead of liboil for CPU feature detection

This commit is contained in:
Sebastian Dröge 2010-06-14 14:38:44 +02:00
parent 24ec624c77
commit 899d2f0cec
5 changed files with 49 additions and 36 deletions

View file

@ -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

View file

@ -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-@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

View file

@ -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;

View file

@ -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

View file

@ -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);