diff options
Diffstat (limited to 'apps/codecs/libwavpack/float.c')
-rw-r--r-- | apps/codecs/libwavpack/float.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/apps/codecs/libwavpack/float.c b/apps/codecs/libwavpack/float.c index 3e678e824d..2208e616d8 100644 --- a/apps/codecs/libwavpack/float.c +++ b/apps/codecs/libwavpack/float.c | |||
@@ -1,8 +1,8 @@ | |||
1 | //////////////////////////////////////////////////////////////////////////// | 1 | //////////////////////////////////////////////////////////////////////////// |
2 | // **** WAVPACK **** // | 2 | // **** WAVPACK **** // |
3 | // Hybrid Lossless Wavefile Compressor // | 3 | // Hybrid Lossless Wavefile Compressor // |
4 | // Copyright (c) 1998 - 2004 Conifer Software. // | 4 | // Copyright (c) 1998 - 2004 Conifer Software. // |
5 | // All Rights Reserved. // | 5 | // All Rights Reserved. // |
6 | // Distributed under the BSD Software License (see license.txt) // | 6 | // Distributed under the BSD Software License (see license.txt) // |
7 | //////////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////////// |
8 | 8 | ||
@@ -16,7 +16,7 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd) | |||
16 | char *byteptr = wpmd->data; | 16 | char *byteptr = wpmd->data; |
17 | 17 | ||
18 | if (bytecnt != 4) | 18 | if (bytecnt != 4) |
19 | return FALSE; | 19 | return FALSE; |
20 | 20 | ||
21 | wps->float_flags = *byteptr++; | 21 | wps->float_flags = *byteptr++; |
22 | wps->float_shift = *byteptr++; | 22 | wps->float_shift = *byteptr++; |
@@ -28,35 +28,35 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd) | |||
28 | void float_values (WavpackStream *wps, long *values, long num_values) | 28 | void float_values (WavpackStream *wps, long *values, long num_values) |
29 | { | 29 | { |
30 | while (num_values--) { | 30 | while (num_values--) { |
31 | int shift_count = 0, exp = wps->float_max_exp; | 31 | int shift_count = 0, exp = wps->float_max_exp; |
32 | f32 outval = { 0, 0, 0 }; | 32 | f32 outval = { 0, 0, 0 }; |
33 | 33 | ||
34 | if (*values) { | 34 | if (*values) { |
35 | *values <<= wps->float_shift; | 35 | *values <<= wps->float_shift; |
36 | 36 | ||
37 | if (*values < 0) { | 37 | if (*values < 0) { |
38 | *values = -*values; | 38 | *values = -*values; |
39 | outval.sign = 1; | 39 | outval.sign = 1; |
40 | } | 40 | } |
41 | 41 | ||
42 | if (*values == 0x1000000) | 42 | if (*values == 0x1000000) |
43 | outval.exponent = 255; | 43 | outval.exponent = 255; |
44 | else { | 44 | else { |
45 | if (exp) | 45 | if (exp) |
46 | while (!(*values & 0x800000) && --exp) { | 46 | while (!(*values & 0x800000) && --exp) { |
47 | shift_count++; | 47 | shift_count++; |
48 | *values <<= 1; | 48 | *values <<= 1; |
49 | } | 49 | } |
50 | 50 | ||
51 | if (shift_count && (wps->float_flags & FLOAT_SHIFT_ONES)) | 51 | if (shift_count && (wps->float_flags & FLOAT_SHIFT_ONES)) |
52 | *values |= ((1 << shift_count) - 1); | 52 | *values |= ((1 << shift_count) - 1); |
53 | 53 | ||
54 | outval.mantissa = *values; | 54 | outval.mantissa = *values; |
55 | outval.exponent = exp; | 55 | outval.exponent = exp; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | * (f32 *) values++ = outval; | 59 | * (f32 *) values++ = outval; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
@@ -66,18 +66,18 @@ void float_normalize (long *values, long num_values, int delta_exp) | |||
66 | int exp; | 66 | int exp; |
67 | 67 | ||
68 | if (!delta_exp) | 68 | if (!delta_exp) |
69 | return; | 69 | return; |
70 | 70 | ||
71 | while (num_values--) { | 71 | while (num_values--) { |
72 | if ((exp = fvalues->exponent) == 0 || exp + delta_exp <= 0) | 72 | if ((exp = fvalues->exponent) == 0 || exp + delta_exp <= 0) |
73 | *fvalues = fzero; | 73 | *fvalues = fzero; |
74 | else if (exp == 255 || (exp += delta_exp) >= 255) { | 74 | else if (exp == 255 || (exp += delta_exp) >= 255) { |
75 | fvalues->exponent = 255; | 75 | fvalues->exponent = 255; |
76 | fvalues->mantissa = 0; | 76 | fvalues->mantissa = 0; |
77 | } | 77 | } |
78 | else | 78 | else |
79 | fvalues->exponent = exp; | 79 | fvalues->exponent = exp; |
80 | 80 | ||
81 | fvalues++; | 81 | fvalues++; |
82 | } | 82 | } |
83 | } | 83 | } |