diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-03-29 01:55:47 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-03-29 01:55:47 +0000 |
commit | 62e0a516a085de93ec0fc50cfff6e346d80ccebb (patch) | |
tree | 2f37c8830318764bf49106b82a904b6c8541fc1f /apps/codecs | |
parent | 583caa867b052e4287bf531eb9576716ee1ed5a4 (diff) |
Accept FS#6918 - Remove Nested Functions by Tim Ross. Adjust some names. Hunt down and remove the remaining ones in the recording system as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12955 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/aiff_enc.c | 48 | ||||
-rw-r--r-- | apps/codecs/wav_enc.c | 48 | ||||
-rw-r--r-- | apps/codecs/wavpack_enc.c | 78 |
3 files changed, 87 insertions, 87 deletions
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c index 1de25a4915..2292bcc275 100644 --- a/apps/codecs/aiff_enc.c +++ b/apps/codecs/aiff_enc.c @@ -221,6 +221,22 @@ STATICIRAM void enc_events_callback(enum enc_events event, void *data) } /* enc_events_callback */ /* convert native pcm samples to aiff format samples */ +static inline void sample_to_mono(uint32_t **src, uint32_t **dst) +{ + int32_t lr1, lr2; + + lr1 = *(*src)++; + lr1 = (int16_t)lr1 + (lr1 >> 16) + err; + err = lr1 & 1; + lr1 >>= 1; + + lr2 = *(*src)++; + lr2 = (int16_t)lr2 + (lr2 >> 16) + err; + err = lr2 & 1; + lr2 >>= 1; + *(*dst)++ = swap_odd_even_le32((lr1 << 16) | (uint16_t)lr2); +} /* sample_to_mono */ + STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) ICODE_ATTR; STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) { @@ -238,32 +254,16 @@ STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) */ uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; - inline void to_mono(uint32_t **src, uint32_t **dst) - { - int32_t lr1, lr2; - - lr1 = *(*src)++; - lr1 = (int16_t)lr1 + (lr1 >> 16) + err; - err = lr1 & 1; - lr1 >>= 1; - - lr2 = *(*src)++; - lr2 = (int16_t)lr2 + (lr2 >> 16) + err; - err = lr2 & 1; - lr2 >>= 1; - *(*dst)++ = swap_odd_even_le32((lr1 << 16) | (uint16_t)lr2); - } /* to_mono */ - do { - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); } while (src < src_end); } diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c index e14b04ddd3..ff77f137d2 100644 --- a/apps/codecs/wav_enc.c +++ b/apps/codecs/wav_enc.c @@ -209,6 +209,22 @@ STATICIRAM void enc_events_callback(enum enc_events event, void *data) } /* enc_events_callback */ /* convert native pcm samples to wav format samples */ +static inline void sample_to_mono(uint32_t **src, uint32_t **dst) +{ + int32_t lr1, lr2; + + lr1 = *(*src)++; + lr1 = (int16_t)lr1 + (lr1 >> 16) + err; + err = lr1 & 1; + lr1 >>= 1; + + lr2 = *(*src)++; + lr2 = (int16_t)lr2 + (lr2 >> 16) + err; + err = lr2 & 1; + lr2 >>= 1; + *(*dst)++ = swap_odd_even_be32((lr1 << 16) | (uint16_t)lr2); +} /* sample_to_mono */ + STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) ICODE_ATTR; STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) { @@ -226,32 +242,16 @@ STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) */ uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; - inline void to_mono(uint32_t **src, uint32_t **dst) - { - int32_t lr1, lr2; - - lr1 = *(*src)++; - lr1 = (int16_t)lr1 + (lr1 >> 16) + err; - err = lr1 & 1; - lr1 >>= 1; - - lr2 = *(*src)++; - lr2 = (int16_t)lr2 + (lr2 >> 16) + err; - err = lr2 & 1; - lr2 >>= 1; - *(*dst)++ = swap_odd_even_be32((lr1 << 16) | (uint16_t)lr2); - } /* to_mono */ - do { - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); - to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); } while (src < src_end); } diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c index de8fe80423..7b6484d6cf 100644 --- a/apps/codecs/wavpack_enc.c +++ b/apps/codecs/wavpack_enc.c @@ -99,6 +99,25 @@ static const struct riff_header riff_header = /* (*) updated during ENC_END_FILE event */ }; +static inline void sample_to_int32_mono(int32_t **src, int32_t **dst) +{ + int32_t t = *(*src)++; + /* endianness irrelevant */ + t = (int16_t)t + (t >> 16) + err; + err = t & 1; + *(*dst)++ = t >> 1; +} /* sample_to_int32_mono */ + +static inline void sample_to_int32_stereo(int32_t **src, int32_t **dst) +{ + int32_t t = *(*src)++; +#ifdef ROCKBOX_BIG_ENDIAN + *(*dst)++ = t >> 16, *(*dst)++ = (int16_t)t; +#else + *(*dst)++ = (int16_t)t, *(*dst)++ = t >> 16; +#endif +} /* sample_to_int32_stereo */ + STATICIRAM void chunk_to_int32(int32_t *src) ICODE_ATTR; STATICIRAM void chunk_to_int32(int32_t *src) { @@ -123,28 +142,19 @@ STATICIRAM void chunk_to_int32(int32_t *src) * |llllllllllllllll|rrrrrrrrrrrrrrrr| => * |mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm| */ - inline void to_int32(int32_t **src, int32_t **dst) - { - int32_t t = *(*src)++; - /* endianness irrelevant */ - t = (int16_t)t + (t >> 16) + err; - err = t & 1; - *(*dst)++ = t >> 1; - } /* to_int32 */ - do { /* read 10 longs and write 10 longs */ - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); } while(src < src_end); @@ -156,29 +166,19 @@ STATICIRAM void chunk_to_int32(int32_t *src) * |llllllllllllllll|rrrrrrrrrrrrrrrr| => * |llllllllllllllllllllllllllllllll|rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr| */ - inline void to_int32(int32_t **src, int32_t **dst) - { - int32_t t = *(*src)++; -#ifdef ROCKBOX_BIG_ENDIAN - *(*dst)++ = t >> 16, *(*dst)++ = (int16_t)t; -#else - *(*dst)++ = (int16_t)t, *(*dst)++ = t >> 16; -#endif - } /* to_int32 */ - do { /* read 10 longs and write 20 longs */ - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); - to_int32(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); } while (src < src_end); |