summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-10-03 21:40:32 +0000
committerJens Arnold <amiconn@rockbox.org>2008-10-03 21:40:32 +0000
commitd1b19be423ab5fc62a7d16b26813b9624bf57709 (patch)
tree01ad3fe534efbb614b82712ecf419f99edfc349b /apps
parent66fe9a462c5093003a0b65239b54b44f6395b342 (diff)
downloadrockbox-d1b19be423ab5fc62a7d16b26813b9624bf57709.tar.gz
rockbox-d1b19be423ab5fc62a7d16b26813b9624bf57709.zip
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')
-rw-r--r--apps/codecs/demac/libdemac/decoder.c13
-rw-r--r--apps/codecs/demac/libdemac/demac_iram.h42
-rw-r--r--apps/codecs/demac/libdemac/entropy.c11
-rw-r--r--apps/codecs/demac/libdemac/filter.c14
-rw-r--r--apps/codecs/demac/libdemac/predictor-arm.S3
-rw-r--r--apps/codecs/demac/libdemac/predictor.c10
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
29#include "predictor.h" 29#include "predictor.h"
30#include "entropy.h" 30#include "entropy.h"
31#include "filter.h" 31#include "filter.h"
32#include "demac_iram.h"
32 33
33/* Statically allocate the filter buffers */ 34/* Statically allocate the filter buffers */
34 35
@@ -40,7 +41,7 @@ static int16_t filterbuf256[(256*3 + HISTORY_SIZE) * 2] /* 5120 bytes */
40/* This is only needed for "insane" files, and no Rockbox targets can 41/* This is only needed for "insane" files, and no Rockbox targets can
41 hope to decode them in realtime anyway. */ 42 hope to decode them in realtime anyway. */
42static int16_t filterbuf1280[(1280*3 + HISTORY_SIZE) * 2] /* 17408 bytes */ 43static int16_t filterbuf1280[(1280*3 + HISTORY_SIZE) * 2] /* 17408 bytes */
43 __attribute__((aligned(16))); 44 IBSS_ATTR_DEMAC_INSANEBUF __attribute__((aligned(16)));
44 45
45void init_frame_decoder(struct ape_ctx_t* ape_ctx, 46void init_frame_decoder(struct ape_ctx_t* ape_ctx,
46 unsigned char* inbuffer, int* firstbyte, 47 unsigned char* inbuffer, int* firstbyte,
@@ -74,11 +75,11 @@ void init_frame_decoder(struct ape_ctx_t* ape_ctx,
74 } 75 }
75} 76}
76 77
77int decode_chunk(struct ape_ctx_t* ape_ctx, 78int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx,
78 unsigned char* inbuffer, int* firstbyte, 79 unsigned char* inbuffer, int* firstbyte,
79 int* bytesconsumed, 80 int* bytesconsumed,
80 int32_t* decoded0, int32_t* decoded1, 81 int32_t* decoded0, int32_t* decoded1,
81 int count) 82 int count)
82{ 83{
83 int res; 84 int res;
84 int32_t left, right; 85 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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* Define how IRAM is used on the various targets. Note that this file
23 * is included by both .c and .S files so must not contain any C code. */
24
25#ifndef _LIBDEMAC_IRAM_H
26#define _LIBDEMAC_IRAM_H
27
28#include "config.h"
29
30/* On PP5002 code should go into IRAM. Otherwise put the insane
31 * filter buffer into IRAM as long as there is no better use. */
32#if CONFIG_CPU == PP5002
33#define ICODE_SECTION_DEMAC_ARM .icode
34#define ICODE_ATTR_DEMAC ICODE_ATTR
35#define IBSS_ATTR_DEMAC_INSANEBUF
36#else
37#define ICODE_SECTION_DEMAC_ARM .text
38#define ICODE_ATTR_DEMAC
39#define IBSS_ATTR_DEMAC_INSANEBUF IBSS_ATTR
40#endif
41
42#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
28#include "parser.h" 28#include "parser.h"
29#include "entropy.h" 29#include "entropy.h"
30#include "rangecoding.h" /* Range-coding (static inline) functions */ 30#include "rangecoding.h" /* Range-coding (static inline) functions */
31#include "demac_iram.h"
31 32
32#define MODEL_ELEMENTS 64 33#define MODEL_ELEMENTS 64
33 34
@@ -270,11 +271,11 @@ void init_entropy_decoder(struct ape_ctx_t* ape_ctx,
270 *firstbyte = bytebufferoffset; 271 *firstbyte = bytebufferoffset;
271} 272}
272 273
273int entropy_decode(struct ape_ctx_t* ape_ctx, 274int ICODE_ATTR_DEMAC entropy_decode(struct ape_ctx_t* ape_ctx,
274 unsigned char* inbuffer, int* firstbyte, 275 unsigned char* inbuffer, int* firstbyte,
275 int* bytesconsumed, 276 int* bytesconsumed,
276 int32_t* decoded0, int32_t* decoded1, 277 int32_t* decoded0, int32_t* decoded1,
277 int blockstodecode) 278 int blockstodecode)
278{ 279{
279 bytebuffer = inbuffer; 280 bytebuffer = inbuffer;
280 bytebufferoffset = *firstbyte; 281 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
27 27
28#include "demac.h" 28#include "demac.h"
29#include "filter.h" 29#include "filter.h"
30#include "demac_iram.h"
30 31
31#ifdef CPU_COLDFIRE 32#ifdef CPU_COLDFIRE
32#include "vector_math16_cf.h" 33#include "vector_math16_cf.h"
@@ -85,11 +86,16 @@ struct filter_t {
85#define FP_HALF (1 << (FRACBITS - 1)) /* 0.5 in fixed-point format. */ 86#define FP_HALF (1 << (FRACBITS - 1)) /* 0.5 in fixed-point format. */
86#define FP_TO_INT(x) ((x + FP_HALF) >> FRACBITS); /* round(x) */ 87#define FP_TO_INT(x) ((x + FP_HALF) >> FRACBITS); /* round(x) */
87 88
89#if ARM_ARCH >= 6
90#define SATURATE(x) ({int __res; asm("ssat %0, #16, %1" : "=r"(__res) : "r"(x)); __res; })
91#else
88#define SATURATE(x) (int16_t)(((x) == (int16_t)(x)) ? (x) : ((x) >> 31) ^ 0x7FFF); 92#define SATURATE(x) (int16_t)(((x) == (int16_t)(x)) ? (x) : ((x) >> 31) ^ 0x7FFF);
93#endif
89 94
90/* Apply the filter with state f to count entries in data[] */ 95/* Apply the filter with state f to count entries in data[] */
91 96
92static void do_apply_filter_3980(struct filter_t* f, int32_t* data, int count) 97static void ICODE_ATTR_DEMAC do_apply_filter_3980(struct filter_t* f,
98 int32_t* data, int count)
93{ 99{
94 int res; 100 int res;
95 int absres; 101 int absres;
@@ -146,7 +152,8 @@ static void do_apply_filter_3980(struct filter_t* f, int32_t* data, int count)
146 } 152 }
147} 153}
148 154
149static void do_apply_filter_3970(struct filter_t* f, int32_t* data, int count) 155static void ICODE_ATTR_DEMAC do_apply_filter_3970(struct filter_t* f,
156 int32_t* data, int count)
150{ 157{
151 int res; 158 int res;
152 159
@@ -216,7 +223,8 @@ void INIT_FILTER(int16_t* buf)
216 do_init_filter(&filter1, buf + ORDER * 3 + HISTORY_SIZE); 223 do_init_filter(&filter1, buf + ORDER * 3 + HISTORY_SIZE);
217} 224}
218 225
219int APPLY_FILTER(int fileversion, int32_t* data0, int32_t* data1, int count) 226int ICODE_ATTR_DEMAC APPLY_FILTER(int fileversion, int32_t* data0,
227 int32_t* data1, int count)
220{ 228{
221 if (fileversion >= 3980) { 229 if (fileversion >= 3980) {
222 do_apply_filter_3980(&filter0, data0, count); 230 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
21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
22 22
23*/ 23*/
24#include "demac_iram.h"
24 25
25 .section .text,"ax",%progbits 26 .section ICODE_SECTION_DEMAC_ARM,"ax",%progbits
26 27
27 .align 2 28 .align 2
28 29
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
27 27
28#include "parser.h" 28#include "parser.h"
29#include "predictor.h" 29#include "predictor.h"
30#include "demac_iram.h"
30 31
31/* Return 0 if x is zero, -1 if x is positive, 1 if x is negative */ 32/* Return 0 if x is zero, -1 if x is positive, 1 if x is negative */
32#define SIGN(x) (x) ? (((x) > 0) ? -1 : 1) : 0 33#define SIGN(x) (x) ? (((x) > 0) ? -1 : 1) : 0
@@ -67,7 +68,10 @@ void init_predictor_decoder(struct predictor_t* p)
67} 68}
68 69
69#if !defined(CPU_ARM) && !defined(CPU_COLDFIRE) 70#if !defined(CPU_ARM) && !defined(CPU_COLDFIRE)
70int predictor_decode_stereo(struct predictor_t* p, int32_t* decoded0, int32_t* decoded1, int count) 71int ICODE_ATTR_DEMAC predictor_decode_stereo(struct predictor_t* p,
72 int32_t* decoded0,
73 int32_t* decoded1,
74 int count)
71{ 75{
72 int32_t predictionA, predictionB; 76 int32_t predictionA, predictionB;
73 77
@@ -203,7 +207,9 @@ int predictor_decode_stereo(struct predictor_t* p, int32_t* decoded0, int32_t* d
203} 207}
204#endif 208#endif
205 209
206int predictor_decode_mono(struct predictor_t* p, int32_t* decoded0, int count) 210int ICODE_ATTR_DEMAC predictor_decode_mono(struct predictor_t* p,
211 int32_t* decoded0,
212 int count)
207{ 213{
208 int32_t predictionA, currentA, A; 214 int32_t predictionA, currentA, A;
209 215