summaryrefslogtreecommitdiff
path: root/apps/codecs/libwavpack/words.c
diff options
context:
space:
mode:
authorDave Bryant <bryant@rockbox.org>2006-03-26 22:54:15 +0000
committerDave Bryant <bryant@rockbox.org>2006-03-26 22:54:15 +0000
commit0ad19c7262f987691d04051648e71d6f30892d5f (patch)
tree5ed040adca51fe7f5fbffb7ae58a50e7f565c111 /apps/codecs/libwavpack/words.c
parentd2327dd83d9a88acbc936687a1b823c1b2f573d8 (diff)
downloadrockbox-0ad19c7262f987691d04051648e71d6f30892d5f.tar.gz
rockbox-0ad19c7262f987691d04051648e71d6f30892d5f.zip
Eliminate references to "long" types for 64-bit compiles; return audio data
in Rockbox standard S3.28 format git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9272 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwavpack/words.c')
-rw-r--r--apps/codecs/libwavpack/words.c44
1 files changed, 22 insertions, 22 deletions
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
144static int mylog2 (unsigned long avalue); 144static 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
256void update_error_limit (struct words_data *w, ulong flags) 256void 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
313static ulong read_code (Bitstream *bs, ulong maxcode); 313static 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
323long get_words (long *buffer, int nsamples, ulong flags, 323int32_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
496static ulong read_code (Bitstream *bs, ulong maxcode) 496static 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
517void send_words (long *buffer, int nsamples, ulong flags, 517void 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
712static int mylog2 (unsigned long avalue) 712static 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
736int log2s (long value) 736int 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
746long exp2s (int log) 746int32_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);