diff options
Diffstat (limited to 'apps/codecs/libwavpack/wputils.c')
-rw-r--r-- | apps/codecs/libwavpack/wputils.c | 58 |
1 files changed, 29 insertions, 29 deletions
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; |