aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Claesson <andreas.claesson@gmail.com>2005-05-31 16:33:46 +0000
committerAndreas Claesson <andreas.claesson@gmail.com>2005-05-31 16:33:46 +0000
commit5d3c14e2086654e7fa9fe3584ec1434415db05dd (patch)
tree4b7d4f026cadd1b9714637cb5753d667ba8f15e8 /src
parent521042d7a6af0299db9314b928f450e71341317d (diff)
downloadmpd-svn/ancl.tar.gz
mpd-svn/ancl.tar.xz
mpd-svn/ancl.zip
Some none critical fixes and cleanup in pcm_utils.csvn/ancl
git-svn-id: https://svn.musicpd.org/mpd/branches/ancl@3300 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/pcm_utils.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/pcm_utils.c b/src/pcm_utils.c
index 87df0f026..2851bbdf9 100644
--- a/src/pcm_utils.c
+++ b/src/pcm_utils.c
@@ -212,7 +212,6 @@ ERROR("pcm_changeBufferEndianess\n");
break;
case 32:
/* I'm not sure if this code is correct */
- /* I guess it is OK for 32 bit int, but how about float? */
while(bufferSize) {
mpd_uint8 temp = *buffer;
mpd_uint8 temp1 = *(buffer+1);
@@ -283,7 +282,6 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1,
{
mpd_fixed_t * buffer32_1 = (mpd_fixed_t *)buffer1;
mpd_fixed_t * buffer32_2 = (mpd_fixed_t *)buffer2;
- mpd_fixed_t temp;
int samples1 = bufferSize1 >> 2;
int samples2 = bufferSize2 >> 2;
int shift = 10;
@@ -310,6 +308,7 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1,
}
/* lower multiplicator to minimize audio resolution loss */
+ /* TODO? force a maximum shift size? */
while((vol1>31 || !(vol1 & 1)) && (vol2>31 || !(vol2 & 1)) && shift) {
vol1 >>= 1;
vol2 >>= 1;
@@ -319,8 +318,8 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1,
/* scale and add samples */
/* no check for overflow needed - we trust our headroom is enough */
while(samples1-- && samples2--) {
- temp = (*buffer32_1 >> shift) * vol1 +
- (*buffer32_2 >> shift) * vol2;
+ mpd_fixed_t temp = (*buffer32_1 >> shift) * vol1 +
+ (*buffer32_2 >> shift) * vol2;
*buffer32_1 = temp;
buffer32_1++;
buffer32_2++;
@@ -380,7 +379,8 @@ void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t
dataConv = inBuffer;
}
else {
- fracBits = 28; /* use 28 bits as default */
+ /* convert to same fracBits as output or use 28 as default */
+ fracBits = outFormat->fracBits ? outFormat->fracBits : 28;
dataConv = convBuffer;
pcm_convertToMpdFixed(inFormat, inBuffer, inSamples,
dataConv, fracBits);
@@ -445,20 +445,24 @@ void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t
/****** convert to output format ******/
- /* if outformat is mpd_fixed_t then we are done ?!
- * TODO take care of case when in and out have different fracBits */
+ /* if outformat is mpd_fixed_t */
if(outFormat->fracBits==fracBits) {
if(outFormat->bits==32) {
if(outBuffer != dataConv)
- memcpy(outBuffer, dataConv, outSamples << 2);
+ memcpy(outBuffer, dataConv, outSize);
return;
}
else {
- ERROR("%i bit float are not supported for conversion!\n",
+ ERROR("%i bit mpd_fixed_t not supported for conversion!\n",
outFormat->bits);
exit(EXIT_FAILURE);
}
- }
+ }
+ else if(outFormat->fracBits) {
+ /* TODO case when in and out have different fracBits */
+ ERROR("Conversion between different fracBits not supported yet!\n");
+ exit(EXIT_FAILURE);
+ }
/* convert to regular integer while adding dither and checking range */
pcm_convertToIntWithDither(outFormat->bits,