summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-28 19:01:45 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-28 19:01:45 +0000
commit2fefcdf31ccd4d43f578f4954be7821b99a7958a (patch)
tree06461c571358830f5df87702c616d4b9abb4ac40
parentc6af50b787f971bb6849c0d0a5a1161c27878559 (diff)
downloadrockbox-2fefcdf31ccd4d43f578f4954be7821b99a7958a.tar.gz
rockbox-2fefcdf31ccd4d43f578f4954be7821b99a7958a.zip
Refinement of initial lowmem handling for libwmapro (r27593). Set maximum supported channels to 2 instead of 8 for low memory targets. This solution saves more RAM than the former solution and does avoid possible NULLPTR access. As add-on remove tabs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27602 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libwmapro/wmaprodec.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c
index 33848d4ea3..f3920f9d76 100644
--- a/apps/codecs/libwmapro/wmaprodec.c
+++ b/apps/codecs/libwmapro/wmaprodec.c
@@ -104,9 +104,9 @@
104 104
105#undef DEBUGF 105#undef DEBUGF
106#ifdef WMAPRO_DUMP_CTX_EN 106#ifdef WMAPRO_DUMP_CTX_EN
107# define DEBUGF printf 107# define DEBUGF printf
108#else 108#else
109# define DEBUGF(...) 109# define DEBUGF(...)
110#endif 110#endif
111 111
112/* Some defines to make it compile */ 112/* Some defines to make it compile */
@@ -124,8 +124,14 @@
124#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) 124#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
125#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) 125#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
126 126
127/** current decoder limitations */ 127/* Enable multichannel for large-memory targets only */
128#if (MEMORYSIZE > 2)
128#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels 129#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels
130#else
131#define WMAPRO_MAX_CHANNELS 2 ///< max number of handled channels
132#endif
133
134/* Current decoder limitations */
129#define MAX_SUBFRAMES 32 ///< max number of subframes per channel 135#define MAX_SUBFRAMES 32 ///< max number of subframes per channel
130#define MAX_BANDS 29 ///< max number of scale factor bands 136#define MAX_BANDS 29 ///< max number of scale factor bands
131#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size 137#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size
@@ -156,10 +162,8 @@ static VLC coef_vlc[2]; ///< coefficient run length vlc codes
156static int32_t g_tmp[WMAPRO_BLOCK_MAX_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM; 162static int32_t g_tmp[WMAPRO_BLOCK_MAX_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM;
157static int32_t g_out_ch0[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR; 163static int32_t g_out_ch0[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR;
158static int32_t g_out_ch1[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM; 164static int32_t g_out_ch1[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM;
159#if MEMORYSIZE > 2 165#if (WMAPRO_MAX_CHANNELS > 2)
160 /* Enable multichannel for large-memory targets only */
161 static int32_t g_out_multichannel[WMAPRO_MAX_CHANNELS-2][WMAPRO_OUT_BUF_SIZE]; 166 static int32_t g_out_multichannel[WMAPRO_MAX_CHANNELS-2][WMAPRO_OUT_BUF_SIZE];
162# define MC_ENABLED
163#endif 167#endif
164 168
165/** 169/**
@@ -305,7 +309,7 @@ int decode_init(asf_waveformatex_t *wfx)
305 /* Use globally defined arrays. Allows IRAM usage for up to 2 channels. */ 309 /* Use globally defined arrays. Allows IRAM usage for up to 2 channels. */
306 s->channel[0].out = g_out_ch0; 310 s->channel[0].out = g_out_ch0;
307 s->channel[1].out = g_out_ch1; 311 s->channel[1].out = g_out_ch1;
308#ifdef MC_ENABLED 312#if (WMAPRO_MAX_CHANNELS > 2)
309 for (i=2; i<WMAPRO_MAX_CHANNELS; ++i) 313 for (i=2; i<WMAPRO_MAX_CHANNELS; ++i)
310 s->channel[i].out = g_out_multichannel[i-2]; 314 s->channel[i].out = g_out_multichannel[i-2];
311#endif 315#endif
@@ -763,8 +767,8 @@ static int decode_channel_transform(WMAProDecodeCtx* s)
763 } 767 }
764 } 768 }
765 } else if (chgroup->num_channels > 2) { 769 } else if (chgroup->num_channels > 2) {
766 DEBUGF("in wmaprodec.c: Multichannel streams still not supported\n"); 770 DEBUGF("in wmaprodec.c: Multichannel streams still not supported\n");
767 return -1; 771 return -1;
768#if 0 772#if 0
769 if (get_bits1(&s->gb)) { 773 if (get_bits1(&s->gb)) {
770 chgroup->transform = 1; 774 chgroup->transform = 1;
@@ -1497,7 +1501,7 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len,
1497 *@return number of bytes that were read from the input buffer 1501 *@return number of bytes that were read from the input buffer
1498 */ 1502 */
1499int decode_packet(asf_waveformatex_t *wfx, int32_t *dec[2], int *data_size, 1503int decode_packet(asf_waveformatex_t *wfx, int32_t *dec[2], int *data_size,
1500 void* pktdata, int size) 1504 void* pktdata, int size)
1501{ 1505{
1502 WMAProDecodeCtx *s = &globWMAProDecCtx; 1506 WMAProDecodeCtx *s = &globWMAProDecCtx;
1503 GetBitContext* gb = &s->pgb; 1507 GetBitContext* gb = &s->pgb;
@@ -1591,7 +1595,7 @@ int decode_packet(asf_waveformatex_t *wfx, int32_t *dec[2], int *data_size,
1591 *data_size = s->samples; 1595 *data_size = s->samples;
1592 s->packet_offset = get_bits_count(gb) & 7; 1596 s->packet_offset = get_bits_count(gb) & 7;
1593 1597
1594 s->frame_num++; 1598 s->frame_num++;
1595 return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; 1599 return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
1596} 1600}
1597 1601