diff options
author | Dave Bryant <bryant@rockbox.org> | 2007-01-08 04:24:32 +0000 |
---|---|---|
committer | Dave Bryant <bryant@rockbox.org> | 2007-01-08 04:24:32 +0000 |
commit | 2446b22db971668f8d6ba5cb2361aabbda286da1 (patch) | |
tree | 3b9bcf9c273783a1ee0b273f7f56d72f92077754 /apps/codecs/libwavpack/wavpack.h | |
parent | 5693622cd4de1d3dff162295690ecb25d29a2937 (diff) | |
download | rockbox-2446b22db971668f8d6ba5cb2361aabbda286da1.tar.gz rockbox-2446b22db971668f8d6ba5cb2361aabbda286da1.zip |
Update libwavpack with latest changes from the tiny_encoder. This allows
playback of floating-point audio files, fixes a obscure decoding bug, and
improves encoding speed somewhat.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11944 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwavpack/wavpack.h')
-rw-r--r-- | apps/codecs/libwavpack/wavpack.h | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h index 3128328e49..a000438081 100644 --- a/apps/codecs/libwavpack/wavpack.h +++ b/apps/codecs/libwavpack/wavpack.h | |||
@@ -18,17 +18,6 @@ typedef unsigned char uchar; | |||
18 | typedef unsigned short ushort; | 18 | typedef unsigned short ushort; |
19 | typedef unsigned int uint; | 19 | typedef unsigned int uint; |
20 | 20 | ||
21 | // This structure is used to access the individual fields of 32-bit ieee | ||
22 | // floating point numbers. This will not be compatible with compilers that | ||
23 | // allocate bit fields from the most significant bits, although I'm not sure | ||
24 | // how common that is. | ||
25 | |||
26 | typedef struct { | ||
27 | unsigned mantissa : 23; | ||
28 | unsigned exponent : 8; | ||
29 | unsigned sign : 1; | ||
30 | } f32; | ||
31 | |||
32 | #include <stdio.h> | 21 | #include <stdio.h> |
33 | 22 | ||
34 | #define FALSE 0 | 23 | #define FALSE 0 |
@@ -281,8 +270,14 @@ uint32_t bs_close_write (Bitstream *bs); | |||
281 | (bs)->bc += 8; \ | 270 | (bs)->bc += 8; \ |
282 | } \ | 271 | } \ |
283 | *(value) = (bs)->sr; \ | 272 | *(value) = (bs)->sr; \ |
284 | (bs)->sr >>= (nbits); \ | 273 | if ((bs)->bc > 32) { \ |
285 | (bs)->bc -= (nbits); \ | 274 | (bs)->bc -= (nbits); \ |
275 | (bs)->sr = *((bs)->ptr) >> (8 - (bs)->bc); \ | ||
276 | } \ | ||
277 | else { \ | ||
278 | (bs)->bc -= (nbits); \ | ||
279 | (bs)->sr >>= (nbits); \ | ||
280 | } \ | ||
286 | } | 281 | } |
287 | 282 | ||
288 | #define putbit(bit, bs) { if (bit) (bs)->sr |= (1 << (bs)->bc); \ | 283 | #define putbit(bit, bs) { if (bit) (bs)->sr |= (1 << (bs)->bc); \ |
@@ -319,10 +314,15 @@ uint32_t bs_close_write (Bitstream *bs); | |||
319 | void little_endian_to_native (void *data, char *format); | 314 | void little_endian_to_native (void *data, char *format); |
320 | void native_to_little_endian (void *data, char *format); | 315 | void native_to_little_endian (void *data, char *format); |
321 | 316 | ||
322 | // these macros implement the weight application and update operations | 317 | // These macros implement the weight application and update operations |
323 | // that are at the heart of the decorrelation loops | 318 | // that are at the heart of the decorrelation loops. Note that when there |
319 | // are several alternative versions of the same macro (marked with PERFCOND) | ||
320 | // then the versions are functionally equivalent with respect to WavPack | ||
321 | // decoding and the user should choose the one that provides the best | ||
322 | // performance. This may be easier to check when NOT using the assembly | ||
323 | // language optimizations. | ||
324 | 324 | ||
325 | #if 0 // PERFCOND | 325 | #if 1 // PERFCOND |
326 | #define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10) | 326 | #define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10) |
327 | #else | 327 | #else |
328 | #define apply_weight_i(weight, sample) ((((weight * sample) >> 8) + 2) >> 2) | 328 | #define apply_weight_i(weight, sample) ((((weight * sample) >> 8) + 2) >> 2) |
@@ -340,15 +340,18 @@ void native_to_little_endian (void *data, char *format); | |||
340 | 340 | ||
341 | #if 0 // PERFCOND | 341 | #if 0 // PERFCOND |
342 | #define update_weight(weight, delta, source, result) \ | 342 | #define update_weight(weight, delta, source, result) \ |
343 | if (source && result) weight -= ((((source ^ result) >> 30) & 2) - 1) * delta; | 343 | if (source && result) { int32_t s = (int32_t) (source ^ result) >> 31; weight = (delta ^ s) + (weight - s); } |
344 | #elif 1 | ||
345 | #define update_weight(weight, delta, source, result) \ | ||
346 | if (source && result) weight += (((source ^ result) >> 30) | 1) * delta | ||
344 | #else | 347 | #else |
345 | #define update_weight(weight, delta, source, result) \ | 348 | #define update_weight(weight, delta, source, result) \ |
346 | if (source && result) (source ^ result) < 0 ? (weight -= delta) : (weight += delta); | 349 | if (source && result) (source ^ result) < 0 ? (weight -= delta) : (weight += delta) |
347 | #endif | 350 | #endif |
348 | 351 | ||
349 | #define update_weight_clip(weight, delta, source, result) \ | 352 | #define update_weight_clip(weight, delta, source, result) \ |
350 | if (source && result && ((source ^ result) < 0 ? (weight -= delta) < -1024 : (weight += delta) > 1024)) \ | 353 | if (source && result && ((source ^ result) < 0 ? (weight -= delta) < -1024 : (weight += delta) > 1024)) \ |
351 | weight = weight < 0 ? -1024 : 1024; | 354 | weight = weight < 0 ? -1024 : 1024 |
352 | 355 | ||
353 | // unpack.c | 356 | // unpack.c |
354 | 357 | ||