diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-10-03 21:40:32 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-10-03 21:40:32 +0000 |
commit | d1b19be423ab5fc62a7d16b26813b9624bf57709 (patch) | |
tree | 01ad3fe534efbb614b82712ecf419f99edfc349b /apps/codecs/demac/libdemac | |
parent | 66fe9a462c5093003a0b65239b54b44f6395b342 (diff) |
Various speedups: (1) Put actual decoding functions into IRAM on PP5002. (2) Put the insane filter buffer into IRAM on coldfire and PP502x (just for completeness, as long as there's no better use). (3) Use the ARMv6 'ssat' instruction for saturation on Gigabeat S.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18701 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/demac/libdemac')
-rw-r--r-- | apps/codecs/demac/libdemac/decoder.c | 13 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/demac_iram.h | 42 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/entropy.c | 11 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/filter.c | 14 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/predictor-arm.S | 3 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/predictor.c | 10 |
6 files changed, 76 insertions, 17 deletions
diff --git a/apps/codecs/demac/libdemac/decoder.c b/apps/codecs/demac/libdemac/decoder.c index 326e893ec4..f6c2451c0c 100644 --- a/apps/codecs/demac/libdemac/decoder.c +++ b/apps/codecs/demac/libdemac/decoder.c @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "predictor.h" #include "entropy.h" #include "filter.h" +#include "demac_iram.h" /* Statically allocate the filter buffers */ @@ -40,7 +41,7 @@ static int16_t filterbuf256[(256*3 + HISTORY_SIZE) * 2] /* 5120 bytes */ /* This is only needed for "insane" files, and no Rockbox targets can hope to decode them in realtime anyway. */ static int16_t filterbuf1280[(1280*3 + HISTORY_SIZE) * 2] /* 17408 bytes */ - __attribute__((aligned(16))); + IBSS_ATTR_DEMAC_INSANEBUF __attribute__((aligned(16))); void init_frame_decoder(struct ape_ctx_t* ape_ctx, unsigned char* inbuffer, int* firstbyte, @@ -74,11 +75,11 @@ void init_frame_decoder(struct ape_ctx_t* ape_ctx, } } -int decode_chunk(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int count) +int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int count) { int res; int32_t left, right; diff --git a/apps/codecs/demac/libdemac/demac_iram.h b/apps/codecs/demac/libdemac/demac_iram.h new file mode 100644 index 0000000000..fb6965a35e --- /dev/null +++ b/apps/codecs/demac/libdemac/demac_iram.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Jens Arnold + * + * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* Define how IRAM is used on the various targets. Note that this file + * is included by both .c and .S files so must not contain any C code. */ + +#ifndef _LIBDEMAC_IRAM_H +#define _LIBDEMAC_IRAM_H + +#include "config.h" + +/* On PP5002 code should go into IRAM. Otherwise put the insane + * filter buffer into IRAM as long as there is no better use. */ +#if CONFIG_CPU == PP5002 +#define ICODE_SECTION_DEMAC_ARM .icode +#define ICODE_ATTR_DEMAC ICODE_ATTR +#define IBSS_ATTR_DEMAC_INSANEBUF +#else +#define ICODE_SECTION_DEMAC_ARM .text +#define ICODE_ATTR_DEMAC +#define IBSS_ATTR_DEMAC_INSANEBUF IBSS_ATTR +#endif + +#endif /* _LIBDEMAC_IRAM_H */ diff --git a/apps/codecs/demac/libdemac/entropy.c b/apps/codecs/demac/libdemac/entropy.c index 76d977da82..1ef5bc4dc1 100644 --- a/apps/codecs/demac/libdemac/entropy.c +++ b/apps/codecs/demac/libdemac/entropy.c @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "parser.h" #include "entropy.h" #include "rangecoding.h" /* Range-coding (static inline) functions */ +#include "demac_iram.h" #define MODEL_ELEMENTS 64 @@ -270,11 +271,11 @@ void init_entropy_decoder(struct ape_ctx_t* ape_ctx, *firstbyte = bytebufferoffset; } -int entropy_decode(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int blockstodecode) +int ICODE_ATTR_DEMAC entropy_decode(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int blockstodecode) { bytebuffer = inbuffer; bytebufferoffset = *firstbyte; diff --git a/apps/codecs/demac/libdemac/filter.c b/apps/codecs/demac/libdemac/filter.c index b191d47364..913654db6e 100644 --- a/apps/codecs/demac/libdemac/filter.c +++ b/apps/codecs/demac/libdemac/filter.c @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "demac.h" #include "filter.h" +#include "demac_iram.h" #ifdef CPU_COLDFIRE #include "vector_math16_cf.h" @@ -85,11 +86,16 @@ struct filter_t { #define FP_HALF (1 << (FRACBITS - 1)) /* 0.5 in fixed-point format. */ #define FP_TO_INT(x) ((x + FP_HALF) >> FRACBITS); /* round(x) */ +#if ARM_ARCH >= 6 +#define SATURATE(x) ({int __res; asm("ssat %0, #16, %1" : "=r"(__res) : "r"(x)); __res; }) +#else #define SATURATE(x) (int16_t)(((x) == (int16_t)(x)) ? (x) : ((x) >> 31) ^ 0x7FFF); +#endif /* Apply the filter with state f to count entries in data[] */ -static void do_apply_filter_3980(struct filter_t* f, int32_t* data, int count) +static void ICODE_ATTR_DEMAC do_apply_filter_3980(struct filter_t* f, + int32_t* data, int count) { int res; int absres; @@ -146,7 +152,8 @@ static void do_apply_filter_3980(struct filter_t* f, int32_t* data, int count) } } -static void do_apply_filter_3970(struct filter_t* f, int32_t* data, int count) +static void ICODE_ATTR_DEMAC do_apply_filter_3970(struct filter_t* f, + int32_t* data, int count) { int res; @@ -216,7 +223,8 @@ void INIT_FILTER(int16_t* buf) do_init_filter(&filter1, buf + ORDER * 3 + HISTORY_SIZE); } -int APPLY_FILTER(int fileversion, int32_t* data0, int32_t* data1, int count) +int ICODE_ATTR_DEMAC APPLY_FILTER(int fileversion, int32_t* data0, + int32_t* data1, int count) { if (fileversion >= 3980) { do_apply_filter_3980(&filter0, data0, count); diff --git a/apps/codecs/demac/libdemac/predictor-arm.S b/apps/codecs/demac/libdemac/predictor-arm.S index e4c7d63815..f54260c934 100644 --- a/apps/codecs/demac/libdemac/predictor-arm.S +++ b/apps/codecs/demac/libdemac/predictor-arm.S @@ -21,8 +21,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA */ +#include "demac_iram.h" - .section .text,"ax",%progbits + .section ICODE_SECTION_DEMAC_ARM,"ax",%progbits .align 2 diff --git a/apps/codecs/demac/libdemac/predictor.c b/apps/codecs/demac/libdemac/predictor.c index edf8b71575..f0e3b65556 100644 --- a/apps/codecs/demac/libdemac/predictor.c +++ b/apps/codecs/demac/libdemac/predictor.c @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "parser.h" #include "predictor.h" +#include "demac_iram.h" /* Return 0 if x is zero, -1 if x is positive, 1 if x is negative */ #define SIGN(x) (x) ? (((x) > 0) ? -1 : 1) : 0 @@ -67,7 +68,10 @@ void init_predictor_decoder(struct predictor_t* p) } #if !defined(CPU_ARM) && !defined(CPU_COLDFIRE) -int predictor_decode_stereo(struct predictor_t* p, int32_t* decoded0, int32_t* decoded1, int count) +int ICODE_ATTR_DEMAC predictor_decode_stereo(struct predictor_t* p, + int32_t* decoded0, + int32_t* decoded1, + int count) { int32_t predictionA, predictionB; @@ -203,7 +207,9 @@ int predictor_decode_stereo(struct predictor_t* p, int32_t* decoded0, int32_t* d } #endif -int predictor_decode_mono(struct predictor_t* p, int32_t* decoded0, int count) +int ICODE_ATTR_DEMAC predictor_decode_mono(struct predictor_t* p, + int32_t* decoded0, + int count) { int32_t predictionA, currentA, A; |