mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
Added CPU detection.
Original commit message from CVS: Added CPU detection. Added SSE optimisation to mpeg_play Modified the mpeg2 decoder and gstidct to use cpu detection. Cleanups in the mpeg1 and mpeg2 decoders.
This commit is contained in:
parent
2fa9336ace
commit
8d2a4dfbec
7 changed files with 140 additions and 4 deletions
|
@ -15,6 +15,8 @@ libgst_la_SOURCES = \
|
||||||
gstbuffer.c \
|
gstbuffer.c \
|
||||||
gstbufferpool.c \
|
gstbufferpool.c \
|
||||||
gstclock.c \
|
gstclock.c \
|
||||||
|
gstcpu.c \
|
||||||
|
gstcpuid_i386.s \
|
||||||
gstelement.c \
|
gstelement.c \
|
||||||
gstelementfactory.c \
|
gstelementfactory.c \
|
||||||
gstbin.c \
|
gstbin.c \
|
||||||
|
@ -42,6 +44,7 @@ libgstinclude_HEADERS = \
|
||||||
gstbuffer.h \
|
gstbuffer.h \
|
||||||
gstbufferpool.h \
|
gstbufferpool.h \
|
||||||
gstclock.h \
|
gstclock.h \
|
||||||
|
gstcpu.h \
|
||||||
gstelement.h \
|
gstelement.h \
|
||||||
gstbin.h \
|
gstbin.h \
|
||||||
gstpipeline.h \
|
gstpipeline.h \
|
||||||
|
|
|
@ -36,6 +36,7 @@ void gst_init(int *argc,char **argv[]) {
|
||||||
|
|
||||||
gtk_init(argc,argv);
|
gtk_init(argc,argv);
|
||||||
|
|
||||||
|
_gst_cpu_initialize();
|
||||||
_gst_type_initialize();
|
_gst_type_initialize();
|
||||||
_gst_plugin_initialize();
|
_gst_plugin_initialize();
|
||||||
_gst_buffer_initialize();
|
_gst_buffer_initialize();
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
#include <gst/gstobject.h>
|
#include <gst/gstobject.h>
|
||||||
#include <gst/gstpad.h>
|
#include <gst/gstpad.h>
|
||||||
#include <gst/gstbuffer.h>
|
#include <gst/gstbuffer.h>
|
||||||
|
#include <gst/gstcpu.h>
|
||||||
#include <gst/gstelement.h>
|
#include <gst/gstelement.h>
|
||||||
|
|
||||||
#include <gst/gstbin.h>
|
#include <gst/gstbin.h>
|
||||||
#include <gst/gstpipeline.h>
|
#include <gst/gstpipeline.h>
|
||||||
#include <gst/gstthread.h>
|
#include <gst/gstthread.h>
|
||||||
|
|
49
gst/gstcpu.c
Normal file
49
gst/gstcpu.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/* Gnome-Streamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gstcpu.h"
|
||||||
|
|
||||||
|
static guint32 _gst_cpu_flags;
|
||||||
|
|
||||||
|
#ifdef __i386__
|
||||||
|
void gst_cpuid_i386(int,long *,long *,long *,long *);
|
||||||
|
#define gst_cpuid gst_cpuid_i386
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define gst_cpuid(o,a,b,c,d)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void _gst_cpu_initialize(void)
|
||||||
|
{
|
||||||
|
long eax=0, ebx=0, ecx=0, edx=0;
|
||||||
|
|
||||||
|
gst_cpuid(1, &eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
if (edx & (1<<23)) _gst_cpu_flags |= GST_CPU_FLAG_MMX;
|
||||||
|
if (edx & (1<<25)) _gst_cpu_flags |= GST_CPU_FLAG_SSE;
|
||||||
|
|
||||||
|
g_print("CPU features (%08x)\n", _gst_cpu_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
guint32 gst_cpu_get_flags(void)
|
||||||
|
{
|
||||||
|
return _gst_cpu_flags;
|
||||||
|
}
|
33
gst/gstcpu.h
Normal file
33
gst/gstcpu.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* Gnome-Streamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __GST_CPU_H__
|
||||||
|
#define __GST_CPU_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#define GST_CPU_FLAG_MMX (1 << 0)
|
||||||
|
#define GST_CPU_FLAG_SSE (1 << 1)
|
||||||
|
|
||||||
|
void _gst_cpu_initialize();
|
||||||
|
|
||||||
|
guint32 gst_cpu_get_flags();
|
||||||
|
|
||||||
|
#endif /* __GST_CPU_H__ */
|
45
gst/gstcpuid_i386.s
Normal file
45
gst/gstcpuid_i386.s
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
.text
|
||||||
|
.globl gst_cpuid_i386
|
||||||
|
.type gst_cpuid_i386,@function
|
||||||
|
gst_cpuid_i386:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %edi
|
||||||
|
pushl %ebx
|
||||||
|
pushl %ecx
|
||||||
|
pushl %edx
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
cpuid
|
||||||
|
movl 12(%ebp),%edi
|
||||||
|
test %edi,%edi
|
||||||
|
jz L1
|
||||||
|
movl %eax,(%edi)
|
||||||
|
L1: movl 16(%ebp),%edi
|
||||||
|
test %edi,%edi
|
||||||
|
jz L2
|
||||||
|
movl %ebx,(%edi)
|
||||||
|
L2: movl 20(%ebp),%edi
|
||||||
|
test %edi,%edi
|
||||||
|
jz L3
|
||||||
|
movl %ecx,(%edi)
|
||||||
|
L3: movl 24(%ebp),%edi
|
||||||
|
test %edi,%edi
|
||||||
|
jz L4
|
||||||
|
movl %edx,(%edi)
|
||||||
|
L4: popl %edx
|
||||||
|
popl %ecx
|
||||||
|
popl %ebx
|
||||||
|
popl %edi
|
||||||
|
movl %ebp,%esp
|
||||||
|
popl %ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
/ doesn't work in user mode (MSRs are privileged)
|
||||||
|
.globl siddisable
|
||||||
|
siddisable:
|
||||||
|
movl 0x119,%ecx
|
||||||
|
rdmsr
|
||||||
|
orl 0x200000,%eax
|
||||||
|
wrmsr
|
||||||
|
ret
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <gst/gstcpu.h>
|
||||||
#include "gstidct.h"
|
#include "gstidct.h"
|
||||||
#include "dct.h"
|
#include "dct.h"
|
||||||
|
|
||||||
|
@ -33,10 +34,14 @@ GstIDCT *gst_idct_new(GstIDCTMethod method)
|
||||||
|
|
||||||
if (method == GST_IDCT_DEFAULT) {
|
if (method == GST_IDCT_DEFAULT) {
|
||||||
#ifdef HAVE_LIBMMX
|
#ifdef HAVE_LIBMMX
|
||||||
method = GST_IDCT_MMX32;
|
if (gst_cpu_get_flags() & GST_CPU_FLAG_MMX) {
|
||||||
#else
|
method = GST_IDCT_MMX;
|
||||||
method = GST_IDCT_FAST_INT;
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
method = GST_IDCT_FAST_INT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new->convert_sparse = gst_idct_int_sparse_idct;
|
new->convert_sparse = gst_idct_int_sparse_idct;
|
||||||
|
|
Loading…
Reference in a new issue