From 42bd5b46f09556e04994981e83d8da397912a303 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Thu, 12 Jul 2007 22:12:25 +0000 Subject: WMA codec: Coldfire is capable of unaligned memory accesses, so lets make use of it. ~1.5% speedup. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13865 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libwma/Makefile | 2 +- apps/codecs/libwma/bitstream.h | 2 +- apps/codecs/libwma/bswap.h | 25 +++++++++++++++++++++++-- apps/codecs/libwma/ffmpeg_config.h | 11 +++++++++-- 4 files changed, 34 insertions(+), 6 deletions(-) (limited to 'apps/codecs/libwma') diff --git a/apps/codecs/libwma/Makefile b/apps/codecs/libwma/Makefile index 0d7f966737..91ea49b1fb 100644 --- a/apps/codecs/libwma/Makefile +++ b/apps/codecs/libwma/Makefile @@ -14,7 +14,7 @@ ifdef APPEXTRA INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) endif -WMAOPTS = -O2 +WMAOPTS = -O2 -DROCKBOX CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET_INC) $(WMAOPTS) $(TARGET) \ $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} $(PROFILE_OPTS) -DCODEC=1 diff --git a/apps/codecs/libwma/bitstream.h b/apps/codecs/libwma/bitstream.h index c02845e09b..77ccff695e 100644 --- a/apps/codecs/libwma/bitstream.h +++ b/apps/codecs/libwma/bitstream.h @@ -203,7 +203,7 @@ typedef struct RL_VLC_ELEM { #endif /* used to avoid missaligned exceptions on some archs (alpha, ...) */ -#if defined(ARCH_X86) +#if defined(ARCH_X86) || defined(CPU_COLDFIRE) # define unaligned16(a) (*(const uint16_t*)(a)) # define unaligned32(a) (*(const uint32_t*)(a)) # define unaligned64(a) (*(const uint64_t*)(a)) diff --git a/apps/codecs/libwma/bswap.h b/apps/codecs/libwma/bswap.h index 460f7abd40..33377cfcba 100644 --- a/apps/codecs/libwma/bswap.h +++ b/apps/codecs/libwma/bswap.h @@ -10,7 +10,28 @@ #include #else -#ifdef ARCH_X86 +#ifdef ROCKBOX +#include "codecs.h" + +/* rockbox' optimised inline functions */ +#define bswap_16(x) swap16(x) +#define bswap_32(x) swap32(x) + +static inline uint64_t ByteSwap64(uint64_t x) +{ + union { + uint64_t ll; + struct { + uint32_t l,h; + } l; + } r; + r.l.l = bswap_32 (x); + r.l.h = bswap_32 (x>>32); + return r.ll; +} +#define bswap_64(x) ByteSwap64(x) + +#elif defined(ARCH_X86) static inline unsigned short ByteSwap16(unsigned short x) { __asm("xchgb %b0,%h0" : @@ -83,7 +104,7 @@ static inline uint64_t ByteSwap64(uint64_t x) #else #define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) - + // code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. #define bswap_32(x) \ diff --git a/apps/codecs/libwma/ffmpeg_config.h b/apps/codecs/libwma/ffmpeg_config.h index 40815cb54b..12b0666e42 100644 --- a/apps/codecs/libwma/ffmpeg_config.h +++ b/apps/codecs/libwma/ffmpeg_config.h @@ -1,7 +1,14 @@ /* Automatically generated by configure - do not modify */ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef _FFMPEG_CONFIG_H +#define _FFMPEG_CONFIG_H +#include "codecs.h" +#ifdef CPU_ARM #define CONFIG_ALIGN 1 +#endif + +#ifdef ROCKBOX_BIG_ENDIAN +#define WORDS_BIGENDIAN +#endif #endif -- cgit v1.2.3