summaryrefslogtreecommitdiff
path: root/lib/rbcodec
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec')
-rw-r--r--lib/rbcodec/codecs/mp3_enc.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/rbcodec/codecs/mp3_enc.c b/lib/rbcodec/codecs/mp3_enc.c
index 2f5528f74c..f765e6bba6 100644
--- a/lib/rbcodec/codecs/mp3_enc.c
+++ b/lib/rbcodec/codecs/mp3_enc.c
@@ -2082,6 +2082,34 @@ static bool init_mp3_encoder_engine(int sample_rate,
2082 return true; 2082 return true;
2083} 2083}
2084 2084
2085static inline void to_mono(uint16_t **samp)
2086{
2087 int16_t l = **samp;
2088 int16_t r = *(*samp+1);
2089 int32_t m;
2090
2091 switch(cfg.rec_mono_mode)
2092 {
2093 case 1:
2094 /* mono = L */
2095 m = l;
2096 break;
2097 case 2:
2098 /* mono = R */
2099 m = r;
2100 break;
2101 case 0:
2102 default:
2103 /* mono = (L+R)/2 */
2104 m = l + r + err;
2105 err = m & 1;
2106 m >>= 1;
2107 break;
2108 }
2109 *(*samp)++ = (uint16_t)m;
2110 *(*samp)++ = (uint16_t)m;
2111} /* to_mono */
2112
2085STATICIRAM void to_mono_mm(void) ICODE_ATTR; 2113STATICIRAM void to_mono_mm(void) ICODE_ATTR;
2086STATICIRAM void to_mono_mm(void) 2114STATICIRAM void to_mono_mm(void)
2087{ 2115{
@@ -2091,34 +2119,6 @@ STATICIRAM void to_mono_mm(void)
2091 uint16_t *samp = &mfbuf[2*512]; 2119 uint16_t *samp = &mfbuf[2*512];
2092 uint16_t *samp_end = samp + 2*samp_per_frame; 2120 uint16_t *samp_end = samp + 2*samp_per_frame;
2093 2121
2094 inline void to_mono(uint16_t **samp)
2095 {
2096 int16_t l = **samp;
2097 int16_t r = *(*samp+1);
2098 int32_t m;
2099
2100 switch(cfg.rec_mono_mode)
2101 {
2102 case 1:
2103 /* mono = L */
2104 m = l;
2105 break;
2106 case 2:
2107 /* mono = R */
2108 m = r;
2109 break;
2110 case 0:
2111 default:
2112 /* mono = (L+R)/2 */
2113 m = l + r + err;
2114 err = m & 1;
2115 m >>= 1;
2116 break;
2117 }
2118 *(*samp)++ = (uint16_t)m;
2119 *(*samp)++ = (uint16_t)m;
2120 } /* to_mono */
2121
2122 do 2122 do
2123 { 2123 {
2124 to_mono(&samp); 2124 to_mono(&samp);