summaryrefslogtreecommitdiffstats
path: root/libhb/declpcm.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-04-08 16:49:24 +0000
committerjstebbins <[email protected]>2011-04-08 16:49:24 +0000
commitf20621c2d30ad805dfefcab335506f660a133ffe (patch)
tree5d1a3e9e844b94584790b7f002c3fdec39081326 /libhb/declpcm.c
parentde122b044e99b0ad1abff0ba51e1a4d9e7d8b020 (diff)
Change internal audio representation range
...from float [-32768...32767] to float [-1.0...1.0] Using the range [-1.0..1.0] requires fewer translations of the range for our various encoders and decoders. This also gets rid of a hacky translation from float to int to float in decavcodec audio decoding. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3908 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/declpcm.c')
-rw-r--r--libhb/declpcm.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libhb/declpcm.c b/libhb/declpcm.c
index f47fe87b9..fc120a333 100644
--- a/libhb/declpcm.c
+++ b/libhb/declpcm.c
@@ -198,7 +198,7 @@ static hb_buffer_t *Decode( hb_work_object_t *w )
case 16: // 2 byte, big endian, signed (the right shift sign extends)
while ( --count >= 0 )
{
- *odat++ = ( (int)( frm[0] << 24 ) >> 16 ) | frm[1];
+ *odat++ = (float)(( (int)( frm[0] << 24 ) >> 16 ) | frm[1]) / 32768.0;
frm += 2;
}
break;
@@ -209,9 +209,9 @@ static hb_buffer_t *Decode( hb_work_object_t *w )
while ( --count >= 0 )
{
*odat++ = (float)( ( (int)( frm[0] << 24 ) >> 12 ) |
- ( frm[1] << 4 ) | ( frm[2] >> 4 ) ) / 16.;
+ ( frm[1] << 4 ) | ( frm[2] >> 4 ) ) / (16. * 32768.0);
*odat++ = (float)( ( (int)( frm[2] << 28 ) >> 16 ) |
- ( frm[3] << 8 ) | frm[4] ) / 16.;
+ ( frm[3] << 8 ) | frm[4] ) / (16. * 32768.0);
frm += 5;
}
break;
@@ -227,13 +227,13 @@ static hb_buffer_t *Decode( hb_work_object_t *w )
while ( --count >= 0 )
{
*odat++ = (float)( ( (int)( frm[0] << 24 ) >> 8 ) |
- ( frm[1] << 8 ) | frm[8] ) / 256.;
+ ( frm[1] << 8 ) | frm[8] ) / (256. * 32768.0);
*odat++ = (float)( ( (int)( frm[2] << 24 ) >> 8 ) |
- ( frm[3] << 8 ) | frm[9] ) / 256.;
+ ( frm[3] << 8 ) | frm[9] ) / (256. * 32768.0);
*odat++ = (float)( ( (int)( frm[4] << 24 ) >> 8 ) |
- ( frm[5] << 8 ) | frm[10] ) / 256.;
+ ( frm[5] << 8 ) | frm[10] ) / (256. * 32768.0);
*odat++ = (float)( ( (int)( frm[6] << 24 ) >> 8 ) |
- ( frm[7] << 8 ) | frm[11] ) / 256.;
+ ( frm[7] << 8 ) | frm[11] ) / (256. * 32768.0);
frm += 12;
}
break;