summaryrefslogtreecommitdiff
path: root/apps/codecs/aiff_enc.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2008-10-08 22:18:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2008-10-08 22:18:16 +0000
commit528fe442fc6e6e077172b2e8a3b586a3ce96d16b (patch)
tree4985fe6f102727419862cf58bcb5aa8a7d736f11 /apps/codecs/aiff_enc.c
parentcb1173cedd4eb1c8648420a3926a591995390537 (diff)
New recording setting to configure how mono recordings are made. Previously, this was always L+R, which was kinda silly if your signal was on L only. This setting allows for L, R or L+R. SWCODEC only for now, to be added for HWCODEC (although that will only be L and L+R probably)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18745 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/aiff_enc.c')
-rw-r--r--apps/codecs/aiff_enc.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c
index 7e085d5721..78c25b8711 100644
--- a/apps/codecs/aiff_enc.c
+++ b/apps/codecs/aiff_enc.c
@@ -72,6 +72,7 @@ struct aiff_header aiff_header =
/* (*) updated when finalizing file */
static int num_channels IBSS_ATTR;
+static int rec_mono_mode IBSS_ATTR;
static uint32_t sample_rate;
static uint32_t enc_size;
static int32_t err IBSS_ATTR;
@@ -226,16 +227,37 @@ 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);
+ switch(rec_mono_mode)
+ {
+ case 1:
+ /* mono = L */
+ lr1 = *(*src)++;
+ lr1 = lr1 >> 16;
+ lr2 = *(*src)++;
+ lr2 = lr2 >> 16;
+ break;
+ case 2:
+ /* mono = R */
+ lr1 = *(*src)++;
+ lr1 = (int16_t)lr1;
+ lr2 = *(*src)++;
+ lr2 = (int16_t)lr2;
+ break;
+ case 0:
+ default:
+ /* mono = (L+R)/2 */
+ 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;
+ break;
+ }
+ *(*dst)++ = swap_odd_even_be32((lr1 << 16) | (uint16_t)lr2);
} /* sample_to_mono */
STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) ICODE_ATTR;
@@ -316,6 +338,7 @@ static bool init_encoder(void)
sample_rate = inputs.sample_rate;
num_channels = inputs.num_channels;
+ rec_mono_mode = inputs.rec_mono_mode;
err = 0;
/* configure the buffer system */