diff options
author | Dave Chapman <dave@dchapman.com> | 2007-12-01 01:01:35 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-12-01 01:01:35 +0000 |
commit | aaacb7010fc247cfc9f16b2e3aee568f29089a22 (patch) | |
tree | 5270f80f3dbad56eba3a408bdc8b36ac7394722d /apps/codecs/libalac/alac.c | |
parent | 95c117cdb8b2db2e3b5520e9181443a7915463e7 (diff) | |
download | rockbox-aaacb7010fc247cfc9f16b2e3aee568f29089a22.tar.gz rockbox-aaacb7010fc247cfc9f16b2e3aee568f29089a22.zip |
Remove the mallocs for the codecdata in the m4a parser and assume a maximum size of 64 bytes (see comments in source). Also clean up the alac_set_info() function a little and make it alignment-safe. We still need to remove the seektable related mallocs. Please report if any AAC or ALAC files stop playing in Rockbox after this commit - but it is not expected to cause problems.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15861 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libalac/alac.c')
-rw-r--r-- | apps/codecs/libalac/alac.c | 66 |
1 files changed, 24 insertions, 42 deletions
diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c index f8e4df8b1d..d5d9be17f7 100644 --- a/apps/codecs/libalac/alac.c +++ b/apps/codecs/libalac/alac.c | |||
@@ -38,23 +38,25 @@ | |||
38 | #include "../codec.h" | 38 | #include "../codec.h" |
39 | #include "decomp.h" | 39 | #include "decomp.h" |
40 | 40 | ||
41 | #define _Swap32(v) do { \ | ||
42 | v = (((v) & 0x000000FF) << 0x18) | \ | ||
43 | (((v) & 0x0000FF00) << 0x08) | \ | ||
44 | (((v) & 0x00FF0000) >> 0x08) | \ | ||
45 | (((v) & 0xFF000000) >> 0x18); } while(0) | ||
46 | |||
47 | #define _Swap16(v) do { \ | ||
48 | v = (((v) & 0x00FF) << 0x08) | \ | ||
49 | (((v) & 0xFF00) >> 0x08); } while (0) | ||
50 | |||
51 | int16_t predictor_coef_table[32] IBSS_ATTR; | 41 | int16_t predictor_coef_table[32] IBSS_ATTR; |
52 | int16_t predictor_coef_table_a[32] IBSS_ATTR; | 42 | int16_t predictor_coef_table_a[32] IBSS_ATTR; |
53 | int16_t predictor_coef_table_b[32] IBSS_ATTR; | 43 | int16_t predictor_coef_table_b[32] IBSS_ATTR; |
54 | 44 | ||
45 | |||
46 | /* Endian/aligment safe functions - only used in alac_set_info() */ | ||
47 | static uint32_t get_uint32be(unsigned char* p) | ||
48 | { | ||
49 | return((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); | ||
50 | } | ||
51 | |||
52 | static uint16_t get_uint16be(unsigned char* p) | ||
53 | { | ||
54 | return((p[0]<<8) | p[1]); | ||
55 | } | ||
56 | |||
55 | void alac_set_info(alac_file *alac, char *inputbuffer) | 57 | void alac_set_info(alac_file *alac, char *inputbuffer) |
56 | { | 58 | { |
57 | char *ptr = inputbuffer; | 59 | unsigned char* ptr = (unsigned char*)inputbuffer; |
58 | ptr += 4; /* size */ | 60 | ptr += 4; /* size */ |
59 | ptr += 4; /* frma */ | 61 | ptr += 4; /* frma */ |
60 | ptr += 4; /* alac */ | 62 | ptr += 4; /* alac */ |
@@ -63,42 +65,22 @@ void alac_set_info(alac_file *alac, char *inputbuffer) | |||
63 | 65 | ||
64 | ptr += 4; /* 0 ? */ | 66 | ptr += 4; /* 0 ? */ |
65 | 67 | ||
66 | alac->setinfo_max_samples_per_frame = *(uint32_t*)ptr; /* buffer size / 2 ? */ | 68 | alac->setinfo_max_samples_per_frame = get_uint32be(ptr); /* buffer size / 2 ? */ |
67 | #ifdef ROCKBOX_LITTLE_ENDIAN | ||
68 | _Swap32(alac->setinfo_max_samples_per_frame); | ||
69 | #endif | ||
70 | ptr += 4; | 69 | ptr += 4; |
71 | alac->setinfo_7a = *(uint8_t*)ptr; | 70 | alac->setinfo_7a = *ptr++; |
71 | alac->setinfo_sample_size = *ptr++; | ||
72 | alac->setinfo_rice_historymult = *ptr++; | ||
73 | alac->setinfo_rice_initialhistory = *ptr++; | ||
74 | alac->setinfo_rice_kmodifier = *ptr++; | ||
75 | alac->setinfo_7f = *ptr++; | ||
72 | ptr += 1; | 76 | ptr += 1; |
73 | alac->setinfo_sample_size = *(uint8_t*)ptr; | 77 | alac->setinfo_80 = get_uint16be(ptr); |
74 | ptr += 1; | ||
75 | alac->setinfo_rice_historymult = *(uint8_t*)ptr; | ||
76 | ptr += 1; | ||
77 | alac->setinfo_rice_initialhistory = *(uint8_t*)ptr; | ||
78 | ptr += 1; | ||
79 | alac->setinfo_rice_kmodifier = *(uint8_t*)ptr; | ||
80 | ptr += 1; | ||
81 | alac->setinfo_7f = *(uint8_t*)ptr; | ||
82 | ptr += 1; | ||
83 | alac->setinfo_80 = *(uint16_t*)ptr; | ||
84 | #ifdef ROCKBOX_LITTLE_ENDIAN | ||
85 | _Swap16(alac->setinfo_80); | ||
86 | #endif | ||
87 | ptr += 2; | 78 | ptr += 2; |
88 | alac->setinfo_82 = *(uint32_t*)ptr; | 79 | alac->setinfo_82 = get_uint32be(ptr); |
89 | #ifdef ROCKBOX_LITTLE_ENDIAN | ||
90 | _Swap32(alac->setinfo_82); | ||
91 | #endif | ||
92 | ptr += 4; | 80 | ptr += 4; |
93 | alac->setinfo_86 = *(uint32_t*)ptr; | 81 | alac->setinfo_86 = get_uint32be(ptr); |
94 | #ifdef ROCKBOX_LITTLE_ENDIAN | ||
95 | _Swap32(alac->setinfo_86); | ||
96 | #endif | ||
97 | ptr += 4; | 82 | ptr += 4; |
98 | alac->setinfo_8a_rate = *(uint32_t*)ptr; | 83 | alac->setinfo_8a_rate = get_uint32be(ptr); |
99 | #ifdef ROCKBOX_LITTLE_ENDIAN | ||
100 | _Swap32(alac->setinfo_8a_rate); | ||
101 | #endif | ||
102 | ptr += 4; | 84 | ptr += 4; |
103 | } | 85 | } |
104 | 86 | ||