diff options
Diffstat (limited to 'apps/codecs/libwavpack')
-rw-r--r-- | apps/codecs/libwavpack/bits.c | 20 | ||||
-rw-r--r-- | apps/codecs/libwavpack/float.c | 4 | ||||
-rw-r--r-- | apps/codecs/libwavpack/metadata.c | 12 | ||||
-rw-r--r-- | apps/codecs/libwavpack/pack.c | 48 | ||||
-rw-r--r-- | apps/codecs/libwavpack/unpack.c | 68 | ||||
-rw-r--r-- | apps/codecs/libwavpack/wavpack.h | 67 | ||||
-rw-r--r-- | apps/codecs/libwavpack/words.c | 44 | ||||
-rw-r--r-- | apps/codecs/libwavpack/wputils.c | 58 |
8 files changed, 160 insertions, 161 deletions
diff --git a/apps/codecs/libwavpack/bits.c b/apps/codecs/libwavpack/bits.c index bf056a9392..0a148e123f 100644 --- a/apps/codecs/libwavpack/bits.c +++ b/apps/codecs/libwavpack/bits.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | static void bs_read (Bitstream *bs); | 25 | static void bs_read (Bitstream *bs); |
26 | 26 | ||
27 | void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, ulong file_bytes) | 27 | void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes) |
28 | { | 28 | { |
29 | CLEAR (*bs); | 29 | CLEAR (*bs); |
30 | bs->buf = buffer_start; | 30 | bs->buf = buffer_start; |
@@ -49,7 +49,7 @@ void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_s | |||
49 | static void bs_read (Bitstream *bs) | 49 | static void bs_read (Bitstream *bs) |
50 | { | 50 | { |
51 | if (bs->file && bs->file_bytes) { | 51 | if (bs->file && bs->file_bytes) { |
52 | ulong bytes_read, bytes_to_read = bs->end - bs->buf; | 52 | uint32_t bytes_read, bytes_to_read = bs->end - bs->buf; |
53 | 53 | ||
54 | if (bytes_to_read > bs->file_bytes) | 54 | if (bytes_to_read > bs->file_bytes) |
55 | bytes_to_read = bs->file_bytes; | 55 | bytes_to_read = bs->file_bytes; |
@@ -100,12 +100,12 @@ static void bs_write (Bitstream *bs) | |||
100 | // This function forces a flushing write of the specified BitStream, and | 100 | // This function forces a flushing write of the specified BitStream, and |
101 | // returns the total number of bytes written into the buffer. | 101 | // returns the total number of bytes written into the buffer. |
102 | 102 | ||
103 | ulong bs_close_write (Bitstream *bs) | 103 | uint32_t bs_close_write (Bitstream *bs) |
104 | { | 104 | { |
105 | ulong bytes_written; | 105 | uint32_t bytes_written; |
106 | 106 | ||
107 | if (bs->error) | 107 | if (bs->error) |
108 | return (ulong) -1; | 108 | return (uint32_t) -1; |
109 | 109 | ||
110 | while (bs->bc || ((bs->ptr - bs->buf) & 1)) putbit_1 (bs); | 110 | while (bs->bc || ((bs->ptr - bs->buf) & 1)) putbit_1 (bs); |
111 | bytes_written = bs->ptr - bs->buf; | 111 | bytes_written = bs->ptr - bs->buf; |
@@ -118,13 +118,13 @@ ulong bs_close_write (Bitstream *bs) | |||
118 | void little_endian_to_native (void *data, char *format) | 118 | void little_endian_to_native (void *data, char *format) |
119 | { | 119 | { |
120 | uchar *cp = (uchar *) data; | 120 | uchar *cp = (uchar *) data; |
121 | long temp; | 121 | int32_t temp; |
122 | 122 | ||
123 | while (*format) { | 123 | while (*format) { |
124 | switch (*format) { | 124 | switch (*format) { |
125 | case 'L': | 125 | case 'L': |
126 | temp = cp [0] + ((long) cp [1] << 8) + ((long) cp [2] << 16) + ((long) cp [3] << 24); | 126 | temp = cp [0] + ((int32_t) cp [1] << 8) + ((int32_t) cp [2] << 16) + ((int32_t) cp [3] << 24); |
127 | * (long *) cp = temp; | 127 | * (int32_t *) cp = temp; |
128 | cp += 4; | 128 | cp += 4; |
129 | break; | 129 | break; |
130 | 130 | ||
@@ -148,12 +148,12 @@ void little_endian_to_native (void *data, char *format) | |||
148 | void native_to_little_endian (void *data, char *format) | 148 | void native_to_little_endian (void *data, char *format) |
149 | { | 149 | { |
150 | uchar *cp = (uchar *) data; | 150 | uchar *cp = (uchar *) data; |
151 | long temp; | 151 | int32_t temp; |
152 | 152 | ||
153 | while (*format) { | 153 | while (*format) { |
154 | switch (*format) { | 154 | switch (*format) { |
155 | case 'L': | 155 | case 'L': |
156 | temp = * (long *) cp; | 156 | temp = * (int32_t *) cp; |
157 | *cp++ = (uchar) temp; | 157 | *cp++ = (uchar) temp; |
158 | *cp++ = (uchar) (temp >> 8); | 158 | *cp++ = (uchar) (temp >> 8); |
159 | *cp++ = (uchar) (temp >> 16); | 159 | *cp++ = (uchar) (temp >> 16); |
diff --git a/apps/codecs/libwavpack/float.c b/apps/codecs/libwavpack/float.c index 2208e616d8..9d3a82c001 100644 --- a/apps/codecs/libwavpack/float.c +++ b/apps/codecs/libwavpack/float.c | |||
@@ -25,7 +25,7 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd) | |||
25 | return TRUE; | 25 | return TRUE; |
26 | } | 26 | } |
27 | 27 | ||
28 | void float_values (WavpackStream *wps, long *values, long num_values) | 28 | void float_values (WavpackStream *wps, int32_t *values, int32_t 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; |
@@ -60,7 +60,7 @@ void float_values (WavpackStream *wps, long *values, long num_values) | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | void float_normalize (long *values, long num_values, int delta_exp) | 63 | void float_normalize (int32_t *values, int32_t num_values, int delta_exp) |
64 | { | 64 | { |
65 | f32 *fvalues = (f32 *) values, fzero = { 0, 0, 0 }; | 65 | f32 *fvalues = (f32 *) values, fzero = { 0, 0, 0 }; |
66 | int exp; | 66 | int exp; |
diff --git a/apps/codecs/libwavpack/metadata.c b/apps/codecs/libwavpack/metadata.c index ebc7dcf99d..b7d1e950bf 100644 --- a/apps/codecs/libwavpack/metadata.c +++ b/apps/codecs/libwavpack/metadata.c | |||
@@ -29,12 +29,12 @@ int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
29 | if (!wpc->infile (&tchar, 1)) | 29 | if (!wpc->infile (&tchar, 1)) |
30 | return FALSE; | 30 | return FALSE; |
31 | 31 | ||
32 | wpmd->byte_length += (long) tchar << 9; | 32 | wpmd->byte_length += (int32_t) tchar << 9; |
33 | 33 | ||
34 | if (!wpc->infile (&tchar, 1)) | 34 | if (!wpc->infile (&tchar, 1)) |
35 | return FALSE; | 35 | return FALSE; |
36 | 36 | ||
37 | wpmd->byte_length += (long) tchar << 17; | 37 | wpmd->byte_length += (int32_t) tchar << 17; |
38 | } | 38 | } |
39 | 39 | ||
40 | if (wpmd->id & ID_ODD_SIZE) { | 40 | if (wpmd->id & ID_ODD_SIZE) { |
@@ -42,10 +42,10 @@ int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
42 | wpmd->byte_length--; | 42 | wpmd->byte_length--; |
43 | } | 43 | } |
44 | 44 | ||
45 | if (wpmd->byte_length && wpmd->byte_length <= (long)sizeof (wpc->read_buffer)) { | 45 | if (wpmd->byte_length && wpmd->byte_length <= (int32_t)sizeof (wpc->read_buffer)) { |
46 | ulong bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1); | 46 | uint32_t bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1); |
47 | 47 | ||
48 | if (wpc->infile (wpc->read_buffer, bytes_to_read) != (long) bytes_to_read) { | 48 | if (wpc->infile (wpc->read_buffer, bytes_to_read) != (int32_t) bytes_to_read) { |
49 | wpmd->data = NULL; | 49 | wpmd->data = NULL; |
50 | return FALSE; | 50 | return FALSE; |
51 | } | 51 | } |
@@ -108,7 +108,7 @@ int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
108 | 108 | ||
109 | int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end) | 109 | int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end) |
110 | { | 110 | { |
111 | ulong mdsize = wpmd->byte_length + (wpmd->byte_length & 1); | 111 | uint32_t mdsize = wpmd->byte_length + (wpmd->byte_length & 1); |
112 | WavpackHeader *wphdr = (WavpackHeader *) buffer_start; | 112 | WavpackHeader *wphdr = (WavpackHeader *) buffer_start; |
113 | 113 | ||
114 | if (wpmd->byte_length & 1) | 114 | if (wpmd->byte_length & 1) |
diff --git a/apps/codecs/libwavpack/pack.c b/apps/codecs/libwavpack/pack.c index 588efccc6f..9ccfa07261 100644 --- a/apps/codecs/libwavpack/pack.c +++ b/apps/codecs/libwavpack/pack.c | |||
@@ -39,7 +39,7 @@ static const signed char fast_terms [] = { 17,17,0 }; | |||
39 | void pack_init (WavpackContext *wpc) | 39 | void pack_init (WavpackContext *wpc) |
40 | { | 40 | { |
41 | WavpackStream *wps = &wpc->stream; | 41 | WavpackStream *wps = &wpc->stream; |
42 | ulong flags = wps->wphdr.flags; | 42 | uint32_t flags = wps->wphdr.flags; |
43 | struct decorr_pass *dpp; | 43 | struct decorr_pass *dpp; |
44 | const signed char *term_string; | 44 | const signed char *term_string; |
45 | int ti; | 45 | int ti; |
@@ -264,19 +264,19 @@ int pack_start_block (WavpackContext *wpc) | |||
264 | return TRUE; | 264 | return TRUE; |
265 | } | 265 | } |
266 | 266 | ||
267 | static void decorr_stereo_pass (struct decorr_pass *dpp, long *bptr, long *eptr, int m); | 267 | static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr, int m); |
268 | static void decorr_stereo_pass_18 (struct decorr_pass *dpp, long *bptr, long *eptr); | 268 | static void decorr_stereo_pass_18 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); |
269 | static void decorr_stereo_pass_17 (struct decorr_pass *dpp, long *bptr, long *eptr); | 269 | static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); |
270 | static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, long *bptr, long *eptr); | 270 | static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); |
271 | 271 | ||
272 | int pack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) | 272 | int pack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count) |
273 | { | 273 | { |
274 | WavpackStream *wps = &wpc->stream; | 274 | WavpackStream *wps = &wpc->stream; |
275 | ulong flags = wps->wphdr.flags; | 275 | uint32_t flags = wps->wphdr.flags; |
276 | struct decorr_pass *dpp; | 276 | struct decorr_pass *dpp; |
277 | long *bptr, *eptr; | 277 | int32_t *bptr, *eptr; |
278 | int tcount, m; | 278 | int tcount, m; |
279 | ulong crc; | 279 | uint32_t crc; |
280 | 280 | ||
281 | if (!sample_count) | 281 | if (!sample_count) |
282 | return TRUE; | 282 | return TRUE; |
@@ -289,12 +289,12 @@ int pack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) | |||
289 | 289 | ||
290 | if (!(flags & HYBRID_FLAG) && (flags & MONO_FLAG)) | 290 | if (!(flags & HYBRID_FLAG) && (flags & MONO_FLAG)) |
291 | for (bptr = buffer; bptr < eptr;) { | 291 | for (bptr = buffer; bptr < eptr;) { |
292 | long code; | 292 | int32_t code; |
293 | 293 | ||
294 | crc = crc * 3 + (code = *bptr); | 294 | crc = crc * 3 + (code = *bptr); |
295 | 295 | ||
296 | for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { | 296 | for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { |
297 | long sam; | 297 | int32_t sam; |
298 | 298 | ||
299 | if (dpp->term > MAX_TERM) { | 299 | if (dpp->term > MAX_TERM) { |
300 | if (dpp->term & 1) | 300 | if (dpp->term & 1) |
@@ -350,10 +350,10 @@ int pack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) | |||
350 | return TRUE; | 350 | return TRUE; |
351 | } | 351 | } |
352 | 352 | ||
353 | static void decorr_stereo_pass (struct decorr_pass *dpp, long *bptr, long *eptr, int m) | 353 | static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr, int m) |
354 | { | 354 | { |
355 | int k = (m + dpp->term) & (MAX_TERM - 1); | 355 | int k = (m + dpp->term) & (MAX_TERM - 1); |
356 | long sam; | 356 | int32_t sam; |
357 | 357 | ||
358 | while (bptr < eptr) { | 358 | while (bptr < eptr) { |
359 | dpp->samples_A [k] = bptr [0]; | 359 | dpp->samples_A [k] = bptr [0]; |
@@ -369,9 +369,9 @@ static void decorr_stereo_pass (struct decorr_pass *dpp, long *bptr, long *eptr, | |||
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | static void decorr_stereo_pass_18 (struct decorr_pass *dpp, long *bptr, long *eptr) | 372 | static void decorr_stereo_pass_18 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) |
373 | { | 373 | { |
374 | long sam; | 374 | int32_t sam; |
375 | 375 | ||
376 | while (bptr < eptr) { | 376 | while (bptr < eptr) { |
377 | sam = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; | 377 | sam = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; |
@@ -389,9 +389,9 @@ static void decorr_stereo_pass_18 (struct decorr_pass *dpp, long *bptr, long *ep | |||
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, long *bptr, long *eptr) | 392 | static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) |
393 | { | 393 | { |
394 | long sam_A, sam_B; | 394 | int32_t sam_A, sam_B; |
395 | 395 | ||
396 | for (; bptr < eptr; bptr += 2) { | 396 | for (; bptr < eptr; bptr += 2) { |
397 | sam_A = bptr [1]; | 397 | sam_A = bptr [1]; |
@@ -404,18 +404,18 @@ static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, long *bptr, long *ep | |||
404 | } | 404 | } |
405 | } | 405 | } |
406 | 406 | ||
407 | static void decorr_stereo_pass_17 (struct decorr_pass *dpp, long *bptr, long *eptr) | 407 | static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) |
408 | { | 408 | { |
409 | long sam; | 409 | int32_t sam; |
410 | 410 | ||
411 | while (bptr < eptr) { | 411 | while (bptr < eptr) { |
412 | sam = 2 * dpp->samples_A [0] - dpp->samples_A [1]; | 412 | sam = 2 * dpp->samples_A [0] - dpp->samples_A [1]; |
413 | dpp->samples_A [1] = dpp->samples_A [0]; | 413 | dpp->samples_A [1] = dpp->samples_A [0]; |
414 | dpp->samples_A [0] = bptr [0]; | 414 | dpp->samples_A [0] = bptr [0]; |
415 | bptr [0] -= apply_weight_i (dpp->weight_A, sam); | 415 | bptr [0] -= apply_weight_i (dpp->weight_A, sam); |
416 | update_weight (dpp->weight_A, 2, sam, bptr [0]); | 416 | update_weight (dpp->weight_A, 2, sam, bptr [0]); |
417 | bptr++; | 417 | bptr++; |
418 | sam = 2 * dpp->samples_B [0] - dpp->samples_B [1]; | 418 | sam = 2 * dpp->samples_B [0] - dpp->samples_B [1]; |
419 | dpp->samples_B [1] = dpp->samples_B [0]; | 419 | dpp->samples_B [1] = dpp->samples_B [0]; |
420 | dpp->samples_B [0] = bptr [0]; | 420 | dpp->samples_B [0] = bptr [0]; |
421 | bptr [0] -= apply_weight_i (dpp->weight_B, sam); | 421 | bptr [0] -= apply_weight_i (dpp->weight_B, sam); |
@@ -428,7 +428,7 @@ int pack_finish_block (WavpackContext *wpc) | |||
428 | { | 428 | { |
429 | WavpackStream *wps = &wpc->stream; | 429 | WavpackStream *wps = &wpc->stream; |
430 | struct decorr_pass *dpp; | 430 | struct decorr_pass *dpp; |
431 | ulong data_count; | 431 | uint32_t data_count; |
432 | int tcount, m; | 432 | int tcount, m; |
433 | 433 | ||
434 | m = ((WavpackHeader *) wps->blockbuff)->block_samples & (MAX_TERM - 1); | 434 | m = ((WavpackHeader *) wps->blockbuff)->block_samples & (MAX_TERM - 1); |
@@ -436,7 +436,7 @@ int pack_finish_block (WavpackContext *wpc) | |||
436 | if (m) | 436 | if (m) |
437 | for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) | 437 | for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) |
438 | if (dpp->term > 0 && dpp->term <= MAX_TERM) { | 438 | if (dpp->term > 0 && dpp->term <= MAX_TERM) { |
439 | long temp_A [MAX_TERM], temp_B [MAX_TERM]; | 439 | int32_t temp_A [MAX_TERM], temp_B [MAX_TERM]; |
440 | int k; | 440 | int k; |
441 | 441 | ||
442 | memcpy (temp_A, dpp->samples_A, sizeof (dpp->samples_A)); | 442 | memcpy (temp_A, dpp->samples_A, sizeof (dpp->samples_A)); |
@@ -453,7 +453,7 @@ int pack_finish_block (WavpackContext *wpc) | |||
453 | data_count = bs_close_write (&wps->wvbits); | 453 | data_count = bs_close_write (&wps->wvbits); |
454 | 454 | ||
455 | if (data_count) { | 455 | if (data_count) { |
456 | if (data_count != (ulong) -1) { | 456 | if (data_count != (uint32_t) -1) { |
457 | uchar *cptr = wps->blockbuff + ((WavpackHeader *) wps->blockbuff)->ckSize + 8; | 457 | uchar *cptr = wps->blockbuff + ((WavpackHeader *) wps->blockbuff)->ckSize + 8; |
458 | 458 | ||
459 | *cptr++ = ID_WV_BITSTREAM | ID_LARGE; | 459 | *cptr++ = ID_WV_BITSTREAM | ID_LARGE; |
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c index af5d71585e..dcc9bf5bf9 100644 --- a/apps/codecs/libwavpack/unpack.c +++ b/apps/codecs/libwavpack/unpack.c | |||
@@ -35,7 +35,7 @@ int unpack_init (WavpackContext *wpc) | |||
35 | WavpackStream *wps = &wpc->stream; | 35 | WavpackStream *wps = &wpc->stream; |
36 | WavpackMetadata wpmd; | 36 | WavpackMetadata wpmd; |
37 | 37 | ||
38 | if (wps->wphdr.block_samples && wps->wphdr.block_index != (ulong) -1) | 38 | if (wps->wphdr.block_samples && wps->wphdr.block_index != (uint32_t) -1) |
39 | wps->sample_index = wps->wphdr.block_index; | 39 | wps->sample_index = wps->wphdr.block_index; |
40 | 40 | ||
41 | wps->mute_error = FALSE; | 41 | wps->mute_error = FALSE; |
@@ -237,7 +237,7 @@ int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
237 | { | 237 | { |
238 | int bytecnt = wpmd->byte_length, shift = 0; | 238 | int bytecnt = wpmd->byte_length, shift = 0; |
239 | char *byteptr = wpmd->data; | 239 | char *byteptr = wpmd->data; |
240 | ulong mask = 0; | 240 | uint32_t mask = 0; |
241 | 241 | ||
242 | if (!bytecnt || bytecnt > 5) | 242 | if (!bytecnt || bytecnt > 5) |
243 | return FALSE; | 243 | return FALSE; |
@@ -245,7 +245,7 @@ int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
245 | wpc->config.num_channels = *byteptr++; | 245 | wpc->config.num_channels = *byteptr++; |
246 | 246 | ||
247 | while (--bytecnt) { | 247 | while (--bytecnt) { |
248 | mask |= (ulong) *byteptr++ << shift; | 248 | mask |= (uint32_t) *byteptr++ << shift; |
249 | shift += 8; | 249 | shift += 8; |
250 | } | 250 | } |
251 | 251 | ||
@@ -262,9 +262,9 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
262 | 262 | ||
263 | if (bytecnt >= 3) { | 263 | if (bytecnt >= 3) { |
264 | wpc->config.flags &= 0xff; | 264 | wpc->config.flags &= 0xff; |
265 | wpc->config.flags |= (long) *byteptr++ << 8; | 265 | wpc->config.flags |= (int32_t) *byteptr++ << 8; |
266 | wpc->config.flags |= (long) *byteptr++ << 16; | 266 | wpc->config.flags |= (int32_t) *byteptr++ << 16; |
267 | wpc->config.flags |= (long) *byteptr << 24; | 267 | wpc->config.flags |= (int32_t) *byteptr << 24; |
268 | } | 268 | } |
269 | 269 | ||
270 | return TRUE; | 270 | return TRUE; |
@@ -273,7 +273,7 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
273 | // This monster actually unpacks the WavPack bitstream(s) into the specified | 273 | // This monster actually unpacks the WavPack bitstream(s) into the specified |
274 | // buffer as 32-bit integers or floats (depending on orignal data). Lossy | 274 | // buffer as 32-bit integers or floats (depending on orignal data). Lossy |
275 | // samples will be clipped to their original limits (i.e. 8-bit samples are | 275 | // samples will be clipped to their original limits (i.e. 8-bit samples are |
276 | // clipped to -128/+127) but are still returned in longs. It is up to the | 276 | // clipped to -128/+127) but are still returned in int32_ts. It is up to the |
277 | // caller to potentially reformat this for the final output including any | 277 | // caller to potentially reformat this for the final output including any |
278 | // multichannel distribution, block alignment or endian compensation. The | 278 | // multichannel distribution, block alignment or endian compensation. The |
279 | // function unpack_init() must have been called and the entire WavPack block | 279 | // function unpack_init() must have been called and the entire WavPack block |
@@ -287,25 +287,25 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) | |||
287 | // occurs or the end of the block is reached. | 287 | // occurs or the end of the block is reached. |
288 | 288 | ||
289 | #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) | 289 | #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) |
290 | extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, long *buffer, long sample_count); | 290 | extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); |
291 | #elif defined(CPU_ARM) && !defined(SIMULATOR) | 291 | #elif defined(CPU_ARM) && !defined(SIMULATOR) |
292 | extern void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, long *buffer, long sample_count); | 292 | extern void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); |
293 | extern void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, long *buffer, long sample_count); | 293 | extern void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); |
294 | #else | 294 | #else |
295 | static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count); | 295 | static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); |
296 | #endif | 296 | #endif |
297 | 297 | ||
298 | static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count); | 298 | static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); |
299 | static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long sample_count); | 299 | static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); |
300 | static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count); | 300 | static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count); |
301 | 301 | ||
302 | long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) | 302 | int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count) |
303 | { | 303 | { |
304 | WavpackStream *wps = &wpc->stream; | 304 | WavpackStream *wps = &wpc->stream; |
305 | ulong flags = wps->wphdr.flags, crc = wps->crc, i; | 305 | uint32_t flags = wps->wphdr.flags, crc = wps->crc, i; |
306 | long mute_limit = (1L << ((flags & MAG_MASK) >> MAG_LSB)) + 2; | 306 | int32_t mute_limit = (1L << ((flags & MAG_MASK) >> MAG_LSB)) + 2; |
307 | struct decorr_pass *dpp; | 307 | struct decorr_pass *dpp; |
308 | long *bptr, *eptr; | 308 | int32_t *bptr, *eptr; |
309 | int tcount; | 309 | int tcount; |
310 | 310 | ||
311 | if (wps->sample_index + sample_count > wps->wphdr.block_index + wps->wphdr.block_samples) | 311 | if (wps->sample_index + sample_count > wps->wphdr.block_index + wps->wphdr.block_samples) |
@@ -403,10 +403,10 @@ long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) | |||
403 | return i; | 403 | return i; |
404 | } | 404 | } |
405 | 405 | ||
406 | static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long sample_count) | 406 | static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) |
407 | { | 407 | { |
408 | long delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; | 408 | int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; |
409 | long *bptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; | 409 | int32_t *bptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; |
410 | int m, k; | 410 | int m, k; |
411 | 411 | ||
412 | switch (dpp->term) { | 412 | switch (dpp->term) { |
@@ -462,7 +462,7 @@ static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long samp | |||
462 | } | 462 | } |
463 | 463 | ||
464 | if (m) { | 464 | if (m) { |
465 | long temp_samples [MAX_TERM]; | 465 | int32_t temp_samples [MAX_TERM]; |
466 | 466 | ||
467 | memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); | 467 | memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); |
468 | 468 | ||
@@ -520,10 +520,10 @@ static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long samp | |||
520 | 520 | ||
521 | #if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM)) || defined(SIMULATOR) | 521 | #if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM)) || defined(SIMULATOR) |
522 | 522 | ||
523 | static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count) | 523 | static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) |
524 | { | 524 | { |
525 | long delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; | 525 | int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; |
526 | long *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; | 526 | int32_t *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; |
527 | int k, i; | 527 | int k, i; |
528 | 528 | ||
529 | switch (dpp->term) { | 529 | switch (dpp->term) { |
@@ -619,10 +619,10 @@ static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long | |||
619 | 619 | ||
620 | #endif | 620 | #endif |
621 | 621 | ||
622 | static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count) | 622 | static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) |
623 | { | 623 | { |
624 | long delta = dpp->delta, weight_A = dpp->weight_A; | 624 | int32_t delta = dpp->delta, weight_A = dpp->weight_A; |
625 | long *bptr, *eptr = buffer + sample_count, sam_A; | 625 | int32_t *bptr, *eptr = buffer + sample_count, sam_A; |
626 | int m, k; | 626 | int m, k; |
627 | 627 | ||
628 | switch (dpp->term) { | 628 | switch (dpp->term) { |
@@ -660,7 +660,7 @@ static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample | |||
660 | } | 660 | } |
661 | 661 | ||
662 | if (m) { | 662 | if (m) { |
663 | long temp_samples [MAX_TERM]; | 663 | int32_t temp_samples [MAX_TERM]; |
664 | 664 | ||
665 | memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); | 665 | memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); |
666 | 666 | ||
@@ -687,12 +687,12 @@ static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample | |||
687 | // as 28-bits, and clipping (for lossy mode) has been eliminated because this | 687 | // as 28-bits, and clipping (for lossy mode) has been eliminated because this |
688 | // now happens in the dsp module. | 688 | // now happens in the dsp module. |
689 | 689 | ||
690 | static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count) | 690 | static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count) |
691 | { | 691 | { |
692 | ulong flags = wps->wphdr.flags; | 692 | uint32_t flags = wps->wphdr.flags; |
693 | int shift = (flags & SHIFT_MASK) >> SHIFT_LSB; | 693 | int shift = (flags & SHIFT_MASK) >> SHIFT_LSB; |
694 | 694 | ||
695 | shift += 20 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit data | 695 | shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign) |
696 | 696 | ||
697 | if (flags & FLOAT_DATA) { | 697 | if (flags & FLOAT_DATA) { |
698 | float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2); | 698 | float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2); |
@@ -700,10 +700,10 @@ static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count) | |||
700 | } | 700 | } |
701 | 701 | ||
702 | if (flags & INT32_DATA) { | 702 | if (flags & INT32_DATA) { |
703 | ulong count = (flags & MONO_FLAG) ? sample_count : sample_count * 2; | 703 | uint32_t count = (flags & MONO_FLAG) ? sample_count : sample_count * 2; |
704 | int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; | 704 | int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; |
705 | int ones = wps->int32_ones, dups = wps->int32_dups; | 705 | int ones = wps->int32_ones, dups = wps->int32_dups; |
706 | long *dptr = buffer; | 706 | int32_t *dptr = buffer; |
707 | 707 | ||
708 | if (!(flags & HYBRID_FLAG) && !sent_bits && (zeros + ones + dups)) | 708 | if (!(flags & HYBRID_FLAG) && !sent_bits && (zeros + ones + dups)) |
709 | while (count--) { | 709 | while (count--) { |
diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h index e26cac353a..593af7831d 100644 --- a/apps/codecs/libwavpack/wavpack.h +++ b/apps/codecs/libwavpack/wavpack.h | |||
@@ -16,7 +16,6 @@ | |||
16 | 16 | ||
17 | typedef unsigned char uchar; | 17 | typedef unsigned char uchar; |
18 | typedef unsigned short ushort; | 18 | typedef unsigned short ushort; |
19 | typedef unsigned long ulong; | ||
20 | typedef unsigned int uint; | 19 | typedef unsigned int uint; |
21 | 20 | ||
22 | // This structure is used to access the individual fields of 32-bit ieee | 21 | // This structure is used to access the individual fields of 32-bit ieee |
@@ -43,10 +42,10 @@ typedef struct { | |||
43 | 42 | ||
44 | typedef struct { | 43 | typedef struct { |
45 | char ckID [4]; | 44 | char ckID [4]; |
46 | ulong ckSize; | 45 | uint32_t ckSize; |
47 | short version; | 46 | short version; |
48 | uchar track_no, index_no; | 47 | uchar track_no, index_no; |
49 | ulong total_samples, block_index, block_samples, flags, crc; | 48 | uint32_t total_samples, block_index, block_samples, flags, crc; |
50 | } WavpackHeader; | 49 | } WavpackHeader; |
51 | 50 | ||
52 | #define WavpackHeaderFormat "4LS2LLLLL" | 51 | #define WavpackHeaderFormat "4LS2LLLLL" |
@@ -88,7 +87,7 @@ typedef struct { | |||
88 | 87 | ||
89 | typedef struct { | 88 | typedef struct { |
90 | uchar temp_data [64]; | 89 | uchar temp_data [64]; |
91 | long byte_length; | 90 | int32_t byte_length; |
92 | void *data; | 91 | void *data; |
93 | uchar id; | 92 | uchar id; |
94 | } WavpackMetadata; | 93 | } WavpackMetadata; |
@@ -128,7 +127,7 @@ typedef struct { | |||
128 | typedef struct { | 127 | typedef struct { |
129 | int bits_per_sample, bytes_per_sample; | 128 | int bits_per_sample, bytes_per_sample; |
130 | int flags, num_channels, float_norm_exp; | 129 | int flags, num_channels, float_norm_exp; |
131 | ulong sample_rate, channel_mask; | 130 | uint32_t sample_rate, channel_mask; |
132 | } WavpackConfig; | 131 | } WavpackConfig; |
133 | 132 | ||
134 | #define CONFIG_BYTES_STORED 3 // 1-4 bytes/sample | 133 | #define CONFIG_BYTES_STORED 3 // 1-4 bytes/sample |
@@ -169,12 +168,12 @@ typedef struct { | |||
169 | // pointers to hold a complete allocated block of WavPack data, although it's | 168 | // pointers to hold a complete allocated block of WavPack data, although it's |
170 | // possible to decode WavPack blocks without buffering an entire block. | 169 | // possible to decode WavPack blocks without buffering an entire block. |
171 | 170 | ||
172 | typedef long (*read_stream)(void *, long); | 171 | typedef int32_t (*read_stream)(void *, int32_t); |
173 | 172 | ||
174 | typedef struct bs { | 173 | typedef struct bs { |
175 | uchar *buf, *end, *ptr; | 174 | uchar *buf, *end, *ptr; |
176 | void (*wrap)(struct bs *bs); | 175 | void (*wrap)(struct bs *bs); |
177 | ulong file_bytes, sr; | 176 | uint32_t file_bytes, sr; |
178 | int error, bc; | 177 | int error, bc; |
179 | read_stream file; | 178 | read_stream file; |
180 | } Bitstream; | 179 | } Bitstream; |
@@ -184,16 +183,16 @@ typedef struct bs { | |||
184 | 183 | ||
185 | struct decorr_pass { | 184 | struct decorr_pass { |
186 | short term, delta, weight_A, weight_B; | 185 | short term, delta, weight_A, weight_B; |
187 | long samples_A [MAX_TERM], samples_B [MAX_TERM]; | 186 | int32_t samples_A [MAX_TERM], samples_B [MAX_TERM]; |
188 | }; | 187 | }; |
189 | 188 | ||
190 | struct entropy_data { | 189 | struct entropy_data { |
191 | ulong median [3], slow_level, error_limit; | 190 | uint32_t median [3], slow_level, error_limit; |
192 | }; | 191 | }; |
193 | 192 | ||
194 | struct words_data { | 193 | struct words_data { |
195 | ulong bitrate_delta [2], bitrate_acc [2]; | 194 | uint32_t bitrate_delta [2], bitrate_acc [2]; |
196 | ulong pend_data, holding_one, zeros_acc; | 195 | uint32_t pend_data, holding_one, zeros_acc; |
197 | int holding_zero, pend_count; | 196 | int holding_zero, pend_count; |
198 | struct entropy_data c [2]; | 197 | struct entropy_data c [2]; |
199 | }; | 198 | }; |
@@ -205,7 +204,7 @@ typedef struct { | |||
205 | struct words_data w; | 204 | struct words_data w; |
206 | 205 | ||
207 | int num_terms, mute_error; | 206 | int num_terms, mute_error; |
208 | ulong sample_index, crc; | 207 | uint32_t sample_index, crc; |
209 | 208 | ||
210 | uchar int32_sent_bits, int32_zeros, int32_ones, int32_dups; | 209 | uchar int32_sent_bits, int32_zeros, int32_ones, int32_dups; |
211 | uchar float_flags, float_shift, float_max_exp, float_norm_exp; | 210 | uchar float_flags, float_shift, float_max_exp, float_norm_exp; |
@@ -241,7 +240,7 @@ typedef struct { | |||
241 | char error_message [80]; | 240 | char error_message [80]; |
242 | 241 | ||
243 | read_stream infile; | 242 | read_stream infile; |
244 | ulong total_samples, crc_errors, first_flags; | 243 | uint32_t total_samples, crc_errors, first_flags; |
245 | int open_flags, norm_offset, reduced_channels, lossy_blocks; | 244 | int open_flags, norm_offset, reduced_channels, lossy_blocks; |
246 | 245 | ||
247 | } WavpackContext; | 246 | } WavpackContext; |
@@ -252,9 +251,9 @@ typedef struct { | |||
252 | 251 | ||
253 | // bits.c | 252 | // bits.c |
254 | 253 | ||
255 | void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, ulong file_bytes); | 254 | void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes); |
256 | void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end); | 255 | void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end); |
257 | ulong bs_close_write (Bitstream *bs); | 256 | uint32_t bs_close_write (Bitstream *bs); |
258 | 257 | ||
259 | #define bs_is_open(bs) ((bs)->ptr != NULL) | 258 | #define bs_is_open(bs) ((bs)->ptr != NULL) |
260 | 259 | ||
@@ -270,7 +269,7 @@ ulong bs_close_write (Bitstream *bs); | |||
270 | #define getbits(value, nbits, bs) { \ | 269 | #define getbits(value, nbits, bs) { \ |
271 | while ((nbits) > (bs)->bc) { \ | 270 | while ((nbits) > (bs)->bc) { \ |
272 | if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ | 271 | if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ |
273 | (bs)->sr |= (long)*((bs)->ptr) << (bs)->bc; \ | 272 | (bs)->sr |= (int32_t)*((bs)->ptr) << (bs)->bc; \ |
274 | (bs)->bc += 8; \ | 273 | (bs)->bc += 8; \ |
275 | } \ | 274 | } \ |
276 | *(value) = (bs)->sr; \ | 275 | *(value) = (bs)->sr; \ |
@@ -300,7 +299,7 @@ ulong bs_close_write (Bitstream *bs); | |||
300 | }} | 299 | }} |
301 | 300 | ||
302 | #define putbits(value, nbits, bs) { \ | 301 | #define putbits(value, nbits, bs) { \ |
303 | (bs)->sr |= (long)(value) << (bs)->bc; \ | 302 | (bs)->sr |= (int32_t)(value) << (bs)->bc; \ |
304 | if (((bs)->bc += (nbits)) >= 8) \ | 303 | if (((bs)->bc += (nbits)) >= 8) \ |
305 | do { \ | 304 | do { \ |
306 | *((bs)->ptr) = (bs)->sr; \ | 305 | *((bs)->ptr) = (bs)->sr; \ |
@@ -354,14 +353,14 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); | |||
354 | int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd); | 353 | int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd); |
355 | int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd); | 354 | int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd); |
356 | int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd); | 355 | int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd); |
357 | long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count); | 356 | int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count); |
358 | int check_crc_error (WavpackContext *wpc); | 357 | int check_crc_error (WavpackContext *wpc); |
359 | 358 | ||
360 | // pack.c | 359 | // pack.c |
361 | 360 | ||
362 | void pack_init (WavpackContext *wpc); | 361 | void pack_init (WavpackContext *wpc); |
363 | int pack_start_block (WavpackContext *wpc); | 362 | int pack_start_block (WavpackContext *wpc); |
364 | int pack_samples (WavpackContext *wpc, long *buffer, ulong sample_count); | 363 | int pack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count); |
365 | int pack_finish_block (WavpackContext *wpc); | 364 | int pack_finish_block (WavpackContext *wpc); |
366 | 365 | ||
367 | // metadata.c stuff | 366 | // metadata.c stuff |
@@ -377,15 +376,15 @@ void init_words (WavpackStream *wps); | |||
377 | int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); | 376 | int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); |
378 | void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); | 377 | void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); |
379 | int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd); | 378 | int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd); |
380 | long get_words (long *buffer, int nsamples, ulong flags, | 379 | int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags, |
381 | struct words_data *w, Bitstream *bs); | 380 | struct words_data *w, Bitstream *bs); |
382 | void send_word_lossless (long value, int chan, | 381 | void send_word_lossless (int32_t value, int chan, |
383 | struct words_data *w, Bitstream *bs); | 382 | struct words_data *w, Bitstream *bs); |
384 | void send_words (long *buffer, int nsamples, ulong flags, | 383 | void send_words (int32_t *buffer, int nsamples, uint32_t flags, |
385 | struct words_data *w, Bitstream *bs); | 384 | struct words_data *w, Bitstream *bs); |
386 | void flush_word (struct words_data *w, Bitstream *bs); | 385 | void flush_word (struct words_data *w, Bitstream *bs); |
387 | int log2s (long value); | 386 | int log2s (int32_t value); |
388 | long exp2s (int log); | 387 | int32_t exp2s (int log); |
389 | signed char store_weight (int weight); | 388 | signed char store_weight (int weight); |
390 | int restore_weight (signed char weight); | 389 | int restore_weight (signed char weight); |
391 | 390 | ||
@@ -394,8 +393,8 @@ int restore_weight (signed char weight); | |||
394 | // float.c | 393 | // float.c |
395 | 394 | ||
396 | int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); | 395 | int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); |
397 | void float_values (WavpackStream *wps, long *values, long num_values); | 396 | void float_values (WavpackStream *wps, int32_t *values, int32_t num_values); |
398 | void float_normalize (long *values, long num_values, int delta_exp); | 397 | void float_normalize (int32_t *values, int32_t num_values, int delta_exp); |
399 | 398 | ||
400 | // wputils.c | 399 | // wputils.c |
401 | 400 | ||
@@ -411,21 +410,21 @@ int WavpackGetMode (WavpackContext *wpc); | |||
411 | #define MODE_HIGH 0x20 | 410 | #define MODE_HIGH 0x20 |
412 | #define MODE_FAST 0x40 | 411 | #define MODE_FAST 0x40 |
413 | 412 | ||
414 | ulong WavpackUnpackSamples (WavpackContext *wpc, long *buffer, ulong samples); | 413 | uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples); |
415 | ulong WavpackGetNumSamples (WavpackContext *wpc); | 414 | uint32_t WavpackGetNumSamples (WavpackContext *wpc); |
416 | ulong WavpackGetSampleIndex (WavpackContext *wpc); | 415 | uint32_t WavpackGetSampleIndex (WavpackContext *wpc); |
417 | int WavpackGetNumErrors (WavpackContext *wpc); | 416 | int WavpackGetNumErrors (WavpackContext *wpc); |
418 | int WavpackLossyBlocks (WavpackContext *wpc); | 417 | int WavpackLossyBlocks (WavpackContext *wpc); |
419 | ulong WavpackGetSampleRate (WavpackContext *wpc); | 418 | uint32_t WavpackGetSampleRate (WavpackContext *wpc); |
420 | int WavpackGetBitsPerSample (WavpackContext *wpc); | 419 | int WavpackGetBitsPerSample (WavpackContext *wpc); |
421 | int WavpackGetBytesPerSample (WavpackContext *wpc); | 420 | int WavpackGetBytesPerSample (WavpackContext *wpc); |
422 | int WavpackGetNumChannels (WavpackContext *wpc); | 421 | int WavpackGetNumChannels (WavpackContext *wpc); |
423 | int WavpackGetReducedChannels (WavpackContext *wpc); | 422 | int WavpackGetReducedChannels (WavpackContext *wpc); |
424 | WavpackContext *WavpackOpenFileOutput (void); | 423 | WavpackContext *WavpackOpenFileOutput (void); |
425 | int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, ulong total_samples); | 424 | int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples); |
426 | void WavpackAddWrapper (WavpackContext *wpc, void *data, ulong bcount); | 425 | void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount); |
427 | int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end); | 426 | int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end); |
428 | int WavpackPackSamples (WavpackContext *wpc, long *sample_buffer, ulong sample_count); | 427 | int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count); |
429 | ulong WavpackFinishBlock (WavpackContext *wpc); | 428 | uint32_t WavpackFinishBlock (WavpackContext *wpc); |
430 | 429 | ||
431 | 430 | ||
diff --git a/apps/codecs/libwavpack/words.c b/apps/codecs/libwavpack/words.c index 96e3b60ebb..ccbd77f8f9 100644 --- a/apps/codecs/libwavpack/words.c +++ b/apps/codecs/libwavpack/words.c | |||
@@ -141,7 +141,7 @@ void init_words (WavpackStream *wps) | |||
141 | CLEAR (wps->w); | 141 | CLEAR (wps->w); |
142 | } | 142 | } |
143 | 143 | ||
144 | static int mylog2 (unsigned long avalue); | 144 | static int mylog2 (unsigned int32_t avalue); |
145 | 145 | ||
146 | // Read the median log2 values from the specifed metadata structure, convert | 146 | // Read the median log2 values from the specifed metadata structure, convert |
147 | // them back to 32-bit unsigned values and store them. If length is not | 147 | // them back to 32-bit unsigned values and store them. If length is not |
@@ -221,11 +221,11 @@ int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd) | |||
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | wps->w.bitrate_acc [0] = (long)(byteptr [0] + (byteptr [1] << 8)) << 16; | 224 | wps->w.bitrate_acc [0] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16; |
225 | byteptr += 2; | 225 | byteptr += 2; |
226 | 226 | ||
227 | if (!(wps->wphdr.flags & MONO_FLAG)) { | 227 | if (!(wps->wphdr.flags & MONO_FLAG)) { |
228 | wps->w.bitrate_acc [1] = (long)(byteptr [0] + (byteptr [1] << 8)) << 16; | 228 | wps->w.bitrate_acc [1] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16; |
229 | byteptr += 2; | 229 | byteptr += 2; |
230 | } | 230 | } |
231 | 231 | ||
@@ -253,7 +253,7 @@ int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd) | |||
253 | // currently implemented) this is calculated from the slow_level values and the | 253 | // currently implemented) this is calculated from the slow_level values and the |
254 | // bitrate accumulators. Note that the bitrate accumulators can be changing. | 254 | // bitrate accumulators. Note that the bitrate accumulators can be changing. |
255 | 255 | ||
256 | void update_error_limit (struct words_data *w, ulong flags) | 256 | void update_error_limit (struct words_data *w, uint32_t flags) |
257 | { | 257 | { |
258 | int bitrate_0 = (w->bitrate_acc [0] += w->bitrate_delta [0]) >> 16; | 258 | int bitrate_0 = (w->bitrate_acc [0] += w->bitrate_delta [0]) >> 16; |
259 | 259 | ||
@@ -310,7 +310,7 @@ void update_error_limit (struct words_data *w, ulong flags) | |||
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | static ulong read_code (Bitstream *bs, ulong maxcode); | 313 | static uint32_t read_code (Bitstream *bs, uint32_t maxcode); |
314 | 314 | ||
315 | // Read the next word from the bitstream "wvbits" and return the value. This | 315 | // Read the next word from the bitstream "wvbits" and return the value. This |
316 | // function can be used for hybrid or lossless streams, but since an | 316 | // function can be used for hybrid or lossless streams, but since an |
@@ -320,7 +320,7 @@ static ulong read_code (Bitstream *bs, ulong maxcode); | |||
320 | // of WORD_EOF indicates that the end of the bitstream was reached (all 1s) or | 320 | // of WORD_EOF indicates that the end of the bitstream was reached (all 1s) or |
321 | // some other error occurred. | 321 | // some other error occurred. |
322 | 322 | ||
323 | long get_words (long *buffer, int nsamples, ulong flags, | 323 | int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags, |
324 | struct words_data *w, Bitstream *bs) | 324 | struct words_data *w, Bitstream *bs) |
325 | { | 325 | { |
326 | register struct entropy_data *c = w->c; | 326 | register struct entropy_data *c = w->c; |
@@ -330,13 +330,13 @@ long get_words (long *buffer, int nsamples, ulong flags, | |||
330 | nsamples *= 2; | 330 | nsamples *= 2; |
331 | 331 | ||
332 | for (csamples = 0; csamples < nsamples; ++csamples) { | 332 | for (csamples = 0; csamples < nsamples; ++csamples) { |
333 | ulong ones_count, low, mid, high; | 333 | uint32_t ones_count, low, mid, high; |
334 | 334 | ||
335 | if (!(flags & MONO_FLAG)) | 335 | if (!(flags & MONO_FLAG)) |
336 | c = w->c + (csamples & 1); | 336 | c = w->c + (csamples & 1); |
337 | 337 | ||
338 | if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !w->holding_one && !(w->c [1].median [0] & ~1)) { | 338 | if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !w->holding_one && !(w->c [1].median [0] & ~1)) { |
339 | ulong mask; | 339 | uint32_t mask; |
340 | int cbits; | 340 | int cbits; |
341 | 341 | ||
342 | if (w->zeros_acc) { | 342 | if (w->zeros_acc) { |
@@ -397,7 +397,7 @@ long get_words (long *buffer, int nsamples, ulong flags, | |||
397 | break; | 397 | break; |
398 | 398 | ||
399 | if (ones_count == LIMIT_ONES) { | 399 | if (ones_count == LIMIT_ONES) { |
400 | ulong mask; | 400 | uint32_t mask; |
401 | int cbits; | 401 | int cbits; |
402 | 402 | ||
403 | for (cbits = 0; cbits < 33 && getbit (bs); ++cbits); | 403 | for (cbits = 0; cbits < 33 && getbit (bs); ++cbits); |
@@ -493,10 +493,10 @@ long get_words (long *buffer, int nsamples, ulong flags, | |||
493 | // minimum number of bits and then determines whether another bit is needed | 493 | // minimum number of bits and then determines whether another bit is needed |
494 | // to define the code. | 494 | // to define the code. |
495 | 495 | ||
496 | static ulong read_code (Bitstream *bs, ulong maxcode) | 496 | static uint32_t read_code (Bitstream *bs, uint32_t maxcode) |
497 | { | 497 | { |
498 | int bitcount = count_bits (maxcode); | 498 | int bitcount = count_bits (maxcode); |
499 | ulong extras = (1L << bitcount) - maxcode - 1, code; | 499 | uint32_t extras = (1L << bitcount) - maxcode - 1, code; |
500 | 500 | ||
501 | if (!bitcount) | 501 | if (!bitcount) |
502 | return 0; | 502 | return 0; |
@@ -514,7 +514,7 @@ static ulong read_code (Bitstream *bs, ulong maxcode) | |||
514 | return code; | 514 | return code; |
515 | } | 515 | } |
516 | 516 | ||
517 | void send_words (long *buffer, int nsamples, ulong flags, | 517 | void send_words (int32_t *buffer, int nsamples, uint32_t flags, |
518 | struct words_data *w, Bitstream *bs) | 518 | struct words_data *w, Bitstream *bs) |
519 | { | 519 | { |
520 | register struct entropy_data *c = w->c; | 520 | register struct entropy_data *c = w->c; |
@@ -523,9 +523,9 @@ void send_words (long *buffer, int nsamples, ulong flags, | |||
523 | nsamples *= 2; | 523 | nsamples *= 2; |
524 | 524 | ||
525 | while (nsamples--) { | 525 | while (nsamples--) { |
526 | long value = *buffer++; | 526 | int32_t value = *buffer++; |
527 | int sign = (value < 0) ? 1 : 0; | 527 | int sign = (value < 0) ? 1 : 0; |
528 | ulong ones_count, low, high; | 528 | uint32_t ones_count, low, high; |
529 | 529 | ||
530 | if (!(flags & MONO_FLAG)) | 530 | if (!(flags & MONO_FLAG)) |
531 | c = w->c + (~nsamples & 1); | 531 | c = w->c + (~nsamples & 1); |
@@ -553,7 +553,7 @@ void send_words (long *buffer, int nsamples, ulong flags, | |||
553 | if (sign) | 553 | if (sign) |
554 | value = ~value; | 554 | value = ~value; |
555 | 555 | ||
556 | if ((unsigned long) value < GET_MED (0)) { | 556 | if ((unsigned int32_t) value < GET_MED (0)) { |
557 | ones_count = low = 0; | 557 | ones_count = low = 0; |
558 | high = GET_MED (0) - 1; | 558 | high = GET_MED (0) - 1; |
559 | DEC_MED0 (); | 559 | DEC_MED0 (); |
@@ -604,9 +604,9 @@ void send_words (long *buffer, int nsamples, ulong flags, | |||
604 | w->holding_one = ones_count * 2; | 604 | w->holding_one = ones_count * 2; |
605 | 605 | ||
606 | if (high != low) { | 606 | if (high != low) { |
607 | ulong maxcode = high - low, code = value - low; | 607 | uint32_t maxcode = high - low, code = value - low; |
608 | int bitcount = count_bits (maxcode); | 608 | int bitcount = count_bits (maxcode); |
609 | ulong extras = (1L << bitcount) - maxcode - 1; | 609 | uint32_t extras = (1L << bitcount) - maxcode - 1; |
610 | 610 | ||
611 | if (code < extras) { | 611 | if (code < extras) { |
612 | w->pend_data |= code << w->pend_count; | 612 | w->pend_data |= code << w->pend_count; |
@@ -619,7 +619,7 @@ void send_words (long *buffer, int nsamples, ulong flags, | |||
619 | } | 619 | } |
620 | } | 620 | } |
621 | 621 | ||
622 | w->pend_data |= ((long) sign << w->pend_count++); | 622 | w->pend_data |= ((int32_t) sign << w->pend_count++); |
623 | 623 | ||
624 | if (!w->holding_zero) | 624 | if (!w->holding_zero) |
625 | flush_word (w, bs); | 625 | flush_word (w, bs); |
@@ -709,7 +709,7 @@ void flush_word (struct words_data *w, Bitstream *bs) | |||
709 | // This function returns the log2 for the specified 32-bit unsigned value. | 709 | // This function returns the log2 for the specified 32-bit unsigned value. |
710 | // The maximum value allowed is about 0xff800000 and returns 8447. | 710 | // The maximum value allowed is about 0xff800000 and returns 8447. |
711 | 711 | ||
712 | static int mylog2 (unsigned long avalue) | 712 | static int mylog2 (unsigned int32_t avalue) |
713 | { | 713 | { |
714 | int dbits; | 714 | int dbits; |
715 | 715 | ||
@@ -733,7 +733,7 @@ static int mylog2 (unsigned long avalue) | |||
733 | // All input values are valid and the return values are in the range of | 733 | // All input values are valid and the return values are in the range of |
734 | // +/- 8192. | 734 | // +/- 8192. |
735 | 735 | ||
736 | int log2s (long value) | 736 | int log2s (int32_t value) |
737 | { | 737 | { |
738 | return (value < 0) ? -mylog2 (-value) : mylog2 (value); | 738 | return (value < 0) ? -mylog2 (-value) : mylog2 (value); |
739 | } | 739 | } |
@@ -743,9 +743,9 @@ int log2s (long value) | |||
743 | // but since a full 32-bit value is returned this can be used for unsigned | 743 | // but since a full 32-bit value is returned this can be used for unsigned |
744 | // conversions as well (i.e. the input range is -8192 to +8447). | 744 | // conversions as well (i.e. the input range is -8192 to +8447). |
745 | 745 | ||
746 | long exp2s (int log) | 746 | int32_t exp2s (int log) |
747 | { | 747 | { |
748 | ulong value; | 748 | uint32_t value; |
749 | 749 | ||
750 | if (log < 0) | 750 | if (log < 0) |
751 | return -exp2s (-log); | 751 | return -exp2s (-log); |
diff --git a/apps/codecs/libwavpack/wputils.c b/apps/codecs/libwavpack/wputils.c index 549cd8a4fa..7a6cc44ad4 100644 --- a/apps/codecs/libwavpack/wputils.c +++ b/apps/codecs/libwavpack/wputils.c | |||
@@ -23,12 +23,12 @@ static void strcpy_loc (char *dst, char *src) { while ((*dst++ = *src++) != 0); | |||
23 | 23 | ||
24 | ///////////////////////////// local table storage //////////////////////////// | 24 | ///////////////////////////// local table storage //////////////////////////// |
25 | 25 | ||
26 | const ulong sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050, | 26 | const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050, |
27 | 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 }; | 27 | 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 }; |
28 | 28 | ||
29 | ///////////////////////////// executable code //////////////////////////////// | 29 | ///////////////////////////// executable code //////////////////////////////// |
30 | 30 | ||
31 | static ulong read_next_header (read_stream infile, WavpackHeader *wphdr); | 31 | static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr); |
32 | 32 | ||
33 | // This function reads data from the specified stream in search of a valid | 33 | // This function reads data from the specified stream in search of a valid |
34 | // WavPack 4.0 audio block. If this fails in 1 megabyte (or an invalid or | 34 | // WavPack 4.0 audio block. If this fails in 1 megabyte (or an invalid or |
@@ -50,11 +50,11 @@ static WavpackContext wpc IBSS_ATTR; | |||
50 | WavpackContext *WavpackOpenFileInput (read_stream infile, char *error) | 50 | WavpackContext *WavpackOpenFileInput (read_stream infile, char *error) |
51 | { | 51 | { |
52 | WavpackStream *wps = &wpc.stream; | 52 | WavpackStream *wps = &wpc.stream; |
53 | ulong bcount; | 53 | uint32_t bcount; |
54 | 54 | ||
55 | CLEAR (wpc); | 55 | CLEAR (wpc); |
56 | wpc.infile = infile; | 56 | wpc.infile = infile; |
57 | wpc.total_samples = (ulong) -1; | 57 | wpc.total_samples = (uint32_t) -1; |
58 | wpc.norm_offset = 0; | 58 | wpc.norm_offset = 0; |
59 | wpc.open_flags = 0; | 59 | wpc.open_flags = 0; |
60 | 60 | ||
@@ -64,7 +64,7 @@ WavpackContext *WavpackOpenFileInput (read_stream infile, char *error) | |||
64 | 64 | ||
65 | bcount = read_next_header (wpc.infile, &wps->wphdr); | 65 | bcount = read_next_header (wpc.infile, &wps->wphdr); |
66 | 66 | ||
67 | if (bcount == (ulong) -1) { | 67 | if (bcount == (uint32_t) -1) { |
68 | strcpy_loc (error, "invalid WavPack file!"); | 68 | strcpy_loc (error, "invalid WavPack file!"); |
69 | return NULL; | 69 | return NULL; |
70 | } | 70 | } |
@@ -74,7 +74,7 @@ WavpackContext *WavpackOpenFileInput (read_stream infile, char *error) | |||
74 | return NULL; | 74 | return NULL; |
75 | } | 75 | } |
76 | 76 | ||
77 | if (wps->wphdr.block_samples && wps->wphdr.total_samples != (ulong) -1) | 77 | if (wps->wphdr.block_samples && wps->wphdr.total_samples != (uint32_t) -1) |
78 | wpc.total_samples = wps->wphdr.total_samples; | 78 | wpc.total_samples = wps->wphdr.total_samples; |
79 | 79 | ||
80 | if (!unpack_init (&wpc)) { | 80 | if (!unpack_init (&wpc)) { |
@@ -148,18 +148,18 @@ int WavpackGetMode (WavpackContext *wpc) | |||
148 | 148 | ||
149 | // Unpack the specified number of samples from the current file position. | 149 | // Unpack the specified number of samples from the current file position. |
150 | // Note that "samples" here refers to "complete" samples, which would be | 150 | // Note that "samples" here refers to "complete" samples, which would be |
151 | // 2 longs for stereo files. The audio data is returned right-justified in | 151 | // 2 int32_t's for stereo files. The audio data is returned right-justified in |
152 | // 32-bit longs in the endian mode native to the executing processor. So, | 152 | // 32-bit int32_t's in the endian mode native to the executing processor. So, |
153 | // if the original data was 16-bit, then the values returned would be | 153 | // if the original data was 16-bit, then the values returned would be |
154 | // +/-32k. Floating point data can also be returned if the source was | 154 | // +/-32k. Floating point data can also be returned if the source was |
155 | // floating point data (and this is normalized to +/-1.0). The actual number | 155 | // floating point data (and this is normalized to +/-1.0). The actual number |
156 | // of samples unpacked is returned, which should be equal to the number | 156 | // of samples unpacked is returned, which should be equal to the number |
157 | // requested unless the end of fle is encountered or an error occurs. | 157 | // requested unless the end of fle is encountered or an error occurs. |
158 | 158 | ||
159 | ulong WavpackUnpackSamples (WavpackContext *wpc, long *buffer, ulong samples) | 159 | uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples) |
160 | { | 160 | { |
161 | WavpackStream *wps = &wpc->stream; | 161 | WavpackStream *wps = &wpc->stream; |
162 | ulong bcount, samples_unpacked = 0, samples_to_unpack; | 162 | uint32_t bcount, samples_unpacked = 0, samples_to_unpack; |
163 | int num_channels = wpc->config.num_channels; | 163 | int num_channels = wpc->config.num_channels; |
164 | 164 | ||
165 | while (samples) { | 165 | while (samples) { |
@@ -167,7 +167,7 @@ ulong WavpackUnpackSamples (WavpackContext *wpc, long *buffer, ulong samples) | |||
167 | wps->sample_index >= wps->wphdr.block_index + wps->wphdr.block_samples) { | 167 | wps->sample_index >= wps->wphdr.block_index + wps->wphdr.block_samples) { |
168 | bcount = read_next_header (wpc->infile, &wps->wphdr); | 168 | bcount = read_next_header (wpc->infile, &wps->wphdr); |
169 | 169 | ||
170 | if (bcount == (ulong) -1) | 170 | if (bcount == (uint32_t) -1) |
171 | break; | 171 | break; |
172 | 172 | ||
173 | if (wps->wphdr.version < 0x402 || wps->wphdr.version > 0x40f) { | 173 | if (wps->wphdr.version < 0x402 || wps->wphdr.version > 0x40f) { |
@@ -234,19 +234,19 @@ ulong WavpackUnpackSamples (WavpackContext *wpc, long *buffer, ulong samples) | |||
234 | 234 | ||
235 | // Get total number of samples contained in the WavPack file, or -1 if unknown | 235 | // Get total number of samples contained in the WavPack file, or -1 if unknown |
236 | 236 | ||
237 | ulong WavpackGetNumSamples (WavpackContext *wpc) | 237 | uint32_t WavpackGetNumSamples (WavpackContext *wpc) |
238 | { | 238 | { |
239 | return wpc ? wpc->total_samples : (ulong) -1; | 239 | return wpc ? wpc->total_samples : (uint32_t) -1; |
240 | } | 240 | } |
241 | 241 | ||
242 | // Get the current sample index position, or -1 if unknown | 242 | // Get the current sample index position, or -1 if unknown |
243 | 243 | ||
244 | ulong WavpackGetSampleIndex (WavpackContext *wpc) | 244 | uint32_t WavpackGetSampleIndex (WavpackContext *wpc) |
245 | { | 245 | { |
246 | if (wpc) | 246 | if (wpc) |
247 | return wpc->stream.sample_index; | 247 | return wpc->stream.sample_index; |
248 | 248 | ||
249 | return (ulong) -1; | 249 | return (uint32_t) -1; |
250 | } | 250 | } |
251 | 251 | ||
252 | // Get the number of errors encountered so far | 252 | // Get the number of errors encountered so far |
@@ -265,7 +265,7 @@ int WavpackLossyBlocks (WavpackContext *wpc) | |||
265 | 265 | ||
266 | // Returns the sample rate of the specified WavPack file | 266 | // Returns the sample rate of the specified WavPack file |
267 | 267 | ||
268 | ulong WavpackGetSampleRate (WavpackContext *wpc) | 268 | uint32_t WavpackGetSampleRate (WavpackContext *wpc) |
269 | { | 269 | { |
270 | return wpc ? wpc->config.sample_rate : 44100; | 270 | return wpc ? wpc->config.sample_rate : 44100; |
271 | } | 271 | } |
@@ -284,7 +284,7 @@ int WavpackGetNumChannels (WavpackContext *wpc) | |||
284 | // always has 32 bits, integers may be from 1 to 32 bits each. When this | 284 | // always has 32 bits, integers may be from 1 to 32 bits each. When this |
285 | // value is not a multiple of 8, then the "extra" bits are located in the | 285 | // value is not a multiple of 8, then the "extra" bits are located in the |
286 | // LSBs of the results. That is, values are right justified when unpacked | 286 | // LSBs of the results. That is, values are right justified when unpacked |
287 | // into longs, but are left justified in the number of bytes used by the | 287 | // into int32_t's, but are left justified in the number of bytes used by the |
288 | // original data. | 288 | // original data. |
289 | 289 | ||
290 | int WavpackGetBitsPerSample (WavpackContext *wpc) | 290 | int WavpackGetBitsPerSample (WavpackContext *wpc) |
@@ -294,8 +294,8 @@ int WavpackGetBitsPerSample (WavpackContext *wpc) | |||
294 | 294 | ||
295 | // Returns the number of bytes used for each sample (1 to 4) in the original | 295 | // Returns the number of bytes used for each sample (1 to 4) in the original |
296 | // file. This is required information for the user of this module because the | 296 | // file. This is required information for the user of this module because the |
297 | // audio data is returned in the LOWER bytes of the long buffer and must be | 297 | // audio data is returned in the LOWER bytes of the int32_t buffer and must be |
298 | // left-shifted 8, 16, or 24 bits if normalized longs are required. | 298 | // left-shifted 8, 16, or 24 bits if normalized int32_t's are required. |
299 | 299 | ||
300 | int WavpackGetBytesPerSample (WavpackContext *wpc) | 300 | int WavpackGetBytesPerSample (WavpackContext *wpc) |
301 | { | 301 | { |
@@ -321,10 +321,10 @@ int WavpackGetReducedChannels (WavpackContext *wpc) | |||
321 | // to indicate the error. No additional bytes are read past the header and it | 321 | // to indicate the error. No additional bytes are read past the header and it |
322 | // is returned in the processor's native endian mode. Seeking is not required. | 322 | // is returned in the processor's native endian mode. Seeking is not required. |
323 | 323 | ||
324 | static ulong read_next_header (read_stream infile, WavpackHeader *wphdr) | 324 | static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr) |
325 | { | 325 | { |
326 | char buffer [sizeof (*wphdr)], *sp = buffer + sizeof (*wphdr), *ep = sp; | 326 | char buffer [sizeof (*wphdr)], *sp = buffer + sizeof (*wphdr), *ep = sp; |
327 | ulong bytes_skipped = 0; | 327 | uint32_t bytes_skipped = 0; |
328 | int bleft; | 328 | int bleft; |
329 | 329 | ||
330 | while (1) { | 330 | while (1) { |
@@ -335,7 +335,7 @@ static ulong read_next_header (read_stream infile, WavpackHeader *wphdr) | |||
335 | else | 335 | else |
336 | bleft = 0; | 336 | bleft = 0; |
337 | 337 | ||
338 | if (infile (buffer + bleft, sizeof (*wphdr) - bleft) != (long) sizeof (*wphdr) - bleft) | 338 | if (infile (buffer + bleft, sizeof (*wphdr) - bleft) != (int32_t) sizeof (*wphdr) - bleft) |
339 | return -1; | 339 | return -1; |
340 | 340 | ||
341 | sp = buffer; | 341 | sp = buffer; |
@@ -407,10 +407,10 @@ WavpackContext *WavpackOpenFileOutput (void) | |||
407 | // WavPack file will not be directly unpackable to a valid wav file (although | 407 | // WavPack file will not be directly unpackable to a valid wav file (although |
408 | // it will still be usable by itself). A return of FALSE indicates an error. | 408 | // it will still be usable by itself). A return of FALSE indicates an error. |
409 | 409 | ||
410 | int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, ulong total_samples) | 410 | int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples) |
411 | { | 411 | { |
412 | WavpackStream *wps = &wpc->stream; | 412 | WavpackStream *wps = &wpc->stream; |
413 | ulong flags = (config->bytes_per_sample - 1), shift = 0; | 413 | uint32_t flags = (config->bytes_per_sample - 1), shift = 0; |
414 | int num_chans = config->num_channels; | 414 | int num_chans = config->num_channels; |
415 | int i; | 415 | int i; |
416 | 416 | ||
@@ -467,7 +467,7 @@ int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, ulong t | |||
467 | // first block written and update the header directly. An example of this can | 467 | // first block written and update the header directly. An example of this can |
468 | // be found in the Audition filter. | 468 | // be found in the Audition filter. |
469 | 469 | ||
470 | void WavpackAddWrapper (WavpackContext *wpc, void *data, ulong bcount) | 470 | void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount) |
471 | { | 471 | { |
472 | wpc->wrapper_data = data; | 472 | wpc->wrapper_data = data; |
473 | wpc->wrapper_bytes = bcount; | 473 | wpc->wrapper_bytes = bcount; |
@@ -484,7 +484,7 @@ int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end) | |||
484 | return pack_start_block (wpc); | 484 | return pack_start_block (wpc); |
485 | } | 485 | } |
486 | 486 | ||
487 | // Pack the specified samples. Samples must be stored in longs in the native | 487 | // Pack the specified samples. Samples must be stored in int32_ts in the native |
488 | // endian format of the executing processor. The number of samples specified | 488 | // endian format of the executing processor. The number of samples specified |
489 | // indicates composite samples (sometimes called "frames"). So, the actual | 489 | // indicates composite samples (sometimes called "frames"). So, the actual |
490 | // number of data points would be this "sample_count" times the number of | 490 | // number of data points would be this "sample_count" times the number of |
@@ -493,7 +493,7 @@ int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end) | |||
493 | // many times as desired to build the final block (and performs the actual | 493 | // many times as desired to build the final block (and performs the actual |
494 | // compression during the call). A return of FALSE indicates an error. | 494 | // compression during the call). A return of FALSE indicates an error. |
495 | 495 | ||
496 | int WavpackPackSamples (WavpackContext *wpc, long *sample_buffer, ulong sample_count) | 496 | int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count) |
497 | { | 497 | { |
498 | if (!sample_count || pack_samples (wpc, sample_buffer, sample_count)) | 498 | if (!sample_count || pack_samples (wpc, sample_buffer, sample_count)) |
499 | return TRUE; | 499 | return TRUE; |
@@ -506,10 +506,10 @@ int WavpackPackSamples (WavpackContext *wpc, long *sample_buffer, ulong sample_c | |||
506 | // block in bytes. Note that the possible conversion of the WavPack header to | 506 | // block in bytes. Note that the possible conversion of the WavPack header to |
507 | // little-endian takes place here. | 507 | // little-endian takes place here. |
508 | 508 | ||
509 | ulong WavpackFinishBlock (WavpackContext *wpc) | 509 | uint32_t WavpackFinishBlock (WavpackContext *wpc) |
510 | { | 510 | { |
511 | WavpackStream *wps = &wpc->stream; | 511 | WavpackStream *wps = &wpc->stream; |
512 | ulong bcount; | 512 | uint32_t bcount; |
513 | 513 | ||
514 | pack_finish_block (wpc); | 514 | pack_finish_block (wpc); |
515 | bcount = ((WavpackHeader *) wps->blockbuff)->ckSize + 8; | 515 | bcount = ((WavpackHeader *) wps->blockbuff)->ckSize + 8; |