diff options
-rw-r--r-- | HISTORY | 13 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | dxr3.c | 5 | ||||
-rw-r--r-- | dxr3colormanager.c | 1 | ||||
-rw-r--r-- | dxr3cpu.c | 155 | ||||
-rw-r--r-- | dxr3cpu.h | 136 | ||||
-rw-r--r-- | dxr3memcpy.c | 455 | ||||
-rw-r--r-- | dxr3memcpy.h | 99 | ||||
-rw-r--r-- | dxr3syncbuffer.c | 3 |
9 files changed, 6 insertions, 866 deletions
@@ -237,10 +237,6 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 - rewrote i18n support, improved Finnish translation and other bits (Christian Gmeiner, Ville Skyttä) - fixed void cDxr3Interface::SetAudioDigitalPCM() (Stephan Skrodzki) -- dxr3memcpy.c/h: fix to support older compilers like gcc-2.95 - (Christian Gmeiner, Marco Schlüßler) -- dxr3memcpy.c/h: should now compile on alpha and powerpc - (bug #1000647, Christian Gmeiner, Paavo Hartikainen) - added many comments into source (Christian Gmeiner) - using doxygen for docs (Christian Gmeiner) - made path to microcode configurable in Makefile (Sascha Volkenandt) @@ -248,9 +244,6 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 You may also want to search and remove files called "dxr3plugin.log" as the old plugin wrote them into the current working directory. - better default directories in Makefile (Christian Gmeiner, vdr-wiki.de folks) -- extended cDxr3MemcpyBench::Rdtsc(uint32_t config_flags): support for - non-x86 archs, support for cpu's, which dont support rdtsc timing - (Christian Gmeiner) - use std:: instead of namespace std (bug #1044069, Christian Gmeiner, Ville Skyttä) - removed extra log commands in dxr3outputthread.c (Christian Gmeiner) @@ -267,8 +260,6 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 - fixed audio and video thread deletion in demux device destructor (#1112674, Ville Skyttä) - made "all" the default target in Makefile (Ville Skyttä) -- assume SSE support implies MMXEXT support, this enables optimized - memcpy routines on more systems (Ville Skyttä) - avoid hang in pause mode with VDR >= 1.3.18 (Luca Olivetti) - avoid high CPU usage in pause mode (Luca Olivetti, Klaus Schmidinger) - improved GetSTC(): fixes DVB subtitles sync problems (Mikko Tuumanen) @@ -276,8 +267,6 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 refreshed too often, see FLUSHRATE in Makefile (Luca Olivetti, Ville Skyttä) - borrow better OSD scaling routines from the Xine plugin (Luca Olivetti) - improve original OSD scaler for small resolutions (#1014339, Luca Olivetti) -- fix PIC and AMD64 problems in the cpuid code, kudos to ffmpeg - (Ville Skyttä, Jon Burgess) - eliminate some compiler warnings (Ville Skyttä) - fix OSD going pink after returning from the MPlayer plugin; while at it, remove dxr3palettemanager.* and use VDR's cPalette @@ -294,3 +283,5 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 - fix crash at exit (Marco Schlüßler) - add support for mandatory subtitles (Marco Schlüßler) - avoid crashing with some corrupted streams (Jon Burgess) +- remove optimized memcpy routines and related stuff, just use the glibc + one (Ville Skyttä) @@ -1,7 +1,7 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.1.2.15 2005/04/19 17:28:22 scop Exp $ +# $Id: Makefile,v 1.1.2.16 2005/05/17 20:26:00 scop Exp $ # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. @@ -69,8 +69,7 @@ DEFINES += -DFLUSHRATE=40 OBJS = $(PLUGIN).o dxr3multichannelaudio.o dxr3sysclock.o dxr3colormanager.o dxr3syncbuffer.o dxr3audiodecoder.o \ dxr3blackframe.o dxr3nextpts.o dxr3pesframe.o dxr3demuxdevice.o dxr3configdata.o \ dxr3log.o dxr3ffmpeg.o dxr3interface_spu_encoder.o dxr3i18n.o \ -dxr3interface.o dxr3device.o dxr3outputthread.o dxr3osd.o dxr3osd_subpicture.o dxr3spudecoder.o \ -dxr3cpu.o dxr3memcpy.o +dxr3interface.o dxr3device.o dxr3outputthread.o dxr3osd.o dxr3osd_subpicture.o dxr3spudecoder.o ### Default target: @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: dxr3.c,v 1.1.2.10 2005/04/19 18:19:36 scop Exp $ + * $Id: dxr3.c,v 1.1.2.11 2005/05/17 20:26:00 scop Exp $ * */ @@ -19,8 +19,6 @@ static const char *VERSION = "0.2.3-cvs"; static const char *DESCRIPTION = "Hardware MPEG decoder"; static const char *MAINMENUENTRY = "DXR3"; -#include "dxr3cpu.h" - // ================================== // 'message-handler' for the main screen eOSState cDxr3OsdItem::ProcessKey(eKeys Key) @@ -170,7 +168,6 @@ bool cPluginDxr3::Initialize() { RegisterI18n(Phrases); - new cDxr3CPU(); cDxr3Device::InstanceP(); return true; diff --git a/dxr3colormanager.c b/dxr3colormanager.c index 56f38ea..f8b4002 100644 --- a/dxr3colormanager.c +++ b/dxr3colormanager.c @@ -52,7 +52,6 @@ #include "dxr3colormanager.h" #include "dxr3log.h" -#include "dxr3memcpy.h" #include <stdio.h> #include <string.h> diff --git a/dxr3cpu.c b/dxr3cpu.c deleted file mode 100644 index a937b25..0000000 --- a/dxr3cpu.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -* dxr3cpu.c -* -* Copyright (C) 2004 Christian Gmeiner -* -* Taken from Nesseia-Renderengine Copyright (C) 2003-2004 Christian Gmeiner -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public License -* as published by the Free Software Foundation; either version 2.1 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#include "dxr3cpu.h" -#include "dxr3log.h" -#include "dxr3memcpy.h" - -// ================================== -//! constructor -cDxr3CPU::cDxr3CPU() -{ - unsigned long eax, ebx, edx, unused; - - // readout the vendor - Cpuid(0, eax, ebx, unused, edx); - - // set Vendor to "" - memset(m_Info.Vendor, 0, 16); - - // connect the single register values to the vendor string - // maybe there is an better solution - i will google :) - *(unsigned long *)(m_Info.Vendor) = ebx; - *(unsigned long *)(m_Info.Vendor + 4) = edx; - *(unsigned long *)(m_Info.Vendor + 8) = unused; - - // check the features - // could we get the needed infos? - if (Cpuid(1, eax, ebx, unused, edx)) - { - m_Info.MMX = ((edx & 1<<23) != 0); - m_Info.SSE = ((edx & 1<<25) != 0); - m_Info.SSE2 = ((edx & 1<<26) != 0); - m_Info.RDTSC = ((edx & 1<<4) != 0); /*0x10*/ - m_Info.HT = ((edx & 1<<28) !=0 ); // need additional checks? - - // 3DNow is a litle bit harder to read out - // We read the ext. CPUID level 0x80000000 - if (Cpuid(0x80000000, eax, ebx, unused, edx)) - { - // now in eax there is the max. supported extended CPUID level - // we check if theres an extended CPUID level support - if (eax >= 0x80000001) - { - // If we can access the extended CPUID level 0x80000001 we - // get the edx register - if (Cpuid(0x80000001, eax, ebx, unused, edx)) - { - // Now we can mask some AMD specific cpu extensions - // 22 ... Extended MMX_MultimediaExtensions - m_Info.MMXEXT = ((edx & 1<<22) != 0); - m_Info.AMD64Bit = ((edx & 1<<29) != 0); - // 30 ... Extended 3DNOW_InstructionExtensions - m_Info.Now = ((edx & 1<<31) != 0); - } - } - } - } - - // MPlayer, Xine-lib, Transcode: SSE implies MMXEXT - m_Info.MMXEXT = m_Info.MMXEXT || m_Info.SSE; - - // fill cabs - if (m_Info.MMX) - { - m_Info.caps |= CC_MMX; - } - - if (m_Info.MMXEXT) - { - m_Info.caps |= CC_MMXEXT; - } - - if (m_Info.SSE) - { - m_Info.caps |= CC_SSE; - } - - if (m_Info.Now) - { - m_Info.caps |= CC_3DNOW; - } - - // print some infos about cpu - cLog::Instance() << "cpu vendor: " << m_Info.Vendor << "\n"; - cLog::Instance() << "cpu extensions:\n"; - cLog::Instance() << "mmx: " << m_Info.MMX << "\n"; - cLog::Instance() << "mmx-ext: " << m_Info.MMXEXT << "\n"; - cLog::Instance() << "sse: " << m_Info.SSE << "\n"; - cLog::Instance() << "sse2: " << m_Info.SSE2 << "\n"; - cLog::Instance() << "3dnow: " << m_Info.Now << "\n"; - - // now we select the best memcpy mehtode - cDxr3MemcpyBench Benchmark(m_Info.caps); -} - -// ================================== -//! does the cpu support cpuid instructions -bool cDxr3CPU::CheckCPUIDPresence() -{ - // todo - return true; -} - -// ================================== -//! cpuid function -bool cDxr3CPU::Cpuid(unsigned long function, unsigned long& out_eax, - unsigned long& out_ebx, unsigned long& out_ecx, - unsigned long& out_edx) -{ - // This works with PIC/non-PIC, from ffmpeg (libavcodec/i386/cputest.c) - -#ifdef __x86_64__ -# define REG_b "rbx" -# define REG_S "rsi" -#else -# define REG_b "ebx" -# define REG_S "esi" -#endif - - __asm __volatile \ - ("mov %%"REG_b", %%"REG_S"\n\t" \ - "cpuid\n\t" \ - "xchg %%"REG_b", %%"REG_S \ - : "=a" (out_eax), "=S" (out_ebx), \ - "=c" (out_ecx), "=d" (out_edx) \ - : "0" (function)); - return true; -} - -// Local variables: -// mode: c++ -// c-file-style: "stroustrup" -// c-file-offsets: ((inline-open . 0)) -// indent-tabs-mode: t -// End: diff --git a/dxr3cpu.h b/dxr3cpu.h deleted file mode 100644 index ee5fc63..0000000 --- a/dxr3cpu.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * dxr3cpu.h - * - * Copyright (C) 2004 Christian Gmeiner - * - * Taken (modifized) from Nesseia-Renderengine Copyright (C) 2003-2004 Christian Gmeiner - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _DXR3_CPU_H_ -#define _DXR3_CPU_H_ - -#include <inttypes.h> -#include "dxr3singleton.h" - -// ================================== -//! all possible cabs -enum Cpu_cabs -{ - CC_MMX = 0x80000000, ///< Value for mmx - CC_3DNOW = 0x40000000, ///< Value for 3dnow - CC_MMXEXT = 0x20000000, ///< Value for mmx ext - CC_SSE = 0x10000000, ///< Value for sse - CC_SSE2 = 0x08000000 ///< Value for sse2 -}; - -// ================================== -//! easy and fast access to all infos -struct CPUInformation -{ - CPUInformation() - { - AMD = false; - INTEL = false; - MMX = false; - MMXEXT = false; - SSE = false; - SSE2 = false; - Now = false; - RDTSC = false; - HT = false; - AMD64Bit = false; - } - - char Vendor[16]; ///< vendorname - - bool AMD; ///< is it an AMD CPU? - bool INTEL; ///< is it an Intel CPU? - bool MMX; ///< is MMX-Technology supported? - bool MMXEXT; ///< is Extended MMX supported? - bool SSE; ///< is SSE-Technology supported? - bool SSE2; ///< is SSE2-Technology supported? - bool Now; ///< is 3DNow-Technology supported? - bool RDTSC; ///< is RDTSC-Technology supported? - bool HT; ///< is HyperThreading supported? - bool AMD64Bit; ///< is it a 64 bit machine? - - uint32_t caps; ///< all features represanted as caps -}; - -// ================================== -//! Grab some infos about the cpu(s) -/*! - If you want to know what the cpu of the - target machine can do, this class is for you :) - It is used intern for the math and memcpy part. -*/ -class cDxr3CPU : public Singleton<cDxr3CPU> -{ -public: - cDxr3CPU(); - ~cDxr3CPU() {} - - bool HasMMXSupport() const - { - return m_Info.MMX; - } - bool HasSSESupport() const - { - return m_Info.SSE; - } - bool HasSSE2Support() const - { - return m_Info.SSE2; - } - bool Has3DNowSupport() const - { - return m_Info.Now; - } - bool HasRDTSCSupport() const - { - return m_Info.RDTSC; - } - bool HasHTSupport() const - { - return m_Info.HT; - } - - inline CPUInformation GetInfos() const - { - return m_Info; - } - -private: - bool CheckCPUIDPresence(); - - // main function to get cpu(s) features - bool Cpuid(unsigned long function, unsigned long& out_eax, - unsigned long& out_ebx, unsigned long& out_ecx, - unsigned long& out_edx); - - CPUInformation m_Info; -}; - -#endif /*_DXR3_CPU_H_*/ - -// Local variables: -// mode: c++ -// c-file-style: "stroustrup" -// c-file-offsets: ((inline-open . 0)) -// indent-tabs-mode: t -// End: diff --git a/dxr3memcpy.c b/dxr3memcpy.c deleted file mode 100644 index 19f7fda..0000000 --- a/dxr3memcpy.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * dxr3memcpy.c - * - * Copyright (C) 2004 Christian Gmeiner - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * - * Orgianal from xine: - * - * Copyright (C) 2001-2003 the xine project - * - * This file is part of xine, a free video player. - * - * These are the MMX/MMX2/SSE optimized versions of memcpy - * - * This code was adapted from Linux Kernel sources by Nick Kurshev to - * the mplayer program. (http://mplayer.sourceforge.net) - * - */ - -#include "dxr3log.h" -#include "dxr3cpu.h" -#include "dxr3memcpy.h" -#include <sys/times.h> -#include <limits.h> - - -// ================================== -//! our function pointer -void *(* dxr3_memcpy)(void *to, const void *from, size_t len); - -#if defined(__i386__) || defined(__x86_64__) -// ================================== -// for small memory blocks (<256 bytes) this version is faster -#define small_memcpy(to,from,n) { register unsigned long int dummy; __asm__ __volatile__("rep; movsb":"=&D"(to), "=&S"(from), "=&c"(dummy) :"0" (to), "1" (from),"2" (n) : "memory"); } -/* -// -- doesn't compile with 2.95 gcc -- -#define small_memcpy(to,from,n)\ -{\ -register unsigned long int dummy;\ -__asm__ __volatile__(\ - "rep; movsb"\ - :"=&D"(to), "=&S"(from), "=&c"(dummy)\ - :"0" (to), "1" (from),"2" (n)\ - : "memory");\ -} -*/ -// ================================== -//! linux kernel __memcpy (from: /include/asm/string.h) -static __inline__ void * __memcpy (void * to, const void * from, size_t n) -{ - int d0, d1, d2; - - if (n < 4) - { - small_memcpy(to, from, n); - } - else - __asm__ __volatile__( - "rep ; movsl\n\t" - "testb $2,%b4\n\t" - "je 1f\n\t" - "movsw\n" - "1:\ttestb $1,%b4\n\t" - "je 2f\n\t" - "movsb\n" - "2:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) - : "memory"); - - return (to); -} - -#define SSE_MMREG_SIZE 16 -#define MMX_MMREG_SIZE 8 - -#define MMX1_MIN_LEN 0x800 /* 2K blocks */ -#define MIN_LEN 0x40 /* 64-byte blocks */ - - -// ================================== -/* SSE note: i tried to move 128 bytes a time instead of 64 but it - didn't make any measureable difference. i'm using 64 for the sake of - simplicity. [MF] */ -static void * sse_memcpy(void * to, const void * from, size_t len) -{ - void *retval; - size_t i; - retval = to; - - /* PREFETCH has effect even for MOVSB instruction ;) */ - __asm__ __volatile__ ( - " prefetchnta (%0)\n" - " prefetchnta 32(%0)\n" - " prefetchnta 64(%0)\n" - " prefetchnta 96(%0)\n" - " prefetchnta 128(%0)\n" - " prefetchnta 160(%0)\n" - " prefetchnta 192(%0)\n" - " prefetchnta 224(%0)\n" - " prefetchnta 256(%0)\n" - " prefetchnta 288(%0)\n" - : : "r" (from) ); - - if (len >= MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)to) & (SSE_MMREG_SIZE - 1); - if (delta) - { - delta = SSE_MMREG_SIZE - delta; - len -= delta; - small_memcpy(to, from, delta); - } - i = len >> 6; /* len/64 */ - len&=63; - if (((unsigned long)from) & 15) /* if SRC is misaligned */ - { - for( ; i > 0; i--) - { - __asm__ __volatile__ ( - "prefetchnta 320(%0)\n" - "prefetchnta 352(%0)\n" - "movups (%0), %%xmm0\n" - "movups 16(%0), %%xmm1\n" - "movups 32(%0), %%xmm2\n" - "movups 48(%0), %%xmm3\n" - "movntps %%xmm0, (%1)\n" - "movntps %%xmm1, 16(%1)\n" - "movntps %%xmm2, 32(%1)\n" - "movntps %%xmm3, 48(%1)\n" - : : "r" (from), "r" (to) : "memory"); - from = ((const unsigned char *)from) + 64; - to = ((unsigned char *)to) + 64; - } - } - else - { - /* - Only if SRC is aligned on 16-byte boundary. - It allows to use movaps instead of movups, which required data - to be aligned or a general-protection exception (#GP) is generated. - */ - for( ; i > 0; i--) - { - __asm__ __volatile__ ( - "prefetchnta 320(%0)\n" - "prefetchnta 352(%0)\n" - "movaps (%0), %%xmm0\n" - "movaps 16(%0), %%xmm1\n" - "movaps 32(%0), %%xmm2\n" - "movaps 48(%0), %%xmm3\n" - "movntps %%xmm0, (%1)\n" - "movntps %%xmm1, 16(%1)\n" - "movntps %%xmm2, 32(%1)\n" - "movntps %%xmm3, 48(%1)\n" - : : "r" (from), "r" (to) : "memory"); - from = ((const unsigned char *)from) + 64; - to = ((unsigned char *)to) + 64; - } - } - /* since movntq is weakly-ordered, a "sfence" - * is needed to become ordered again. */ - __asm__ __volatile__ ("sfence": : :"memory"); - /* enables to use FPU */ - __asm__ __volatile__ ("emms": : :"memory"); - } - /* - * Now do the tail of the block - */ - if(len) __memcpy(to, from, len); - return retval; -} - -// ================================== -static void * mmx_memcpy(void * to, const void * from, size_t len) -{ - void *retval; - size_t i; - retval = to; - - if(len >= MMX1_MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)to) & (MMX_MMREG_SIZE - 1); - if (delta) - { - delta = MMX_MMREG_SIZE - delta; - len -= delta; - small_memcpy(to, from, delta); - } - i = len >> 6; /* len/64 */ - len&=63; - for( ; i > 0; i--) - { - __asm__ __volatile__ ( - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "movq 32(%0), %%mm4\n" - "movq 40(%0), %%mm5\n" - "movq 48(%0), %%mm6\n" - "movq 56(%0), %%mm7\n" - "movq %%mm0, (%1)\n" - "movq %%mm1, 8(%1)\n" - "movq %%mm2, 16(%1)\n" - "movq %%mm3, 24(%1)\n" - "movq %%mm4, 32(%1)\n" - "movq %%mm5, 40(%1)\n" - "movq %%mm6, 48(%1)\n" - "movq %%mm7, 56(%1)\n" - : : "r" (from), "r" (to) : "memory"); - from = ((const unsigned char *)from) + 64; - to = ((unsigned char *)to) + 64; - } - __asm__ __volatile__ ("emms": : :"memory"); - } - /* - * Now do the tail of the block - */ - if(len) __memcpy(to, from, len); - return retval; -} - -// ================================== -static void * mmx2_memcpy(void * to, const void * from, size_t len) -{ - void *retval; - size_t i; - retval = to; - - /* PREFETCH has effect even for MOVSB instruction ;) */ - __asm__ __volatile__ ( - " prefetchnta (%0)\n" - " prefetchnta 32(%0)\n" - " prefetchnta 64(%0)\n" - " prefetchnta 96(%0)\n" - " prefetchnta 128(%0)\n" - " prefetchnta 160(%0)\n" - " prefetchnta 192(%0)\n" - " prefetchnta 224(%0)\n" - " prefetchnta 256(%0)\n" - " prefetchnta 288(%0)\n" - : : "r" (from) ); - - if (len >= MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)to) & (MMX_MMREG_SIZE - 1); - if (delta) - { - delta = MMX_MMREG_SIZE - delta; - len -= delta; - small_memcpy(to, from, delta); - } - i = len >> 6; /* len/64 */ - len&=63; - for( ; i > 0; i--) - { - __asm__ __volatile__ ( - "prefetchnta 320(%0)\n" - "prefetchnta 352(%0)\n" - "movq (%0), %%mm0\n" - "movq 8(%0), %%mm1\n" - "movq 16(%0), %%mm2\n" - "movq 24(%0), %%mm3\n" - "movq 32(%0), %%mm4\n" - "movq 40(%0), %%mm5\n" - "movq 48(%0), %%mm6\n" - "movq 56(%0), %%mm7\n" - "movntq %%mm0, (%1)\n" - "movntq %%mm1, 8(%1)\n" - "movntq %%mm2, 16(%1)\n" - "movntq %%mm3, 24(%1)\n" - "movntq %%mm4, 32(%1)\n" - "movntq %%mm5, 40(%1)\n" - "movntq %%mm6, 48(%1)\n" - "movntq %%mm7, 56(%1)\n" - : : "r" (from), "r" (to) : "memory"); - from = ((const unsigned char *)from) + 64; - to = ((unsigned char *)to) + 64; - } - /* since movntq is weakly-ordered, a "sfence" - * is needed to become ordered again. */ - __asm__ __volatile__ ("sfence": : :"memory"); - __asm__ __volatile__ ("emms": : :"memory"); - } - /* - * Now do the tail of the block - */ - if(len) __memcpy(to, from, len); - return retval; -} - -// ================================== -static void *linux_kernel_memcpy(void *to, const void *from, size_t len) -{ - return __memcpy(to, from, len); -} -#endif /* __i386__ || __x86_64__ */ - - -// ================================== -//! constr. -cDxr3MemcpyBench::cDxr3MemcpyBench(uint32_t config_flags) -{ - // - // add all available memcpy routines - // - - memcpy_routine routine; - - // glibc memcpy - routine.name = "glibc memcpy()"; - routine.function = memcpy; - routine.time = 0; - routine.cpu_require = 0; - m_methods.push_back(routine); - -#if defined(__i386__) || defined(__x86_64__) - - // linux_kernel_memcpy - routine.name = "linux_kernel_memcpy()"; - routine.function = linux_kernel_memcpy; - routine.cpu_require = 0; - m_methods.push_back(routine); - - // MMX optimized memcpy() - routine.name = "MMX optimized memcpy()"; - routine.function = mmx_memcpy; - routine.cpu_require = CC_MMX; - m_methods.push_back(routine); - - // MMXEXT optimized memcpy() - routine.name = "MMXEXT optimized memcpy()"; - routine.function = mmx2_memcpy; - routine.cpu_require = CC_MMXEXT; - m_methods.push_back(routine); - -#ifndef __FreeBSD__ - - // SSE optimized memcpy() - routine.name = "SSE optimized memcpy()"; - routine.function = sse_memcpy; - routine.cpu_require = CC_MMXEXT|CC_SSE; - m_methods.push_back(routine); - -#endif /* not __FreeBSD__ */ -#endif /* __i386__ || __x86_64__ */ - - // - // run benchmarking - // - - unsigned long long t = 0; - void *buf1, *buf2; - int j, best = -1; - - if ((buf1 = malloc(BUFSIZE)) == NULL) - return; - - if ((buf2 = malloc(BUFSIZE)) == NULL) - { - free(buf1); - return; - } - - cLog::Instance() << - "\nBenchmarking memcpy() methods (smaller is better):\n"; - // make sure buffers are present on physical memory - memcpy(buf1, buf2, BUFSIZE); - - for (size_t i = 0; i < m_methods.size(); i++) - { - if ((config_flags & m_methods[i].cpu_require) != m_methods[i].cpu_require) - { - continue; - } - - // count 100 runs of the memcpy function - t = Rdtsc(config_flags); - for (j = 0; j < 50; j++) - { - m_methods[i].function(buf2, buf1, BUFSIZE); - m_methods[i].function(buf1, buf2, BUFSIZE); - } - t = Rdtsc(config_flags) - t; - - m_methods[i].time = t; - - cLog::Instance() << m_methods[i].name.c_str() << ": " - << (unsigned long long)t << "\n"; - - if (best == -1 || t < m_methods[best].time) - { - best = i; - } - } - cLog::Instance() << "\nBest one: " - << m_methods[best].name.c_str() << "\n\n"; - - dxr3_memcpy = m_methods[best].function; - - - // clear unused memory - free(buf1); - free(buf2); -} - -// ================================== -//! needed for exact timing -unsigned long long int cDxr3MemcpyBench::Rdtsc(uint32_t config_flags) -{ -#if defined(__i386__) || defined(__x86_64__) - // we need rdtsc support - if (config_flags && CC_MMX) - { - unsigned long long int x; - __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); - return x; - } - else - { - return times(NULL); - } -#else - struct tms tp; - return times(&tp); -#endif /* __i386__ || __x86_64__ */ -} - -// Local variables: -// mode: c++ -// c-file-style: "stroustrup" -// c-file-offsets: ((inline-open . 0)) -// indent-tabs-mode: t -// End: diff --git a/dxr3memcpy.h b/dxr3memcpy.h deleted file mode 100644 index c590d6c..0000000 --- a/dxr3memcpy.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * dxr3memcpy.h - * - * Copyright (C) 2004 Christian Gmeiner - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -/***************************************************************************** - * memcpy.h: functions and definitions of the MMX/MMX2/SSE optimized versions - * of memcpy - ***************************************************************************** - * Copyright (C) 2001 Keuleu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - ***************************************************************************** - * - * Original code: - * - * Copyright (C) 2000-2001 the xine project - * - * This file is part of xine, a unix video player. - * - *****************************************************************************/ - -#ifndef _DXR3MEMCPY_H_ -#define _DXR3MEMCPY_H_ - -#include "dxr3vdrincludes.h" - -// ================================== -/*! \def BUFSIZE - \brief size of buffers for benchmark :) -*/ -#define BUFSIZE 1024*1024 - -// ================================== -struct memcpy_routine -{ - std::string name; ///< name of memcpy methode - void *(* function)(void *to, const void *from, size_t len); ///< our memcopy methode - unsigned long long time; ///< needed time for banchmark - uint32_t cpu_require; ///< caps from dxr3cpu.h -}; - -// ================================== -//! Little class to do a nice benchmark -/* - Whith this class we can get the fastest memcyp - methode for target computer. -*/ -class cDxr3MemcpyBench -{ -public: - cDxr3MemcpyBench(uint32_t config_flags = 0); - -private: - unsigned long long int Rdtsc(uint32_t config_flags); - - std::vector<memcpy_routine> m_methods; ///< a std::vector with all methods -}; - -// ================================== -//! optimized/fast memcpy -extern void *(* dxr3_memcpy)(void *to, const void *from, size_t len); - -#endif /*_DXR3MEMCPY_H_*/ - -// Local variables: -// mode: c++ -// c-file-style: "stroustrup" -// c-file-offsets: ((inline-open . 0)) -// indent-tabs-mode: t -// End: diff --git a/dxr3syncbuffer.c b/dxr3syncbuffer.c index d7fe170..4569222 100644 --- a/dxr3syncbuffer.c +++ b/dxr3syncbuffer.c @@ -27,7 +27,6 @@ #include <unistd.h> #include "dxr3syncbuffer.h" -#include "dxr3memcpy.h" const int DXR3_MAX_VIDEO_FRAME_LENGTH = 4096; const int DXR3_MAX_AUDIO_FRAME_LENGTH = 4096; @@ -80,7 +79,7 @@ void cFixedLengthFrame::CopyFrame(const uint8_t* pStart, int length, m_type = type; m_count = length; m_pts = pts; - dxr3_memcpy((void*) m_pData, (void*) pStart, length); + memcpy((void*) m_pData, (void*) pStart, length); } // ================================== |