From 1b14167861bb5bf4c692f8fc661b33e26a706183 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 16 Nov 2008 17:49:37 +0000 Subject: Centralise compile-time configuration. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19121 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/demac/libdemac/decoder.c | 8 +-- apps/codecs/demac/libdemac/demac_config.h | 80 ++++++++++++++++++++++++++++++ apps/codecs/demac/libdemac/demac_iram.h | 50 ------------------- apps/codecs/demac/libdemac/entropy.c | 13 +---- apps/codecs/demac/libdemac/filter.c | 6 +-- apps/codecs/demac/libdemac/filter.h | 5 +- apps/codecs/demac/libdemac/parser.h | 18 +------ apps/codecs/demac/libdemac/predictor-arm.S | 7 ++- apps/codecs/demac/libdemac/predictor-cf.S | 6 +-- apps/codecs/demac/libdemac/predictor.c | 6 +-- 10 files changed, 101 insertions(+), 98 deletions(-) create mode 100644 apps/codecs/demac/libdemac/demac_config.h delete mode 100644 apps/codecs/demac/libdemac/demac_iram.h diff --git a/apps/codecs/demac/libdemac/decoder.c b/apps/codecs/demac/libdemac/decoder.c index 2b8dcd2cf3..540db47636 100644 --- a/apps/codecs/demac/libdemac/decoder.c +++ b/apps/codecs/demac/libdemac/decoder.c @@ -29,18 +29,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "predictor.h" #include "entropy.h" #include "filter.h" -#include "demac_iram.h" +#include "demac_config.h" /* Statically allocate the filter buffers */ -static int16_t filterbuf32[(32*3 + HISTORY_SIZE) * 2] /* 2432 bytes */ +static int16_t filterbuf32[(32*3 + FILTER_HISTORY_SIZE) * 2] /* 2432 bytes */ IBSS_ATTR __attribute__((aligned(16))); -static int16_t filterbuf256[(256*3 + HISTORY_SIZE) * 2] /* 5120 bytes */ +static int16_t filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2] /* 5120 bytes */ IBSS_ATTR __attribute__((aligned(16))); /* This is only needed for "insane" files, and no current Rockbox targets can hope to decode them in realtime, although the Gigabeat S comes close. */ -static int16_t filterbuf1280[(1280*3 + HISTORY_SIZE) * 2] /* 17408 bytes */ +static int16_t filterbuf1280[(1280*3 + FILTER_HISTORY_SIZE) * 2] /* 17408 bytes */ IBSS_ATTR_DEMAC_INSANEBUF __attribute__((aligned(16))); void init_frame_decoder(struct ape_ctx_t* ape_ctx, diff --git a/apps/codecs/demac/libdemac/demac_config.h b/apps/codecs/demac/libdemac/demac_config.h new file mode 100644 index 0000000000..93fda76e25 --- /dev/null +++ b/apps/codecs/demac/libdemac/demac_config.h @@ -0,0 +1,80 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +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., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _DEMAC_CONFIG_H +#define _DEMAC_CONFIG_H + +/* Build-time choices for libdemac. + * Note that this file is included by both .c and .S files. */ + +#ifdef ROCKBOX + +#include "config.h" + +#ifndef __ASSEMBLER__ +#include "../lib/codeclib.h" +#include +#endif + +#define APE_OUTPUT_DEPTH 29 + +/* 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 + +#else /* !ROCKBOX */ + +#define APE_OUTPUT_DEPTH (ape_ctx->bps) + +#define IBSS_ATTR +#define IBSS_ATTR_DEMAC_INSANEBUF +#define ICONST_ATTR +#define ICODE_ATTR +#define ICODE_ATTR_DEMAC + +#endif /* !ROCKBOX */ + +/* Defaults */ + +#ifndef UDIV32 +#define UDIV32(a, b) (a / b) +#endif + +#ifndef FILTER_HISTORY_SIZE +#define FILTER_HISTORY_SIZE 512 +#endif + +#ifndef PREDICTOR_HISTORY_SIZE +#define PREDICTOR_HISTORY_SIZE 512 +#endif + +#endif /* _DEMAC_CONFIG_H */ diff --git a/apps/codecs/demac/libdemac/demac_iram.h b/apps/codecs/demac/libdemac/demac_iram.h deleted file mode 100644 index 5dd02f812d..0000000000 --- a/apps/codecs/demac/libdemac/demac_iram.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 - -#ifdef ROCKBOX -#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 - -#else - -#define IBSS_ATTR_DEMAC_INSANEBUF -#define ICODE_ATTR_DEMAC - -#endif /* !ROCKBOX */ - -#endif /* _LIBDEMAC_IRAM_H */ diff --git a/apps/codecs/demac/libdemac/entropy.c b/apps/codecs/demac/libdemac/entropy.c index baddce07be..54ff226bce 100644 --- a/apps/codecs/demac/libdemac/entropy.c +++ b/apps/codecs/demac/libdemac/entropy.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "parser.h" #include "entropy.h" -#include "demac_iram.h" +#include "demac_config.h" #define MODEL_ELEMENTS 64 @@ -115,20 +115,11 @@ each function (and the RNGC macro)). */ -#ifdef ROCKBOX -#include "../lib/codeclib.h" -/* for UDIV32() */ -#endif - -#ifndef UDIV32 -#define UDIV32(a, b) (a / b) -#endif - /* BITSTREAM READING FUNCTIONS */ /* We deal with the input data one byte at a time - to ensure functionality on CPUs of any endianness regardless of any requirements - for aligned reads. + for aligned reads. */ static unsigned char* bytebuffer IBSS_ATTR; diff --git a/apps/codecs/demac/libdemac/filter.c b/apps/codecs/demac/libdemac/filter.c index a73215f6d0..b47a37a041 100644 --- a/apps/codecs/demac/libdemac/filter.c +++ b/apps/codecs/demac/libdemac/filter.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "demac.h" #include "filter.h" -#include "demac_iram.h" +#include "demac_config.h" #ifdef CPU_COLDFIRE #include "vector_math16_cf.h" @@ -203,7 +203,7 @@ static struct filter_t filter1 IBSS_ATTR; static void do_init_filter(struct filter_t* f, int16_t* buf) { f->coeffs = buf; - f->history_end = buf + ORDER*3 + HISTORY_SIZE; + f->history_end = buf + ORDER*3 + FILTER_HISTORY_SIZE; /* Init pointers */ f->adaptcoeffs = f->coeffs + ORDER*2; @@ -219,7 +219,7 @@ static void do_init_filter(struct filter_t* f, int16_t* buf) void INIT_FILTER(int16_t* buf) { do_init_filter(&filter0, buf); - do_init_filter(&filter1, buf + ORDER * 3 + HISTORY_SIZE); + do_init_filter(&filter1, buf + ORDER*3 + FILTER_HISTORY_SIZE); } int ICODE_ATTR_DEMAC APPLY_FILTER(int fileversion, int32_t* data0, diff --git a/apps/codecs/demac/libdemac/filter.h b/apps/codecs/demac/libdemac/filter.h index b98403cfc8..acbb155b29 100644 --- a/apps/codecs/demac/libdemac/filter.h +++ b/apps/codecs/demac/libdemac/filter.h @@ -2,7 +2,7 @@ libdemac - A Monkey's Audio decoder -$Id:$ +$Id$ Copyright (C) Dave Chapman 2007 @@ -27,9 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include -/* The size of the history buffers */ -#define HISTORY_SIZE 512 - void init_filter_16_11(int16_t* buf); int apply_filter_16_11(int fileversion, int32_t* decoded0, int32_t* decoded1, int count); diff --git a/apps/codecs/demac/libdemac/parser.h b/apps/codecs/demac/libdemac/parser.h index 4ef0977e6b..53157f7681 100644 --- a/apps/codecs/demac/libdemac/parser.h +++ b/apps/codecs/demac/libdemac/parser.h @@ -26,20 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #define _APE_PARSER_H #include - -#ifdef ROCKBOX -/* Include the Rockbox Codec API when building for Rockbox */ -#define APE_OUTPUT_DEPTH 29 -#ifndef ROCKBOX_PLUGIN -#include "../lib/codeclib.h" -#include -#endif -#else -#define APE_OUTPUT_DEPTH (ape_ctx->bps) -#define IBSS_ATTR -#define ICONST_ATTR -#define ICODE_ATTR -#endif +#include "demac_config.h" /* The earliest and latest file formats supported by this library */ #define APE_MIN_VERSION 3970 @@ -66,7 +53,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #define APE_FRAMECODE_STEREO_SILENCE 3 #define APE_FRAMECODE_PSEUDO_STEREO 4 -#define HISTORY_SIZE 512 #define PREDICTOR_ORDER 8 /* Total size of all predictor histories - 50 * sizeof(int32_t) */ #define PREDICTOR_SIZE 50 @@ -95,7 +81,7 @@ struct predictor_t int32_t XcoeffsA[4]; int32_t YcoeffsB[5]; int32_t XcoeffsB[5]; - int32_t historybuffer[HISTORY_SIZE + PREDICTOR_SIZE]; + int32_t historybuffer[PREDICTOR_HISTORY_SIZE + PREDICTOR_SIZE]; }; struct ape_ctx_t diff --git a/apps/codecs/demac/libdemac/predictor-arm.S b/apps/codecs/demac/libdemac/predictor-arm.S index f54260c934..dfeba0dcc8 100644 --- a/apps/codecs/demac/libdemac/predictor-arm.S +++ b/apps/codecs/demac/libdemac/predictor-arm.S @@ -21,7 +21,7 @@ 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" +#include "demac_config.h" .section ICODE_SECTION_DEMAC_ARM,"ax",%progbits @@ -33,8 +33,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA /* NOTE: The following need to be kept in sync with parser.h */ -#define HISTORY_SIZE 512 - #define YDELAYA 200 #define YDELAYB 168 #define XDELAYA 136 @@ -470,7 +468,8 @@ loop: add r11, r12, #historybuffer @ r11 := &p->historybuffer[0] - sub r10, r14, #HISTORY_SIZE*4 @ r10 := p->buf - HISTORY_SIZE + sub r10, r14, #PREDICTOR_HISTORY_SIZE*4 + @ r10 := p->buf - PREDICTOR_HISTORY_SIZE cmp r10, r11 bne endofloop diff --git a/apps/codecs/demac/libdemac/predictor-cf.S b/apps/codecs/demac/libdemac/predictor-cf.S index 3b9489e791..b12d0932b0 100644 --- a/apps/codecs/demac/libdemac/predictor-cf.S +++ b/apps/codecs/demac/libdemac/predictor-cf.S @@ -23,6 +23,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA */ +#include "demac_config.h" .text @@ -33,8 +34,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA /* NOTE: The following need to be kept in sync with parser.h */ -#define HISTORY_SIZE 512 - #define YDELAYA 200 #define YDELAYB 168 #define XDELAYA 136 @@ -483,7 +482,8 @@ predictor_decode_stereo: addq.l #4, %a5 | p->buf++ - lea.l (historybuffer+HISTORY_SIZE*4,%a6), %a3 | %a3 = &p->historybuffer[HISTORY_SIZE] + lea.l (historybuffer+PREDICTOR_HISTORY_SIZE*4,%a6), %a3 + | %a3 = &p->historybuffer[PREDICTOR_HISTORY_SIZE] cmp.l %a3, %a5 bne.s .endofloop diff --git a/apps/codecs/demac/libdemac/predictor.c b/apps/codecs/demac/libdemac/predictor.c index f0e3b65556..1a9b48e0ca 100644 --- a/apps/codecs/demac/libdemac/predictor.c +++ b/apps/codecs/demac/libdemac/predictor.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include "parser.h" #include "predictor.h" -#include "demac_iram.h" +#include "demac_config.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 @@ -196,7 +196,7 @@ int ICODE_ATTR_DEMAC predictor_decode_stereo(struct predictor_t* p, p->buf++; /* Have we filled the history buffer? */ - if (p->buf == p->historybuffer + HISTORY_SIZE) { + if (p->buf == p->historybuffer + PREDICTOR_HISTORY_SIZE) { memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(int32_t)); p->buf = p->historybuffer; @@ -250,7 +250,7 @@ int ICODE_ATTR_DEMAC predictor_decode_mono(struct predictor_t* p, p->buf++; /* Have we filled the history buffer? */ - if (p->buf == p->historybuffer + HISTORY_SIZE) { + if (p->buf == p->historybuffer + PREDICTOR_HISTORY_SIZE) { memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(int32_t)); p->buf = p->historybuffer; -- cgit v1.2.3