static gboolean _gst_use_threads = TRUE;
+static gboolean _gst_enable_cpu_opt = TRUE;
+
static gboolean gst_initialized = FALSE;
/* this will be set in popt callbacks when a problem has been encountered */
static gboolean _gst_initialization_failure = FALSE;
ARG_DEBUG_MASK,
ARG_MASK,
ARG_MASK_HELP,
+ ARG_DISABLE_CPU_OPT,
ARG_PLUGIN_SPEW,
ARG_PLUGIN_PATH,
ARG_PLUGIN_LOAD,
{"gst-debug-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_MASK, "debugging bitmask", "MASK"},
{"gst-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_MASK, "bitmask for both info and debugging", "MASK"},
{"gst-mask-help", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_MASK_HELP, "how to set the level of diagnostic output (-mask values)", NULL},
+ {"gst-disable-cpu-opt",NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DISABLE_CPU_OPT,"Disable accelerated CPU instructions", NULL},
{"gst-plugin-spew", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_SPEW, "enable verbose plugin loading diagnostics", NULL},
{"gst-plugin-path", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_PATH, "'" G_SEARCHPATH_SEPARATOR_S "'--separated path list for loading plugins", "PATHS"},
{"gst-plugin-load", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_LOAD, "comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH", "PLUGINS"},
/* register core plugins */
_gst_plugin_register_static (&plugin_desc);
- _gst_cpu_initialize ();
+ _gst_cpu_initialize (_gst_enable_cpu_opt);
_gst_props_initialize ();
_gst_caps_initialize ();
_gst_plugin_initialize ();
case ARG_MASK_HELP:
gst_mask_help ();
exit (0);
+ case ARG_DISABLE_CPU_OPT:
+ _gst_enable_cpu_opt = FALSE;
+ break;
case ARG_PLUGIN_SPEW:
break;
case ARG_PLUGIN_PATH:
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
+ * 2003 Colin Walters <walters@verbum.org>
*
* gstcpu.c: CPU detection and architecture-specific routines
*
#include "gst_private.h"
#include "gstcpu.h"
-static guint32 _gst_cpu_flags;
+static guint32 _gst_cpu_flags = 0;
#ifdef HAVE_CPU_I386
+#define _gst_cpu_initialize_arch _gst_cpu_initialize_i386
void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *, unsigned long *);
-#define gst_cpuid gst_cpuid_i386
#else
-#define gst_cpuid(o,a,b,c,d) (void)(a);(void)(b);(void)(c);
+#define _gst_cpu_initialize_arch _gst_cpu_initialize_none
#endif
-static gchar *
-stringcat (gchar * a, gchar * b)
-{
- gchar *c;
+gboolean _gst_cpu_initialize_i386 (gulong *flags, GString *featurelist);
- if (a) {
- c = g_strconcat (a, b, NULL);
- g_free (a);
- }
- else {
- c = g_strdup (b);
- }
- return c;
+void
+_gst_cpu_initialize (gboolean opt)
+{
+ GString *featurelist = g_string_new ("");
+ gulong flags = 0;
+
+ if (opt) {
+ if (!_gst_cpu_initialize_arch (&flags, featurelist))
+ g_string_append (featurelist, "NONE");
+ } else
+ g_string_append (featurelist, "(DISABLED)");
+
+ GST_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", flags, featurelist->str);
+ g_string_free (featurelist, TRUE);
}
+gboolean
+_gst_cpu_initialize_none (gulong *flags, GString *featurelist)
+{
+ return FALSE;
+}
-void
-_gst_cpu_initialize (void)
+gboolean
+_gst_cpu_initialize_i386 (gulong *flags, GString *featurelist)
{
- gchar *featurelist = NULL;
gboolean AMD;
-
gulong eax = 0, ebx = 0, ecx = 0, edx = 0;
- gst_cpuid (0, &eax, &ebx, &ecx, &edx);
+ gst_cpuid_i386 (0, &eax, &ebx, &ecx, &edx);
AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
- gst_cpuid (1, &eax, &ebx, &ecx, &edx);
+ gst_cpuid_i386 (1, &eax, &ebx, &ecx, &edx);
if (edx & (1 << 23)) {
_gst_cpu_flags |= GST_CPU_FLAG_MMX;
- featurelist = stringcat (featurelist, "MMX ");
+ g_string_append (featurelist, "MMX ");
if (edx & (1 << 25)) {
_gst_cpu_flags |= GST_CPU_FLAG_SSE;
_gst_cpu_flags |= GST_CPU_FLAG_MMXEXT;
- featurelist = stringcat (featurelist, "SSE ");
+ g_string_append (featurelist, "SSE ");
}
- gst_cpuid (0x80000000, &eax, &ebx, &ecx, &edx);
+ gst_cpuid_i386 (0x80000000, &eax, &ebx, &ecx, &edx);
if (eax >= 0x80000001) {
- gst_cpuid (0x80000001, &eax, &ebx, &ecx, &edx);
+ gst_cpuid_i386 (0x80000001, &eax, &ebx, &ecx, &edx);
if (edx & (1 << 31)) {
_gst_cpu_flags |= GST_CPU_FLAG_3DNOW;
- featurelist = stringcat (featurelist, "3DNOW ");
+ g_string_append (featurelist, "3DNOW ");
}
if (AMD && (edx & (1 << 22))) {
_gst_cpu_flags |= GST_CPU_FLAG_MMXEXT;
- featurelist = stringcat (featurelist, "MMXEXT ");
+ g_string_append (featurelist, "MMXEXT ");
}
}
}
-
- if (!_gst_cpu_flags) {
- featurelist = stringcat (featurelist, "NONE");
- }
-
- GST_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", edx, featurelist);
- g_free (featurelist);
+ *flags = eax;
+ if (_gst_cpu_flags)
+ return TRUE;
+ return FALSE;
}
GstCPUFlags