From 07405841c67ac29b2a75f20f8732b34064a28cff Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Mon, 19 Dec 2011 19:46:10 +0000 Subject: FS#12463: Improve performance for multichannel FLAC decoding. Speeds up decoding by 3 MHz on PP5022, 6-7 MHz on S5L870x and 11-12 MHz on MCF5250. 5.1-88kHz-files still do not decode in realtime on Coldfire and PP502x. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31367 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/flac.c | 27 +++++++++++++++++---------- apps/codecs/libffmpegFLAC/bitstream.h | 22 ++++++++++++++++++---- apps/codecs/libffmpegFLAC/decoder.c | 1 + 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index b9f6654f92..e10403819c 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c @@ -24,10 +24,15 @@ CODEC_HEADER +static FLACContext fc IBSS_ATTR_FLAC; + /* The output buffers containing the decoded samples (channels 0 and 1) */ -static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0; -static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR; -static int32_t dummydec[4][MAX_BLOCKSIZE]; +static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC; +static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR_FLAC; +static int32_t decoded2[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM; +static int32_t decoded3[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM; +static int32_t decoded4[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM; +static int32_t decoded5[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM; #define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 @@ -81,7 +86,6 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) uint16_t blocksize; int endofmetadata=0; uint32_t blocklength; - int ch; ci->memset(fc,0,sizeof(FLACContext)); nseekpoints=0; @@ -91,15 +95,19 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) /* Reset sample buffers */ memset(decoded0, 0, sizeof(decoded0)); memset(decoded1, 0, sizeof(decoded1)); - memset(dummydec, 0, sizeof(dummydec)); + memset(decoded2, 0, sizeof(decoded2)); + memset(decoded3, 0, sizeof(decoded3)); + memset(decoded4, 0, sizeof(decoded4)); + memset(decoded5, 0, sizeof(decoded5)); /* Set sample buffers in decoder structure */ fc->decoded[0] = decoded0; fc->decoded[1] = decoded1; - for (ch=2; chdecoded[ch] = dummydec[ch-2]; - } + fc->decoded[2] = decoded2; + fc->decoded[3] = decoded3; + fc->decoded[4] = decoded4; + fc->decoded[5] = decoded5; + /* Skip any foreign tags at start of file */ ci->seek_buffer(first_frame_offset); @@ -447,7 +455,6 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) enum codec_status codec_run(void) { int8_t *buf; - FLACContext fc; uint32_t samplesdone; uint32_t elapsedtime; size_t bytesleft; diff --git a/apps/codecs/libffmpegFLAC/bitstream.h b/apps/codecs/libffmpegFLAC/bitstream.h index 1333b9f4b8..5fc3460c8e 100644 --- a/apps/codecs/libffmpegFLAC/bitstream.h +++ b/apps/codecs/libffmpegFLAC/bitstream.h @@ -19,12 +19,26 @@ #define ICODE_ATTR #endif -#ifndef ICODE_ATTR_FLAC +#if (CONFIG_CPU == MCF5250) || (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) #define ICODE_ATTR_FLAC ICODE_ATTR -#endif +#define IBSS_ATTR_FLAC IBSS_ATTR +/* Enough IRAM to move additional data to it. */ +#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR +#define IBSS_ATTR_FLAC_XLARGE_IRAM + +#elif defined(CPU_S5L870X) +#define ICODE_ATTR_FLAC ICODE_ATTR +#define IBSS_ATTR_FLAC IBSS_ATTR +/* Enough IRAM to move even more additional data to it. */ +#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR +#define IBSS_ATTR_FLAC_XLARGE_IRAM IBSS_ATTR -#ifndef IBSS_ATTR_FLAC_DECODED0 -#define IBSS_ATTR_FLAC_DECODED0 IBSS_ATTR +#else +#define ICODE_ATTR_FLAC ICODE_ATTR +#define IBSS_ATTR_FLAC IBSS_ATTR +/* Not enough IRAM available. */ +#define IBSS_ATTR_FLAC_LARGE_IRAM +#define IBSS_ATTR_FLAC_XLARGE_IRAM #endif /* Endian conversion routines for standalone compilation */ diff --git a/apps/codecs/libffmpegFLAC/decoder.c b/apps/codecs/libffmpegFLAC/decoder.c index 1be5fbb6ef..2e92c4b90d 100644 --- a/apps/codecs/libffmpegFLAC/decoder.c +++ b/apps/codecs/libffmpegFLAC/decoder.c @@ -488,6 +488,7 @@ static int decode_frame(FLACContext *s, return 0; } +static int flac_downmix(FLACContext *s) ICODE_ATTR_FLAC; static int flac_downmix(FLACContext *s) { int32_t *FL, *FR, *FC, *SB, *RL, *RR; -- cgit v1.2.3