forked from len0rd/rockbox
Added lossless encoding to WavPack library. Also made a few changes to
decoding stuff in preparation for future optimization and eliminated all tabs. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7009 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1d5f07b0a6
commit
dacbc16d5b
9 changed files with 2034 additions and 977 deletions
|
@ -1,8 +1,8 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2004 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2004 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -16,7 +16,7 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
char *byteptr = wpmd->data;
|
||||
|
||||
if (bytecnt != 4)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
wps->float_flags = *byteptr++;
|
||||
wps->float_shift = *byteptr++;
|
||||
|
@ -28,35 +28,35 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
void float_values (WavpackStream *wps, long *values, long num_values)
|
||||
{
|
||||
while (num_values--) {
|
||||
int shift_count = 0, exp = wps->float_max_exp;
|
||||
f32 outval = { 0, 0, 0 };
|
||||
int shift_count = 0, exp = wps->float_max_exp;
|
||||
f32 outval = { 0, 0, 0 };
|
||||
|
||||
if (*values) {
|
||||
*values <<= wps->float_shift;
|
||||
if (*values) {
|
||||
*values <<= wps->float_shift;
|
||||
|
||||
if (*values < 0) {
|
||||
*values = -*values;
|
||||
outval.sign = 1;
|
||||
}
|
||||
if (*values < 0) {
|
||||
*values = -*values;
|
||||
outval.sign = 1;
|
||||
}
|
||||
|
||||
if (*values == 0x1000000)
|
||||
outval.exponent = 255;
|
||||
else {
|
||||
if (exp)
|
||||
while (!(*values & 0x800000) && --exp) {
|
||||
shift_count++;
|
||||
*values <<= 1;
|
||||
}
|
||||
if (*values == 0x1000000)
|
||||
outval.exponent = 255;
|
||||
else {
|
||||
if (exp)
|
||||
while (!(*values & 0x800000) && --exp) {
|
||||
shift_count++;
|
||||
*values <<= 1;
|
||||
}
|
||||
|
||||
if (shift_count && (wps->float_flags & FLOAT_SHIFT_ONES))
|
||||
*values |= ((1 << shift_count) - 1);
|
||||
if (shift_count && (wps->float_flags & FLOAT_SHIFT_ONES))
|
||||
*values |= ((1 << shift_count) - 1);
|
||||
|
||||
outval.mantissa = *values;
|
||||
outval.exponent = exp;
|
||||
}
|
||||
}
|
||||
outval.mantissa = *values;
|
||||
outval.exponent = exp;
|
||||
}
|
||||
}
|
||||
|
||||
* (f32 *) values++ = outval;
|
||||
* (f32 *) values++ = outval;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,18 +66,18 @@ void float_normalize (long *values, long num_values, int delta_exp)
|
|||
int exp;
|
||||
|
||||
if (!delta_exp)
|
||||
return;
|
||||
return;
|
||||
|
||||
while (num_values--) {
|
||||
if ((exp = fvalues->exponent) == 0 || exp + delta_exp <= 0)
|
||||
*fvalues = fzero;
|
||||
else if (exp == 255 || (exp += delta_exp) >= 255) {
|
||||
fvalues->exponent = 255;
|
||||
fvalues->mantissa = 0;
|
||||
}
|
||||
else
|
||||
fvalues->exponent = exp;
|
||||
if ((exp = fvalues->exponent) == 0 || exp + delta_exp <= 0)
|
||||
*fvalues = fzero;
|
||||
else if (exp == 255 || (exp += delta_exp) >= 255) {
|
||||
fvalues->exponent = 255;
|
||||
fvalues->mantissa = 0;
|
||||
}
|
||||
else
|
||||
fvalues->exponent = exp;
|
||||
|
||||
fvalues++;
|
||||
fvalues++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue