summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/demac/libdemac/predictor-arm.S2
-rw-r--r--apps/codecs/lib/ffmpeg_bswap.h36
-rw-r--r--apps/codecs/lib/fft-ffmpeg.c2
-rw-r--r--apps/codecs/lib/setjmp.h8
-rw-r--r--apps/codecs/lib/setjmp_arm.S128
-rw-r--r--apps/codecs/lib/setjmp_cf.S60
-rw-r--r--apps/codecs/lib/tlsf/src/tlsf.c160
-rw-r--r--apps/codecs/liba52/a52.h6
-rw-r--r--apps/codecs/liba52/a52_internal.h84
-rw-r--r--apps/codecs/liba52/bit_allocate.c242
-rw-r--r--apps/codecs/liba52/bitstream.c12
-rw-r--r--apps/codecs/liba52/bitstream.h16
-rw-r--r--apps/codecs/liba52/downmix.c674
-rw-r--r--apps/codecs/liba52/imdct.c172
-rw-r--r--apps/codecs/liba52/imdct_lookups.h2
-rw-r--r--apps/codecs/liba52/mm_accel.h8
-rw-r--r--apps/codecs/liba52/parse.c1200
-rw-r--r--apps/codecs/libasap/acpu.c2270
-rw-r--r--apps/codecs/libasap/apokeysnd.c920
-rw-r--r--apps/codecs/libasap/asap.c3716
-rw-r--r--apps/codecs/libasap/asap.h204
-rw-r--r--apps/codecs/libasap/players.h2736
-rw-r--r--apps/codecs/libfaad/hcr.c2
-rw-r--r--apps/codecs/libfaad/huffman.c6
-rw-r--r--apps/codecs/libfaad/sbr_dct.c26
-rw-r--r--apps/codecs/libfaad/sbr_dec.c2
-rw-r--r--apps/codecs/libfaad/sbr_hfadj.c2
-rw-r--r--apps/codecs/libfaad/sbr_hfgen.c36
-rw-r--r--apps/codecs/libfaad/sbr_qmf.c22
-rw-r--r--apps/codecs/libfaad/sbr_syntax.c10
-rw-r--r--apps/codecs/libffmpegFLAC/bitstream.h8
-rw-r--r--apps/codecs/libffmpegFLAC/golomb.h2
-rw-r--r--apps/codecs/libffmpegFLAC/main.c2
-rw-r--r--apps/codecs/libmad/bit.c40
-rw-r--r--apps/codecs/libmad/bit.h4
-rw-r--r--apps/codecs/libmad/decoder.c196
-rw-r--r--apps/codecs/libmad/decoder.h36
-rw-r--r--apps/codecs/libmad/fixed.c8
-rw-r--r--apps/codecs/libmad/fixed.h238
-rw-r--r--apps/codecs/libmad/frame.c62
-rw-r--r--apps/codecs/libmad/frame.h74
-rw-r--r--apps/codecs/libmad/global.h4
-rw-r--r--apps/codecs/libmad/huffman.c692
-rw-r--r--apps/codecs/libmad/layer12.c226
-rw-r--r--apps/codecs/libmad/layer3.c694
-rw-r--r--apps/codecs/libmad/mad.h566
-rw-r--r--apps/codecs/libmad/minimad.c18
-rw-r--r--apps/codecs/libmad/stream.c70
-rw-r--r--apps/codecs/libmad/stream.h98
-rw-r--r--apps/codecs/libmad/synth.c518
-rw-r--r--apps/codecs/libmad/synth.h16
-rw-r--r--apps/codecs/libmad/timer.c82
-rw-r--r--apps/codecs/libmad/timer.h64
-rw-r--r--apps/codecs/libmad/version.h26
-rw-r--r--apps/codecs/librm/rm.c4
-rw-r--r--apps/codecs/libspeex/_kiss_fft_guts.h42
-rw-r--r--apps/codecs/libspeex/cb_search.c24
-rw-r--r--apps/codecs/libspeex/kiss_fft.c6
-rw-r--r--apps/codecs/libspeex/kiss_fft.h8
-rw-r--r--apps/codecs/libspeex/lsp.c200
-rw-r--r--apps/codecs/libspeex/lsp.h12
-rw-r--r--apps/codecs/libspeex/ltp_bfin.h60
-rw-r--r--apps/codecs/libspeex/nb_celp.c6
-rw-r--r--apps/codecs/libspeex/oggframing.c62
-rw-r--r--apps/codecs/libspeex/quant_lsp_bfin.h66
-rw-r--r--apps/codecs/libspeex/sb_celp.c2
-rw-r--r--apps/codecs/libspeex/smallft.c12
-rw-r--r--apps/codecs/libspeex/speex/ogg.h14
-rw-r--r--apps/codecs/libspeex/vorbis_psy.c16
-rw-r--r--apps/codecs/libtremor/asm_arm.h82
-rw-r--r--apps/codecs/libtremor/backends.h10
-rw-r--r--apps/codecs/libtremor/codebook.c204
-rw-r--r--apps/codecs/libtremor/codebook.h18
-rw-r--r--apps/codecs/libtremor/floor0.c36
-rw-r--r--apps/codecs/libtremor/framing.c4
-rw-r--r--apps/codecs/libtremor/info.c64
-rw-r--r--apps/codecs/libtremor/ivorbiscodec.h4
-rw-r--r--apps/codecs/libtremor/ivorbisfile.h6
-rw-r--r--apps/codecs/libtremor/lsp_lookup.h100
-rw-r--r--apps/codecs/libtremor/misc.h32
-rw-r--r--apps/codecs/libtremor/sharedbook.c240
-rw-r--r--apps/codecs/libtremor/window.h4
-rw-r--r--apps/codecs/libwavpack/pack.c4
-rw-r--r--apps/codecs/libwma/asf.h16
84 files changed, 8933 insertions, 8933 deletions
diff --git a/apps/codecs/demac/libdemac/predictor-arm.S b/apps/codecs/demac/libdemac/predictor-arm.S
index 28808c8e96..1d5587661a 100644
--- a/apps/codecs/demac/libdemac/predictor-arm.S
+++ b/apps/codecs/demac/libdemac/predictor-arm.S
@@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
49 49
50#define XfilterB 20 /* int32_t XfilterB; */ 50#define XfilterB 20 /* int32_t XfilterB; */
51#define YfilterA 24 /* int32_t YfilterA; */ 51#define YfilterA 24 /* int32_t YfilterA; */
52 52
53#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */ 53#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */
54#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */ 54#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */
55#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */ 55#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */
diff --git a/apps/codecs/lib/ffmpeg_bswap.h b/apps/codecs/lib/ffmpeg_bswap.h
index b083d10ed0..24a2aab7ea 100644
--- a/apps/codecs/lib/ffmpeg_bswap.h
+++ b/apps/codecs/lib/ffmpeg_bswap.h
@@ -34,8 +34,8 @@ static inline uint64_t ByteSwap64(uint64_t x)
34#elif defined(ARCH_X86) 34#elif defined(ARCH_X86)
35static inline unsigned short ByteSwap16(unsigned short x) 35static inline unsigned short ByteSwap16(unsigned short x)
36{ 36{
37 __asm("xchgb %b0,%h0" : 37 __asm("xchgb %b0,%h0" :
38 "=q" (x) : 38 "=q" (x) :
39 "0" (x)); 39 "0" (x));
40 return x; 40 return x;
41} 41}
@@ -44,13 +44,13 @@ static inline unsigned short ByteSwap16(unsigned short x)
44static inline unsigned int ByteSwap32(unsigned int x) 44static inline unsigned int ByteSwap32(unsigned int x)
45{ 45{
46#if __CPU__ > 386 46#if __CPU__ > 386
47 __asm("bswap %0": 47 __asm("bswap %0":
48 "=r" (x) : 48 "=r" (x) :
49#else 49#else
50 __asm("xchgb %b0,%h0\n" 50 __asm("xchgb %b0,%h0\n"
51 " rorl $16,%0\n" 51 " rorl $16,%0\n"
52 " xchgb %b0,%h0": 52 " xchgb %b0,%h0":
53 "=q" (x) : 53 "=q" (x) :
54#endif 54#endif
55 "0" (x)); 55 "0" (x));
56 return x; 56 return x;
@@ -61,7 +61,7 @@ static inline unsigned long long int ByteSwap64(unsigned long long int x)
61{ 61{
62 register union { __extension__ uint64_t __ll; 62 register union { __extension__ uint64_t __ll;
63 uint32_t __l[2]; } __x; 63 uint32_t __l[2]; } __x;
64 asm("xchgl %0,%1": 64 asm("xchgl %0,%1":
65 "=r"(__x.__l[0]),"=r"(__x.__l[1]): 65 "=r"(__x.__l[0]),"=r"(__x.__l[1]):
66 "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); 66 "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
67 return __x.__ll; 67 return __x.__ll;
@@ -71,17 +71,17 @@ static inline unsigned long long int ByteSwap64(unsigned long long int x)
71#elif defined(ARCH_SH4) 71#elif defined(ARCH_SH4)
72 72
73static inline uint16_t ByteSwap16(uint16_t x) { 73static inline uint16_t ByteSwap16(uint16_t x) {
74 __asm__("swap.b %0,%0":"=r"(x):"0"(x)); 74 __asm__("swap.b %0,%0":"=r"(x):"0"(x));
75 return x; 75 return x;
76} 76}
77 77
78static inline uint32_t ByteSwap32(uint32_t x) { 78static inline uint32_t ByteSwap32(uint32_t x) {
79 __asm__( 79 __asm__(
80 "swap.b %0,%0\n" 80 "swap.b %0,%0\n"
81 "swap.w %0,%0\n" 81 "swap.w %0,%0\n"
82 "swap.b %0,%0\n" 82 "swap.b %0,%0\n"
83 :"=r"(x):"0"(x)); 83 :"=r"(x):"0"(x));
84 return x; 84 return x;
85} 85}
86 86
87#define bswap_16(x) ByteSwap16(x) 87#define bswap_16(x) ByteSwap16(x)
@@ -124,9 +124,9 @@ static inline uint64_t ByteSwap64(uint64_t x)
124} 124}
125#define bswap_64(x) ByteSwap64(x) 125#define bswap_64(x) ByteSwap64(x)
126 126
127#endif /* !ARCH_X86 */ 127#endif /* !ARCH_X86 */
128 128
129#endif /* !HAVE_BYTESWAP_H */ 129#endif /* !HAVE_BYTESWAP_H */
130 130
131// be2me ... BigEndian to MachineEndian 131// be2me ... BigEndian to MachineEndian
132// le2me ... LittleEndian to MachineEndian 132// le2me ... LittleEndian to MachineEndian
diff --git a/apps/codecs/lib/fft-ffmpeg.c b/apps/codecs/lib/fft-ffmpeg.c
index 203a82e7d4..d18f0481c0 100644
--- a/apps/codecs/lib/fft-ffmpeg.c
+++ b/apps/codecs/lib/fft-ffmpeg.c
@@ -463,7 +463,7 @@ int main (void)
463//exec_time = (((double)end-(double)start)/CLOCKS_PER_SEC); 463//exec_time = (((double)end-(double)start)/CLOCKS_PER_SEC);
464 for(j = 0; j < FFT_SIZE; j++) 464 for(j = 0; j < FFT_SIZE; j++)
465 { 465 {
466 printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2))); 466 printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2)));
467 //getchar(); 467 //getchar();
468 } 468 }
469 printf("muls = %d, adds = %d\n", muls, adds); 469 printf("muls = %d, adds = %d\n", muls, adds);
diff --git a/apps/codecs/lib/setjmp.h b/apps/codecs/lib/setjmp.h
index eed43c6f95..f7ff2ea58c 100644
--- a/apps/codecs/lib/setjmp.h
+++ b/apps/codecs/lib/setjmp.h
@@ -18,10 +18,10 @@
18#ifdef CPU_COLDFIRE 18#ifdef CPU_COLDFIRE
19/* 19/*
20 * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6, 20 * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
21 * fp2-fp7 for 68881. 21 * fp2-fp7 for 68881.
22 * All else recovered by under/over(flow) handling. 22 * All else recovered by under/over(flow) handling.
23 */ 23 */
24#define _JBLEN 34 24#define _JBLEN 34
25#endif 25#endif
26 26
27#ifdef CPU_MIPS 27#ifdef CPU_MIPS
@@ -48,9 +48,9 @@
48 48
49#ifdef _JBLEN 49#ifdef _JBLEN
50#ifdef _JBTYPE 50#ifdef _JBTYPE
51typedef _JBTYPE jmp_buf[_JBLEN]; 51typedef _JBTYPE jmp_buf[_JBLEN];
52#else 52#else
53typedef int jmp_buf[_JBLEN]; 53typedef int jmp_buf[_JBLEN];
54#endif 54#endif
55#else 55#else
56typedef int jmp_buf; 56typedef int jmp_buf;
diff --git a/apps/codecs/lib/setjmp_arm.S b/apps/codecs/lib/setjmp_arm.S
index 4bb2a46a7a..a4d5a016bd 100644
--- a/apps/codecs/lib/setjmp_arm.S
+++ b/apps/codecs/lib/setjmp_arm.S
@@ -27,10 +27,10 @@
27 in both interworked and non-interworked environments as well as with 27 in both interworked and non-interworked environments as well as with
28 older processors which do not have the BX instruction we do the 28 older processors which do not have the BX instruction we do the
29 following: 29 following:
30 Test the return address. 30 Test the return address.
31 If the bottom bit is clear perform an "old style" function exit. 31 If the bottom bit is clear perform an "old style" function exit.
32 (We know that we are in ARM mode and returning to an ARM mode caller). 32 (We know that we are in ARM mode and returning to an ARM mode caller).
33 Otherwise use the BX instruction to perform the function exit. 33 Otherwise use the BX instruction to perform the function exit.
34 34
35 We know that we will never attempt to perform the BX instruction on 35 We know that we will never attempt to perform the BX instruction on
36 an older processor, because that kind of processor will never be 36 an older processor, because that kind of processor will never be
@@ -47,7 +47,7 @@
47 test the bottom bit, because this is part of the processor status. 47 test the bottom bit, because this is part of the processor status.
48 Instead we just do a normal return, since we know that we cannot be 48 Instead we just do a normal return, since we know that we cannot be
49 returning to a Thumb caller - the Thumb does not support APCS-26. 49 returning to a Thumb caller - the Thumb does not support APCS-26.
50 50
51 Function entry is much simpler. If we are compiling for the Thumb we 51 Function entry is much simpler. If we are compiling for the Thumb we
52 just switch into ARM mode and then drop through into the rest of the 52 just switch into ARM mode and then drop through into the rest of the
53 function. The function exit code will take care of the restore to 53 function. The function exit code will take care of the restore to
@@ -56,18 +56,18 @@
56 For Thumb-2 do everything in Thumb mode. */ 56 For Thumb-2 do everything in Thumb mode. */
57 57
58#ifdef __APCS_26__ 58#ifdef __APCS_26__
59#define RET movs pc, lr 59#define RET movs pc, lr
60#elif defined(__thumb2__) 60#elif defined(__thumb2__)
61#define RET bx lr 61#define RET bx lr
62#else 62#else
63#define RET tst lr, #1; \ 63#define RET tst lr, #1; \
64 moveq pc, lr ; \ 64 moveq pc, lr ; \
65.word 0xe12fff1e /* bx lr */ 65.word 0xe12fff1e /* bx lr */
66#endif 66#endif
67 67
68#ifdef __thumb2__ 68#ifdef __thumb2__
69.macro COND where when 69.macro COND where when
70 i\where \when 70 i\where \when
71.endm 71.endm
72#else 72#else
73.macro COND where when 73.macro COND where when
@@ -77,96 +77,96 @@
77#if defined(__thumb2__) 77#if defined(__thumb2__)
78.syntax unified 78.syntax unified
79.macro MODE 79.macro MODE
80 .thumb 80 .thumb
81 .thumb_func 81 .thumb_func
82.endm 82.endm
83.macro PROLOGUE name 83.macro PROLOGUE name
84.endm 84.endm
85 85
86#elif defined(__thumb__) 86#elif defined(__thumb__)
87#define MODE .thumb_func 87#define MODE .thumb_func
88.macro PROLOGUE name 88.macro PROLOGUE name
89 .code 16 89 .code 16
90 bx pc 90 bx pc
91 nop 91 nop
92 .code 32 92 .code 32
93SYM (.arm_start_of.\name): 93SYM (.arm_start_of.\name):
94.endm 94.endm
95#else /* Arm */ 95#else /* Arm */
96#define MODE .code 32 96#define MODE .code 32
97.macro PROLOGUE name 97.macro PROLOGUE name
98.endm 98.endm
99#endif 99#endif
100 100
101.macro FUNC_START name 101.macro FUNC_START name
102 .text 102 .text
103 .align 2 103 .align 2
104 MODE 104 MODE
105 .globl SYM (\name) 105 .globl SYM (\name)
106 TYPE (\name) 106 TYPE (\name)
107SYM (\name): 107SYM (\name):
108 PROLOGUE \name 108 PROLOGUE \name
109.endm 109.endm
110 110
111.macro FUNC_END name 111.macro FUNC_END name
112 RET 112 RET
113 SIZE (\name) 113 SIZE (\name)
114.endm 114.endm
115 115
116/* -------------------------------------------------------------------- 116/* --------------------------------------------------------------------
117 int setjmp (jmp_buf); 117 int setjmp (jmp_buf);
118 -------------------------------------------------------------------- */ 118 -------------------------------------------------------------------- */
119 119
120 FUNC_START setjmp 120 FUNC_START setjmp
121 121
122 /* Save all the callee-preserved registers into the jump buffer. */ 122 /* Save all the callee-preserved registers into the jump buffer. */
123#ifdef __thumb2__ 123#ifdef __thumb2__
124 stmea a1!, { v1-v7, fp, ip, lr } 124 stmea a1!, { v1-v7, fp, ip, lr }
125 str sp, [a1],#+4 125 str sp, [a1],#+4
126#else 126#else
127 stmea a1!, { v1-v7, fp, ip, sp, lr } 127 stmea a1!, { v1-v7, fp, ip, sp, lr }
128#endif 128#endif
129 129
130#if 0 /* Simulator does not cope with FP instructions yet. */ 130#if 0 /* Simulator does not cope with FP instructions yet. */
131#ifndef __SOFTFP__ 131#ifndef __SOFTFP__
132 /* Save the floating point registers. */ 132 /* Save the floating point registers. */
133 sfmea f4, 4, [a1] 133 sfmea f4, 4, [a1]
134#endif 134#endif
135#endif 135#endif
136 /* When setting up the jump buffer return 0. */ 136 /* When setting up the jump buffer return 0. */
137 mov a1, #0 137 mov a1, #0
138 138
139 FUNC_END setjmp 139 FUNC_END setjmp
140 140
141/* -------------------------------------------------------------------- 141/* --------------------------------------------------------------------
142 volatile void longjmp (jmp_buf, int); 142 volatile void longjmp (jmp_buf, int);
143 -------------------------------------------------------------------- */ 143 -------------------------------------------------------------------- */
144 144
145 FUNC_START longjmp 145 FUNC_START longjmp
146 146
147 /* If we have stack extension code it ought to be handled here. */ 147 /* If we have stack extension code it ought to be handled here. */
148 148
149 /* Restore the registers, retrieving the state when setjmp() was called. */ 149 /* Restore the registers, retrieving the state when setjmp() was called. */
150#ifdef __thumb2__ 150#ifdef __thumb2__
151 ldmfd a1!, { v1-v7, fp, ip, lr } 151 ldmfd a1!, { v1-v7, fp, ip, lr }
152 ldr sp, [a1],#+4 152 ldr sp, [a1],#+4
153#else 153#else
154 ldmfd a1!, { v1-v7, fp, ip, sp, lr } 154 ldmfd a1!, { v1-v7, fp, ip, sp, lr }
155#endif 155#endif
156 156
157#if 0 /* Simulator does not cope with FP instructions yet. */ 157#if 0 /* Simulator does not cope with FP instructions yet. */
158#ifndef __SOFTFP__ 158#ifndef __SOFTFP__
159 /* Restore floating point registers as well. */ 159 /* Restore floating point registers as well. */
160 lfmfd f4, 4, [a1] 160 lfmfd f4, 4, [a1]
161#endif 161#endif
162#endif 162#endif
163 /* Put the return value into the integer result register. 163 /* Put the return value into the integer result register.
164 But if it is zero then return 1 instead. */ 164 But if it is zero then return 1 instead. */
165 movs a1, a2 165 movs a1, a2
166#ifdef __thumb2__ 166#ifdef __thumb2__
167 it eq 167 it eq
168#endif 168#endif
169 moveq a1, #1 169 moveq a1, #1
170 170
171 FUNC_END longjmp 171 FUNC_END longjmp
172 172
diff --git a/apps/codecs/lib/setjmp_cf.S b/apps/codecs/lib/setjmp_cf.S
index acc98c3f59..86eda8079c 100644
--- a/apps/codecs/lib/setjmp_cf.S
+++ b/apps/codecs/lib/setjmp_cf.S
@@ -34,46 +34,46 @@
34.global SYM (longjmp) 34.global SYM (longjmp)
35 35
36SYM (setjmp): 36SYM (setjmp):
37 moveal sp@(4),a0 37 moveal sp@(4),a0
38 movel sp@(0),a0@(12) 38 movel sp@(0),a0@(12)
39 movel sp,a0@(8) 39 movel sp,a0@(8)
40 moveml d2-d7/a2-a6,a0@(20) 40 moveml d2-d7/a2-a6,a0@(20)
41 clrl d0 41 clrl d0
42 rts 42 rts
43 43
44SYM (longjmp): 44SYM (longjmp):
45 moveal sp@(4),a0 45 moveal sp@(4),a0
46 movel sp@(8),d0 46 movel sp@(8),d0
47 bne 1f 47 bne 1f
48 movel &1,d0 48 movel &1,d0
491: 491:
50 moveml a0@(20),d2-d7/a2-a6 50 moveml a0@(20),d2-d7/a2-a6
51 moveal a0@(8),sp 51 moveal a0@(8),sp
52 movel a0@(12),sp@ 52 movel a0@(12),sp@
53 rts 53 rts
54 54
55#ifdef M68881 55#ifdef M68881
56.global SYM (setjmp_68881) 56.global SYM (setjmp_68881)
57.global SYM (longjmp_68881) 57.global SYM (longjmp_68881)
58 58
59SYM (setjmp_68881): 59SYM (setjmp_68881):
60 moveal sp@(4),a0 60 moveal sp@(4),a0
61 movel sp@(0),a0@(12) 61 movel sp@(0),a0@(12)
62 movel sp,a0@(8) 62 movel sp,a0@(8)
63 moveml d2-d7/a2-a6,a0@(20) 63 moveml d2-d7/a2-a6,a0@(20)
64 fmovemx fp2-fp7,a0@(64) 64 fmovemx fp2-fp7,a0@(64)
65 clrl d0 65 clrl d0
66 rts 66 rts
67 67
68SYM (longjmp_68881): 68SYM (longjmp_68881):
69 moveal sp@(4),a0 69 moveal sp@(4),a0
70 fmovemx a0@(64),fp2-fp7 70 fmovemx a0@(64),fp2-fp7
71 movel sp@(8),d0 71 movel sp@(8),d0
72 bne 1f 72 bne 1f
73 movel &1,d0 73 movel &1,d0
741: 741:
75 moveml a0@(20),d2-d7/a2-a6 75 moveml a0@(20),d2-d7/a2-a6
76 moveal a0@(8),sp 76 moveal a0@(8),sp
77 movel a0@(12),sp@ 77 movel a0@(12),sp@
78 rts 78 rts
79#endif 79#endif
diff --git a/apps/codecs/lib/tlsf/src/tlsf.c b/apps/codecs/lib/tlsf/src/tlsf.c
index 830184761a..6d15c3a3f6 100644
--- a/apps/codecs/lib/tlsf/src/tlsf.c
+++ b/apps/codecs/lib/tlsf/src/tlsf.c
@@ -56,19 +56,19 @@
56#include <string.h> 56#include <string.h>
57 57
58#ifndef TLSF_USE_LOCKS 58#ifndef TLSF_USE_LOCKS
59#define TLSF_USE_LOCKS (0) 59#define TLSF_USE_LOCKS (0)
60#endif 60#endif
61 61
62#ifndef TLSF_STATISTIC 62#ifndef TLSF_STATISTIC
63#define TLSF_STATISTIC (0) 63#define TLSF_STATISTIC (0)
64#endif 64#endif
65 65
66#ifndef USE_MMAP 66#ifndef USE_MMAP
67#define USE_MMAP (0) 67#define USE_MMAP (0)
68#endif 68#endif
69 69
70#ifndef USE_SBRK 70#ifndef USE_SBRK
71#define USE_SBRK (0) 71#define USE_SBRK (0)
72#endif 72#endif
73 73
74 74
@@ -82,18 +82,18 @@
82#endif 82#endif
83 83
84#if TLSF_STATISTIC 84#if TLSF_STATISTIC
85#define TLSF_ADD_SIZE(tlsf, b) do { \ 85#define TLSF_ADD_SIZE(tlsf, b) do { \
86 tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \ 86 tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
87 if (tlsf->used_size > tlsf->max_size) \ 87 if (tlsf->used_size > tlsf->max_size) \
88 tlsf->max_size = tlsf->used_size; \ 88 tlsf->max_size = tlsf->used_size; \
89 } while(0) 89 } while(0)
90 90
91#define TLSF_REMOVE_SIZE(tlsf, b) do { \ 91#define TLSF_REMOVE_SIZE(tlsf, b) do { \
92 tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \ 92 tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
93 } while(0) 93 } while(0)
94#else 94#else
95#define TLSF_ADD_SIZE(tlsf, b) do{}while(0) 95#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
96#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0) 96#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
97#endif 97#endif
98 98
99#if USE_MMAP || USE_SBRK 99#if USE_MMAP || USE_SBRK
@@ -125,37 +125,37 @@
125/* Unlike the preview TLSF versions, now they are statics */ 125/* Unlike the preview TLSF versions, now they are statics */
126#define BLOCK_ALIGN (sizeof(void *) * 2) 126#define BLOCK_ALIGN (sizeof(void *) * 2)
127 127
128#define MAX_FLI (30) 128#define MAX_FLI (30)
129#define MAX_LOG2_SLI (5) 129#define MAX_LOG2_SLI (5)
130#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */ 130#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */
131 131
132#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */ 132#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
133/* than 128 bytes */ 133/* than 128 bytes */
134#define SMALL_BLOCK (128) 134#define SMALL_BLOCK (128)
135#define REAL_FLI (MAX_FLI - FLI_OFFSET) 135#define REAL_FLI (MAX_FLI - FLI_OFFSET)
136#define MIN_BLOCK_SIZE (sizeof (free_ptr_t)) 136#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
137#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE) 137#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
138#define TLSF_SIGNATURE (0x2A59FA59) 138#define TLSF_SIGNATURE (0x2A59FA59)
139 139
140#define PTR_MASK (sizeof(void *) - 1) 140#define PTR_MASK (sizeof(void *) - 1)
141#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK) 141#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)
142 142
143#define GET_NEXT_BLOCK(_addr, _r) ((bhdr_t *) ((char *) (_addr) + (_r))) 143#define GET_NEXT_BLOCK(_addr, _r) ((bhdr_t *) ((char *) (_addr) + (_r)))
144#define MEM_ALIGN ((BLOCK_ALIGN) - 1) 144#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
145#define ROUNDUP_SIZE(_r) (((_r) + MEM_ALIGN) & ~MEM_ALIGN) 145#define ROUNDUP_SIZE(_r) (((_r) + MEM_ALIGN) & ~MEM_ALIGN)
146#define ROUNDDOWN_SIZE(_r) ((_r) & ~MEM_ALIGN) 146#define ROUNDDOWN_SIZE(_r) ((_r) & ~MEM_ALIGN)
147#define ROUNDUP(_x, _v) ((((~(_x)) + 1) & ((_v)-1)) + (_x)) 147#define ROUNDUP(_x, _v) ((((~(_x)) + 1) & ((_v)-1)) + (_x))
148 148
149#define BLOCK_STATE (0x1) 149#define BLOCK_STATE (0x1)
150#define PREV_STATE (0x2) 150#define PREV_STATE (0x2)
151 151
152/* bit 0 of the block size */ 152/* bit 0 of the block size */
153#define FREE_BLOCK (0x1) 153#define FREE_BLOCK (0x1)
154#define USED_BLOCK (0x0) 154#define USED_BLOCK (0x0)
155 155
156/* bit 1 of the block size */ 156/* bit 1 of the block size */
157#define PREV_FREE (0x2) 157#define PREV_FREE (0x2)
158#define PREV_USED (0x0) 158#define PREV_USED (0x0)
159 159
160 160
161#define DEFAULT_AREA_SIZE (1024*10) 161#define DEFAULT_AREA_SIZE (1024*10)
@@ -352,46 +352,46 @@ static __inline__ bhdr_t *FIND_SUITABLE_BLOCK(tlsf_t * _tlsf, int *_fl, int *_sl
352} 352}
353 353
354 354
355#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \ 355#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
356 _tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \ 356 _tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
357 if (_tlsf -> matrix[_fl][_sl]) \ 357 if (_tlsf -> matrix[_fl][_sl]) \
358 _tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \ 358 _tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
359 else { \ 359 else { \
360 clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \ 360 clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
361 if (!_tlsf -> sl_bitmap [_fl]) \ 361 if (!_tlsf -> sl_bitmap [_fl]) \
362 clear_bit (_fl, &_tlsf -> fl_bitmap); \ 362 clear_bit (_fl, &_tlsf -> fl_bitmap); \
363 } \ 363 } \
364 _b -> ptr.free_ptr.prev = NULL; \ 364 _b -> ptr.free_ptr.prev = NULL; \
365 _b -> ptr.free_ptr.next = NULL; \ 365 _b -> ptr.free_ptr.next = NULL; \
366 }while(0) 366 }while(0)
367 367
368 368
369#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \ 369#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
370 if (_b -> ptr.free_ptr.next) \ 370 if (_b -> ptr.free_ptr.next) \
371 _b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \ 371 _b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
372 if (_b -> ptr.free_ptr.prev) \ 372 if (_b -> ptr.free_ptr.prev) \
373 _b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \ 373 _b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
374 if (_tlsf -> matrix [_fl][_sl] == _b) { \ 374 if (_tlsf -> matrix [_fl][_sl] == _b) { \
375 _tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \ 375 _tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
376 if (!_tlsf -> matrix [_fl][_sl]) { \ 376 if (!_tlsf -> matrix [_fl][_sl]) { \
377 clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \ 377 clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
378 if (!_tlsf -> sl_bitmap [_fl]) \ 378 if (!_tlsf -> sl_bitmap [_fl]) \
379 clear_bit (_fl, &_tlsf -> fl_bitmap); \ 379 clear_bit (_fl, &_tlsf -> fl_bitmap); \
380 } \ 380 } \
381 } \ 381 } \
382 _b -> ptr.free_ptr.prev = NULL; \ 382 _b -> ptr.free_ptr.prev = NULL; \
383 _b -> ptr.free_ptr.next = NULL; \ 383 _b -> ptr.free_ptr.next = NULL; \
384 } while(0) 384 } while(0)
385 385
386#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \ 386#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
387 _b -> ptr.free_ptr.prev = NULL; \ 387 _b -> ptr.free_ptr.prev = NULL; \
388 _b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \ 388 _b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
389 if (_tlsf -> matrix [_fl][_sl]) \ 389 if (_tlsf -> matrix [_fl][_sl]) \
390 _tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \ 390 _tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
391 _tlsf -> matrix [_fl][_sl] = _b; \ 391 _tlsf -> matrix [_fl][_sl] = _b; \
392 set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \ 392 set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
393 set_bit (_fl, &_tlsf -> fl_bitmap); \ 393 set_bit (_fl, &_tlsf -> fl_bitmap); \
394 } while(0) 394 } while(0)
395 395
396#if USE_SBRK || USE_MMAP 396#if USE_SBRK || USE_MMAP
397static __inline__ void *get_new_area(size_t * size) 397static __inline__ void *get_new_area(size_t * size)
@@ -656,9 +656,9 @@ void *tlsf_realloc(void *ptr, size_t size)
656 void *ret; 656 void *ret;
657 657
658#if USE_MMAP || USE_SBRK 658#if USE_MMAP || USE_SBRK
659 if (!mp) { 659 if (!mp) {
660 return tlsf_malloc(size); 660 return tlsf_malloc(size);
661 } 661 }
662#endif 662#endif
663 663
664 TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock); 664 TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
@@ -813,7 +813,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
813 new_size = (new_size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : ROUNDUP_SIZE(new_size); 813 new_size = (new_size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : ROUNDUP_SIZE(new_size);
814 tmp_size = (b->size & BLOCK_SIZE); 814 tmp_size = (b->size & BLOCK_SIZE);
815 if (new_size <= tmp_size) { 815 if (new_size <= tmp_size) {
816 TLSF_REMOVE_SIZE(tlsf, b); 816 TLSF_REMOVE_SIZE(tlsf, b);
817 if (next_b->size & FREE_BLOCK) { 817 if (next_b->size & FREE_BLOCK) {
818 MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl); 818 MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
819 EXTRACT_BLOCK(next_b, tlsf, fl, sl); 819 EXTRACT_BLOCK(next_b, tlsf, fl, sl);
@@ -833,12 +833,12 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
833 INSERT_BLOCK(tmp_b, tlsf, fl, sl); 833 INSERT_BLOCK(tmp_b, tlsf, fl, sl);
834 b->size = new_size | (b->size & PREV_STATE); 834 b->size = new_size | (b->size & PREV_STATE);
835 } 835 }
836 TLSF_ADD_SIZE(tlsf, b); 836 TLSF_ADD_SIZE(tlsf, b);
837 return (void *) b->ptr.buffer; 837 return (void *) b->ptr.buffer;
838 } 838 }
839 if ((next_b->size & FREE_BLOCK)) { 839 if ((next_b->size & FREE_BLOCK)) {
840 if (new_size <= (tmp_size + (next_b->size & BLOCK_SIZE))) { 840 if (new_size <= (tmp_size + (next_b->size & BLOCK_SIZE))) {
841 TLSF_REMOVE_SIZE(tlsf, b); 841 TLSF_REMOVE_SIZE(tlsf, b);
842 MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl); 842 MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
843 EXTRACT_BLOCK(next_b, tlsf, fl, sl); 843 EXTRACT_BLOCK(next_b, tlsf, fl, sl);
844 b->size += (next_b->size & BLOCK_SIZE) + BHDR_OVERHEAD; 844 b->size += (next_b->size & BLOCK_SIZE) + BHDR_OVERHEAD;
@@ -856,7 +856,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
856 INSERT_BLOCK(tmp_b, tlsf, fl, sl); 856 INSERT_BLOCK(tmp_b, tlsf, fl, sl);
857 b->size = new_size | (b->size & PREV_STATE); 857 b->size = new_size | (b->size & PREV_STATE);
858 } 858 }
859 TLSF_ADD_SIZE(tlsf, b); 859 TLSF_ADD_SIZE(tlsf, b);
860 return (void *) b->ptr.buffer; 860 return (void *) b->ptr.buffer;
861 } 861 }
862 } 862 }
diff --git a/apps/codecs/liba52/a52.h b/apps/codecs/liba52/a52.h
index aa4e7f6243..cae9ae6403 100644
--- a/apps/codecs/liba52/a52.h
+++ b/apps/codecs/liba52/a52.h
@@ -56,11 +56,11 @@ typedef struct a52_state_s a52_state_t;
56a52_state_t * a52_init (uint32_t mm_accel); 56a52_state_t * a52_init (uint32_t mm_accel);
57sample_t * a52_samples (a52_state_t * state); 57sample_t * a52_samples (a52_state_t * state);
58int a52_syncinfo (uint8_t * buf, int * flags, 58int a52_syncinfo (uint8_t * buf, int * flags,
59 int * sample_rate, int * bit_rate); 59 int * sample_rate, int * bit_rate);
60int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, 60int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
61 level_t * level, sample_t bias); 61 level_t * level, sample_t bias);
62void a52_dynrng (a52_state_t * state, 62void a52_dynrng (a52_state_t * state,
63 level_t (* call) (level_t, void *), void * data); 63 level_t (* call) (level_t, void *), void * data);
64int a52_block (a52_state_t * state); 64int a52_block (a52_state_t * state);
65void a52_free (a52_state_t * state); 65void a52_free (a52_state_t * state);
66 66
diff --git a/apps/codecs/liba52/a52_internal.h b/apps/codecs/liba52/a52_internal.h
index 1e3b4a7edf..48f23836f7 100644
--- a/apps/codecs/liba52/a52_internal.h
+++ b/apps/codecs/liba52/a52_internal.h
@@ -22,62 +22,62 @@
22 */ 22 */
23 23
24typedef struct { 24typedef struct {
25 uint8_t bai; /* fine SNR offset, fast gain */ 25 uint8_t bai; /* fine SNR offset, fast gain */
26 uint8_t deltbae; /* delta bit allocation exists */ 26 uint8_t deltbae; /* delta bit allocation exists */
27 int8_t deltba[50]; /* per-band delta bit allocation */ 27 int8_t deltba[50]; /* per-band delta bit allocation */
28} ba_t; 28} ba_t;
29 29
30typedef struct { 30typedef struct {
31 uint8_t exp[256]; /* decoded channel exponents */ 31 uint8_t exp[256]; /* decoded channel exponents */
32 int8_t bap[256]; /* derived channel bit allocation */ 32 int8_t bap[256]; /* derived channel bit allocation */
33} expbap_t; 33} expbap_t;
34 34
35struct a52_state_s { 35struct a52_state_s {
36 uint8_t fscod; /* sample rate */ 36 uint8_t fscod; /* sample rate */
37 uint8_t halfrate; /* halfrate factor */ 37 uint8_t halfrate; /* halfrate factor */
38 uint8_t acmod; /* coded channels */ 38 uint8_t acmod; /* coded channels */
39 uint8_t lfeon; /* coded lfe channel */ 39 uint8_t lfeon; /* coded lfe channel */
40 level_t clev; /* centre channel mix level */ 40 level_t clev; /* centre channel mix level */
41 level_t slev; /* surround channels mix level */ 41 level_t slev; /* surround channels mix level */
42 42
43 int output; /* type of output */ 43 int output; /* type of output */
44 level_t level; /* output level */ 44 level_t level; /* output level */
45 sample_t bias; /* output bias */ 45 sample_t bias; /* output bias */
46 46
47 int dynrnge; /* apply dynamic range */ 47 int dynrnge; /* apply dynamic range */
48 level_t dynrng; /* dynamic range */ 48 level_t dynrng; /* dynamic range */
49 void * dynrngdata; /* dynamic range callback funtion and data */ 49 void * dynrngdata; /* dynamic range callback funtion and data */
50 level_t (* dynrngcall) (level_t range, void * dynrngdata); 50 level_t (* dynrngcall) (level_t range, void * dynrngdata);
51 51
52 uint8_t chincpl; /* channel coupled */ 52 uint8_t chincpl; /* channel coupled */
53 uint8_t phsflginu; /* phase flags in use (stereo only) */ 53 uint8_t phsflginu; /* phase flags in use (stereo only) */
54 uint8_t cplstrtmant; /* coupling channel start mantissa */ 54 uint8_t cplstrtmant; /* coupling channel start mantissa */
55 uint8_t cplendmant; /* coupling channel end mantissa */ 55 uint8_t cplendmant; /* coupling channel end mantissa */
56 uint32_t cplbndstrc; /* coupling band structure */ 56 uint32_t cplbndstrc; /* coupling band structure */
57 level_t cplco[5][18]; /* coupling coordinates */ 57 level_t cplco[5][18]; /* coupling coordinates */
58 58
59 /* derived information */ 59 /* derived information */
60 uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */ 60 uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
61 uint8_t ncplbnd; /* number of coupling bands */ 61 uint8_t ncplbnd; /* number of coupling bands */
62 62
63 uint8_t rematflg; /* stereo rematrixing */ 63 uint8_t rematflg; /* stereo rematrixing */
64 64
65 uint8_t endmant[5]; /* channel end mantissa */ 65 uint8_t endmant[5]; /* channel end mantissa */
66 66
67 uint16_t bai; /* bit allocation information */ 67 uint16_t bai; /* bit allocation information */
68 68
69 uint32_t * buffer_start; 69 uint32_t * buffer_start;
70 uint16_t lfsr_state; /* dither state */ 70 uint16_t lfsr_state; /* dither state */
71 uint32_t bits_left; 71 uint32_t bits_left;
72 uint32_t current_word; 72 uint32_t current_word;
73 73
74 uint8_t csnroffst; /* coarse SNR offset */ 74 uint8_t csnroffst; /* coarse SNR offset */
75 ba_t cplba; /* coupling bit allocation parameters */ 75 ba_t cplba; /* coupling bit allocation parameters */
76 ba_t ba[5]; /* channel bit allocation parameters */ 76 ba_t ba[5]; /* channel bit allocation parameters */
77 ba_t lfeba; /* lfe bit allocation parameters */ 77 ba_t lfeba; /* lfe bit allocation parameters */
78 78
79 uint8_t cplfleak; /* coupling fast leak init */ 79 uint8_t cplfleak; /* coupling fast leak init */
80 uint8_t cplsleak; /* coupling slow leak init */ 80 uint8_t cplsleak; /* coupling slow leak init */
81 81
82 expbap_t cpl_expbap; 82 expbap_t cpl_expbap;
83 expbap_t fbw_expbap[5]; 83 expbap_t fbw_expbap[5];
@@ -104,15 +104,15 @@ struct a52_state_s {
104#define DELTA_BIT_RESERVED (3) 104#define DELTA_BIT_RESERVED (3)
105 105
106void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, 106void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
107 int start, int end, int fastleak, int slowleak, 107 int start, int end, int fastleak, int slowleak,
108 expbap_t * expbap); 108 expbap_t * expbap);
109 109
110int a52_downmix_init (int input, int flags, level_t * level, 110int a52_downmix_init (int input, int flags, level_t * level,
111 level_t clev, level_t slev); 111 level_t clev, level_t slev);
112int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, 112int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
113 level_t clev, level_t slev); 113 level_t clev, level_t slev);
114void a52_downmix (sample_t * samples, int acmod, int output, 114void a52_downmix (sample_t * samples, int acmod, int output,
115 level_t clev, level_t slev); 115 level_t clev, level_t slev);
116void a52_upmix (sample_t * samples, int acmod, int output); 116void a52_upmix (sample_t * samples, int acmod, int output);
117 117
118void a52_imdct_init (uint32_t mm_accel); 118void a52_imdct_init (uint32_t mm_accel);
diff --git a/apps/codecs/liba52/bit_allocate.c b/apps/codecs/liba52/bit_allocate.c
index f72cd75f0a..3f68c92c0c 100644
--- a/apps/codecs/liba52/bit_allocate.c
+++ b/apps/codecs/liba52/bit_allocate.c
@@ -52,7 +52,7 @@ static int8_t baptab[305] IDATA_ATTR = {
52 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 52 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
53 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 53 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
54 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 54 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
55 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */ 55 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */
56 56
57 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14, 57 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14,
58 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 58 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9,
@@ -68,12 +68,12 @@ static int8_t baptab[305] IDATA_ATTR = {
68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0 /* 148 padding elems */ 71 0, 0, 0, 0 /* 148 padding elems */
72}; 72};
73 73
74static int bndtab[30] IDATA_ATTR = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34, 74static int bndtab[30] IDATA_ATTR = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
75 37, 40, 43, 46, 49, 55, 61, 67, 73, 79, 75 37, 40, 43, 46, 49, 55, 61, 67, 73, 79,
76 85, 97, 109, 121, 133, 157, 181, 205, 229, 253}; 76 85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
77 77
78static int8_t latab[256] IDATA_ATTR = { 78static int8_t latab[256] IDATA_ATTR = {
79 -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, 79 -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53,
@@ -100,35 +100,35 @@ static int8_t latab[256] IDATA_ATTR = {
100 0, 0, 0, 0 100 0, 0, 0, 0
101}; 101};
102 102
103#define UPDATE_LEAK() \ 103#define UPDATE_LEAK() \
104do { \ 104do { \
105 fastleak += fdecay; \ 105 fastleak += fdecay; \
106 if (fastleak > psd + fgain) \ 106 if (fastleak > psd + fgain) \
107 fastleak = psd + fgain; \ 107 fastleak = psd + fgain; \
108 slowleak += sdecay; \ 108 slowleak += sdecay; \
109 if (slowleak > psd + sgain) \ 109 if (slowleak > psd + sgain) \
110 slowleak = psd + sgain; \ 110 slowleak = psd + sgain; \
111} while (0) 111} while (0)
112 112
113#define COMPUTE_MASK() \ 113#define COMPUTE_MASK() \
114do { \ 114do { \
115 if (psd > dbknee) \ 115 if (psd > dbknee) \
116 mask -= (psd - dbknee) >> 2; \ 116 mask -= (psd - dbknee) >> 2; \
117 if (mask > hth [i >> halfrate]) \ 117 if (mask > hth [i >> halfrate]) \
118 mask = hth [i >> halfrate]; \ 118 mask = hth [i >> halfrate]; \
119 mask -= snroffset + 128 * deltba[i]; \ 119 mask -= snroffset + 128 * deltba[i]; \
120 mask = (mask > 0) ? 0 : ((-mask) >> 5); \ 120 mask = (mask > 0) ? 0 : ((-mask) >> 5); \
121 mask -= floor; \ 121 mask -= floor; \
122} while (0) 122} while (0)
123 123
124void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, 124void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
125 int start, int end, int fastleak, int slowleak, 125 int start, int end, int fastleak, int slowleak,
126 expbap_t * expbap) 126 expbap_t * expbap)
127{ 127{
128 static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410}; 128 static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
129 static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100}; 129 static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100};
130 static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0, 130 static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
131 0xa10, 0xa90, 0xb10, 0x1400}; 131 0xa10, 0xa90, 0xb10, 0x1400};
132 132
133 int i, j; 133 int i, j;
134 uint8_t * exp; 134 uint8_t * exp;
@@ -140,18 +140,18 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
140 int halfrate; 140 int halfrate;
141 141
142 halfrate = state->halfrate; 142 halfrate = state->halfrate;
143 fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */ 143 fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */
144 fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */ 144 fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */
145 sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */ 145 sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */
146 sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */ 146 sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */
147 dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */ 147 dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */
148 hth = hthtab[state->fscod]; 148 hth = hthtab[state->fscod];
149 /* 149 /*
150 * if there is no delta bit allocation, make deltba point to an area 150 * if there is no delta bit allocation, make deltba point to an area
151 * known to contain zeroes. baptab+156 here. 151 * known to contain zeroes. baptab+156 here.
152 */ 152 */
153 deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba; 153 deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba;
154 floor = floortab[state->bai & 7]; /* floorcod */ 154 floor = floortab[state->bai & 7]; /* floorcod */
155 snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor; 155 snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor;
156 floor >>= 5; 156 floor >>= 5;
157 157
@@ -160,106 +160,106 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
160 160
161 i = bndstart; 161 i = bndstart;
162 j = start; 162 j = start;
163 if (start == 0) { /* not the coupling channel */ 163 if (start == 0) { /* not the coupling channel */
164 int lowcomp; 164 int lowcomp;
165 165
166 lowcomp = 0; 166 lowcomp = 0;
167 j = end - 1; 167 j = end - 1;
168 do { 168 do {
169 if (i < j) { 169 if (i < j) {
170 if (exp[i+1] == exp[i] - 2) 170 if (exp[i+1] == exp[i] - 2)
171 lowcomp = 384; 171 lowcomp = 384;
172 else if (lowcomp && (exp[i+1] > exp[i])) 172 else if (lowcomp && (exp[i+1] > exp[i]))
173 lowcomp -= 64; 173 lowcomp -= 64;
174 } 174 }
175 psd = 128 * exp[i]; 175 psd = 128 * exp[i];
176 mask = psd + fgain + lowcomp; 176 mask = psd + fgain + lowcomp;
177 COMPUTE_MASK (); 177 COMPUTE_MASK ();
178 bap[i] = (baptab+156)[mask + 4 * exp[i]]; 178 bap[i] = (baptab+156)[mask + 4 * exp[i]];
179 i++; 179 i++;
180 } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1]))); 180 } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
181 fastleak = psd + fgain; 181 fastleak = psd + fgain;
182 slowleak = psd + sgain; 182 slowleak = psd + sgain;
183 183
184 while (i < 7) { 184 while (i < 7) {
185 if (i < j) { 185 if (i < j) {
186 if (exp[i+1] == exp[i] - 2) 186 if (exp[i+1] == exp[i] - 2)
187 lowcomp = 384; 187 lowcomp = 384;
188 else if (lowcomp && (exp[i+1] > exp[i])) 188 else if (lowcomp && (exp[i+1] > exp[i]))
189 lowcomp -= 64; 189 lowcomp -= 64;
190 } 190 }
191 psd = 128 * exp[i]; 191 psd = 128 * exp[i];
192 UPDATE_LEAK (); 192 UPDATE_LEAK ();
193 mask = ((fastleak + lowcomp < slowleak) ? 193 mask = ((fastleak + lowcomp < slowleak) ?
194 fastleak + lowcomp : slowleak); 194 fastleak + lowcomp : slowleak);
195 COMPUTE_MASK (); 195 COMPUTE_MASK ();
196 bap[i] = (baptab+156)[mask + 4 * exp[i]]; 196 bap[i] = (baptab+156)[mask + 4 * exp[i]];
197 i++; 197 i++;
198 } 198 }
199 199
200 if (end == 7) /* lfe channel */ 200 if (end == 7) /* lfe channel */
201 return; 201 return;
202 202
203 do { 203 do {
204 if (exp[i+1] == exp[i] - 2) 204 if (exp[i+1] == exp[i] - 2)
205 lowcomp = 320; 205 lowcomp = 320;
206 else if (lowcomp && (exp[i+1] > exp[i])) 206 else if (lowcomp && (exp[i+1] > exp[i]))
207 lowcomp -= 64; 207 lowcomp -= 64;
208 psd = 128 * exp[i]; 208 psd = 128 * exp[i];
209 UPDATE_LEAK (); 209 UPDATE_LEAK ();
210 mask = ((fastleak + lowcomp < slowleak) ? 210 mask = ((fastleak + lowcomp < slowleak) ?
211 fastleak + lowcomp : slowleak); 211 fastleak + lowcomp : slowleak);
212 COMPUTE_MASK (); 212 COMPUTE_MASK ();
213 bap[i] = (baptab+156)[mask + 4 * exp[i]]; 213 bap[i] = (baptab+156)[mask + 4 * exp[i]];
214 i++; 214 i++;
215 } while (i < 20); 215 } while (i < 20);
216 216
217 while (lowcomp > 128) { /* two iterations maximum */ 217 while (lowcomp > 128) { /* two iterations maximum */
218 lowcomp -= 128; 218 lowcomp -= 128;
219 psd = 128 * exp[i]; 219 psd = 128 * exp[i];
220 UPDATE_LEAK (); 220 UPDATE_LEAK ();
221 mask = ((fastleak + lowcomp < slowleak) ? 221 mask = ((fastleak + lowcomp < slowleak) ?
222 fastleak + lowcomp : slowleak); 222 fastleak + lowcomp : slowleak);
223 COMPUTE_MASK (); 223 COMPUTE_MASK ();
224 bap[i] = (baptab+156)[mask + 4 * exp[i]]; 224 bap[i] = (baptab+156)[mask + 4 * exp[i]];
225 i++; 225 i++;
226 } 226 }
227 j = i; 227 j = i;
228 } 228 }
229 229
230 do { 230 do {
231 int startband, endband; 231 int startband, endband;
232 232
233 startband = j; 233 startband = j;
234 endband = (bndtab[i-20] < end) ? bndtab[i-20] : end; 234 endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
235 psd = 128 * exp[j++]; 235 psd = 128 * exp[j++];
236 while (j < endband) { 236 while (j < endband) {
237 int next, delta; 237 int next, delta;
238 238
239 next = 128 * exp[j++]; 239 next = 128 * exp[j++];
240 delta = next - psd; 240 delta = next - psd;
241 switch (delta >> 9) { 241 switch (delta >> 9) {
242 case -6: case -5: case -4: case -3: case -2: 242 case -6: case -5: case -4: case -3: case -2:
243 psd = next; 243 psd = next;
244 break; 244 break;
245 case -1: 245 case -1:
246 psd = next + latab[(-delta) >> 1]; 246 psd = next + latab[(-delta) >> 1];
247 break; 247 break;
248 case 0: 248 case 0:
249 psd += latab[delta >> 1]; 249 psd += latab[delta >> 1];
250 break; 250 break;
251 } 251 }
252 } 252 }
253 /* minpsd = -289 */ 253 /* minpsd = -289 */
254 UPDATE_LEAK (); 254 UPDATE_LEAK ();
255 mask = (fastleak < slowleak) ? fastleak : slowleak; 255 mask = (fastleak < slowleak) ? fastleak : slowleak;
256 COMPUTE_MASK (); 256 COMPUTE_MASK ();
257 i++; 257 i++;
258 j = startband; 258 j = startband;
259 do { 259 do {
260 /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */ 260 /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
261 /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */ 261 /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
262 bap[j] = (baptab+156)[mask + 4 * exp[j]]; 262 bap[j] = (baptab+156)[mask + 4 * exp[j]];
263 } while (++j < endband); 263 } while (++j < endband);
264 } while (j < end); 264 } while (j < end);
265} 265}
diff --git a/apps/codecs/liba52/bitstream.c b/apps/codecs/liba52/bitstream.c
index 231654939a..f9f3ad76b0 100644
--- a/apps/codecs/liba52/bitstream.c
+++ b/apps/codecs/liba52/bitstream.c
@@ -40,7 +40,7 @@ void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
40 state->bits_left = 0; 40 state->bits_left = 0;
41 state->current_word = 0; 41 state->current_word = 0;
42 bitstream_get (state, align * 8); 42 bitstream_get (state, align * 8);
43 bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */ 43 bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */
44} 44}
45 45
46static inline void bitstream_fill_current (a52_state_t * state) 46static inline void bitstream_fill_current (a52_state_t * state)
@@ -66,12 +66,12 @@ uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits)
66 66
67 num_bits -= state->bits_left; 67 num_bits -= state->bits_left;
68 result = ((state->current_word << (32 - state->bits_left)) >> 68 result = ((state->current_word << (32 - state->bits_left)) >>
69 (32 - state->bits_left)); 69 (32 - state->bits_left));
70 70
71 bitstream_fill_current (state); 71 bitstream_fill_current (state);
72 72
73 if (num_bits != 0) 73 if (num_bits != 0)
74 result = (result << num_bits) | (state->current_word >> (32 - num_bits)); 74 result = (result << num_bits) | (state->current_word >> (32 - num_bits));
75 75
76 state->bits_left = 32 - num_bits; 76 state->bits_left = 32 - num_bits;
77 77
@@ -84,13 +84,13 @@ int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits)
84 84
85 num_bits -= state->bits_left; 85 num_bits -= state->bits_left;
86 result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >> 86 result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >>
87 (32 - state->bits_left)); 87 (32 - state->bits_left));
88 88
89 bitstream_fill_current(state); 89 bitstream_fill_current(state);
90 90
91 if (num_bits != 0) 91 if (num_bits != 0)
92 result = (result << num_bits) | (state->current_word >> (32 - num_bits)); 92 result = (result << num_bits) | (state->current_word >> (32 - num_bits));
93 93
94 state->bits_left = 32 - num_bits; 94 state->bits_left = 32 - num_bits;
95 95
96 return result; 96 return result;
diff --git a/apps/codecs/liba52/bitstream.h b/apps/codecs/liba52/bitstream.h
index 88f8fc4660..c316a971b5 100644
--- a/apps/codecs/liba52/bitstream.h
+++ b/apps/codecs/liba52/bitstream.h
@@ -30,11 +30,11 @@ int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits);
30static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits) 30static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
31{ 31{
32 uint32_t result; 32 uint32_t result;
33 33
34 if (num_bits < state->bits_left) { 34 if (num_bits < state->bits_left) {
35 result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits); 35 result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
36 state->bits_left -= num_bits; 36 state->bits_left -= num_bits;
37 return result; 37 return result;
38 } 38 }
39 39
40 return a52_bitstream_get_bh (state, num_bits); 40 return a52_bitstream_get_bh (state, num_bits);
@@ -43,11 +43,11 @@ static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
43static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits) 43static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits)
44{ 44{
45 int32_t result; 45 int32_t result;
46 46
47 if (num_bits < state->bits_left) { 47 if (num_bits < state->bits_left) {
48 result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits); 48 result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
49 state->bits_left -= num_bits; 49 state->bits_left -= num_bits;
50 return result; 50 return result;
51 } 51 }
52 52
53 return a52_bitstream_get_bh_2 (state, num_bits); 53 return a52_bitstream_get_bh_2 (state, num_bits);
diff --git a/apps/codecs/liba52/downmix.c b/apps/codecs/liba52/downmix.c
index 2e8567bceb..b9506de8c1 100644
--- a/apps/codecs/liba52/downmix.c
+++ b/apps/codecs/liba52/downmix.c
@@ -32,135 +32,135 @@
32#define CONVERT(acmod,output) (((output) << 3) + (acmod)) 32#define CONVERT(acmod,output) (((output) << 3) + (acmod))
33 33
34int a52_downmix_init (int input, int flags, level_t * level, 34int a52_downmix_init (int input, int flags, level_t * level,
35 level_t clev, level_t slev) 35 level_t clev, level_t slev)
36{ 36{
37 static uint8_t table[11][8] = { 37 static uint8_t table[11][8] = {
38 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, 38 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
39 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, 39 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
40 {A52_MONO, A52_MONO, A52_MONO, A52_MONO, 40 {A52_MONO, A52_MONO, A52_MONO, A52_MONO,
41 A52_MONO, A52_MONO, A52_MONO, A52_MONO}, 41 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
42 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, 42 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
43 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, 43 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
44 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, 44 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
45 A52_STEREO, A52_3F, A52_STEREO, A52_3F}, 45 A52_STEREO, A52_3F, A52_STEREO, A52_3F},
46 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, 46 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
47 A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R}, 47 A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
48 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, 48 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
49 A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R}, 49 A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
50 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, 50 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
51 A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R}, 51 A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
52 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, 52 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
53 A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R}, 53 A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
54 {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO, 54 {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
55 A52_MONO, A52_MONO, A52_MONO, A52_MONO}, 55 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
56 {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO, 56 {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
57 A52_MONO, A52_MONO, A52_MONO, A52_MONO}, 57 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
58 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY, 58 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
59 A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY} 59 A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
60 }; 60 };
61 int output; 61 int output;
62 62
63 output = flags & A52_CHANNEL_MASK; 63 output = flags & A52_CHANNEL_MASK;
64 if (output > A52_DOLBY) 64 if (output > A52_DOLBY)
65 return -1; 65 return -1;
66 66
67 output = table[output][input & 7]; 67 output = table[output][input & 7];
68 68
69 if (output == A52_STEREO && 69 if (output == A52_STEREO &&
70 (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB)))) 70 (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB))))
71 output = A52_DOLBY; 71 output = A52_DOLBY;
72 72
73 if (flags & A52_ADJUST_LEVEL) { 73 if (flags & A52_ADJUST_LEVEL) {
74 level_t adjust; 74 level_t adjust;
75 75
76 switch (CONVERT (input & 7, output)) { 76 switch (CONVERT (input & 7, output)) {
77 77
78 case CONVERT (A52_3F, A52_MONO): 78 case CONVERT (A52_3F, A52_MONO):
79 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev); 79 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
80 break; 80 break;
81 81
82 case CONVERT (A52_STEREO, A52_MONO): 82 case CONVERT (A52_STEREO, A52_MONO):
83 case CONVERT (A52_2F2R, A52_2F1R): 83 case CONVERT (A52_2F2R, A52_2F1R):
84 case CONVERT (A52_3F2R, A52_3F1R): 84 case CONVERT (A52_3F2R, A52_3F1R):
85 level_3db: 85 level_3db:
86 adjust = LEVEL (LEVEL_3DB); 86 adjust = LEVEL (LEVEL_3DB);
87 break; 87 break;
88 88
89 case CONVERT (A52_3F2R, A52_2F1R): 89 case CONVERT (A52_3F2R, A52_2F1R):
90 if (clev < LEVEL (LEVEL_PLUS3DB - 1)) 90 if (clev < LEVEL (LEVEL_PLUS3DB - 1))
91 goto level_3db; 91 goto level_3db;
92 /* break thru */ 92 /* break thru */
93 case CONVERT (A52_3F, A52_STEREO): 93 case CONVERT (A52_3F, A52_STEREO):
94 case CONVERT (A52_3F1R, A52_2F1R): 94 case CONVERT (A52_3F1R, A52_2F1R):
95 case CONVERT (A52_3F1R, A52_2F2R): 95 case CONVERT (A52_3F1R, A52_2F2R):
96 case CONVERT (A52_3F2R, A52_2F2R): 96 case CONVERT (A52_3F2R, A52_2F2R):
97 adjust = DIV (1, LEVEL (1) + clev); 97 adjust = DIV (1, LEVEL (1) + clev);
98 break; 98 break;
99 99
100 case CONVERT (A52_2F1R, A52_MONO): 100 case CONVERT (A52_2F1R, A52_MONO):
101 adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev); 101 adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
102 break; 102 break;
103 103
104 case CONVERT (A52_2F1R, A52_STEREO): 104 case CONVERT (A52_2F1R, A52_STEREO):
105 case CONVERT (A52_3F1R, A52_3F): 105 case CONVERT (A52_3F1R, A52_3F):
106 adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB)); 106 adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
107 break; 107 break;
108 108
109 case CONVERT (A52_3F1R, A52_MONO): 109 case CONVERT (A52_3F1R, A52_MONO):
110 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5)); 110 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
111 break; 111 break;
112 112
113 case CONVERT (A52_3F1R, A52_STEREO): 113 case CONVERT (A52_3F1R, A52_STEREO):
114 adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB)); 114 adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
115 break; 115 break;
116 116
117 case CONVERT (A52_2F2R, A52_MONO): 117 case CONVERT (A52_2F2R, A52_MONO):
118 adjust = DIV (LEVEL_3DB, LEVEL (1) + slev); 118 adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
119 break; 119 break;
120 120
121 case CONVERT (A52_2F2R, A52_STEREO): 121 case CONVERT (A52_2F2R, A52_STEREO):
122 case CONVERT (A52_3F2R, A52_3F): 122 case CONVERT (A52_3F2R, A52_3F):
123 adjust = DIV (1, LEVEL (1) + slev); 123 adjust = DIV (1, LEVEL (1) + slev);
124 break; 124 break;
125 125
126 case CONVERT (A52_3F2R, A52_MONO): 126 case CONVERT (A52_3F2R, A52_MONO):
127 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev); 127 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
128 break; 128 break;
129 129
130 case CONVERT (A52_3F2R, A52_STEREO): 130 case CONVERT (A52_3F2R, A52_STEREO):
131 adjust = DIV (1, LEVEL (1) + clev + slev); 131 adjust = DIV (1, LEVEL (1) + clev + slev);
132 break; 132 break;
133 133
134 case CONVERT (A52_MONO, A52_DOLBY): 134 case CONVERT (A52_MONO, A52_DOLBY):
135 adjust = LEVEL (LEVEL_PLUS3DB); 135 adjust = LEVEL (LEVEL_PLUS3DB);
136 break; 136 break;
137 137
138 case CONVERT (A52_3F, A52_DOLBY): 138 case CONVERT (A52_3F, A52_DOLBY):
139 case CONVERT (A52_2F1R, A52_DOLBY): 139 case CONVERT (A52_2F1R, A52_DOLBY):
140 adjust = LEVEL (1 / (1 + LEVEL_3DB)); 140 adjust = LEVEL (1 / (1 + LEVEL_3DB));
141 break; 141 break;
142 142
143 case CONVERT (A52_3F1R, A52_DOLBY): 143 case CONVERT (A52_3F1R, A52_DOLBY):
144 case CONVERT (A52_2F2R, A52_DOLBY): 144 case CONVERT (A52_2F2R, A52_DOLBY):
145 adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB)); 145 adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
146 break; 146 break;
147 147
148 case CONVERT (A52_3F2R, A52_DOLBY): 148 case CONVERT (A52_3F2R, A52_DOLBY):
149 adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB)); 149 adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
150 break; 150 break;
151 151
152 default: 152 default:
153 return output; 153 return output;
154 } 154 }
155 155
156 *level = MUL_L (*level, adjust); 156 *level = MUL_L (*level, adjust);
157 } 157 }
158 158
159 return output; 159 return output;
160} 160}
161 161
162int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, 162int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
163 level_t clev, level_t slev) 163 level_t clev, level_t slev)
164{ 164{
165 level_t level_3db; 165 level_t level_3db;
166 166
@@ -177,156 +177,156 @@ int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
177 case CONVERT (A52_2F2R, A52_2F2R): 177 case CONVERT (A52_2F2R, A52_2F2R):
178 case CONVERT (A52_3F2R, A52_3F2R): 178 case CONVERT (A52_3F2R, A52_3F2R):
179 case CONVERT (A52_STEREO, A52_DOLBY): 179 case CONVERT (A52_STEREO, A52_DOLBY):
180 coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level; 180 coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
181 return 0; 181 return 0;
182 182
183 case CONVERT (A52_CHANNEL, A52_MONO): 183 case CONVERT (A52_CHANNEL, A52_MONO):
184 coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB); 184 coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
185 return 3; 185 return 3;
186 186
187 case CONVERT (A52_STEREO, A52_MONO): 187 case CONVERT (A52_STEREO, A52_MONO):
188 coeff[0] = coeff[1] = level_3db; 188 coeff[0] = coeff[1] = level_3db;
189 return 3; 189 return 3;
190 190
191 case CONVERT (A52_3F, A52_MONO): 191 case CONVERT (A52_3F, A52_MONO):
192 coeff[0] = coeff[2] = level_3db; 192 coeff[0] = coeff[2] = level_3db;
193 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); 193 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
194 return 7; 194 return 7;
195 195
196 case CONVERT (A52_2F1R, A52_MONO): 196 case CONVERT (A52_2F1R, A52_MONO):
197 coeff[0] = coeff[1] = level_3db; 197 coeff[0] = coeff[1] = level_3db;
198 coeff[2] = MUL_L (level_3db, slev); 198 coeff[2] = MUL_L (level_3db, slev);
199 return 7; 199 return 7;
200 200
201 case CONVERT (A52_2F2R, A52_MONO): 201 case CONVERT (A52_2F2R, A52_MONO):
202 coeff[0] = coeff[1] = level_3db; 202 coeff[0] = coeff[1] = level_3db;
203 coeff[2] = coeff[3] = MUL_L (level_3db, slev); 203 coeff[2] = coeff[3] = MUL_L (level_3db, slev);
204 return 15; 204 return 15;
205 205
206 case CONVERT (A52_3F1R, A52_MONO): 206 case CONVERT (A52_3F1R, A52_MONO):
207 coeff[0] = coeff[2] = level_3db; 207 coeff[0] = coeff[2] = level_3db;
208 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); 208 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
209 coeff[3] = MUL_L (level_3db, slev); 209 coeff[3] = MUL_L (level_3db, slev);
210 return 15; 210 return 15;
211 211
212 case CONVERT (A52_3F2R, A52_MONO): 212 case CONVERT (A52_3F2R, A52_MONO):
213 coeff[0] = coeff[2] = level_3db; 213 coeff[0] = coeff[2] = level_3db;
214 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); 214 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
215 coeff[3] = coeff[4] = MUL_L (level_3db, slev); 215 coeff[3] = coeff[4] = MUL_L (level_3db, slev);
216 return 31; 216 return 31;
217 217
218 case CONVERT (A52_MONO, A52_DOLBY): 218 case CONVERT (A52_MONO, A52_DOLBY):
219 coeff[0] = level_3db; 219 coeff[0] = level_3db;
220 return 0; 220 return 0;
221 221
222 case CONVERT (A52_3F, A52_DOLBY): 222 case CONVERT (A52_3F, A52_DOLBY):
223 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; 223 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
224 coeff[1] = level_3db; 224 coeff[1] = level_3db;
225 return 7; 225 return 7;
226 226
227 case CONVERT (A52_3F, A52_STEREO): 227 case CONVERT (A52_3F, A52_STEREO):
228 case CONVERT (A52_3F1R, A52_2F1R): 228 case CONVERT (A52_3F1R, A52_2F1R):
229 case CONVERT (A52_3F2R, A52_2F2R): 229 case CONVERT (A52_3F2R, A52_2F2R):
230 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; 230 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
231 coeff[1] = MUL_L (level, clev); 231 coeff[1] = MUL_L (level, clev);
232 return 7; 232 return 7;
233 233
234 case CONVERT (A52_2F1R, A52_DOLBY): 234 case CONVERT (A52_2F1R, A52_DOLBY):
235 coeff[0] = coeff[1] = level; 235 coeff[0] = coeff[1] = level;
236 coeff[2] = level_3db; 236 coeff[2] = level_3db;
237 return 7; 237 return 7;
238 238
239 case CONVERT (A52_2F1R, A52_STEREO): 239 case CONVERT (A52_2F1R, A52_STEREO):
240 coeff[0] = coeff[1] = level; 240 coeff[0] = coeff[1] = level;
241 coeff[2] = MUL_L (level_3db, slev); 241 coeff[2] = MUL_L (level_3db, slev);
242 return 7; 242 return 7;
243 243
244 case CONVERT (A52_3F1R, A52_DOLBY): 244 case CONVERT (A52_3F1R, A52_DOLBY):
245 coeff[0] = coeff[2] = level; 245 coeff[0] = coeff[2] = level;
246 coeff[1] = coeff[3] = level_3db; 246 coeff[1] = coeff[3] = level_3db;
247 return 15; 247 return 15;
248 248
249 case CONVERT (A52_3F1R, A52_STEREO): 249 case CONVERT (A52_3F1R, A52_STEREO):
250 coeff[0] = coeff[2] = level; 250 coeff[0] = coeff[2] = level;
251 coeff[1] = MUL_L (level, clev); 251 coeff[1] = MUL_L (level, clev);
252 coeff[3] = MUL_L (level_3db, slev); 252 coeff[3] = MUL_L (level_3db, slev);
253 return 15; 253 return 15;
254 254
255 case CONVERT (A52_2F2R, A52_DOLBY): 255 case CONVERT (A52_2F2R, A52_DOLBY):
256 coeff[0] = coeff[1] = level; 256 coeff[0] = coeff[1] = level;
257 coeff[2] = coeff[3] = level_3db; 257 coeff[2] = coeff[3] = level_3db;
258 return 15; 258 return 15;
259 259
260 case CONVERT (A52_2F2R, A52_STEREO): 260 case CONVERT (A52_2F2R, A52_STEREO):
261 coeff[0] = coeff[1] = level; 261 coeff[0] = coeff[1] = level;
262 coeff[2] = coeff[3] = MUL_L (level, slev); 262 coeff[2] = coeff[3] = MUL_L (level, slev);
263 return 15; 263 return 15;
264 264
265 case CONVERT (A52_3F2R, A52_DOLBY): 265 case CONVERT (A52_3F2R, A52_DOLBY):
266 coeff[0] = coeff[2] = level; 266 coeff[0] = coeff[2] = level;
267 coeff[1] = coeff[3] = coeff[4] = level_3db; 267 coeff[1] = coeff[3] = coeff[4] = level_3db;
268 return 31; 268 return 31;
269 269
270 case CONVERT (A52_3F2R, A52_2F1R): 270 case CONVERT (A52_3F2R, A52_2F1R):
271 coeff[0] = coeff[2] = level; 271 coeff[0] = coeff[2] = level;
272 coeff[1] = MUL_L (level, clev); 272 coeff[1] = MUL_L (level, clev);
273 coeff[3] = coeff[4] = level_3db; 273 coeff[3] = coeff[4] = level_3db;
274 return 31; 274 return 31;
275 275
276 case CONVERT (A52_3F2R, A52_STEREO): 276 case CONVERT (A52_3F2R, A52_STEREO):
277 coeff[0] = coeff[2] = level; 277 coeff[0] = coeff[2] = level;
278 coeff[1] = MUL_L (level, clev); 278 coeff[1] = MUL_L (level, clev);
279 coeff[3] = coeff[4] = MUL_L (level, slev); 279 coeff[3] = coeff[4] = MUL_L (level, slev);
280 return 31; 280 return 31;
281 281
282 case CONVERT (A52_3F1R, A52_3F): 282 case CONVERT (A52_3F1R, A52_3F):
283 coeff[0] = coeff[1] = coeff[2] = level; 283 coeff[0] = coeff[1] = coeff[2] = level;
284 coeff[3] = MUL_L (level_3db, slev); 284 coeff[3] = MUL_L (level_3db, slev);
285 return 13; 285 return 13;
286 286
287 case CONVERT (A52_3F2R, A52_3F): 287 case CONVERT (A52_3F2R, A52_3F):
288 coeff[0] = coeff[1] = coeff[2] = level; 288 coeff[0] = coeff[1] = coeff[2] = level;
289 coeff[3] = coeff[4] = MUL_L (level, slev); 289 coeff[3] = coeff[4] = MUL_L (level, slev);
290 return 29; 290 return 29;
291 291
292 case CONVERT (A52_2F2R, A52_2F1R): 292 case CONVERT (A52_2F2R, A52_2F1R):
293 coeff[0] = coeff[1] = level; 293 coeff[0] = coeff[1] = level;
294 coeff[2] = coeff[3] = level_3db; 294 coeff[2] = coeff[3] = level_3db;
295 return 12; 295 return 12;
296 296
297 case CONVERT (A52_3F2R, A52_3F1R): 297 case CONVERT (A52_3F2R, A52_3F1R):
298 coeff[0] = coeff[1] = coeff[2] = level; 298 coeff[0] = coeff[1] = coeff[2] = level;
299 coeff[3] = coeff[4] = level_3db; 299 coeff[3] = coeff[4] = level_3db;
300 return 24; 300 return 24;
301 301
302 case CONVERT (A52_2F1R, A52_2F2R): 302 case CONVERT (A52_2F1R, A52_2F2R):
303 coeff[0] = coeff[1] = level; 303 coeff[0] = coeff[1] = level;
304 coeff[2] = level_3db; 304 coeff[2] = level_3db;
305 return 0; 305 return 0;
306 306
307 case CONVERT (A52_3F1R, A52_2F2R): 307 case CONVERT (A52_3F1R, A52_2F2R):
308 coeff[0] = coeff[2] = level; 308 coeff[0] = coeff[2] = level;
309 coeff[1] = MUL_L (level, clev); 309 coeff[1] = MUL_L (level, clev);
310 coeff[3] = level_3db; 310 coeff[3] = level_3db;
311 return 7; 311 return 7;
312 312
313 case CONVERT (A52_3F1R, A52_3F2R): 313 case CONVERT (A52_3F1R, A52_3F2R):
314 coeff[0] = coeff[1] = coeff[2] = level; 314 coeff[0] = coeff[1] = coeff[2] = level;
315 coeff[3] = level_3db; 315 coeff[3] = level_3db;
316 return 0; 316 return 0;
317 317
318 case CONVERT (A52_CHANNEL, A52_CHANNEL1): 318 case CONVERT (A52_CHANNEL, A52_CHANNEL1):
319 coeff[0] = level; 319 coeff[0] = level;
320 coeff[1] = 0; 320 coeff[1] = 0;
321 return 0; 321 return 0;
322 322
323 case CONVERT (A52_CHANNEL, A52_CHANNEL2): 323 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
324 coeff[0] = 0; 324 coeff[0] = 0;
325 coeff[1] = level; 325 coeff[1] = level;
326 return 0; 326 return 0;
327 } 327 }
328 328
329 return -1; /* NOTREACHED */ 329 return -1; /* NOTREACHED */
330} 330}
331 331
332static void mix2to1 (sample_t * dest, sample_t * src) 332static void mix2to1 (sample_t * dest, sample_t * src)
@@ -334,7 +334,7 @@ static void mix2to1 (sample_t * dest, sample_t * src)
334 int i; 334 int i;
335 335
336 for (i = 0; i < 256; i++) 336 for (i = 0; i < 256; i++)
337 dest[i] += BIAS (src[i]); 337 dest[i] += BIAS (src[i]);
338} 338}
339 339
340static void mix3to1 (sample_t * samples) 340static void mix3to1 (sample_t * samples)
@@ -342,7 +342,7 @@ static void mix3to1 (sample_t * samples)
342 int i; 342 int i;
343 343
344 for (i = 0; i < 256; i++) 344 for (i = 0; i < 256; i++)
345 samples[i] += BIAS (samples[i + 256] + samples[i + 512]); 345 samples[i] += BIAS (samples[i + 256] + samples[i + 512]);
346} 346}
347 347
348static void mix4to1 (sample_t * samples) 348static void mix4to1 (sample_t * samples)
@@ -350,8 +350,8 @@ static void mix4to1 (sample_t * samples)
350 int i; 350 int i;
351 351
352 for (i = 0; i < 256; i++) 352 for (i = 0; i < 256; i++)
353 samples[i] += BIAS (samples[i + 256] + samples[i + 512] + 353 samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
354 samples[i + 768]); 354 samples[i + 768]);
355} 355}
356 356
357static void mix5to1 (sample_t * samples) 357static void mix5to1 (sample_t * samples)
@@ -359,8 +359,8 @@ static void mix5to1 (sample_t * samples)
359 int i; 359 int i;
360 360
361 for (i = 0; i < 256; i++) 361 for (i = 0; i < 256; i++)
362 samples[i] += BIAS (samples[i + 256] + samples[i + 512] + 362 samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
363 samples[i + 768] + samples[i + 1024]); 363 samples[i + 768] + samples[i + 1024]);
364} 364}
365 365
366static void mix3to2 (sample_t * samples) 366static void mix3to2 (sample_t * samples)
@@ -369,9 +369,9 @@ static void mix3to2 (sample_t * samples)
369 sample_t common; 369 sample_t common;
370 370
371 for (i = 0; i < 256; i++) { 371 for (i = 0; i < 256; i++) {
372 common = BIAS (samples[i + 256]); 372 common = BIAS (samples[i + 256]);
373 samples[i] += common; 373 samples[i] += common;
374 samples[i + 256] = samples[i + 512] + common; 374 samples[i + 256] = samples[i + 512] + common;
375 } 375 }
376} 376}
377 377
@@ -381,9 +381,9 @@ static void mix21to2 (sample_t * left, sample_t * right)
381 sample_t common; 381 sample_t common;
382 382
383 for (i = 0; i < 256; i++) { 383 for (i = 0; i < 256; i++) {
384 common = BIAS (right[i + 256]); 384 common = BIAS (right[i + 256]);
385 left[i] += common; 385 left[i] += common;
386 right[i] += common; 386 right[i] += common;
387 } 387 }
388} 388}
389 389
@@ -393,9 +393,9 @@ static void mix21toS (sample_t * samples)
393 sample_t surround; 393 sample_t surround;
394 394
395 for (i = 0; i < 256; i++) { 395 for (i = 0; i < 256; i++) {
396 surround = samples[i + 512]; 396 surround = samples[i + 512];
397 samples[i] += BIAS (-surround); 397 samples[i] += BIAS (-surround);
398 samples[i + 256] += BIAS (surround); 398 samples[i + 256] += BIAS (surround);
399 } 399 }
400} 400}
401 401
@@ -405,9 +405,9 @@ static void mix31to2 (sample_t * samples)
405 sample_t common; 405 sample_t common;
406 406
407 for (i = 0; i < 256; i++) { 407 for (i = 0; i < 256; i++) {
408 common = BIAS (samples[i + 256] + samples[i + 768]); 408 common = BIAS (samples[i + 256] + samples[i + 768]);
409 samples[i] += common; 409 samples[i] += common;
410 samples[i + 256] = samples[i + 512] + common; 410 samples[i + 256] = samples[i + 512] + common;
411 } 411 }
412} 412}
413 413
@@ -417,10 +417,10 @@ static void mix31toS (sample_t * samples)
417 sample_t common, surround; 417 sample_t common, surround;
418 418
419 for (i = 0; i < 256; i++) { 419 for (i = 0; i < 256; i++) {
420 common = BIAS (samples[i + 256]); 420 common = BIAS (samples[i + 256]);
421 surround = samples[i + 768]; 421 surround = samples[i + 768];
422 samples[i] += common - surround; 422 samples[i] += common - surround;
423 samples[i + 256] = samples[i + 512] + common + surround; 423 samples[i + 256] = samples[i + 512] + common + surround;
424 } 424 }
425} 425}
426 426
@@ -430,9 +430,9 @@ static void mix22toS (sample_t * samples)
430 sample_t surround; 430 sample_t surround;
431 431
432 for (i = 0; i < 256; i++) { 432 for (i = 0; i < 256; i++) {
433 surround = samples[i + 512] + samples[i + 768]; 433 surround = samples[i + 512] + samples[i + 768];
434 samples[i] += BIAS (-surround); 434 samples[i] += BIAS (-surround);
435 samples[i + 256] += BIAS (surround); 435 samples[i + 256] += BIAS (surround);
436 } 436 }
437} 437}
438 438
@@ -442,9 +442,9 @@ static void mix32to2 (sample_t * samples)
442 sample_t common; 442 sample_t common;
443 443
444 for (i = 0; i < 256; i++) { 444 for (i = 0; i < 256; i++) {
445 common = BIAS (samples[i + 256]); 445 common = BIAS (samples[i + 256]);
446 samples[i] += common + samples[i + 768]; 446 samples[i] += common + samples[i + 768];
447 samples[i + 256] = common + samples[i + 512] + samples[i + 1024]; 447 samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
448 } 448 }
449} 449}
450 450
@@ -454,10 +454,10 @@ static void mix32toS (sample_t * samples)
454 sample_t common, surround; 454 sample_t common, surround;
455 455
456 for (i = 0; i < 256; i++) { 456 for (i = 0; i < 256; i++) {
457 common = BIAS (samples[i + 256]); 457 common = BIAS (samples[i + 256]);
458 surround = samples[i + 768] + samples[i + 1024]; 458 surround = samples[i + 768] + samples[i + 1024];
459 samples[i] += common - surround; 459 samples[i] += common - surround;
460 samples[i + 256] = samples[i + 512] + common + surround; 460 samples[i + 256] = samples[i + 512] + common + surround;
461 } 461 }
462} 462}
463 463
@@ -466,7 +466,7 @@ static void move2to1 (sample_t * src, sample_t * dest)
466 int i; 466 int i;
467 467
468 for (i = 0; i < 256; i++) 468 for (i = 0; i < 256; i++)
469 dest[i] = BIAS (src[i] + src[i + 256]); 469 dest[i] = BIAS (src[i] + src[i + 256]);
470} 470}
471 471
472static void zero (sample_t * samples) 472static void zero (sample_t * samples)
@@ -474,11 +474,11 @@ static void zero (sample_t * samples)
474 int i; 474 int i;
475 475
476 for (i = 0; i < 256; i++) 476 for (i = 0; i < 256; i++)
477 samples[i] = 0; 477 samples[i] = 0;
478} 478}
479 479
480void a52_downmix (sample_t * samples, int acmod, int output, 480void a52_downmix (sample_t * samples, int acmod, int output,
481 level_t clev, level_t slev) 481 level_t clev, level_t slev)
482{ 482{
483 /* avoid compiler warning */ 483 /* avoid compiler warning */
484 (void)clev; 484 (void)clev;
@@ -486,138 +486,138 @@ void a52_downmix (sample_t * samples, int acmod, int output,
486 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { 486 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
487 487
488 case CONVERT (A52_CHANNEL, A52_CHANNEL2): 488 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
489 memcpy (samples, samples + 256, 256 * sizeof (sample_t)); 489 memcpy (samples, samples + 256, 256 * sizeof (sample_t));
490 break; 490 break;
491 491
492 case CONVERT (A52_CHANNEL, A52_MONO): 492 case CONVERT (A52_CHANNEL, A52_MONO):
493 case CONVERT (A52_STEREO, A52_MONO): 493 case CONVERT (A52_STEREO, A52_MONO):
494 mix_2to1: 494 mix_2to1:
495 mix2to1 (samples, samples + 256); 495 mix2to1 (samples, samples + 256);
496 break; 496 break;
497 497
498 case CONVERT (A52_2F1R, A52_MONO): 498 case CONVERT (A52_2F1R, A52_MONO):
499 if (slev == 0) 499 if (slev == 0)
500 goto mix_2to1; 500 goto mix_2to1;
501 case CONVERT (A52_3F, A52_MONO): 501 case CONVERT (A52_3F, A52_MONO):
502 mix_3to1: 502 mix_3to1:
503 mix3to1 (samples); 503 mix3to1 (samples);
504 break; 504 break;
505 505
506 case CONVERT (A52_3F1R, A52_MONO): 506 case CONVERT (A52_3F1R, A52_MONO):
507 if (slev == 0) 507 if (slev == 0)
508 goto mix_3to1; 508 goto mix_3to1;
509 case CONVERT (A52_2F2R, A52_MONO): 509 case CONVERT (A52_2F2R, A52_MONO):
510 if (slev == 0) 510 if (slev == 0)
511 goto mix_2to1; 511 goto mix_2to1;
512 mix4to1 (samples); 512 mix4to1 (samples);
513 break; 513 break;
514 514
515 case CONVERT (A52_3F2R, A52_MONO): 515 case CONVERT (A52_3F2R, A52_MONO):
516 if (slev == 0) 516 if (slev == 0)
517 goto mix_3to1; 517 goto mix_3to1;
518 mix5to1 (samples); 518 mix5to1 (samples);
519 break; 519 break;
520 520
521 case CONVERT (A52_MONO, A52_DOLBY): 521 case CONVERT (A52_MONO, A52_DOLBY):
522 memcpy (samples + 256, samples, 256 * sizeof (sample_t)); 522 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
523 break; 523 break;
524 524
525 case CONVERT (A52_3F, A52_STEREO): 525 case CONVERT (A52_3F, A52_STEREO):
526 case CONVERT (A52_3F, A52_DOLBY): 526 case CONVERT (A52_3F, A52_DOLBY):
527 mix_3to2: 527 mix_3to2:
528 mix3to2 (samples); 528 mix3to2 (samples);
529 break; 529 break;
530 530
531 case CONVERT (A52_2F1R, A52_STEREO): 531 case CONVERT (A52_2F1R, A52_STEREO):
532 if (slev == 0) 532 if (slev == 0)
533 break; 533 break;
534 mix21to2 (samples, samples + 256); 534 mix21to2 (samples, samples + 256);
535 break; 535 break;
536 536
537 case CONVERT (A52_2F1R, A52_DOLBY): 537 case CONVERT (A52_2F1R, A52_DOLBY):
538 mix21toS (samples); 538 mix21toS (samples);
539 break; 539 break;
540 540
541 case CONVERT (A52_3F1R, A52_STEREO): 541 case CONVERT (A52_3F1R, A52_STEREO):
542 if (slev == 0) 542 if (slev == 0)
543 goto mix_3to2; 543 goto mix_3to2;
544 mix31to2 (samples); 544 mix31to2 (samples);
545 break; 545 break;
546 546
547 case CONVERT (A52_3F1R, A52_DOLBY): 547 case CONVERT (A52_3F1R, A52_DOLBY):
548 mix31toS (samples); 548 mix31toS (samples);
549 break; 549 break;
550 550
551 case CONVERT (A52_2F2R, A52_STEREO): 551 case CONVERT (A52_2F2R, A52_STEREO):
552 if (slev == 0) 552 if (slev == 0)
553 break; 553 break;
554 mix2to1 (samples, samples + 512); 554 mix2to1 (samples, samples + 512);
555 mix2to1 (samples + 256, samples + 768); 555 mix2to1 (samples + 256, samples + 768);
556 break; 556 break;
557 557
558 case CONVERT (A52_2F2R, A52_DOLBY): 558 case CONVERT (A52_2F2R, A52_DOLBY):
559 mix22toS (samples); 559 mix22toS (samples);
560 break; 560 break;
561 561
562 case CONVERT (A52_3F2R, A52_STEREO): 562 case CONVERT (A52_3F2R, A52_STEREO):
563 if (slev == 0) 563 if (slev == 0)
564 goto mix_3to2; 564 goto mix_3to2;
565 mix32to2 (samples); 565 mix32to2 (samples);
566 break; 566 break;
567 567
568 case CONVERT (A52_3F2R, A52_DOLBY): 568 case CONVERT (A52_3F2R, A52_DOLBY):
569 mix32toS (samples); 569 mix32toS (samples);
570 break; 570 break;
571 571
572 case CONVERT (A52_3F1R, A52_3F): 572 case CONVERT (A52_3F1R, A52_3F):
573 if (slev == 0) 573 if (slev == 0)
574 break; 574 break;
575 mix21to2 (samples, samples + 512); 575 mix21to2 (samples, samples + 512);
576 break; 576 break;
577 577
578 case CONVERT (A52_3F2R, A52_3F): 578 case CONVERT (A52_3F2R, A52_3F):
579 if (slev == 0) 579 if (slev == 0)
580 break; 580 break;
581 mix2to1 (samples, samples + 768); 581 mix2to1 (samples, samples + 768);
582 mix2to1 (samples + 512, samples + 1024); 582 mix2to1 (samples + 512, samples + 1024);
583 break; 583 break;
584 584
585 case CONVERT (A52_3F1R, A52_2F1R): 585 case CONVERT (A52_3F1R, A52_2F1R):
586 mix3to2 (samples); 586 mix3to2 (samples);
587 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); 587 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
588 break; 588 break;
589 589
590 case CONVERT (A52_2F2R, A52_2F1R): 590 case CONVERT (A52_2F2R, A52_2F1R):
591 mix2to1 (samples + 512, samples + 768); 591 mix2to1 (samples + 512, samples + 768);
592 break; 592 break;
593 593
594 case CONVERT (A52_3F2R, A52_2F1R): 594 case CONVERT (A52_3F2R, A52_2F1R):
595 mix3to2 (samples); 595 mix3to2 (samples);
596 move2to1 (samples + 768, samples + 512); 596 move2to1 (samples + 768, samples + 512);
597 break; 597 break;
598 598
599 case CONVERT (A52_3F2R, A52_3F1R): 599 case CONVERT (A52_3F2R, A52_3F1R):
600 mix2to1 (samples + 768, samples + 1024); 600 mix2to1 (samples + 768, samples + 1024);
601 break; 601 break;
602 602
603 case CONVERT (A52_2F1R, A52_2F2R): 603 case CONVERT (A52_2F1R, A52_2F2R):
604 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); 604 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
605 break; 605 break;
606 606
607 case CONVERT (A52_3F1R, A52_2F2R): 607 case CONVERT (A52_3F1R, A52_2F2R):
608 mix3to2 (samples); 608 mix3to2 (samples);
609 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); 609 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
610 break; 610 break;
611 611
612 case CONVERT (A52_3F2R, A52_2F2R): 612 case CONVERT (A52_3F2R, A52_2F2R):
613 mix3to2 (samples); 613 mix3to2 (samples);
614 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); 614 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
615 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t)); 615 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
616 break; 616 break;
617 617
618 case CONVERT (A52_3F1R, A52_3F2R): 618 case CONVERT (A52_3F1R, A52_3F2R):
619 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); 619 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
620 break; 620 break;
621 } 621 }
622} 622}
623 623
@@ -626,63 +626,63 @@ void a52_upmix (sample_t * samples, int acmod, int output)
626 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { 626 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
627 627
628 case CONVERT (A52_CHANNEL, A52_CHANNEL2): 628 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
629 memcpy (samples + 256, samples, 256 * sizeof (sample_t)); 629 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
630 break; 630 break;
631 631
632 case CONVERT (A52_3F2R, A52_MONO): 632 case CONVERT (A52_3F2R, A52_MONO):
633 zero (samples + 1024); 633 zero (samples + 1024);
634 case CONVERT (A52_3F1R, A52_MONO): 634 case CONVERT (A52_3F1R, A52_MONO):
635 case CONVERT (A52_2F2R, A52_MONO): 635 case CONVERT (A52_2F2R, A52_MONO):
636 zero (samples + 768); 636 zero (samples + 768);
637 case CONVERT (A52_3F, A52_MONO): 637 case CONVERT (A52_3F, A52_MONO):
638 case CONVERT (A52_2F1R, A52_MONO): 638 case CONVERT (A52_2F1R, A52_MONO):
639 zero (samples + 512); 639 zero (samples + 512);
640 case CONVERT (A52_CHANNEL, A52_MONO): 640 case CONVERT (A52_CHANNEL, A52_MONO):
641 case CONVERT (A52_STEREO, A52_MONO): 641 case CONVERT (A52_STEREO, A52_MONO):
642 zero (samples + 256); 642 zero (samples + 256);
643 break; 643 break;
644 644
645 case CONVERT (A52_3F2R, A52_STEREO): 645 case CONVERT (A52_3F2R, A52_STEREO):
646 case CONVERT (A52_3F2R, A52_DOLBY): 646 case CONVERT (A52_3F2R, A52_DOLBY):
647 zero (samples + 1024); 647 zero (samples + 1024);
648 case CONVERT (A52_3F1R, A52_STEREO): 648 case CONVERT (A52_3F1R, A52_STEREO):
649 case CONVERT (A52_3F1R, A52_DOLBY): 649 case CONVERT (A52_3F1R, A52_DOLBY):
650 zero (samples + 768); 650 zero (samples + 768);
651 case CONVERT (A52_3F, A52_STEREO): 651 case CONVERT (A52_3F, A52_STEREO):
652 case CONVERT (A52_3F, A52_DOLBY): 652 case CONVERT (A52_3F, A52_DOLBY):
653 mix_3to2: 653 mix_3to2:
654 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t)); 654 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
655 zero (samples + 256); 655 zero (samples + 256);
656 break; 656 break;
657 657
658 case CONVERT (A52_2F2R, A52_STEREO): 658 case CONVERT (A52_2F2R, A52_STEREO):
659 case CONVERT (A52_2F2R, A52_DOLBY): 659 case CONVERT (A52_2F2R, A52_DOLBY):
660 zero (samples + 768); 660 zero (samples + 768);
661 case CONVERT (A52_2F1R, A52_STEREO): 661 case CONVERT (A52_2F1R, A52_STEREO):
662 case CONVERT (A52_2F1R, A52_DOLBY): 662 case CONVERT (A52_2F1R, A52_DOLBY):
663 zero (samples + 512); 663 zero (samples + 512);
664 break; 664 break;
665 665
666 case CONVERT (A52_3F2R, A52_3F): 666 case CONVERT (A52_3F2R, A52_3F):
667 zero (samples + 1024); 667 zero (samples + 1024);
668 case CONVERT (A52_3F1R, A52_3F): 668 case CONVERT (A52_3F1R, A52_3F):
669 case CONVERT (A52_2F2R, A52_2F1R): 669 case CONVERT (A52_2F2R, A52_2F1R):
670 zero (samples + 768); 670 zero (samples + 768);
671 break; 671 break;
672 672
673 case CONVERT (A52_3F2R, A52_3F1R): 673 case CONVERT (A52_3F2R, A52_3F1R):
674 zero (samples + 1024); 674 zero (samples + 1024);
675 break; 675 break;
676 676
677 case CONVERT (A52_3F2R, A52_2F1R): 677 case CONVERT (A52_3F2R, A52_2F1R):
678 zero (samples + 1024); 678 zero (samples + 1024);
679 case CONVERT (A52_3F1R, A52_2F1R): 679 case CONVERT (A52_3F1R, A52_2F1R):
680 mix_31to21: 680 mix_31to21:
681 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); 681 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
682 goto mix_3to2; 682 goto mix_3to2;
683 683
684 case CONVERT (A52_3F2R, A52_2F2R): 684 case CONVERT (A52_3F2R, A52_2F2R):
685 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); 685 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
686 goto mix_31to21; 686 goto mix_31to21;
687 } 687 }
688} 688}
diff --git a/apps/codecs/liba52/imdct.c b/apps/codecs/liba52/imdct.c
index 4483bd0667..9aaa9d85ad 100644
--- a/apps/codecs/liba52/imdct.c
+++ b/apps/codecs/liba52/imdct.c
@@ -114,73 +114,73 @@ static inline void ifft4 (complex_t * buf)
114*/ 114*/
115/* basic radix-2 ifft butterfly */ 115/* basic radix-2 ifft butterfly */
116 116
117#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \ 117#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \
118 t0 = MUL (W1, d1) + MUL (W0, d0); \ 118 t0 = MUL (W1, d1) + MUL (W0, d0); \
119 t1 = MUL (W0, d1) - MUL (W1, d0); \ 119 t1 = MUL (W0, d1) - MUL (W1, d0); \
120} while (0) 120} while (0)
121 121
122/* radix-2 ifft butterfly with bias */ 122/* radix-2 ifft butterfly with bias */
123 123
124#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \ 124#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \
125 t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \ 125 t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \
126 t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \ 126 t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \
127} while (0) 127} while (0)
128 128
129/* the basic split-radix ifft butterfly */ 129/* the basic split-radix ifft butterfly */
130 130
131#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \ 131#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \
132 BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \ 132 BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \
133 BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \ 133 BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \
134 tmp1 = tmp5 + tmp7; \ 134 tmp1 = tmp5 + tmp7; \
135 tmp2 = tmp6 + tmp8; \ 135 tmp2 = tmp6 + tmp8; \
136 tmp3 = tmp6 - tmp8; \ 136 tmp3 = tmp6 - tmp8; \
137 tmp4 = tmp7 - tmp5; \ 137 tmp4 = tmp7 - tmp5; \
138 a2.real = a0.real - tmp1; \ 138 a2.real = a0.real - tmp1; \
139 a2.imag = a0.imag - tmp2; \ 139 a2.imag = a0.imag - tmp2; \
140 a3.real = a1.real - tmp3; \ 140 a3.real = a1.real - tmp3; \
141 a3.imag = a1.imag - tmp4; \ 141 a3.imag = a1.imag - tmp4; \
142 a0.real += tmp1; \ 142 a0.real += tmp1; \
143 a0.imag += tmp2; \ 143 a0.imag += tmp2; \
144 a1.real += tmp3; \ 144 a1.real += tmp3; \
145 a1.imag += tmp4; \ 145 a1.imag += tmp4; \
146} while (0) 146} while (0)
147 147
148/* split-radix ifft butterfly, specialized for wr=1 wi=0 */ 148/* split-radix ifft butterfly, specialized for wr=1 wi=0 */
149 149
150#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \ 150#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \
151 tmp1 = a2.real + a3.real; \ 151 tmp1 = a2.real + a3.real; \
152 tmp2 = a2.imag + a3.imag; \ 152 tmp2 = a2.imag + a3.imag; \
153 tmp3 = a2.imag - a3.imag; \ 153 tmp3 = a2.imag - a3.imag; \
154 tmp4 = a3.real - a2.real; \ 154 tmp4 = a3.real - a2.real; \
155 a2.real = a0.real - tmp1; \ 155 a2.real = a0.real - tmp1; \
156 a2.imag = a0.imag - tmp2; \ 156 a2.imag = a0.imag - tmp2; \
157 a3.real = a1.real - tmp3; \ 157 a3.real = a1.real - tmp3; \
158 a3.imag = a1.imag - tmp4; \ 158 a3.imag = a1.imag - tmp4; \
159 a0.real += tmp1; \ 159 a0.real += tmp1; \
160 a0.imag += tmp2; \ 160 a0.imag += tmp2; \
161 a1.real += tmp3; \ 161 a1.real += tmp3; \
162 a1.imag += tmp4; \ 162 a1.imag += tmp4; \
163} while (0) 163} while (0)
164 164
165/* split-radix ifft butterfly, specialized for wr=wi */ 165/* split-radix ifft butterfly, specialized for wr=wi */
166/* 166/*
167#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \ 167#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \
168 tmp5 = MUL (a2.real + a2.imag, w); \ 168 tmp5 = MUL (a2.real + a2.imag, w); \
169 tmp6 = MUL (a2.imag - a2.real, w); \ 169 tmp6 = MUL (a2.imag - a2.real, w); \
170 tmp7 = MUL (a3.real - a3.imag, w); \ 170 tmp7 = MUL (a3.real - a3.imag, w); \
171 tmp8 = MUL (a3.imag + a3.real, w); \ 171 tmp8 = MUL (a3.imag + a3.real, w); \
172 tmp1 = tmp5 + tmp7; \ 172 tmp1 = tmp5 + tmp7; \
173 tmp2 = tmp6 + tmp8; \ 173 tmp2 = tmp6 + tmp8; \
174 tmp3 = tmp6 - tmp8; \ 174 tmp3 = tmp6 - tmp8; \
175 tmp4 = tmp7 - tmp5; \ 175 tmp4 = tmp7 - tmp5; \
176 a2.real = a0.real - tmp1; \ 176 a2.real = a0.real - tmp1; \
177 a2.imag = a0.imag - tmp2; \ 177 a2.imag = a0.imag - tmp2; \
178 a3.real = a1.real - tmp3; \ 178 a3.real = a1.real - tmp3; \
179 a3.imag = a1.imag - tmp4; \ 179 a3.imag = a1.imag - tmp4; \
180 a0.real += tmp1; \ 180 a0.real += tmp1; \
181 a0.imag += tmp2; \ 181 a0.imag += tmp2; \
182 a1.real += tmp3; \ 182 a1.real += tmp3; \
183 a1.imag += tmp4; \ 183 a1.imag += tmp4; \
184} while (0) 184} while (0)
185 185
186static inline void ifft8 (complex_t * buf) 186static inline void ifft8 (complex_t * buf)
@@ -212,13 +212,13 @@ static void ifft_pass (complex_t * buf, const sample_t * weight, int n)
212 i = n - 1; 212 i = n - 1;
213 213
214 do { 214 do {
215 BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0], 215 BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0],
216 weight[0], weight[2*i-n]); 216 weight[0], weight[2*i-n]);
217 buf++; 217 buf++;
218 buf1++; 218 buf1++;
219 buf2++; 219 buf2++;
220 buf3++; 220 buf3++;
221 weight++; 221 weight++;
222 } while (--i); 222 } while (--i);
223} 223}
224 224
@@ -264,7 +264,7 @@ void a52_imdct_512 (sample_t * data, sample_t * delay)
264 sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2; 264 sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2;
265 const sample_t * window = a52_imdct_window; 265 const sample_t * window = a52_imdct_window;
266 FFTComplex buf[128]; 266 FFTComplex buf[128];
267 267
268 for (i = 0; i < 128; i++) { 268 for (i = 0; i < 128; i++) {
269 k = fftorder[i]; 269 k = fftorder[i];
270 t_r = pre1[i].real; 270 t_r = pre1[i].real;
@@ -357,7 +357,7 @@ static double besselI0 (double x)
357 int i = 100; 357 int i = 100;
358 358
359 do 359 do
360 bessel = bessel * x / (i * i) + 1; 360 bessel = bessel * x / (i * i) + 1;
361 while (--i); 361 while (--i);
362 return bessel; 362 return bessel;
363} 363}
@@ -376,13 +376,13 @@ void a52_imdct_init (uint32_t mm_accel)
376 /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */ 376 /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */
377 /* sum = 0; 377 /* sum = 0;
378 for (i = 0; i < 256; i++) { 378 for (i = 0; i < 256; i++) {
379 sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256)); 379 sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
380 local_imdct_window[i] = sum; 380 local_imdct_window[i] = sum;
381 } 381 }
382 sum++; 382 sum++;
383 */ 383 */
384 /* for (i = 0; i < 256; i++) 384 /* for (i = 0; i < 256; i++)
385 a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum)); 385 a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum));
386 386
387 printf("static sample_t a52_imdct_window[256]={"); 387 printf("static sample_t a52_imdct_window[256]={");
388 for (i=0;i<256;i++) { 388 for (i=0;i<256;i++) {
@@ -393,26 +393,26 @@ void a52_imdct_init (uint32_t mm_accel)
393 */ 393 */
394 394
395 /* for (i = 0; i < 3; i++) 395 /* for (i = 0; i < 3; i++)
396 roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1))); 396 roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1)));
397 397
398 printf("static sample_t roots16[3]={%d,%d,%d};\n\n",roots16[0],roots16[1],roots16[2]); 398 printf("static sample_t roots16[3]={%d,%d,%d};\n\n",roots16[0],roots16[1],roots16[2]);
399 399
400 for (i = 0; i < 7; i++) 400 for (i = 0; i < 7; i++)
401 roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1))); 401 roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1)));
402 402
403 printf("static sample_t roots32[7]={"); 403 printf("static sample_t roots32[7]={");
404 for (i=0;i<7;i++) { printf("%d%s",roots32[i],(i < 6 ? "," : "")); } 404 for (i=0;i<7;i++) { printf("%d%s",roots32[i],(i < 6 ? "," : "")); }
405 printf("};\n"); 405 printf("};\n");
406 406
407 for (i = 0; i < 15; i++) 407 for (i = 0; i < 15; i++)
408 roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1))); 408 roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1)));
409 409
410 printf("static sample_t roots64[15]={"); 410 printf("static sample_t roots64[15]={");
411 for (i=0;i<15;i++) { printf("%d%s",roots64[i],(i < 14 ? "," : "")); } 411 for (i=0;i<15;i++) { printf("%d%s",roots64[i],(i < 14 ? "," : "")); }
412 printf("};\n"); 412 printf("};\n");
413 413
414 for (i = 0; i < 31; i++) 414 for (i = 0; i < 31; i++)
415 roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1))); 415 roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1)));
416 416
417 printf("static sample_t roots128[31]={"); 417 printf("static sample_t roots128[31]={");
418 for (i=0;i<31;i++) { printf("%d%s",roots128[i],(i < 30 ? "," : "")); } 418 for (i=0;i<31;i++) { printf("%d%s",roots128[i],(i < 30 ? "," : "")); }
@@ -420,15 +420,15 @@ void a52_imdct_init (uint32_t mm_accel)
420 */ 420 */
421 /* 421 /*
422 for (i = 0; i < 64; i++) { 422 for (i = 0; i < 64; i++) {
423 k = fftorder[i] / 2 + 64; 423 k = fftorder[i] / 2 + 64;
424 pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25))); 424 pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25)));
425 pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25))); 425 pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25)));
426 } 426 }
427 427
428 for (i = 64; i < 128; i++) { 428 for (i = 64; i < 128; i++) {
429 k = fftorder[i] / 2 + 64; 429 k = fftorder[i] / 2 + 64;
430 pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25))); 430 pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25)));
431 pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25))); 431 pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25)));
432 } 432 }
433 433
434 printf("static complex_t pre1[128]={"); 434 printf("static complex_t pre1[128]={");
@@ -437,8 +437,8 @@ void a52_imdct_init (uint32_t mm_accel)
437 */ 437 */
438 /* 438 /*
439 for (i = 0; i < 64; i++) { 439 for (i = 0; i < 64; i++) {
440 post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5))); 440 post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5)));
441 post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5))); 441 post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5)));
442 } 442 }
443 443
444 printf("static complex_t post1[64]={"); 444 printf("static complex_t post1[64]={");
@@ -448,9 +448,9 @@ void a52_imdct_init (uint32_t mm_accel)
448 448
449 /* 449 /*
450 for (i = 0; i < 64; i++) { 450 for (i = 0; i < 64; i++) {
451 k = fftorder[i] / 4; 451 k = fftorder[i] / 4;
452 pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25))); 452 pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25)));
453 pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25))); 453 pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25)));
454 } 454 }
455 455
456 printf("static complex_t pre2[64]={"); 456 printf("static complex_t pre2[64]={");
@@ -458,8 +458,8 @@ void a52_imdct_init (uint32_t mm_accel)
458 printf("};\n"); 458 printf("};\n");
459 459
460 for (i = 0; i < 32; i++) { 460 for (i = 0; i < 32; i++) {
461 post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5))); 461 post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5)));
462 post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5))); 462 post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5)));
463 } 463 }
464 464
465 printf("static complex_t post2[32]={"); 465 printf("static complex_t post2[32]={");
@@ -470,17 +470,17 @@ void a52_imdct_init (uint32_t mm_accel)
470#ifdef LIBA52_DJBFFT 470#ifdef LIBA52_DJBFFT
471 if (mm_accel & MM_ACCEL_DJBFFT) { 471 if (mm_accel & MM_ACCEL_DJBFFT) {
472#ifndef LIBA52_DOUBLE 472#ifndef LIBA52_DOUBLE
473 ifft128 = (void (*) (complex_t *)) fftc4_un128; 473 ifft128 = (void (*) (complex_t *)) fftc4_un128;
474 ifft64 = (void (*) (complex_t *)) fftc4_un64; 474 ifft64 = (void (*) (complex_t *)) fftc4_un64;
475#else 475#else
476 ifft128 = (void (*) (complex_t *)) fftc8_un128; 476 ifft128 = (void (*) (complex_t *)) fftc8_un128;
477 ifft64 = (void (*) (complex_t *)) fftc8_un64; 477 ifft64 = (void (*) (complex_t *)) fftc8_un64;
478#endif 478#endif
479 } else 479 } else
480#endif 480#endif
481 { 481 {
482 ifft128 = ifft128_c; 482 ifft128 = ifft128_c;
483 ifft64 = ifft64_c; 483 ifft64 = ifft64_c;
484 } 484 }
485 */ 485 */
486} 486}
diff --git a/apps/codecs/liba52/imdct_lookups.h b/apps/codecs/liba52/imdct_lookups.h
index 88e0ec3fd8..769623ff53 100644
--- a/apps/codecs/liba52/imdct_lookups.h
+++ b/apps/codecs/liba52/imdct_lookups.h
@@ -1,5 +1,5 @@
1static const sample_t a52_imdct_window[256]ICONST_ATTR={ 1static const sample_t a52_imdct_window[256]ICONST_ATTR={
2 146020,261886,393529,545197,719447,918478,1144416,1399394,1685589,2005234,2360623,2754115,3188134,3665170,4187773,4758556, 5380193,6055411,6786995,7577779,8430645,9348521,10334375,11391212,12522071,13730020,15018150,16389576,17847424,19394833,21034947,22770912, 24605865,26542938,28585242,30735872,32997891,35374332,37868188,40482408,43219889,46083473,49075937,52199993,55458273,58853331,62387636,66063559, 69883377,73849259,77963266,82227341,86643307,91212859,95937560,100818835,105857968,111056092,116414194,121933098,127613474,133455822,139460477,145627601, 151957182,158449029,165102772,171917855,178893540,186028900,193322822,200774000,208380940,216141958,224055176,232118527,240329753,248686407,257185854,265825270, 274601649,283511802,292552357,301719768,311010314,320420105,329945084,339581031,349323572,359168178,369110174,379144743,389266934,399471665,409753732,420107815, 430528483,441010205,451547355,462134219,472765003,483433845,494134818,504861939,515609181,526370480,537139740,547910849,558677680,569434108,580174011,590891284, 601579849,612233658,622846709,633413050,643926788,654382103,664773249,675094567,685340494,695505569,705584441,715571877,725462772,735252152,744935184,754507184, 763963620,773300119,782512477,791596659,800548807,809365245,818042484,826577226,834966364,843206992,851296404,859232096,867011771,874633340,882094922,889394844, 896531647,903504079,910311101,916951881,923425798,929732436,935871584,941843233,947647575,953284997,958756080,964061593,969202490,974179906,978995149,983649698, 988145195,992483442,996666390,1000696136,1004574919,1008305104,1011889185,1015329772,1018629583,1021791439,1024818257,1027713038,1030478862,1033118881,1035636308,1038034411, 1040316504,1042485942,1044546109,1046500412,1048352275,1050105129,1051762405,1053327531,1054803917,1056194958,1057504020,1058734435,1059889501,1060972468,1061986539,1062934861, 1063820523,1064646551,1065415903,1066131467,1066796055,1067412403,1067983168,1068510924,1068998160,1069447282,1069860607,1070240366,1070588702,1070907668,1071199230,1071465266, 1071707567,1071927836,1072127692,1072308670,1072472221,1072619716,1072752449,1072871635,1072978415,1073073858,1073158963,1073234663,1073301826,1073361257,1073413702,1073459852, 1073500344,1073535763,1073566646,1073593486,1073616731,1073636791,1073654036,1073668804,1073681398,1073692090,1073701126,1073708726,1073715084,1073720373,1073724748,1073728344, 1073731279,1073733657,1073735568,1073737090,1073738291,1073739229,1073739951,1073740500,1073740912,1073741214,1073741431,1073741582,1073741685,1073741751,1073741792,1073741814 2 146020,261886,393529,545197,719447,918478,1144416,1399394,1685589,2005234,2360623,2754115,3188134,3665170,4187773,4758556, 5380193,6055411,6786995,7577779,8430645,9348521,10334375,11391212,12522071,13730020,15018150,16389576,17847424,19394833,21034947,22770912, 24605865,26542938,28585242,30735872,32997891,35374332,37868188,40482408,43219889,46083473,49075937,52199993,55458273,58853331,62387636,66063559, 69883377,73849259,77963266,82227341,86643307,91212859,95937560,100818835,105857968,111056092,116414194,121933098,127613474,133455822,139460477,145627601, 151957182,158449029,165102772,171917855,178893540,186028900,193322822,200774000,208380940,216141958,224055176,232118527,240329753,248686407,257185854,265825270, 274601649,283511802,292552357,301719768,311010314,320420105,329945084,339581031,349323572,359168178,369110174,379144743,389266934,399471665,409753732,420107815, 430528483,441010205,451547355,462134219,472765003,483433845,494134818,504861939,515609181,526370480,537139740,547910849,558677680,569434108,580174011,590891284, 601579849,612233658,622846709,633413050,643926788,654382103,664773249,675094567,685340494,695505569,705584441,715571877,725462772,735252152,744935184,754507184, 763963620,773300119,782512477,791596659,800548807,809365245,818042484,826577226,834966364,843206992,851296404,859232096,867011771,874633340,882094922,889394844, 896531647,903504079,910311101,916951881,923425798,929732436,935871584,941843233,947647575,953284997,958756080,964061593,969202490,974179906,978995149,983649698, 988145195,992483442,996666390,1000696136,1004574919,1008305104,1011889185,1015329772,1018629583,1021791439,1024818257,1027713038,1030478862,1033118881,1035636308,1038034411, 1040316504,1042485942,1044546109,1046500412,1048352275,1050105129,1051762405,1053327531,1054803917,1056194958,1057504020,1058734435,1059889501,1060972468,1061986539,1062934861, 1063820523,1064646551,1065415903,1066131467,1066796055,1067412403,1067983168,1068510924,1068998160,1069447282,1069860607,1070240366,1070588702,1070907668,1071199230,1071465266, 1071707567,1071927836,1072127692,1072308670,1072472221,1072619716,1072752449,1072871635,1072978415,1073073858,1073158963,1073234663,1073301826,1073361257,1073413702,1073459852, 1073500344,1073535763,1073566646,1073593486,1073616731,1073636791,1073654036,1073668804,1073681398,1073692090,1073701126,1073708726,1073715084,1073720373,1073724748,1073728344, 1073731279,1073733657,1073735568,1073737090,1073738291,1073739229,1073739951,1073740500,1073740912,1073741214,1073741431,1073741582,1073741685,1073741751,1073741792,1073741814
3}; 3};
4 4
5static const sample_t roots16[3]ICONST_ATTR={992008094,759250124,410903206}; 5static const sample_t roots16[3]ICONST_ATTR={992008094,759250124,410903206};
diff --git a/apps/codecs/liba52/mm_accel.h b/apps/codecs/liba52/mm_accel.h
index f569787aec..8005930cc6 100644
--- a/apps/codecs/liba52/mm_accel.h
+++ b/apps/codecs/liba52/mm_accel.h
@@ -25,12 +25,12 @@
25#define MM_ACCEL_H 25#define MM_ACCEL_H
26 26
27/* generic accelerations */ 27/* generic accelerations */
28#define MM_ACCEL_DJBFFT 0x00000001 28#define MM_ACCEL_DJBFFT 0x00000001
29 29
30/* x86 accelerations */ 30/* x86 accelerations */
31#define MM_ACCEL_X86_MMX 0x80000000 31#define MM_ACCEL_X86_MMX 0x80000000
32#define MM_ACCEL_X86_3DNOW 0x40000000 32#define MM_ACCEL_X86_3DNOW 0x40000000
33#define MM_ACCEL_X86_MMXEXT 0x20000000 33#define MM_ACCEL_X86_MMXEXT 0x20000000
34 34
35uint32_t mm_accel (void); 35uint32_t mm_accel (void);
36 36
diff --git a/apps/codecs/liba52/parse.c b/apps/codecs/liba52/parse.c
index f2b0ce4f6d..fd7e13006d 100644
--- a/apps/codecs/liba52/parse.c
+++ b/apps/codecs/liba52/parse.c
@@ -66,19 +66,19 @@ a52_state_t * a52_init (uint32_t mm_accel)
66 simultenously. NOTE, you also need to remove comments in a52_free. 66 simultenously. NOTE, you also need to remove comments in a52_free.
67 state = (a52_state_t *) malloc (sizeof (a52_state_t)); 67 state = (a52_state_t *) malloc (sizeof (a52_state_t));
68 if (state == NULL) 68 if (state == NULL)
69 return NULL; 69 return NULL;
70 70
71 state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t)); 71 state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t));
72 if (state->samples == NULL) { 72 if (state->samples == NULL) {
73 free (state); 73 free (state);
74 return NULL; 74 return NULL;
75 } 75 }
76 76
77 */ 77 */
78 state = &istate; 78 state = &istate;
79 state->samples = isamples; 79 state->samples = isamples;
80 for (i = 0; i < 256 * 12; i++) 80 for (i = 0; i < 256 * 12; i++)
81 state->samples[i] = 0; 81 state->samples[i] = 0;
82 82
83 state->downmixed = 1; 83 state->downmixed = 1;
84 84
@@ -95,57 +95,57 @@ sample_t * a52_samples (a52_state_t * state)
95} 95}
96 96
97int a52_syncinfo (uint8_t * buf, int * flags, 97int a52_syncinfo (uint8_t * buf, int * flags,
98 int * sample_rate, int * bit_rate) 98 int * sample_rate, int * bit_rate)
99{ 99{
100 static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, 100 static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112,
101 128, 160, 192, 224, 256, 320, 384, 448, 101 128, 160, 192, 224, 256, 320, 384, 448,
102 512, 576, 640}; 102 512, 576, 640};
103 static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01}; 103 static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
104 int frmsizecod; 104 int frmsizecod;
105 int bitrate; 105 int bitrate;
106 int half; 106 int half;
107 int acmod; 107 int acmod;
108 108
109 if ((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */ 109 if ((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */
110 return 0; 110 return 0;
111 111
112 if (buf[5] >= 0x60) /* bsid >= 12 */ 112 if (buf[5] >= 0x60) /* bsid >= 12 */
113 return 0; 113 return 0;
114 half = halfrate[buf[5] >> 3]; 114 half = halfrate[buf[5] >> 3];
115 115
116 /* acmod, dsurmod and lfeon */ 116 /* acmod, dsurmod and lfeon */
117 acmod = buf[6] >> 5; 117 acmod = buf[6] >> 5;
118 *flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) | 118 *flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) |
119 ((buf[6] & lfeon[acmod]) ? A52_LFE : 0)); 119 ((buf[6] & lfeon[acmod]) ? A52_LFE : 0));
120 120
121 frmsizecod = buf[4] & 63; 121 frmsizecod = buf[4] & 63;
122 if (frmsizecod >= 38) 122 if (frmsizecod >= 38)
123 return 0; 123 return 0;
124 bitrate = rate [frmsizecod >> 1]; 124 bitrate = rate [frmsizecod >> 1];
125 *bit_rate = (bitrate * 1000) >> half; 125 *bit_rate = (bitrate * 1000) >> half;
126 126
127 switch (buf[4] & 0xc0) { 127 switch (buf[4] & 0xc0) {
128 case 0: 128 case 0:
129 *sample_rate = 48000 >> half; 129 *sample_rate = 48000 >> half;
130 return 4 * bitrate; 130 return 4 * bitrate;
131 case 0x40: 131 case 0x40:
132 *sample_rate = 44100 >> half; 132 *sample_rate = 44100 >> half;
133 return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); 133 return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
134 case 0x80: 134 case 0x80:
135 *sample_rate = 32000 >> half; 135 *sample_rate = 32000 >> half;
136 return 6 * bitrate; 136 return 6 * bitrate;
137 default: 137 default:
138 return 0; 138 return 0;
139 } 139 }
140} 140}
141 141
142int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, 142int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
143 level_t * level, sample_t bias) 143 level_t * level, sample_t bias)
144{ 144{
145 static level_t clev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_45DB), 145 static level_t clev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_45DB),
146 LEVEL (LEVEL_6DB), LEVEL (LEVEL_45DB) }; 146 LEVEL (LEVEL_6DB), LEVEL (LEVEL_45DB) };
147 static level_t slev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_6DB), 147 static level_t slev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_6DB),
148 0, LEVEL (LEVEL_6DB) }; 148 0, LEVEL (LEVEL_6DB) };
149 int chaninfo; 149 int chaninfo;
150 int acmod; 150 int acmod;
151 151
@@ -154,27 +154,27 @@ int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
154 state->acmod = acmod = buf[6] >> 5; 154 state->acmod = acmod = buf[6] >> 5;
155 155
156 a52_bitstream_set_ptr (state, buf + 6); 156 a52_bitstream_set_ptr (state, buf + 6);
157 bitstream_get (state, 3); /* skip acmod we already parsed */ 157 bitstream_get (state, 3); /* skip acmod we already parsed */
158 158
159 if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */ 159 if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */
160 acmod = A52_DOLBY; 160 acmod = A52_DOLBY;
161 161
162 state->clev = state->slev = 0; 162 state->clev = state->slev = 0;
163 163
164 if ((acmod & 1) && (acmod != 1)) 164 if ((acmod & 1) && (acmod != 1))
165 state->clev = clev[bitstream_get (state, 2)]; /* cmixlev */ 165 state->clev = clev[bitstream_get (state, 2)]; /* cmixlev */
166 166
167 if (acmod & 4) 167 if (acmod & 4)
168 state->slev = slev[bitstream_get (state, 2)]; /* surmixlev */ 168 state->slev = slev[bitstream_get (state, 2)]; /* surmixlev */
169 169
170 state->lfeon = bitstream_get (state, 1); 170 state->lfeon = bitstream_get (state, 1);
171 171
172 state->output = a52_downmix_init (acmod, *flags, level, 172 state->output = a52_downmix_init (acmod, *flags, level,
173 state->clev, state->slev); 173 state->clev, state->slev);
174 if (state->output < 0) 174 if (state->output < 0)
175 return 1; 175 return 1;
176 if (state->lfeon && (*flags & A52_LFE)) 176 if (state->lfeon && (*flags & A52_LFE))
177 state->output |= A52_LFE; 177 state->output |= A52_LFE;
178 *flags = state->output; 178 *flags = state->output;
179 /* the 2* compensates for differences in imdct */ 179 /* the 2* compensates for differences in imdct */
180 state->dynrng = state->level = MUL_C (*level, 2); 180 state->dynrng = state->level = MUL_C (*level, 2);
@@ -183,99 +183,99 @@ int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
183 state->dynrngcall = NULL; 183 state->dynrngcall = NULL;
184 state->cplba.deltbae = DELTA_BIT_NONE; 184 state->cplba.deltbae = DELTA_BIT_NONE;
185 state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae = 185 state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae =
186 state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE; 186 state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE;
187 187
188 chaninfo = !acmod; 188 chaninfo = !acmod;
189 do { 189 do {
190 bitstream_get (state, 5); /* dialnorm */ 190 bitstream_get (state, 5); /* dialnorm */
191 if (bitstream_get (state, 1)) /* compre */ 191 if (bitstream_get (state, 1)) /* compre */
192 bitstream_get (state, 8); /* compr */ 192 bitstream_get (state, 8); /* compr */
193 if (bitstream_get (state, 1)) /* langcode */ 193 if (bitstream_get (state, 1)) /* langcode */
194 bitstream_get (state, 8); /* langcod */ 194 bitstream_get (state, 8); /* langcod */
195 if (bitstream_get (state, 1)) /* audprodie */ 195 if (bitstream_get (state, 1)) /* audprodie */
196 bitstream_get (state, 7); /* mixlevel + roomtyp */ 196 bitstream_get (state, 7); /* mixlevel + roomtyp */
197 } while (chaninfo--); 197 } while (chaninfo--);
198 198
199 bitstream_get (state, 2); /* copyrightb + origbs */ 199 bitstream_get (state, 2); /* copyrightb + origbs */
200 200
201 if (bitstream_get (state, 1)) /* timecod1e */ 201 if (bitstream_get (state, 1)) /* timecod1e */
202 bitstream_get (state, 14); /* timecod1 */ 202 bitstream_get (state, 14); /* timecod1 */
203 if (bitstream_get (state, 1)) /* timecod2e */ 203 if (bitstream_get (state, 1)) /* timecod2e */
204 bitstream_get (state, 14); /* timecod2 */ 204 bitstream_get (state, 14); /* timecod2 */
205 205
206 if (bitstream_get (state, 1)) { /* addbsie */ 206 if (bitstream_get (state, 1)) { /* addbsie */
207 int addbsil; 207 int addbsil;
208 208
209 addbsil = bitstream_get (state, 6); 209 addbsil = bitstream_get (state, 6);
210 do { 210 do {
211 bitstream_get (state, 8); /* addbsi */ 211 bitstream_get (state, 8); /* addbsi */
212 } while (addbsil--); 212 } while (addbsil--);
213 } 213 }
214 214
215 return 0; 215 return 0;
216} 216}
217 217
218void a52_dynrng (a52_state_t * state, 218void a52_dynrng (a52_state_t * state,
219 level_t (* call) (level_t, void *), void * data) 219 level_t (* call) (level_t, void *), void * data)
220{ 220{
221 state->dynrnge = 0; 221 state->dynrnge = 0;
222 if (call) { 222 if (call) {
223 state->dynrnge = 1; 223 state->dynrnge = 1;
224 state->dynrngcall = call; 224 state->dynrngcall = call;
225 state->dynrngdata = data; 225 state->dynrngdata = data;
226 } 226 }
227} 227}
228 228
229static int parse_exponents (a52_state_t * state, int expstr, int ngrps, 229static int parse_exponents (a52_state_t * state, int expstr, int ngrps,
230 uint8_t exponent, uint8_t * dest) 230 uint8_t exponent, uint8_t * dest)
231{ 231{
232 int exps; 232 int exps;
233 233
234 while (ngrps--) { 234 while (ngrps--) {
235 exps = bitstream_get (state, 7); 235 exps = bitstream_get (state, 7);
236 236
237 exponent += exp_1[exps]; 237 exponent += exp_1[exps];
238 if (exponent > 24) 238 if (exponent > 24)
239 return 1; 239 return 1;
240 240
241 switch (expstr) { 241 switch (expstr) {
242 case EXP_D45: 242 case EXP_D45:
243 *(dest++) = exponent; 243 *(dest++) = exponent;
244 *(dest++) = exponent; 244 *(dest++) = exponent;
245 case EXP_D25: 245 case EXP_D25:
246 *(dest++) = exponent; 246 *(dest++) = exponent;
247 case EXP_D15: 247 case EXP_D15:
248 *(dest++) = exponent; 248 *(dest++) = exponent;
249 } 249 }
250 250
251 exponent += exp_2[exps]; 251 exponent += exp_2[exps];
252 if (exponent > 24) 252 if (exponent > 24)
253 return 1; 253 return 1;
254 254
255 switch (expstr) { 255 switch (expstr) {
256 case EXP_D45: 256 case EXP_D45:
257 *(dest++) = exponent; 257 *(dest++) = exponent;
258 *(dest++) = exponent; 258 *(dest++) = exponent;
259 case EXP_D25: 259 case EXP_D25:
260 *(dest++) = exponent; 260 *(dest++) = exponent;
261 case EXP_D15: 261 case EXP_D15:
262 *(dest++) = exponent; 262 *(dest++) = exponent;
263 } 263 }
264 264
265 exponent += exp_3[exps]; 265 exponent += exp_3[exps];
266 if (exponent > 24) 266 if (exponent > 24)
267 return 1; 267 return 1;
268 268
269 switch (expstr) { 269 switch (expstr) {
270 case EXP_D45: 270 case EXP_D45:
271 *(dest++) = exponent; 271 *(dest++) = exponent;
272 *(dest++) = exponent; 272 *(dest++) = exponent;
273 case EXP_D25: 273 case EXP_D25:
274 *(dest++) = exponent; 274 *(dest++) = exponent;
275 case EXP_D15: 275 case EXP_D15:
276 *(dest++) = exponent; 276 *(dest++) = exponent;
277 } 277 }
278 } 278 }
279 279
280 return 0; 280 return 0;
281} 281}
@@ -289,16 +289,16 @@ static int parse_deltba (a52_state_t * state, int8_t * deltba)
289 deltnseg = bitstream_get (state, 3); 289 deltnseg = bitstream_get (state, 3);
290 j = 0; 290 j = 0;
291 do { 291 do {
292 j += bitstream_get (state, 5); 292 j += bitstream_get (state, 5);
293 deltlen = bitstream_get (state, 4); 293 deltlen = bitstream_get (state, 4);
294 delta = bitstream_get (state, 3); 294 delta = bitstream_get (state, 3);
295 delta -= (delta >= 4) ? 3 : 4; 295 delta -= (delta >= 4) ? 3 : 4;
296 if (!deltlen) 296 if (!deltlen)
297 continue; 297 continue;
298 if (j + deltlen >= 50) 298 if (j + deltlen >= 50)
299 return 1; 299 return 1;
300 while (deltlen--) 300 while (deltlen--)
301 deltba[j++] = delta; 301 deltba[j++] = delta;
302 } while (deltnseg--); 302 } while (deltnseg--);
303 303
304 return 0; 304 return 0;
@@ -309,12 +309,12 @@ static inline int zero_snr_offsets (int nfchans, a52_state_t * state)
309 int i; 309 int i;
310 310
311 if ((state->csnroffst) || 311 if ((state->csnroffst) ||
312 (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */ 312 (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */
313 (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */ 313 (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */
314 return 0; 314 return 0;
315 for (i = 0; i < nfchans; i++) 315 for (i = 0; i < nfchans; i++)
316 if (state->ba[i].bai >> 3) /* fsnroffst */ 316 if (state->ba[i].bai >> 3) /* fsnroffst */
317 return 0; 317 return 0;
318 return 1; 318 return 1;
319} 319}
320 320
@@ -323,7 +323,7 @@ static inline int16_t dither_gen (a52_state_t * state)
323 int16_t nstate; 323 int16_t nstate;
324 324
325 nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8); 325 nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8);
326 326
327 state->lfsr_state = (uint16_t) nstate; 327 state->lfsr_state = (uint16_t) nstate;
328 328
329 return (3 * nstate) >> 2; 329 return (3 * nstate) >> 2;
@@ -332,21 +332,21 @@ static inline int16_t dither_gen (a52_state_t * state)
332#ifndef LIBA52_FIXED 332#ifndef LIBA52_FIXED
333#define COEFF(c,t,l,s,e) (c) = (t) * (s)[e] 333#define COEFF(c,t,l,s,e) (c) = (t) * (s)[e]
334#else 334#else
335#define COEFF(c,_t,_l,s,e) do { \ 335#define COEFF(c,_t,_l,s,e) do { \
336 quantizer_t t = (_t); \ 336 quantizer_t t = (_t); \
337 level_t l = (_l); \ 337 level_t l = (_l); \
338 int shift = e - 5; \ 338 int shift = e - 5; \
339 sample_t tmp = t * (l >> 16) + ((t * (l & 0xffff)) >> 16); \ 339 sample_t tmp = t * (l >> 16) + ((t * (l & 0xffff)) >> 16); \
340 if (shift >= 0) \ 340 if (shift >= 0) \
341 (c) = tmp >> shift; \ 341 (c) = tmp >> shift; \
342 else \ 342 else \
343 (c) = tmp << -shift; \ 343 (c) = tmp << -shift; \
344} while (0) 344} while (0)
345#endif 345#endif
346 346
347static void coeff_get (a52_state_t * state, sample_t * coeff, 347static void coeff_get (a52_state_t * state, sample_t * coeff,
348 expbap_t * expbap, quantizer_set_t * quant, 348 expbap_t * expbap, quantizer_set_t * quant,
349 level_t level, int dither, int end) 349 level_t level, int dither, int end)
350{ 350{
351 int i; 351 int i;
352 uint8_t * exp; 352 uint8_t * exp;
@@ -356,96 +356,96 @@ static void coeff_get (a52_state_t * state, sample_t * coeff,
356 sample_t factor[25]; 356 sample_t factor[25];
357 357
358 for (i = 0; i <= 24; i++) 358 for (i = 0; i <= 24; i++)
359 factor[i] = scale_factor[i] * level; 359 factor[i] = scale_factor[i] * level;
360#endif 360#endif
361 361
362 exp = expbap->exp; 362 exp = expbap->exp;
363 bap = expbap->bap; 363 bap = expbap->bap;
364 364
365 for (i = 0; i < end; i++) { 365 for (i = 0; i < end; i++) {
366 int bapi; 366 int bapi;
367 367
368 bapi = bap[i]; 368 bapi = bap[i];
369 switch (bapi) { 369 switch (bapi) {
370 case 0: 370 case 0:
371 if (dither) { 371 if (dither) {
372 COEFF (coeff[i], dither_gen (state), level, factor, exp[i]); 372 COEFF (coeff[i], dither_gen (state), level, factor, exp[i]);
373 continue; 373 continue;
374 } else { 374 } else {
375 coeff[i] = 0; 375 coeff[i] = 0;
376 continue; 376 continue;
377 } 377 }
378 378
379 case -1: 379 case -1:
380 if (quant->q1_ptr >= 0) { 380 if (quant->q1_ptr >= 0) {
381 COEFF (coeff[i], quant->q1[quant->q1_ptr--], level, 381 COEFF (coeff[i], quant->q1[quant->q1_ptr--], level,
382 factor, exp[i]); 382 factor, exp[i]);
383 continue; 383 continue;
384 } else { 384 } else {
385 int code; 385 int code;
386 386
387 code = bitstream_get (state, 5); 387 code = bitstream_get (state, 5);
388 388
389 quant->q1_ptr = 1; 389 quant->q1_ptr = 1;
390 quant->q1[0] = q_1_2[code]; 390 quant->q1[0] = q_1_2[code];
391 quant->q1[1] = q_1_1[code]; 391 quant->q1[1] = q_1_1[code];
392 COEFF (coeff[i], q_1_0[code], level, factor, exp[i]); 392 COEFF (coeff[i], q_1_0[code], level, factor, exp[i]);
393 continue; 393 continue;
394 } 394 }
395 395
396 case -2: 396 case -2:
397 if (quant->q2_ptr >= 0) { 397 if (quant->q2_ptr >= 0) {
398 COEFF (coeff[i], quant->q2[quant->q2_ptr--], level, 398 COEFF (coeff[i], quant->q2[quant->q2_ptr--], level,
399 factor, exp[i]); 399 factor, exp[i]);
400 continue; 400 continue;
401 } else { 401 } else {
402 int code; 402 int code;
403 403
404 code = bitstream_get (state, 7); 404 code = bitstream_get (state, 7);
405 405
406 quant->q2_ptr = 1; 406 quant->q2_ptr = 1;
407 quant->q2[0] = q_2_2[code]; 407 quant->q2[0] = q_2_2[code];
408 quant->q2[1] = q_2_1[code]; 408 quant->q2[1] = q_2_1[code];
409 COEFF (coeff[i], q_2_0[code], level, factor, exp[i]); 409 COEFF (coeff[i], q_2_0[code], level, factor, exp[i]);
410 continue; 410 continue;
411 } 411 }
412 412
413 case 3: 413 case 3:
414 COEFF (coeff[i], q_3[bitstream_get (state, 3)], level, 414 COEFF (coeff[i], q_3[bitstream_get (state, 3)], level,
415 factor, exp[i]); 415 factor, exp[i]);
416 continue; 416 continue;
417 417
418 case -3: 418 case -3:
419 if (quant->q4_ptr == 0) { 419 if (quant->q4_ptr == 0) {
420 quant->q4_ptr = -1; 420 quant->q4_ptr = -1;
421 COEFF (coeff[i], quant->q4, level, factor, exp[i]); 421 COEFF (coeff[i], quant->q4, level, factor, exp[i]);
422 continue; 422 continue;
423 } else { 423 } else {
424 int code; 424 int code;
425 425
426 code = bitstream_get (state, 7); 426 code = bitstream_get (state, 7);
427 427
428 quant->q4_ptr = 0; 428 quant->q4_ptr = 0;
429 quant->q4 = q_4_1[code]; 429 quant->q4 = q_4_1[code];
430 COEFF (coeff[i], q_4_0[code], level, factor, exp[i]); 430 COEFF (coeff[i], q_4_0[code], level, factor, exp[i]);
431 continue; 431 continue;
432 } 432 }
433 433
434 case 4: 434 case 4:
435 COEFF (coeff[i], q_5[bitstream_get (state, 4)], level, 435 COEFF (coeff[i], q_5[bitstream_get (state, 4)], level,
436 factor, exp[i]); 436 factor, exp[i]);
437 continue; 437 continue;
438 438
439 default: 439 default:
440 COEFF (coeff[i], bitstream_get_2 (state, bapi) << (16 - bapi), 440 COEFF (coeff[i], bitstream_get_2 (state, bapi) << (16 - bapi),
441 level, factor, exp[i]); 441 level, factor, exp[i]);
442 } 442 }
443 } 443 }
444} 444}
445 445
446static void coeff_get_coupling (a52_state_t * state, int nfchans, 446static void coeff_get_coupling (a52_state_t * state, int nfchans,
447 level_t * coeff, sample_t (* samples)[256], 447 level_t * coeff, sample_t (* samples)[256],
448 quantizer_set_t * quant, uint8_t dithflag[5]) 448 quantizer_set_t * quant, uint8_t dithflag[5])
449{ 449{
450 int cplbndstrc, bnd, i, i_end, ch; 450 int cplbndstrc, bnd, i, i_end, ch;
451 uint8_t * exp; 451 uint8_t * exp;
@@ -458,111 +458,111 @@ static void coeff_get_coupling (a52_state_t * state, int nfchans,
458 cplbndstrc = state->cplbndstrc; 458 cplbndstrc = state->cplbndstrc;
459 i = state->cplstrtmant; 459 i = state->cplstrtmant;
460 while (i < state->cplendmant) { 460 while (i < state->cplendmant) {
461 i_end = i + 12; 461 i_end = i + 12;
462 while (cplbndstrc & 1) { 462 while (cplbndstrc & 1) {
463 cplbndstrc >>= 1; 463 cplbndstrc >>= 1;
464 i_end += 12; 464 i_end += 12;
465 } 465 }
466 cplbndstrc >>= 1; 466 cplbndstrc >>= 1;
467 for (ch = 0; ch < nfchans; ch++) 467 for (ch = 0; ch < nfchans; ch++)
468 cplco[ch] = MUL_L (state->cplco[ch][bnd], coeff[ch]); 468 cplco[ch] = MUL_L (state->cplco[ch][bnd], coeff[ch]);
469 bnd++; 469 bnd++;
470 470
471 while (i < i_end) { 471 while (i < i_end) {
472 quantizer_t cplcoeff; 472 quantizer_t cplcoeff;
473 int bapi; 473 int bapi;
474 474
475 bapi = bap[i]; 475 bapi = bap[i];
476 switch (bapi) { 476 switch (bapi) {
477 case 0: 477 case 0:
478 for (ch = 0; ch < nfchans; ch++) 478 for (ch = 0; ch < nfchans; ch++)
479 if ((state->chincpl >> ch) & 1) { 479 if ((state->chincpl >> ch) & 1) {
480 if (dithflag[ch]) 480 if (dithflag[ch])
481#ifndef LIBA52_FIXED 481#ifndef LIBA52_FIXED
482 samples[ch][i] = (scale_factor[exp[i]] * 482 samples[ch][i] = (scale_factor[exp[i]] *
483 cplco[ch] * dither_gen (state)); 483 cplco[ch] * dither_gen (state));
484#else 484#else
485 COEFF (samples[ch][i], dither_gen (state), 485 COEFF (samples[ch][i], dither_gen (state),
486 cplco[ch], scale_factor, exp[i]); 486 cplco[ch], scale_factor, exp[i]);
487#endif 487#endif
488 else 488 else
489 samples[ch][i] = 0; 489 samples[ch][i] = 0;
490 } 490 }
491 i++; 491 i++;
492 continue; 492 continue;
493 493
494 case -1: 494 case -1:
495 if (quant->q1_ptr >= 0) { 495 if (quant->q1_ptr >= 0) {
496 cplcoeff = quant->q1[quant->q1_ptr--]; 496 cplcoeff = quant->q1[quant->q1_ptr--];
497 break; 497 break;
498 } else { 498 } else {
499 int code; 499 int code;
500 500
501 code = bitstream_get (state, 5); 501 code = bitstream_get (state, 5);
502 502
503 quant->q1_ptr = 1; 503 quant->q1_ptr = 1;
504 quant->q1[0] = q_1_2[code]; 504 quant->q1[0] = q_1_2[code];
505 quant->q1[1] = q_1_1[code]; 505 quant->q1[1] = q_1_1[code];
506 cplcoeff = q_1_0[code]; 506 cplcoeff = q_1_0[code];
507 break; 507 break;
508 } 508 }
509 509
510 case -2: 510 case -2:
511 if (quant->q2_ptr >= 0) { 511 if (quant->q2_ptr >= 0) {
512 cplcoeff = quant->q2[quant->q2_ptr--]; 512 cplcoeff = quant->q2[quant->q2_ptr--];
513 break; 513 break;
514 } else { 514 } else {
515 int code; 515 int code;
516 516
517 code = bitstream_get (state, 7); 517 code = bitstream_get (state, 7);
518 518
519 quant->q2_ptr = 1; 519 quant->q2_ptr = 1;
520 quant->q2[0] = q_2_2[code]; 520 quant->q2[0] = q_2_2[code];
521 quant->q2[1] = q_2_1[code]; 521 quant->q2[1] = q_2_1[code];
522 cplcoeff = q_2_0[code]; 522 cplcoeff = q_2_0[code];
523 break; 523 break;
524 } 524 }
525 525
526 case 3: 526 case 3:
527 cplcoeff = q_3[bitstream_get (state, 3)]; 527 cplcoeff = q_3[bitstream_get (state, 3)];
528 break; 528 break;
529 529
530 case -3: 530 case -3:
531 if (quant->q4_ptr == 0) { 531 if (quant->q4_ptr == 0) {
532 quant->q4_ptr = -1; 532 quant->q4_ptr = -1;
533 cplcoeff = quant->q4; 533 cplcoeff = quant->q4;
534 break; 534 break;
535 } else { 535 } else {
536 int code; 536 int code;
537 537
538 code = bitstream_get (state, 7); 538 code = bitstream_get (state, 7);
539 539
540 quant->q4_ptr = 0; 540 quant->q4_ptr = 0;
541 quant->q4 = q_4_1[code]; 541 quant->q4 = q_4_1[code];
542 cplcoeff = q_4_0[code]; 542 cplcoeff = q_4_0[code];
543 break; 543 break;
544 } 544 }
545 545
546 case 4: 546 case 4:
547 cplcoeff = q_5[bitstream_get (state, 4)]; 547 cplcoeff = q_5[bitstream_get (state, 4)];
548 break; 548 break;
549 549
550 default: 550 default:
551 cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi); 551 cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi);
552 } 552 }
553#ifndef LIBA52_FIXED 553#ifndef LIBA52_FIXED
554 cplcoeff *= scale_factor[exp[i]]; 554 cplcoeff *= scale_factor[exp[i]];
555#endif 555#endif
556 for (ch = 0; ch < nfchans; ch++) 556 for (ch = 0; ch < nfchans; ch++)
557 if ((state->chincpl >> ch) & 1) 557 if ((state->chincpl >> ch) & 1)
558#ifndef LIBA52_FIXED 558#ifndef LIBA52_FIXED
559 samples[ch][i] = cplcoeff * cplco[ch]; 559 samples[ch][i] = cplcoeff * cplco[ch];
560#else 560#else
561 COEFF (samples[ch][i], cplcoeff, cplco[ch], 561 COEFF (samples[ch][i], cplcoeff, cplco[ch],
562 scale_factor, exp[i]); 562 scale_factor, exp[i]);
563#endif 563#endif
564 i++; 564 i++;
565 } 565 }
566 } 566 }
567} 567}
568 568
@@ -581,366 +581,366 @@ int a52_block (a52_state_t * state)
581 nfchans = nfchans_tbl[state->acmod]; 581 nfchans = nfchans_tbl[state->acmod];
582 582
583 for (i = 0; i < nfchans; i++) 583 for (i = 0; i < nfchans; i++)
584 blksw[i] = bitstream_get (state, 1); 584 blksw[i] = bitstream_get (state, 1);
585 585
586 for (i = 0; i < nfchans; i++) 586 for (i = 0; i < nfchans; i++)
587 dithflag[i] = bitstream_get (state, 1); 587 dithflag[i] = bitstream_get (state, 1);
588 588
589 chaninfo = !state->acmod; 589 chaninfo = !state->acmod;
590 do { 590 do {
591 if (bitstream_get (state, 1)) { /* dynrnge */ 591 if (bitstream_get (state, 1)) { /* dynrnge */
592 int dynrng; 592 int dynrng;
593 593
594 dynrng = bitstream_get_2 (state, 8); 594 dynrng = bitstream_get_2 (state, 8);
595 if (state->dynrnge) { 595 if (state->dynrnge) {
596 level_t range; 596 level_t range;
597 597
598#if !defined(LIBA52_FIXED) 598#if !defined(LIBA52_FIXED)
599 range = ((((dynrng & 0x1f) | 0x20) << 13) * 599 range = ((((dynrng & 0x1f) | 0x20) << 13) *
600 scale_factor[3 - (dynrng >> 5)]); 600 scale_factor[3 - (dynrng >> 5)]);
601#else 601#else
602 range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5)); 602 range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5));
603#endif 603#endif
604 if (state->dynrngcall) 604 if (state->dynrngcall)
605 range = state->dynrngcall (range, state->dynrngdata); 605 range = state->dynrngcall (range, state->dynrngdata);
606 state->dynrng = MUL_L (state->level, range); 606 state->dynrng = MUL_L (state->level, range);
607 } 607 }
608 } 608 }
609 } while (chaninfo--); 609 } while (chaninfo--);
610 610
611 if (bitstream_get (state, 1)) { /* cplstre */ 611 if (bitstream_get (state, 1)) { /* cplstre */
612 state->chincpl = 0; 612 state->chincpl = 0;
613 if (bitstream_get (state, 1)) { /* cplinu */ 613 if (bitstream_get (state, 1)) { /* cplinu */
614 static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44, 614 static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44,
615 45, 45, 46, 46, 47, 47, 48, 48}; 615 45, 45, 46, 46, 47, 47, 48, 48};
616 int cplbegf; 616 int cplbegf;
617 int cplendf; 617 int cplendf;
618 int ncplsubnd; 618 int ncplsubnd;
619 619
620 for (i = 0; i < nfchans; i++) 620 for (i = 0; i < nfchans; i++)
621 state->chincpl |= bitstream_get (state, 1) << i; 621 state->chincpl |= bitstream_get (state, 1) << i;
622 switch (state->acmod) { 622 switch (state->acmod) {
623 case 0: case 1: 623 case 0: case 1:
624 return 1; 624 return 1;
625 case 2: 625 case 2:
626 state->phsflginu = bitstream_get (state, 1); 626 state->phsflginu = bitstream_get (state, 1);
627 } 627 }
628 cplbegf = bitstream_get (state, 4); 628 cplbegf = bitstream_get (state, 4);
629 cplendf = bitstream_get (state, 4); 629 cplendf = bitstream_get (state, 4);
630 630
631 if (cplendf + 3 - cplbegf < 0) 631 if (cplendf + 3 - cplbegf < 0)
632 return 1; 632 return 1;
633 state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf; 633 state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf;
634 state->cplstrtbnd = bndtab[cplbegf]; 634 state->cplstrtbnd = bndtab[cplbegf];
635 state->cplstrtmant = cplbegf * 12 + 37; 635 state->cplstrtmant = cplbegf * 12 + 37;
636 state->cplendmant = cplendf * 12 + 73; 636 state->cplendmant = cplendf * 12 + 73;
637 637
638 state->cplbndstrc = 0; 638 state->cplbndstrc = 0;
639 for (i = 0; i < ncplsubnd - 1; i++) 639 for (i = 0; i < ncplsubnd - 1; i++)
640 if (bitstream_get (state, 1)) { 640 if (bitstream_get (state, 1)) {
641 state->cplbndstrc |= 1 << i; 641 state->cplbndstrc |= 1 << i;
642 state->ncplbnd--; 642 state->ncplbnd--;
643 } 643 }
644 } 644 }
645 } 645 }
646 646
647 if (state->chincpl) { /* cplinu */ 647 if (state->chincpl) { /* cplinu */
648 int j, cplcoe; 648 int j, cplcoe;
649 649
650 cplcoe = 0; 650 cplcoe = 0;
651 for (i = 0; i < nfchans; i++) 651 for (i = 0; i < nfchans; i++)
652 if ((state->chincpl) >> i & 1) 652 if ((state->chincpl) >> i & 1)
653 if (bitstream_get (state, 1)) { /* cplcoe */ 653 if (bitstream_get (state, 1)) { /* cplcoe */
654 int mstrcplco, cplcoexp, cplcomant; 654 int mstrcplco, cplcoexp, cplcomant;
655 655
656 cplcoe = 1; 656 cplcoe = 1;
657 mstrcplco = 3 * bitstream_get (state, 2); 657 mstrcplco = 3 * bitstream_get (state, 2);
658 for (j = 0; j < state->ncplbnd; j++) { 658 for (j = 0; j < state->ncplbnd; j++) {
659 cplcoexp = bitstream_get (state, 4); 659 cplcoexp = bitstream_get (state, 4);
660 cplcomant = bitstream_get (state, 4); 660 cplcomant = bitstream_get (state, 4);
661 if (cplcoexp == 15) 661 if (cplcoexp == 15)
662 cplcomant <<= 14; 662 cplcomant <<= 14;
663 else 663 else
664 cplcomant = (cplcomant | 0x10) << 13; 664 cplcomant = (cplcomant | 0x10) << 13;
665#ifndef LIBA52_FIXED 665#ifndef LIBA52_FIXED
666 state->cplco[i][j] = 666 state->cplco[i][j] =
667 cplcomant * scale_factor[cplcoexp + mstrcplco]; 667 cplcomant * scale_factor[cplcoexp + mstrcplco];
668#else 668#else
669 state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco); 669 state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco);
670#endif 670#endif
671 671
672 } 672 }
673 } 673 }
674 if ((state->acmod == 2) && state->phsflginu && cplcoe) 674 if ((state->acmod == 2) && state->phsflginu && cplcoe)
675 for (j = 0; j < state->ncplbnd; j++) 675 for (j = 0; j < state->ncplbnd; j++)
676 if (bitstream_get (state, 1)) /* phsflg */ 676 if (bitstream_get (state, 1)) /* phsflg */
677 state->cplco[1][j] = -state->cplco[1][j]; 677 state->cplco[1][j] = -state->cplco[1][j];
678 } 678 }
679 679
680 if ((state->acmod == 2) && (bitstream_get (state, 1))) { /* rematstr */ 680 if ((state->acmod == 2) && (bitstream_get (state, 1))) { /* rematstr */
681 int end; 681 int end;
682 682
683 state->rematflg = 0; 683 state->rematflg = 0;
684 end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */ 684 end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */
685 i = 0; 685 i = 0;
686 do 686 do
687 state->rematflg |= bitstream_get (state, 1) << i; 687 state->rematflg |= bitstream_get (state, 1) << i;
688 while (rematrix_band[i++] < end); 688 while (rematrix_band[i++] < end);
689 } 689 }
690 690
691 cplexpstr = EXP_REUSE; 691 cplexpstr = EXP_REUSE;
692 lfeexpstr = EXP_REUSE; 692 lfeexpstr = EXP_REUSE;
693 if (state->chincpl) /* cplinu */ 693 if (state->chincpl) /* cplinu */
694 cplexpstr = bitstream_get (state, 2); 694 cplexpstr = bitstream_get (state, 2);
695 for (i = 0; i < nfchans; i++) 695 for (i = 0; i < nfchans; i++)
696 chexpstr[i] = bitstream_get (state, 2); 696 chexpstr[i] = bitstream_get (state, 2);
697 if (state->lfeon) 697 if (state->lfeon)
698 lfeexpstr = bitstream_get (state, 1); 698 lfeexpstr = bitstream_get (state, 1);
699 699
700 for (i = 0; i < nfchans; i++) 700 for (i = 0; i < nfchans; i++)
701 if (chexpstr[i] != EXP_REUSE) { 701 if (chexpstr[i] != EXP_REUSE) {
702 if ((state->chincpl >> i) & 1) 702 if ((state->chincpl >> i) & 1)
703 state->endmant[i] = state->cplstrtmant; 703 state->endmant[i] = state->cplstrtmant;
704 else { 704 else {
705 int chbwcod; 705 int chbwcod;
706 706
707 chbwcod = bitstream_get (state, 6); 707 chbwcod = bitstream_get (state, 6);
708 if (chbwcod > 60) 708 if (chbwcod > 60)
709 return 1; 709 return 1;
710 state->endmant[i] = chbwcod * 3 + 73; 710 state->endmant[i] = chbwcod * 3 + 73;
711 } 711 }
712 } 712 }
713 713
714 do_bit_alloc = 0; 714 do_bit_alloc = 0;
715 715
716 if (cplexpstr != EXP_REUSE) { 716 if (cplexpstr != EXP_REUSE) {
717 int cplabsexp, ncplgrps; 717 int cplabsexp, ncplgrps;
718 718
719 do_bit_alloc = 64; 719 do_bit_alloc = 64;
720 ncplgrps = ((state->cplendmant - state->cplstrtmant) / 720 ncplgrps = ((state->cplendmant - state->cplstrtmant) /
721 (3 << (cplexpstr - 1))); 721 (3 << (cplexpstr - 1)));
722 cplabsexp = bitstream_get (state, 4) << 1; 722 cplabsexp = bitstream_get (state, 4) << 1;
723 if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp, 723 if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp,
724 state->cpl_expbap.exp + state->cplstrtmant)) 724 state->cpl_expbap.exp + state->cplstrtmant))
725 return 1; 725 return 1;
726 } 726 }
727 for (i = 0; i < nfchans; i++) 727 for (i = 0; i < nfchans; i++)
728 if (chexpstr[i] != EXP_REUSE) { 728 if (chexpstr[i] != EXP_REUSE) {
729 int grp_size, nchgrps; 729 int grp_size, nchgrps;
730 730
731 do_bit_alloc |= 1 << i; 731 do_bit_alloc |= 1 << i;
732 grp_size = 3 << (chexpstr[i] - 1); 732 grp_size = 3 << (chexpstr[i] - 1);
733 nchgrps = (state->endmant[i] + grp_size - 4) / grp_size; 733 nchgrps = (state->endmant[i] + grp_size - 4) / grp_size;
734 state->fbw_expbap[i].exp[0] = bitstream_get (state, 4); 734 state->fbw_expbap[i].exp[0] = bitstream_get (state, 4);
735 if (parse_exponents (state, chexpstr[i], nchgrps, 735 if (parse_exponents (state, chexpstr[i], nchgrps,
736 state->fbw_expbap[i].exp[0], 736 state->fbw_expbap[i].exp[0],
737 state->fbw_expbap[i].exp + 1)) 737 state->fbw_expbap[i].exp + 1))
738 return 1; 738 return 1;
739 bitstream_get (state, 2); /* gainrng */ 739 bitstream_get (state, 2); /* gainrng */
740 } 740 }
741 if (lfeexpstr != EXP_REUSE) { 741 if (lfeexpstr != EXP_REUSE) {
742 do_bit_alloc |= 32; 742 do_bit_alloc |= 32;
743 state->lfe_expbap.exp[0] = bitstream_get (state, 4); 743 state->lfe_expbap.exp[0] = bitstream_get (state, 4);
744 if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0], 744 if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0],
745 state->lfe_expbap.exp + 1)) 745 state->lfe_expbap.exp + 1))
746 return 1; 746 return 1;
747 } 747 }
748 748
749 if (bitstream_get (state, 1)) { /* baie */ 749 if (bitstream_get (state, 1)) { /* baie */
750 do_bit_alloc = 127; 750 do_bit_alloc = 127;
751 state->bai = bitstream_get (state, 11); 751 state->bai = bitstream_get (state, 11);
752 } 752 }
753 if (bitstream_get (state, 1)) { /* snroffste */ 753 if (bitstream_get (state, 1)) { /* snroffste */
754 do_bit_alloc = 127; 754 do_bit_alloc = 127;
755 state->csnroffst = bitstream_get (state, 6); 755 state->csnroffst = bitstream_get (state, 6);
756 if (state->chincpl) /* cplinu */ 756 if (state->chincpl) /* cplinu */
757 state->cplba.bai = bitstream_get (state, 7); 757 state->cplba.bai = bitstream_get (state, 7);
758 for (i = 0; i < nfchans; i++) 758 for (i = 0; i < nfchans; i++)
759 state->ba[i].bai = bitstream_get (state, 7); 759 state->ba[i].bai = bitstream_get (state, 7);
760 if (state->lfeon) 760 if (state->lfeon)
761 state->lfeba.bai = bitstream_get (state, 7); 761 state->lfeba.bai = bitstream_get (state, 7);
762 } 762 }
763 if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */ 763 if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */
764 do_bit_alloc |= 64; 764 do_bit_alloc |= 64;
765 state->cplfleak = 9 - bitstream_get (state, 3); 765 state->cplfleak = 9 - bitstream_get (state, 3);
766 state->cplsleak = 9 - bitstream_get (state, 3); 766 state->cplsleak = 9 - bitstream_get (state, 3);
767 } 767 }
768 768
769 if (bitstream_get (state, 1)) { /* deltbaie */ 769 if (bitstream_get (state, 1)) { /* deltbaie */
770 do_bit_alloc = 127; 770 do_bit_alloc = 127;
771 if (state->chincpl) /* cplinu */ 771 if (state->chincpl) /* cplinu */
772 state->cplba.deltbae = bitstream_get (state, 2); 772 state->cplba.deltbae = bitstream_get (state, 2);
773 for (i = 0; i < nfchans; i++) 773 for (i = 0; i < nfchans; i++)
774 state->ba[i].deltbae = bitstream_get (state, 2); 774 state->ba[i].deltbae = bitstream_get (state, 2);
775 if (state->chincpl && /* cplinu */ 775 if (state->chincpl && /* cplinu */
776 (state->cplba.deltbae == DELTA_BIT_NEW) && 776 (state->cplba.deltbae == DELTA_BIT_NEW) &&
777 parse_deltba (state, state->cplba.deltba)) 777 parse_deltba (state, state->cplba.deltba))
778 return 1; 778 return 1;
779 for (i = 0; i < nfchans; i++) 779 for (i = 0; i < nfchans; i++)
780 if ((state->ba[i].deltbae == DELTA_BIT_NEW) && 780 if ((state->ba[i].deltbae == DELTA_BIT_NEW) &&
781 parse_deltba (state, state->ba[i].deltba)) 781 parse_deltba (state, state->ba[i].deltba))
782 return 1; 782 return 1;
783 } 783 }
784 784
785 if (do_bit_alloc) { 785 if (do_bit_alloc) {
786 if (zero_snr_offsets (nfchans, state)) { 786 if (zero_snr_offsets (nfchans, state)) {
787 memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap)); 787 memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap));
788 for (i = 0; i < nfchans; i++) 788 for (i = 0; i < nfchans; i++)
789 memset (state->fbw_expbap[i].bap, 0, 789 memset (state->fbw_expbap[i].bap, 0,
790 sizeof (state->fbw_expbap[i].bap)); 790 sizeof (state->fbw_expbap[i].bap));
791 memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap)); 791 memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap));
792 } else { 792 } else {
793 if (state->chincpl && (do_bit_alloc & 64)) /* cplinu */ 793 if (state->chincpl && (do_bit_alloc & 64)) /* cplinu */
794 a52_bit_allocate (state, &state->cplba, state->cplstrtbnd, 794 a52_bit_allocate (state, &state->cplba, state->cplstrtbnd,
795 state->cplstrtmant, state->cplendmant, 795 state->cplstrtmant, state->cplendmant,
796 state->cplfleak << 8, state->cplsleak << 8, 796 state->cplfleak << 8, state->cplsleak << 8,
797 &state->cpl_expbap); 797 &state->cpl_expbap);
798 for (i = 0; i < nfchans; i++) 798 for (i = 0; i < nfchans; i++)
799 if (do_bit_alloc & (1 << i)) 799 if (do_bit_alloc & (1 << i))
800 a52_bit_allocate (state, state->ba + i, 0, 0, 800 a52_bit_allocate (state, state->ba + i, 0, 0,
801 state->endmant[i], 0, 0, 801 state->endmant[i], 0, 0,
802 state->fbw_expbap +i); 802 state->fbw_expbap +i);
803 if (state->lfeon && (do_bit_alloc & 32)) { 803 if (state->lfeon && (do_bit_alloc & 32)) {
804 state->lfeba.deltbae = DELTA_BIT_NONE; 804 state->lfeba.deltbae = DELTA_BIT_NONE;
805 a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0, 805 a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0,
806 &state->lfe_expbap); 806 &state->lfe_expbap);
807 } 807 }
808 } 808 }
809 } 809 }
810 810
811 if (bitstream_get (state, 1)) { /* skiple */ 811 if (bitstream_get (state, 1)) { /* skiple */
812 i = bitstream_get (state, 9); /* skipl */ 812 i = bitstream_get (state, 9); /* skipl */
813 while (i--) 813 while (i--)
814 bitstream_get (state, 8); 814 bitstream_get (state, 8);
815 } 815 }
816 816
817 samples = state->samples; 817 samples = state->samples;
818 if (state->output & A52_LFE) 818 if (state->output & A52_LFE)
819 samples += 256; /* shift for LFE channel */ 819 samples += 256; /* shift for LFE channel */
820 820
821 chanbias = a52_downmix_coeff (coeff, state->acmod, state->output, 821 chanbias = a52_downmix_coeff (coeff, state->acmod, state->output,
822 state->dynrng, state->clev, state->slev); 822 state->dynrng, state->clev, state->slev);
823 823
824 quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1; 824 quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1;
825 done_cpl = 0; 825 done_cpl = 0;
826 826
827 for (i = 0; i < nfchans; i++) { 827 for (i = 0; i < nfchans; i++) {
828 int j; 828 int j;
829 829
830 coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant, 830 coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant,
831 coeff[i], dithflag[i], state->endmant[i]); 831 coeff[i], dithflag[i], state->endmant[i]);
832 832
833 if ((state->chincpl >> i) & 1) { 833 if ((state->chincpl >> i) & 1) {
834 if (!done_cpl) { 834 if (!done_cpl) {
835 done_cpl = 1; 835 done_cpl = 1;
836 coeff_get_coupling (state, nfchans, coeff, 836 coeff_get_coupling (state, nfchans, coeff,
837 (sample_t (*)[256])samples, &quant, 837 (sample_t (*)[256])samples, &quant,
838 dithflag); 838 dithflag);
839 } 839 }
840 j = state->cplendmant; 840 j = state->cplendmant;
841 } else 841 } else
842 j = state->endmant[i]; 842 j = state->endmant[i];
843 do 843 do
844 (samples + 256 * i)[j] = 0; 844 (samples + 256 * i)[j] = 0;
845 while (++j < 256); 845 while (++j < 256);
846 } 846 }
847 847
848 if (state->acmod == 2) { 848 if (state->acmod == 2) {
849 int j, end, band, rematflg; 849 int j, end, band, rematflg;
850 850
851 end = ((state->endmant[0] < state->endmant[1]) ? 851 end = ((state->endmant[0] < state->endmant[1]) ?
852 state->endmant[0] : state->endmant[1]); 852 state->endmant[0] : state->endmant[1]);
853 853
854 i = 0; 854 i = 0;
855 j = 13; 855 j = 13;
856 rematflg = state->rematflg; 856 rematflg = state->rematflg;
857 do { 857 do {
858 if (! (rematflg & 1)) { 858 if (! (rematflg & 1)) {
859 rematflg >>= 1; 859 rematflg >>= 1;
860 j = rematrix_band[i++]; 860 j = rematrix_band[i++];
861 continue; 861 continue;
862 } 862 }
863 rematflg >>= 1; 863 rematflg >>= 1;
864 band = rematrix_band[i++]; 864 band = rematrix_band[i++];
865 if (band > end) 865 if (band > end)
866 band = end; 866 band = end;
867 do { 867 do {
868 sample_t tmp0, tmp1; 868 sample_t tmp0, tmp1;
869 869
870 tmp0 = samples[j]; 870 tmp0 = samples[j];
871 tmp1 = (samples+256)[j]; 871 tmp1 = (samples+256)[j];
872 samples[j] = tmp0 + tmp1; 872 samples[j] = tmp0 + tmp1;
873 (samples+256)[j] = tmp0 - tmp1; 873 (samples+256)[j] = tmp0 - tmp1;
874 } while (++j < band); 874 } while (++j < band);
875 } while (j < end); 875 } while (j < end);
876 } 876 }
877 877
878 if (state->lfeon) { 878 if (state->lfeon) {
879 if (state->output & A52_LFE) { 879 if (state->output & A52_LFE) {
880 coeff_get (state, samples - 256, &state->lfe_expbap, &quant, 880 coeff_get (state, samples - 256, &state->lfe_expbap, &quant,
881 state->dynrng, 0, 7); 881 state->dynrng, 0, 7);
882 for (i = 7; i < 256; i++) 882 for (i = 7; i < 256; i++)
883 (samples-256)[i] = 0; 883 (samples-256)[i] = 0;
884 a52_imdct_512 (samples - 256, samples + 1536 - 256); 884 a52_imdct_512 (samples - 256, samples + 1536 - 256);
885 } else { 885 } else {
886 /* just skip the LFE coefficients */ 886 /* just skip the LFE coefficients */
887 coeff_get (state, samples + 1280, &state->lfe_expbap, &quant, 887 coeff_get (state, samples + 1280, &state->lfe_expbap, &quant,
888 0, 0, 7); 888 0, 0, 7);
889 } 889 }
890 } 890 }
891 891
892 i = 0; 892 i = 0;
893 if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans) 893 if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans)
894 for (i = 1; i < nfchans; i++) 894 for (i = 1; i < nfchans; i++)
895 if (blksw[i] != blksw[0]) 895 if (blksw[i] != blksw[0])
896 break; 896 break;
897 897
898 if (i < nfchans) { 898 if (i < nfchans) {
899 if (state->downmixed) { 899 if (state->downmixed) {
900 state->downmixed = 0; 900 state->downmixed = 0;
901 a52_upmix (samples + 1536, state->acmod, state->output); 901 a52_upmix (samples + 1536, state->acmod, state->output);
902 } 902 }
903 903
904 for (i = 0; i < nfchans; i++) { 904 for (i = 0; i < nfchans; i++) {
905 sample_t bias; 905 sample_t bias;
906 906
907 bias = 0; 907 bias = 0;
908 if (!(chanbias & (1 << i))) 908 if (!(chanbias & (1 << i)))
909 bias = state->bias; 909 bias = state->bias;
910 910
911 if (coeff[i]) { 911 if (coeff[i]) {
912 if (blksw[i]) 912 if (blksw[i])
913 a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i); 913 a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i);
914 else 914 else
915 a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i); 915 a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i);
916 } else { 916 } else {
917 int j; 917 int j;
918 918
919 for (j = 0; j < 256; j++) 919 for (j = 0; j < 256; j++)
920 (samples + 256 * i)[j] = bias; 920 (samples + 256 * i)[j] = bias;
921 } 921 }
922 } 922 }
923 923
924 a52_downmix (samples, state->acmod, state->output, 924 a52_downmix (samples, state->acmod, state->output,
925 state->clev, state->slev); 925 state->clev, state->slev);
926 } else { 926 } else {
927 nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK]; 927 nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK];
928 928
929 a52_downmix (samples, state->acmod, state->output, 929 a52_downmix (samples, state->acmod, state->output,
930 state->clev, state->slev); 930 state->clev, state->slev);
931 931
932 if (!state->downmixed) { 932 if (!state->downmixed) {
933 state->downmixed = 1; 933 state->downmixed = 1;
934 a52_downmix (samples + 1536, state->acmod, state->output, 934 a52_downmix (samples + 1536, state->acmod, state->output,
935 state->clev, state->slev); 935 state->clev, state->slev);
936 } 936 }
937 937
938 if (blksw[0]) 938 if (blksw[0])
939 for (i = 0; i < nfchans; i++) 939 for (i = 0; i < nfchans; i++)
940 a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i); 940 a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i);
941 else 941 else
942 for (i = 0; i < nfchans; i++) 942 for (i = 0; i < nfchans; i++)
943 a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i); 943 a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i);
944 } 944 }
945 945
946 return 0; 946 return 0;
diff --git a/apps/codecs/libasap/acpu.c b/apps/codecs/libasap/acpu.c
index 7c3c8f6f28..c5bff47a5d 100644
--- a/apps/codecs/libasap/acpu.c
+++ b/apps/codecs/libasap/acpu.c
@@ -52,105 +52,105 @@
52#include "asap_internal.h" 52#include "asap_internal.h"
53 53
54CONST_ARRAY(int, opcode_cycles) 54CONST_ARRAY(int, opcode_cycles)
55/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ 55/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
56 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0x */ 56 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0x */
57 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1x */ 57 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1x */
58 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2x */ 58 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2x */
59 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3x */ 59 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3x */
60 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4x */ 60 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4x */
61 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5x */ 61 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5x */
62 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6x */ 62 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6x */
63 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7x */ 63 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7x */
64 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8x */ 64 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8x */
65 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9x */ 65 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9x */
66 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* Ax */ 66 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* Ax */
67 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* Bx */ 67 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* Bx */
68 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Cx */ 68 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Cx */
69 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* Dx */ 69 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* Dx */
70 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Ex */ 70 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Ex */
71 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* Fx */ 71 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* Fx */
72END_CONST_ARRAY; 72END_CONST_ARRAY;
73 73
74#ifdef ACPU_NO_DECIMAL 74#ifdef ACPU_NO_DECIMAL
75 75
76#define DO_ADC \ 76#define DO_ADC \
77 { \ 77 { \
78 /* binary mode */ \ 78 /* binary mode */ \
79 V(int, tmp) = a + data + c; \ 79 V(int, tmp) = a + data + c; \
80 c = tmp >> 8; \ 80 c = tmp >> 8; \
81 vdi &= D_FLAG | I_FLAG; \ 81 vdi &= D_FLAG | I_FLAG; \
82 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \ 82 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \
83 vdi += V_FLAG; \ 83 vdi += V_FLAG; \
84 nz = a = tmp & 0xff; \ 84 nz = a = tmp & 0xff; \
85 } 85 }
86 86
87#define DO_SBC \ 87#define DO_SBC \
88 { \ 88 { \
89 /* binary mode */ \ 89 /* binary mode */ \
90 V(int, tmp) = a - data - 1 + c; \ 90 V(int, tmp) = a - data - 1 + c; \
91 c = (tmp >= 0) ? 1 : 0; \ 91 c = (tmp >= 0) ? 1 : 0; \
92 vdi &= D_FLAG | I_FLAG; \ 92 vdi &= D_FLAG | I_FLAG; \
93 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \ 93 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \
94 vdi += V_FLAG; \ 94 vdi += V_FLAG; \
95 nz = a = tmp & 0xff; \ 95 nz = a = tmp & 0xff; \
96 } 96 }
97 97
98#else /* ACPU_NO_DECIMAL */ 98#else /* ACPU_NO_DECIMAL */
99 99
100#define DO_ADC \ 100#define DO_ADC \
101 if ((vdi & D_FLAG) == 0) { \ 101 if ((vdi & D_FLAG) == 0) { \
102 /* binary mode */ \ 102 /* binary mode */ \
103 V(int, tmp) = a + data + c; \ 103 V(int, tmp) = a + data + c; \
104 c = tmp >> 8; \ 104 c = tmp >> 8; \
105 vdi &= D_FLAG | I_FLAG; \ 105 vdi &= D_FLAG | I_FLAG; \
106 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \ 106 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \
107 vdi += V_FLAG; \ 107 vdi += V_FLAG; \
108 nz = a = tmp & 0xff; \ 108 nz = a = tmp & 0xff; \
109 } \ 109 } \
110 else { \ 110 else { \
111 /* decimal mode */ \ 111 /* decimal mode */ \
112 V(int, tmp) = (a & 0x0f) + (data & 0x0f) + c; \ 112 V(int, tmp) = (a & 0x0f) + (data & 0x0f) + c; \
113 if (tmp >= 10) \ 113 if (tmp >= 10) \
114 tmp = (tmp - 10) | 0x10; \ 114 tmp = (tmp - 10) | 0x10; \
115 tmp += (a & 0xf0) + (data & 0xf0); \ 115 tmp += (a & 0xf0) + (data & 0xf0); \
116 nz = ((tmp & 0x80) << 1) + ((a + data + c) & 0xff); \ 116 nz = ((tmp & 0x80) << 1) + ((a + data + c) & 0xff); \
117 vdi &= D_FLAG | I_FLAG; \ 117 vdi &= D_FLAG | I_FLAG; \
118 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \ 118 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \
119 vdi += V_FLAG; \ 119 vdi += V_FLAG; \
120 if (tmp > 0x9f) \ 120 if (tmp > 0x9f) \
121 tmp += 0x60; \ 121 tmp += 0x60; \
122 c = (tmp > 0xff) ? 1 : 0; \ 122 c = (tmp > 0xff) ? 1 : 0; \
123 a = tmp & 0xff; \ 123 a = tmp & 0xff; \
124 } 124 }
125 125
126#define DO_SBC \ 126#define DO_SBC \
127 if ((vdi & D_FLAG) == 0) { \ 127 if ((vdi & D_FLAG) == 0) { \
128 /* binary mode */ \ 128 /* binary mode */ \
129 V(int, tmp) = a - data - 1 + c; \ 129 V(int, tmp) = a - data - 1 + c; \
130 c = (tmp >= 0) ? 1 : 0; \ 130 c = (tmp >= 0) ? 1 : 0; \
131 vdi &= D_FLAG | I_FLAG; \ 131 vdi &= D_FLAG | I_FLAG; \
132 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \ 132 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \
133 vdi += V_FLAG; \ 133 vdi += V_FLAG; \
134 nz = a = tmp & 0xff; \ 134 nz = a = tmp & 0xff; \
135 } \ 135 } \
136 else { \ 136 else { \
137 /* decimal mode */ \ 137 /* decimal mode */ \
138 V(int, tmp) = a - data - 1 + c; \ 138 V(int, tmp) = a - data - 1 + c; \
139 V(int, al) = (a & 0x0f) - (data & 0x0f) - 1 + c; \ 139 V(int, al) = (a & 0x0f) - (data & 0x0f) - 1 + c; \
140 V(int, ah) = (a >> 4) - (data >> 4); \ 140 V(int, ah) = (a >> 4) - (data >> 4); \
141 if ((al & 0x10) != 0) { \ 141 if ((al & 0x10) != 0) { \
142 al -= 6; \ 142 al -= 6; \
143 ah--; \ 143 ah--; \
144 } \ 144 } \
145 if ((ah & 0x10) != 0) \ 145 if ((ah & 0x10) != 0) \
146 ah -= 6; \ 146 ah -= 6; \
147 c = tmp >= 0 ? 1 : 0; \ 147 c = tmp >= 0 ? 1 : 0; \
148 vdi &= D_FLAG | I_FLAG; \ 148 vdi &= D_FLAG | I_FLAG; \
149 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \ 149 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \
150 vdi += V_FLAG; \ 150 vdi += V_FLAG; \
151 nz = tmp & 0xff; \ 151 nz = tmp & 0xff; \
152 a = ((ah & 0xf) << 4) + (al & 0x0f); \ 152 a = ((ah & 0xf) << 4) + (al & 0x0f); \
153 } 153 }
154 154
155#endif /* ACPU_NO_DECIMAL */ 155#endif /* ACPU_NO_DECIMAL */
156 156
@@ -239,1068 +239,1068 @@ END_CONST_ARRAY;
239#define INS_ZP INC_ZP; data = nz; DO_SBC 239#define INS_ZP INC_ZP; data = nz; DO_SBC
240 240
241#define BRANCH(cond) \ 241#define BRANCH(cond) \
242 if (cond) { \ 242 if (cond) { \
243 addr = SBYTE(PEEK); \ 243 addr = SBYTE(PEEK); \
244 pc++; \ 244 pc++; \
245 addr += pc; \ 245 addr += pc; \
246 if ((addr ^ pc) >> 8 != 0) \ 246 if ((addr ^ pc) >> 8 != 0) \
247 ast _ cycle++; \ 247 ast _ cycle++; \
248 ast _ cycle++; \ 248 ast _ cycle++; \
249 pc = addr; \ 249 pc = addr; \
250 break; \ 250 break; \
251 } \ 251 } \
252 pc++; \ 252 pc++; \
253 break 253 break
254 254
255#define CHECK_IRQ \ 255#define CHECK_IRQ \
256 if ((vdi & I_FLAG) == 0 && ast _ irqst != 0xff) { \ 256 if ((vdi & I_FLAG) == 0 && ast _ irqst != 0xff) { \
257 PHPC; \ 257 PHPC; \
258 PHPB0; \ 258 PHPB0; \
259 vdi |= I_FLAG; \ 259 vdi |= I_FLAG; \
260 pc = dGetWord(0xfffe); \ 260 pc = dGetWord(0xfffe); \
261 ast _ cycle += 7; \ 261 ast _ cycle += 7; \
262 } 262 }
263 263
264/* Runs 6502 emulation for the specified number of Atari scanlines. 264/* Runs 6502 emulation for the specified number of Atari scanlines.
265 Each scanline is 114 cycles of which 9 is taken by ANTIC for memory refresh. */ 265 Each scanline is 114 cycles of which 9 is taken by ANTIC for memory refresh. */
266FUNC(void, Cpu_RunScanlines, (P(ASAP_State PTR, ast), P(int, scanlines))) 266FUNC(void, Cpu_RunScanlines, (P(ASAP_State PTR, ast), P(int, scanlines)))
267{ 267{
268 /* copy registers from ASAP_State to local variables for improved performance */ 268 /* copy registers from ASAP_State to local variables for improved performance */
269 V(int, pc); 269 V(int, pc);
270 V(int, nz); 270 V(int, nz);
271 V(int, a); 271 V(int, a);
272 V(int, x); 272 V(int, x);
273 V(int, y); 273 V(int, y);
274 V(int, c); 274 V(int, c);
275 V(int, s); 275 V(int, s);
276 V(int, vdi); 276 V(int, vdi);
277 V(int, next_event_cycle); 277 V(int, next_event_cycle);
278 V(int, cycle_limit); 278 V(int, cycle_limit);
279 pc = ast _ cpu_pc; 279 pc = ast _ cpu_pc;
280 nz = ast _ cpu_nz; 280 nz = ast _ cpu_nz;
281 a = ast _ cpu_a; 281 a = ast _ cpu_a;
282 x = ast _ cpu_x; 282 x = ast _ cpu_x;
283 y = ast _ cpu_y; 283 y = ast _ cpu_y;
284 c = ast _ cpu_c; 284 c = ast _ cpu_c;
285 s = ast _ cpu_s; 285 s = ast _ cpu_s;
286 vdi = ast _ cpu_vdi; 286 vdi = ast _ cpu_vdi;
287 ast _ next_scanline_cycle = 114; 287 ast _ next_scanline_cycle = 114;
288 next_event_cycle = 114; 288 next_event_cycle = 114;
289 cycle_limit = 114 * scanlines; 289 cycle_limit = 114 * scanlines;
290 if (next_event_cycle > ast _ timer1_cycle) 290 if (next_event_cycle > ast _ timer1_cycle)
291 next_event_cycle = ast _ timer1_cycle; 291 next_event_cycle = ast _ timer1_cycle;
292 if (next_event_cycle > ast _ timer2_cycle) 292 if (next_event_cycle > ast _ timer2_cycle)
293 next_event_cycle = ast _ timer2_cycle; 293 next_event_cycle = ast _ timer2_cycle;
294 if (next_event_cycle > ast _ timer4_cycle) 294 if (next_event_cycle > ast _ timer4_cycle)
295 next_event_cycle = ast _ timer4_cycle; 295 next_event_cycle = ast _ timer4_cycle;
296 ast _ nearest_event_cycle = next_event_cycle; 296 ast _ nearest_event_cycle = next_event_cycle;
297 for (;;) { 297 for (;;) {
298 V(int, cycle); 298 V(int, cycle);
299 V(int, addr); 299 V(int, addr);
300 V(int, data); 300 V(int, data);
301 cycle = ast _ cycle; 301 cycle = ast _ cycle;
302 if (cycle >= ast _ nearest_event_cycle) { 302 if (cycle >= ast _ nearest_event_cycle) {
303 if (cycle >= ast _ next_scanline_cycle) { 303 if (cycle >= ast _ next_scanline_cycle) {
304 if (++ast _ scanline_number == 312) 304 if (++ast _ scanline_number == 312)
305 ast _ scanline_number = 0; 305 ast _ scanline_number = 0;
306 ast _ cycle = cycle += 9; 306 ast _ cycle = cycle += 9;
307 ast _ next_scanline_cycle += 114; 307 ast _ next_scanline_cycle += 114;
308 if (--scanlines <= 0) 308 if (--scanlines <= 0)
309 break; 309 break;
310 } 310 }
311 next_event_cycle = ast _ next_scanline_cycle; 311 next_event_cycle = ast _ next_scanline_cycle;
312#define CHECK_TIMER_IRQ(ch) \ 312#define CHECK_TIMER_IRQ(ch) \
313 if (cycle >= ast _ timer##ch##_cycle) { \ 313 if (cycle >= ast _ timer##ch##_cycle) { \
314 ast _ irqst &= ~ch; \ 314 ast _ irqst &= ~ch; \
315 ast _ timer##ch##_cycle = NEVER; \ 315 ast _ timer##ch##_cycle = NEVER; \
316 } \ 316 } \
317 else if (next_event_cycle > ast _ timer##ch##_cycle) \ 317 else if (next_event_cycle > ast _ timer##ch##_cycle) \
318 next_event_cycle = ast _ timer##ch##_cycle; 318 next_event_cycle = ast _ timer##ch##_cycle;
319 CHECK_TIMER_IRQ(1); 319 CHECK_TIMER_IRQ(1);
320 CHECK_TIMER_IRQ(2); 320 CHECK_TIMER_IRQ(2);
321 CHECK_TIMER_IRQ(4); 321 CHECK_TIMER_IRQ(4);
322 ast _ nearest_event_cycle = next_event_cycle; 322 ast _ nearest_event_cycle = next_event_cycle;
323 CHECK_IRQ; 323 CHECK_IRQ;
324 } 324 }
325#ifdef ASAPSCAN 325#ifdef ASAPSCAN
326 if (cpu_trace != 0) 326 if (cpu_trace != 0)
327 trace_cpu(ast, pc, a, x, y, s, nz, vdi, c); 327 trace_cpu(ast, pc, a, x, y, s, nz, vdi, c);
328#endif 328#endif
329 data = FETCH; 329 data = FETCH;
330 ast _ cycle += opcode_cycles[data]; 330 ast _ cycle += opcode_cycles[data];
331 switch (data) { 331 switch (data) {
332 case 0x00: /* BRK */ 332 case 0x00: /* BRK */
333 pc++; 333 pc++;
334 PHPC; 334 PHPC;
335 PHPB1; 335 PHPB1;
336 vdi |= I_FLAG; 336 vdi |= I_FLAG;
337 pc = dGetWord(0xfffe); 337 pc = dGetWord(0xfffe);
338 break; 338 break;
339 case 0x01: /* ORA (ab,x) */ 339 case 0x01: /* ORA (ab,x) */
340 INDIRECT_X; 340 INDIRECT_X;
341 ORA; 341 ORA;
342 break; 342 break;
343 case 0x02: /* CIM [unofficial] */ 343 case 0x02: /* CIM [unofficial] */
344 case 0x12: 344 case 0x12:
345 case 0x22: 345 case 0x22:
346 case 0x32: 346 case 0x32:
347 case 0x42: 347 case 0x42:
348 case 0x52: 348 case 0x52:
349 case 0x62: 349 case 0x62:
350 case 0x72: 350 case 0x72:
351 case 0x92: 351 case 0x92:
352 case 0xb2: 352 case 0xb2:
353 case 0xd2: 353 case 0xd2:
354 case 0xf2: 354 case 0xf2:
355 ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % 312; 355 ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % 312;
356 scanlines = 1; 356 scanlines = 1;
357 ast _ cycle = cycle_limit; 357 ast _ cycle = cycle_limit;
358 break; 358 break;
359#ifndef ACPU_NO_UNOFFICIAL 359#ifndef ACPU_NO_UNOFFICIAL
360 case 0x03: /* ASO (ab,x) [unofficial] */ 360 case 0x03: /* ASO (ab,x) [unofficial] */
361 INDIRECT_X; 361 INDIRECT_X;
362 ASO; 362 ASO;
363 break; 363 break;
364 case 0x04: /* NOP ab [unofficial] */ 364 case 0x04: /* NOP ab [unofficial] */
365 case 0x44: 365 case 0x44:
366 case 0x64: 366 case 0x64:
367 case 0x14: /* NOP ab,x [unofficial] */ 367 case 0x14: /* NOP ab,x [unofficial] */
368 case 0x34: 368 case 0x34:
369 case 0x54: 369 case 0x54:
370 case 0x74: 370 case 0x74:
371 case 0xd4: 371 case 0xd4:
372 case 0xf4: 372 case 0xf4:
373 case 0x80: /* NOP #ab [unofficial] */ 373 case 0x80: /* NOP #ab [unofficial] */
374 case 0x82: 374 case 0x82:
375 case 0x89: 375 case 0x89:
376 case 0xc2: 376 case 0xc2:
377 case 0xe2: 377 case 0xe2:
378 pc++; 378 pc++;
379 break; 379 break;
380 case 0x07: /* ASO ab [unofficial] */ 380 case 0x07: /* ASO ab [unofficial] */
381 ZPAGE; 381 ZPAGE;
382 ASO_ZP; 382 ASO_ZP;
383 break; 383 break;
384 case 0x0b: /* ANC #ab [unofficial] */ 384 case 0x0b: /* ANC #ab [unofficial] */
385 case 0x2b: 385 case 0x2b:
386 nz = a &= FETCH; 386 nz = a &= FETCH;
387 c = nz >> 7; 387 c = nz >> 7;
388 break; 388 break;
389 case 0x0c: /* NOP abcd [unofficial] */ 389 case 0x0c: /* NOP abcd [unofficial] */
390 pc += 2; 390 pc += 2;
391 break; 391 break;
392 case 0x0f: /* ASO abcd [unofficial] */ 392 case 0x0f: /* ASO abcd [unofficial] */
393 ABSOLUTE; 393 ABSOLUTE;
394 ASO; 394 ASO;
395 break; 395 break;
396 case 0x13: /* ASO (ab),y [unofficial] */ 396 case 0x13: /* ASO (ab),y [unofficial] */
397 INDIRECT_Y; 397 INDIRECT_Y;
398 ASO; 398 ASO;
399 break; 399 break;
400 case 0x17: /* ASO ab,x [unofficial] */ 400 case 0x17: /* ASO ab,x [unofficial] */
401 ZPAGE_X; 401 ZPAGE_X;
402 ASO_ZP; 402 ASO_ZP;
403 break; 403 break;
404 case 0x1b: /* ASO abcd,y [unofficial] */ 404 case 0x1b: /* ASO abcd,y [unofficial] */
405 ABSOLUTE_Y; 405 ABSOLUTE_Y;
406 ASO; 406 ASO;
407 break; 407 break;
408 case 0x1c: /* NOP abcd,x [unofficial] */ 408 case 0x1c: /* NOP abcd,x [unofficial] */
409 case 0x3c: 409 case 0x3c:
410 case 0x5c: 410 case 0x5c:
411 case 0x7c: 411 case 0x7c:
412 case 0xdc: 412 case 0xdc:
413 case 0xfc: 413 case 0xfc:
414 if (FETCH + x >= 0x100) 414 if (FETCH + x >= 0x100)
415 ast _ cycle++; 415 ast _ cycle++;
416 pc++; 416 pc++;
417 break; 417 break;
418 case 0x1f: /* ASO abcd,x [unofficial] */ 418 case 0x1f: /* ASO abcd,x [unofficial] */
419 ABSOLUTE_X; 419 ABSOLUTE_X;
420 ASO; 420 ASO;
421 break; 421 break;
422 case 0x23: /* RLA (ab,x) [unofficial] */ 422 case 0x23: /* RLA (ab,x) [unofficial] */
423 INDIRECT_X; 423 INDIRECT_X;
424 RLA; 424 RLA;
425 break; 425 break;
426 case 0x27: /* RLA ab [unofficial] */ 426 case 0x27: /* RLA ab [unofficial] */
427 ZPAGE; 427 ZPAGE;
428 RLA_ZP; 428 RLA_ZP;
429 break; 429 break;
430 case 0x2f: /* RLA abcd [unofficial] */ 430 case 0x2f: /* RLA abcd [unofficial] */
431 ABSOLUTE; 431 ABSOLUTE;
432 RLA; 432 RLA;
433 break; 433 break;
434 case 0x33: /* RLA (ab),y [unofficial] */ 434 case 0x33: /* RLA (ab),y [unofficial] */
435 INDIRECT_Y; 435 INDIRECT_Y;
436 RLA; 436 RLA;
437 break; 437 break;
438 case 0x37: /* RLA ab,x [unofficial] */ 438 case 0x37: /* RLA ab,x [unofficial] */
439 ZPAGE_X; 439 ZPAGE_X;
440 RLA_ZP; 440 RLA_ZP;
441 break; 441 break;
442 case 0x3b: /* RLA abcd,y [unofficial] */ 442 case 0x3b: /* RLA abcd,y [unofficial] */
443 ABSOLUTE_Y; 443 ABSOLUTE_Y;
444 RLA; 444 RLA;
445 break; 445 break;
446 case 0x3f: /* RLA abcd,x [unofficial] */ 446 case 0x3f: /* RLA abcd,x [unofficial] */
447 ABSOLUTE_X; 447 ABSOLUTE_X;
448 RLA; 448 RLA;
449 break; 449 break;
450 case 0x43: /* LSE (ab,x) [unofficial] */ 450 case 0x43: /* LSE (ab,x) [unofficial] */
451 INDIRECT_X; 451 INDIRECT_X;
452 LSE; 452 LSE;
453 break; 453 break;
454 case 0x47: /* LSE ab [unofficial] */ 454 case 0x47: /* LSE ab [unofficial] */
455 ZPAGE; 455 ZPAGE;
456 LSE_ZP; 456 LSE_ZP;
457 break; 457 break;
458 case 0x4b: /* ALR #ab [unofficial] */ 458 case 0x4b: /* ALR #ab [unofficial] */
459 a &= FETCH; 459 a &= FETCH;
460 c = a & 1; 460 c = a & 1;
461 nz = a >>= 1; 461 nz = a >>= 1;
462 break; 462 break;
463 case 0x4f: /* LSE abcd [unofficial] */ 463 case 0x4f: /* LSE abcd [unofficial] */
464 ABSOLUTE; 464 ABSOLUTE;
465 LSE; 465 LSE;
466 break; 466 break;
467 case 0x53: /* LSE (ab),y [unofficial] */ 467 case 0x53: /* LSE (ab),y [unofficial] */
468 INDIRECT_Y; 468 INDIRECT_Y;
469 LSE; 469 LSE;
470 break; 470 break;
471 case 0x57: /* LSE ab,x [unofficial] */ 471 case 0x57: /* LSE ab,x [unofficial] */
472 ZPAGE_X; 472 ZPAGE_X;
473 LSE_ZP; 473 LSE_ZP;
474 break; 474 break;
475 case 0x5b: /* LSE abcd,y [unofficial] */ 475 case 0x5b: /* LSE abcd,y [unofficial] */
476 ABSOLUTE_Y; 476 ABSOLUTE_Y;
477 LSE; 477 LSE;
478 break; 478 break;
479 case 0x5f: /* LSE abcd,x [unofficial] */ 479 case 0x5f: /* LSE abcd,x [unofficial] */
480 ABSOLUTE_X; 480 ABSOLUTE_X;
481 LSE; 481 LSE;
482 break; 482 break;
483 case 0x63: /* RRA (ab,x) [unofficial] */ 483 case 0x63: /* RRA (ab,x) [unofficial] */
484 INDIRECT_X; 484 INDIRECT_X;
485 RRA; 485 RRA;
486 break; 486 break;
487 case 0x67: /* RRA ab [unofficial] */ 487 case 0x67: /* RRA ab [unofficial] */
488 ZPAGE; 488 ZPAGE;
489 RRA_ZP; 489 RRA_ZP;
490 break; 490 break;
491 case 0x6b: /* ARR #ab [unofficial] */ 491 case 0x6b: /* ARR #ab [unofficial] */
492 data = a & FETCH; 492 data = a & FETCH;
493 nz = a = (data >> 1) + (c << 7); 493 nz = a = (data >> 1) + (c << 7);
494 vdi = (vdi & (D_FLAG | I_FLAG)) + ((a ^ data) & V_FLAG); 494 vdi = (vdi & (D_FLAG | I_FLAG)) + ((a ^ data) & V_FLAG);
495#ifdef ACPU_NO_DECIMAL 495#ifdef ACPU_NO_DECIMAL
496 c = data >> 7; 496 c = data >> 7;
497#else 497#else
498 if ((vdi & D_FLAG) == 0) 498 if ((vdi & D_FLAG) == 0)
499 c = data >> 7; 499 c = data >> 7;
500 else { 500 else {
501 if ((data & 0xf) >= 5) 501 if ((data & 0xf) >= 5)
502 a = (a & 0xf0) + ((a + 6) & 0xf); 502 a = (a & 0xf0) + ((a + 6) & 0xf);
503 if (data >= 0x50) { 503 if (data >= 0x50) {
504 a = (a + 0x60) & 0xff; 504 a = (a + 0x60) & 0xff;
505 c = 1; 505 c = 1;
506 } 506 }
507 else 507 else
508 c = 0; 508 c = 0;
509 } 509 }
510#endif 510#endif
511 break; 511 break;
512 case 0x6f: /* RRA abcd [unofficial] */ 512 case 0x6f: /* RRA abcd [unofficial] */
513 ABSOLUTE; 513 ABSOLUTE;
514 RRA; 514 RRA;
515 break; 515 break;
516 case 0x73: /* RRA (ab),y [unofficial] */ 516 case 0x73: /* RRA (ab),y [unofficial] */
517 INDIRECT_Y; 517 INDIRECT_Y;
518 RRA; 518 RRA;
519 break; 519 break;
520 case 0x77: /* RRA ab,x [unofficial] */ 520 case 0x77: /* RRA ab,x [unofficial] */
521 ZPAGE_X; 521 ZPAGE_X;
522 RRA_ZP; 522 RRA_ZP;
523 break; 523 break;
524 case 0x7b: /* RRA abcd,y [unofficial] */ 524 case 0x7b: /* RRA abcd,y [unofficial] */
525 ABSOLUTE_Y; 525 ABSOLUTE_Y;
526 RRA; 526 RRA;
527 break; 527 break;
528 case 0x7f: /* RRA abcd,x [unofficial] */ 528 case 0x7f: /* RRA abcd,x [unofficial] */
529 ABSOLUTE_X; 529 ABSOLUTE_X;
530 RRA; 530 RRA;
531 break; 531 break;
532 case 0x83: /* SAX (ab,x) [unofficial] */ 532 case 0x83: /* SAX (ab,x) [unofficial] */
533 INDIRECT_X; 533 INDIRECT_X;
534 SAX; 534 SAX;
535 break; 535 break;
536 case 0x87: /* SAX ab [unofficial] */ 536 case 0x87: /* SAX ab [unofficial] */
537 ZPAGE; 537 ZPAGE;
538 SAX_ZP; 538 SAX_ZP;
539 break; 539 break;
540 case 0x8b: /* ANE #ab [unofficial] */ 540 case 0x8b: /* ANE #ab [unofficial] */
541 data = FETCH; 541 data = FETCH;
542 a &= x; 542 a &= x;
543 nz = a & data; 543 nz = a & data;
544 a &= data | 0xef; 544 a &= data | 0xef;
545 break; 545 break;
546 case 0x8f: /* SAX abcd [unofficial] */ 546 case 0x8f: /* SAX abcd [unofficial] */
547 ABSOLUTE; 547 ABSOLUTE;
548 SAX; 548 SAX;
549 break; 549 break;
550 case 0x93: /* SHA (ab),y [unofficial, unstable] */ 550 case 0x93: /* SHA (ab),y [unofficial, unstable] */
551 ZPAGE; 551 ZPAGE;
552 data = zGetByte(addr + 1); 552 data = zGetByte(addr + 1);
553 addr = (dGetByte(addr) + (data << 8) + y) & 0xffff; 553 addr = (dGetByte(addr) + (data << 8) + y) & 0xffff;
554 data = a & x & (data + 1); 554 data = a & x & (data + 1);
555 PutByte(addr, data); 555 PutByte(addr, data);
556 break; 556 break;
557 case 0x97: /* SAX ab,y [unofficial] */ 557 case 0x97: /* SAX ab,y [unofficial] */
558 ZPAGE_Y; 558 ZPAGE_Y;
559 SAX_ZP; 559 SAX_ZP;
560 break; 560 break;
561 case 0x9b: /* SHS abcd,y [unofficial, unstable] */ 561 case 0x9b: /* SHS abcd,y [unofficial, unstable] */
562 /* S seems to be stable, only memory values vary */ 562 /* S seems to be stable, only memory values vary */
563 addr = FETCH; 563 addr = FETCH;
564 data = FETCH; 564 data = FETCH;
565 addr = (addr + (data << 8) + y) & 0xffff; 565 addr = (addr + (data << 8) + y) & 0xffff;
566 s = a & x; 566 s = a & x;
567 data = s & (data + 1); 567 data = s & (data + 1);
568 PutByte(addr, data); 568 PutByte(addr, data);
569 break; 569 break;
570 case 0x9c: /* SHY abcd,x [unofficial] */ 570 case 0x9c: /* SHY abcd,x [unofficial] */
571 addr = FETCH; 571 addr = FETCH;
572 data = FETCH; 572 data = FETCH;
573 addr = (addr + (data << 8) + x) & 0xffff; 573 addr = (addr + (data << 8) + x) & 0xffff;
574 data = y & (data + 1); 574 data = y & (data + 1);
575 PutByte(addr, data); 575 PutByte(addr, data);
576 break; 576 break;
577 case 0x9e: /* SHX abcd,y [unofficial] */ 577 case 0x9e: /* SHX abcd,y [unofficial] */
578 addr = FETCH; 578 addr = FETCH;
579 data = FETCH; 579 data = FETCH;
580 addr = (addr + (data << 8) + y) & 0xffff; 580 addr = (addr + (data << 8) + y) & 0xffff;
581 data = x & (data + 1); 581 data = x & (data + 1);
582 PutByte(addr, data); 582 PutByte(addr, data);
583 break; 583 break;
584 case 0x9f: /* SHA abcd,y [unofficial, unstable] */ 584 case 0x9f: /* SHA abcd,y [unofficial, unstable] */
585 addr = FETCH; 585 addr = FETCH;
586 data = FETCH; 586 data = FETCH;
587 addr = (addr + (data << 8) + y) & 0xffff; 587 addr = (addr + (data << 8) + y) & 0xffff;
588 data = a & x & (data + 1); 588 data = a & x & (data + 1);
589 PutByte(addr, data); 589 PutByte(addr, data);
590 break; 590 break;
591 case 0xa3: /* LAX (ab,x) [unofficial] */ 591 case 0xa3: /* LAX (ab,x) [unofficial] */
592 INDIRECT_X; 592 INDIRECT_X;
593 LAX; 593 LAX;
594 break; 594 break;
595 case 0xa7: /* LAX ab [unofficial] */ 595 case 0xa7: /* LAX ab [unofficial] */
596 ZPAGE; 596 ZPAGE;
597 LAX_ZP; 597 LAX_ZP;
598 break; 598 break;
599 case 0xab: /* ANX #ab [unofficial] */ 599 case 0xab: /* ANX #ab [unofficial] */
600 nz = x = a &= FETCH; 600 nz = x = a &= FETCH;
601 break; 601 break;
602 case 0xaf: /* LAX abcd [unofficial] */ 602 case 0xaf: /* LAX abcd [unofficial] */
603 ABSOLUTE; 603 ABSOLUTE;
604 LAX; 604 LAX;
605 break; 605 break;
606 case 0xb3: /* LAX (ab),y [unofficial] */ 606 case 0xb3: /* LAX (ab),y [unofficial] */
607 INDIRECT_Y; 607 INDIRECT_Y;
608 NCYCLES_Y; 608 NCYCLES_Y;
609 LAX; 609 LAX;
610 break; 610 break;
611 case 0xb7: /* LAX ab,y [unofficial] */ 611 case 0xb7: /* LAX ab,y [unofficial] */
612 ZPAGE_Y; 612 ZPAGE_Y;
613 LAX_ZP; 613 LAX_ZP;
614 break; 614 break;
615 case 0xbb: /* LAS abcd,y [unofficial] */ 615 case 0xbb: /* LAS abcd,y [unofficial] */
616 ABSOLUTE_Y; 616 ABSOLUTE_Y;
617 NCYCLES_Y; 617 NCYCLES_Y;
618 nz = x = a = s &= GetByte(addr); 618 nz = x = a = s &= GetByte(addr);
619 break; 619 break;
620 case 0xbf: /* LAX abcd,y [unofficial] */ 620 case 0xbf: /* LAX abcd,y [unofficial] */
621 ABSOLUTE_Y; 621 ABSOLUTE_Y;
622 NCYCLES_Y; 622 NCYCLES_Y;
623 LAX; 623 LAX;
624 break; 624 break;
625 case 0xc3: /* DCM (ab,x) [unofficial] */ 625 case 0xc3: /* DCM (ab,x) [unofficial] */
626 INDIRECT_X; 626 INDIRECT_X;
627 DCM; 627 DCM;
628 break; 628 break;
629 case 0xc7: /* DCM ab [unofficial] */ 629 case 0xc7: /* DCM ab [unofficial] */
630 ZPAGE; 630 ZPAGE;
631 DCM_ZP; 631 DCM_ZP;
632 break; 632 break;
633 case 0xcb: /* SBX #ab [unofficial] */ 633 case 0xcb: /* SBX #ab [unofficial] */
634 nz = FETCH; 634 nz = FETCH;
635 x &= a; 635 x &= a;
636 c = (x >= nz) ? 1 : 0; 636 c = (x >= nz) ? 1 : 0;
637 nz = x = (x - nz) & 0xff; 637 nz = x = (x - nz) & 0xff;
638 break; 638 break;
639 case 0xcf: /* DCM abcd [unofficial] */ 639 case 0xcf: /* DCM abcd [unofficial] */
640 ABSOLUTE; 640 ABSOLUTE;
641 DCM; 641 DCM;
642 break; 642 break;
643 case 0xd3: /* DCM (ab),y [unofficial] */ 643 case 0xd3: /* DCM (ab),y [unofficial] */
644 INDIRECT_Y; 644 INDIRECT_Y;
645 DCM; 645 DCM;
646 break; 646 break;
647 case 0xd7: /* DCM ab,x [unofficial] */ 647 case 0xd7: /* DCM ab,x [unofficial] */
648 ZPAGE_X; 648 ZPAGE_X;
649 DCM_ZP; 649 DCM_ZP;
650 break; 650 break;
651 case 0xdb: /* DCM abcd,y [unofficial] */ 651 case 0xdb: /* DCM abcd,y [unofficial] */
652 ABSOLUTE_Y; 652 ABSOLUTE_Y;
653 DCM; 653 DCM;
654 break; 654 break;
655 case 0xdf: /* DCM abcd,x [unofficial] */ 655 case 0xdf: /* DCM abcd,x [unofficial] */
656 ABSOLUTE_X; 656 ABSOLUTE_X;
657 DCM; 657 DCM;
658 break; 658 break;
659 case 0xe3: /* INS (ab,x) [unofficial] */ 659 case 0xe3: /* INS (ab,x) [unofficial] */
660 INDIRECT_X; 660 INDIRECT_X;
661 INS; 661 INS;
662 break; 662 break;
663 case 0xe7: /* INS ab [unofficial] */ 663 case 0xe7: /* INS ab [unofficial] */
664 ZPAGE; 664 ZPAGE;
665 INS_ZP; 665 INS_ZP;
666 break; 666 break;
667 case 0xef: /* INS abcd [unofficial] */ 667 case 0xef: /* INS abcd [unofficial] */
668 ABSOLUTE; 668 ABSOLUTE;
669 INS; 669 INS;
670 break; 670 break;
671 case 0xf3: /* INS (ab),y [unofficial] */ 671 case 0xf3: /* INS (ab),y [unofficial] */
672 INDIRECT_Y; 672 INDIRECT_Y;
673 INS; 673 INS;
674 break; 674 break;
675 case 0xf7: /* INS ab,x [unofficial] */ 675 case 0xf7: /* INS ab,x [unofficial] */
676 ZPAGE_X; 676 ZPAGE_X;
677 INS_ZP; 677 INS_ZP;
678 break; 678 break;
679 case 0xfb: /* INS abcd,y [unofficial] */ 679 case 0xfb: /* INS abcd,y [unofficial] */
680 ABSOLUTE_Y; 680 ABSOLUTE_Y;
681 INS; 681 INS;
682 break; 682 break;
683 case 0xff: /* INS abcd,x [unofficial] */ 683 case 0xff: /* INS abcd,x [unofficial] */
684 ABSOLUTE_X; 684 ABSOLUTE_X;
685 INS; 685 INS;
686 break; 686 break;
687#endif /* ACPU_NO_UNOFFICIAL */ 687#endif /* ACPU_NO_UNOFFICIAL */
688 case 0x05: /* ORA ab */ 688 case 0x05: /* ORA ab */
689 ZPAGE; 689 ZPAGE;
690 ORA_ZP; 690 ORA_ZP;
691 break; 691 break;
692 case 0x06: /* ASL ab */ 692 case 0x06: /* ASL ab */
693 ZPAGE; 693 ZPAGE;
694 ASL_ZP; 694 ASL_ZP;
695 break; 695 break;
696 case 0x08: /* PHP */ 696 case 0x08: /* PHP */
697 PHPB1; 697 PHPB1;
698 break; 698 break;
699 case 0x09: /* ORA #ab */ 699 case 0x09: /* ORA #ab */
700 nz = a |= FETCH; 700 nz = a |= FETCH;
701 break; 701 break;
702 case 0x0a: /* ASL */ 702 case 0x0a: /* ASL */
703 c = a >> 7; 703 c = a >> 7;
704 nz = a = (a << 1) & 0xff; 704 nz = a = (a << 1) & 0xff;
705 break; 705 break;
706 case 0x0d: /* ORA abcd */ 706 case 0x0d: /* ORA abcd */
707 ABSOLUTE; 707 ABSOLUTE;
708 ORA; 708 ORA;
709 break; 709 break;
710 case 0x0e: /* ASL abcd */ 710 case 0x0e: /* ASL abcd */
711 ABSOLUTE; 711 ABSOLUTE;
712 ASL; 712 ASL;
713 break; 713 break;
714 case 0x10: /* BPL */ 714 case 0x10: /* BPL */
715 BRANCH(nz < 0x80); 715 BRANCH(nz < 0x80);
716 case 0x11: /* ORA (ab),y */ 716 case 0x11: /* ORA (ab),y */
717 INDIRECT_Y; 717 INDIRECT_Y;
718 NCYCLES_Y; 718 NCYCLES_Y;
719 ORA; 719 ORA;
720 break; 720 break;
721 case 0x15: /* ORA ab,x */ 721 case 0x15: /* ORA ab,x */
722 ZPAGE_X; 722 ZPAGE_X;
723 ORA_ZP; 723 ORA_ZP;
724 break; 724 break;
725 case 0x16: /* ASL ab,x */ 725 case 0x16: /* ASL ab,x */
726 ZPAGE_X; 726 ZPAGE_X;
727 ASL_ZP; 727 ASL_ZP;
728 break; 728 break;
729 case 0x18: /* CLC */ 729 case 0x18: /* CLC */
730 c = 0; 730 c = 0;
731 break; 731 break;
732 case 0x19: /* ORA abcd,y */ 732 case 0x19: /* ORA abcd,y */
733 ABSOLUTE_Y; 733 ABSOLUTE_Y;
734 NCYCLES_Y; 734 NCYCLES_Y;
735 ORA; 735 ORA;
736 break; 736 break;
737 case 0x1d: /* ORA abcd,x */ 737 case 0x1d: /* ORA abcd,x */
738 ABSOLUTE_X; 738 ABSOLUTE_X;
739 NCYCLES_X; 739 NCYCLES_X;
740 ORA; 740 ORA;
741 break; 741 break;
742 case 0x1e: /* ASL abcd,x */ 742 case 0x1e: /* ASL abcd,x */
743 ABSOLUTE_X; 743 ABSOLUTE_X;
744 ASL; 744 ASL;
745 break; 745 break;
746 case 0x20: /* JSR abcd */ 746 case 0x20: /* JSR abcd */
747 addr = FETCH; 747 addr = FETCH;
748 PHPC; 748 PHPC;
749 pc = addr + (PEEK << 8); 749 pc = addr + (PEEK << 8);
750 break; 750 break;
751 case 0x21: /* AND (ab,x) */ 751 case 0x21: /* AND (ab,x) */
752 INDIRECT_X; 752 INDIRECT_X;
753 AND; 753 AND;
754 break; 754 break;
755 case 0x24: /* BIT ab */ 755 case 0x24: /* BIT ab */
756 ZPAGE; 756 ZPAGE;
757 nz = dGetByte(addr); 757 nz = dGetByte(addr);
758 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); 758 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG);
759 nz = ((nz & 0x80) << 1) + (nz & a); 759 nz = ((nz & 0x80) << 1) + (nz & a);
760 break; 760 break;
761 case 0x25: /* AND ab */ 761 case 0x25: /* AND ab */
762 ZPAGE; 762 ZPAGE;
763 AND_ZP; 763 AND_ZP;
764 break; 764 break;
765 case 0x26: /* ROL ab */ 765 case 0x26: /* ROL ab */
766 ZPAGE; 766 ZPAGE;
767 ROL_ZP; 767 ROL_ZP;
768 break; 768 break;
769 case 0x28: /* PLP */ 769 case 0x28: /* PLP */
770 PLP; 770 PLP;
771 CHECK_IRQ; 771 CHECK_IRQ;
772 break; 772 break;
773 case 0x29: /* AND #ab */ 773 case 0x29: /* AND #ab */
774 nz = a &= FETCH; 774 nz = a &= FETCH;
775 break; 775 break;
776 case 0x2a: /* ROL */ 776 case 0x2a: /* ROL */
777 a = (a << 1) + c; 777 a = (a << 1) + c;
778 c = a >> 8; 778 c = a >> 8;
779 nz = a &= 0xff; 779 nz = a &= 0xff;
780 break; 780 break;
781 case 0x2c: /* BIT abcd */ 781 case 0x2c: /* BIT abcd */
782 ABSOLUTE; 782 ABSOLUTE;
783 nz = GetByte(addr); 783 nz = GetByte(addr);
784 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); 784 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG);
785 nz = ((nz & 0x80) << 1) + (nz & a); 785 nz = ((nz & 0x80) << 1) + (nz & a);
786 break; 786 break;
787 case 0x2d: /* AND abcd */ 787 case 0x2d: /* AND abcd */
788 ABSOLUTE; 788 ABSOLUTE;
789 AND; 789 AND;
790 break; 790 break;
791 case 0x2e: /* ROL abcd */ 791 case 0x2e: /* ROL abcd */
792 ABSOLUTE; 792 ABSOLUTE;
793 ROL; 793 ROL;
794 break; 794 break;
795 case 0x30: /* BMI */ 795 case 0x30: /* BMI */
796 BRANCH(nz >= 0x80); 796 BRANCH(nz >= 0x80);
797 case 0x31: /* AND (ab),y */ 797 case 0x31: /* AND (ab),y */
798 INDIRECT_Y; 798 INDIRECT_Y;
799 NCYCLES_Y; 799 NCYCLES_Y;
800 AND; 800 AND;
801 break; 801 break;
802 case 0x35: /* AND ab,x */ 802 case 0x35: /* AND ab,x */
803 ZPAGE_X; 803 ZPAGE_X;
804 AND_ZP; 804 AND_ZP;
805 break; 805 break;
806 case 0x36: /* ROL ab,x */ 806 case 0x36: /* ROL ab,x */
807 ZPAGE_X; 807 ZPAGE_X;
808 ROL_ZP; 808 ROL_ZP;
809 break; 809 break;
810 case 0x38: /* SEC */ 810 case 0x38: /* SEC */
811 c = 1; 811 c = 1;
812 break; 812 break;
813 case 0x39: /* AND abcd,y */ 813 case 0x39: /* AND abcd,y */
814 ABSOLUTE_Y; 814 ABSOLUTE_Y;
815 NCYCLES_Y; 815 NCYCLES_Y;
816 AND; 816 AND;
817 break; 817 break;
818 case 0x3d: /* AND abcd,x */ 818 case 0x3d: /* AND abcd,x */
819 ABSOLUTE_X; 819 ABSOLUTE_X;
820 NCYCLES_X; 820 NCYCLES_X;
821 AND; 821 AND;
822 break; 822 break;
823 case 0x3e: /* ROL abcd,x */ 823 case 0x3e: /* ROL abcd,x */
824 ABSOLUTE_X; 824 ABSOLUTE_X;
825 ROL; 825 ROL;
826 break; 826 break;
827 case 0x40: /* RTI */ 827 case 0x40: /* RTI */
828 PLP; 828 PLP;
829 PL(pc); 829 PL(pc);
830 PL(addr); 830 PL(addr);
831 pc += addr << 8; 831 pc += addr << 8;
832 CHECK_IRQ; 832 CHECK_IRQ;
833 break; 833 break;
834 case 0x41: /* EOR (ab,x) */ 834 case 0x41: /* EOR (ab,x) */
835 INDIRECT_X; 835 INDIRECT_X;
836 EOR; 836 EOR;
837 break; 837 break;
838 case 0x45: /* EOR ab */ 838 case 0x45: /* EOR ab */
839 ZPAGE; 839 ZPAGE;
840 EOR_ZP; 840 EOR_ZP;
841 break; 841 break;
842 case 0x46: /* LSR ab */ 842 case 0x46: /* LSR ab */
843 ZPAGE; 843 ZPAGE;
844 LSR_ZP; 844 LSR_ZP;
845 break; 845 break;
846 case 0x48: /* PHA */ 846 case 0x48: /* PHA */
847 PH(a); 847 PH(a);
848 break; 848 break;
849 case 0x49: /* EOR #ab */ 849 case 0x49: /* EOR #ab */
850 nz = a ^= FETCH; 850 nz = a ^= FETCH;
851 break; 851 break;
852 case 0x4a: /* LSR */ 852 case 0x4a: /* LSR */
853 c = a & 1; 853 c = a & 1;
854 nz = a >>= 1; 854 nz = a >>= 1;
855 break; 855 break;
856 case 0x4c: /* JMP abcd */ 856 case 0x4c: /* JMP abcd */
857 addr = FETCH; 857 addr = FETCH;
858 pc = addr + (PEEK << 8); 858 pc = addr + (PEEK << 8);
859 break; 859 break;
860 case 0x4d: /* EOR abcd */ 860 case 0x4d: /* EOR abcd */
861 ABSOLUTE; 861 ABSOLUTE;
862 EOR; 862 EOR;
863 break; 863 break;
864 case 0x4e: /* LSR abcd */ 864 case 0x4e: /* LSR abcd */
865 ABSOLUTE; 865 ABSOLUTE;
866 LSR; 866 LSR;
867 break; 867 break;
868 case 0x50: /* BVC */ 868 case 0x50: /* BVC */
869 BRANCH((vdi & V_FLAG) == 0); 869 BRANCH((vdi & V_FLAG) == 0);
870 case 0x51: /* EOR (ab),y */ 870 case 0x51: /* EOR (ab),y */
871 INDIRECT_Y; 871 INDIRECT_Y;
872 NCYCLES_Y; 872 NCYCLES_Y;
873 EOR; 873 EOR;
874 break; 874 break;
875 case 0x55: /* EOR ab,x */ 875 case 0x55: /* EOR ab,x */
876 ZPAGE_X; 876 ZPAGE_X;
877 EOR_ZP; 877 EOR_ZP;
878 break; 878 break;
879 case 0x56: /* LSR ab,x */ 879 case 0x56: /* LSR ab,x */
880 ZPAGE_X; 880 ZPAGE_X;
881 LSR_ZP; 881 LSR_ZP;
882 break; 882 break;
883 case 0x58: /* CLI */ 883 case 0x58: /* CLI */
884 vdi &= V_FLAG | D_FLAG; 884 vdi &= V_FLAG | D_FLAG;
885 CHECK_IRQ; 885 CHECK_IRQ;
886 break; 886 break;
887 case 0x59: /* EOR abcd,y */ 887 case 0x59: /* EOR abcd,y */
888 ABSOLUTE_Y; 888 ABSOLUTE_Y;
889 NCYCLES_Y; 889 NCYCLES_Y;
890 EOR; 890 EOR;
891 break; 891 break;
892 case 0x5d: /* EOR abcd,x */ 892 case 0x5d: /* EOR abcd,x */
893 ABSOLUTE_X; 893 ABSOLUTE_X;
894 NCYCLES_X; 894 NCYCLES_X;
895 EOR; 895 EOR;
896 break; 896 break;
897 case 0x5e: /* LSR abcd,x */ 897 case 0x5e: /* LSR abcd,x */
898 ABSOLUTE_X; 898 ABSOLUTE_X;
899 LSR; 899 LSR;
900 break; 900 break;
901 case 0x60: /* RTS */ 901 case 0x60: /* RTS */
902 PL(pc); 902 PL(pc);
903 PL(addr); 903 PL(addr);
904 pc += (addr << 8) + 1; 904 pc += (addr << 8) + 1;
905 break; 905 break;
906 case 0x61: /* ADC (ab,x) */ 906 case 0x61: /* ADC (ab,x) */
907 INDIRECT_X; 907 INDIRECT_X;
908 ADC; 908 ADC;
909 break; 909 break;
910 case 0x65: /* ADC ab */ 910 case 0x65: /* ADC ab */
911 ZPAGE; 911 ZPAGE;
912 ADC_ZP; 912 ADC_ZP;
913 break; 913 break;
914 case 0x66: /* ROR ab */ 914 case 0x66: /* ROR ab */
915 ZPAGE; 915 ZPAGE;
916 ROR_ZP; 916 ROR_ZP;
917 break; 917 break;
918 case 0x68: /* PLA */ 918 case 0x68: /* PLA */
919 PL(a); 919 PL(a);
920 nz = a; 920 nz = a;
921 break; 921 break;
922 case 0x69: /* ADC #ab */ 922 case 0x69: /* ADC #ab */
923 data = FETCH; 923 data = FETCH;
924 DO_ADC; 924 DO_ADC;
925 break; 925 break;
926 case 0x6a: /* ROR */ 926 case 0x6a: /* ROR */
927 nz = (c << 7) + (a >> 1); 927 nz = (c << 7) + (a >> 1);
928 c = a & 1; 928 c = a & 1;
929 a = nz; 929 a = nz;
930 break; 930 break;
931 case 0x6c: /* JMP (abcd) */ 931 case 0x6c: /* JMP (abcd) */
932 ABSOLUTE; 932 ABSOLUTE;
933 if ((addr & 0xff) == 0xff) 933 if ((addr & 0xff) == 0xff)
934 pc = (dGetByte(addr - 0xff) << 8) + dGetByte(addr); 934 pc = (dGetByte(addr - 0xff) << 8) + dGetByte(addr);
935 else 935 else
936 pc = dGetWord(addr); 936 pc = dGetWord(addr);
937 break; 937 break;
938 case 0x6d: /* ADC abcd */ 938 case 0x6d: /* ADC abcd */
939 ABSOLUTE; 939 ABSOLUTE;
940 ADC; 940 ADC;
941 break; 941 break;
942 case 0x6e: /* ROR abcd */ 942 case 0x6e: /* ROR abcd */
943 ABSOLUTE; 943 ABSOLUTE;
944 ROR; 944 ROR;
945 break; 945 break;
946 case 0x70: /* BVS */ 946 case 0x70: /* BVS */
947 BRANCH((vdi & V_FLAG) != 0); 947 BRANCH((vdi & V_FLAG) != 0);
948 case 0x71: /* ADC (ab),y */ 948 case 0x71: /* ADC (ab),y */
949 INDIRECT_Y; 949 INDIRECT_Y;
950 NCYCLES_Y; 950 NCYCLES_Y;
951 ADC; 951 ADC;
952 break; 952 break;
953 case 0x75: /* ADC ab,x */ 953 case 0x75: /* ADC ab,x */
954 ZPAGE_X; 954 ZPAGE_X;
955 ADC_ZP; 955 ADC_ZP;
956 break; 956 break;
957 case 0x76: /* ROR ab,x */ 957 case 0x76: /* ROR ab,x */
958 ZPAGE_X; 958 ZPAGE_X;
959 ROR_ZP; 959 ROR_ZP;
960 break; 960 break;
961 case 0x78: /* SEI */ 961 case 0x78: /* SEI */
962 vdi |= I_FLAG; 962 vdi |= I_FLAG;
963 break; 963 break;
964 case 0x79: /* ADC abcd,y */ 964 case 0x79: /* ADC abcd,y */
965 ABSOLUTE_Y; 965 ABSOLUTE_Y;
966 NCYCLES_Y; 966 NCYCLES_Y;
967 ADC; 967 ADC;
968 break; 968 break;
969 case 0x7d: /* ADC abcd,x */ 969 case 0x7d: /* ADC abcd,x */
970 ABSOLUTE_X; 970 ABSOLUTE_X;
971 NCYCLES_X; 971 NCYCLES_X;
972 ADC; 972 ADC;
973 break; 973 break;
974 case 0x7e: /* ROR abcd,x */ 974 case 0x7e: /* ROR abcd,x */
975 ABSOLUTE_X; 975 ABSOLUTE_X;
976 ROR; 976 ROR;
977 break; 977 break;
978 case 0x81: /* STA (ab,x) */ 978 case 0x81: /* STA (ab,x) */
979 INDIRECT_X; 979 INDIRECT_X;
980 STA; 980 STA;
981 break; 981 break;
982 case 0x84: /* STY ab */ 982 case 0x84: /* STY ab */
983 ZPAGE; 983 ZPAGE;
984 STY_ZP; 984 STY_ZP;
985 break; 985 break;
986 case 0x85: /* STA ab */ 986 case 0x85: /* STA ab */
987 ZPAGE; 987 ZPAGE;
988 STA_ZP; 988 STA_ZP;
989 break; 989 break;
990 case 0x86: /* STX ab */ 990 case 0x86: /* STX ab */
991 ZPAGE; 991 ZPAGE;
992 STX_ZP; 992 STX_ZP;
993 break; 993 break;
994 case 0x88: /* DEY */ 994 case 0x88: /* DEY */
995 nz = y = (y - 1) & 0xff; 995 nz = y = (y - 1) & 0xff;
996 break; 996 break;
997 case 0x8a: /* TXA */ 997 case 0x8a: /* TXA */
998 nz = a = x; 998 nz = a = x;
999 break; 999 break;
1000 case 0x8c: /* STY abcd */ 1000 case 0x8c: /* STY abcd */
1001 ABSOLUTE; 1001 ABSOLUTE;
1002 STY; 1002 STY;
1003 break; 1003 break;
1004 case 0x8d: /* STA abcd */ 1004 case 0x8d: /* STA abcd */
1005 ABSOLUTE; 1005 ABSOLUTE;
1006 STA; 1006 STA;
1007 break; 1007 break;
1008 case 0x8e: /* STX abcd */ 1008 case 0x8e: /* STX abcd */
1009 ABSOLUTE; 1009 ABSOLUTE;
1010 STX; 1010 STX;
1011 break; 1011 break;
1012 case 0x90: /* BCC */ 1012 case 0x90: /* BCC */
1013 BRANCH(c == 0); 1013 BRANCH(c == 0);
1014 case 0x91: /* STA (ab),y */ 1014 case 0x91: /* STA (ab),y */
1015 INDIRECT_Y; 1015 INDIRECT_Y;
1016 STA; 1016 STA;
1017 break; 1017 break;
1018 case 0x94: /* STY ab,x */ 1018 case 0x94: /* STY ab,x */
1019 ZPAGE_X; 1019 ZPAGE_X;
1020 STY_ZP; 1020 STY_ZP;
1021 break; 1021 break;
1022 case 0x95: /* STA ab,x */ 1022 case 0x95: /* STA ab,x */
1023 ZPAGE_X; 1023 ZPAGE_X;
1024 STA_ZP; 1024 STA_ZP;
1025 break; 1025 break;
1026 case 0x96: /* STX ab,y */ 1026 case 0x96: /* STX ab,y */
1027 ZPAGE_Y; 1027 ZPAGE_Y;
1028 STX_ZP; 1028 STX_ZP;
1029 break; 1029 break;
1030 case 0x98: /* TYA */ 1030 case 0x98: /* TYA */
1031 nz = a = y; 1031 nz = a = y;
1032 break; 1032 break;
1033 case 0x99: /* STA abcd,y */ 1033 case 0x99: /* STA abcd,y */
1034 ABSOLUTE_Y; 1034 ABSOLUTE_Y;
1035 STA; 1035 STA;
1036 break; 1036 break;
1037 case 0x9a: /* TXS */ 1037 case 0x9a: /* TXS */
1038 s = x; 1038 s = x;
1039 break; 1039 break;
1040 case 0x9d: /* STA abcd,x */ 1040 case 0x9d: /* STA abcd,x */
1041 ABSOLUTE_X; 1041 ABSOLUTE_X;
1042 STA; 1042 STA;
1043 break; 1043 break;
1044 case 0xa0: /* LDY #ab */ 1044 case 0xa0: /* LDY #ab */
1045 nz = y = FETCH; 1045 nz = y = FETCH;
1046 break; 1046 break;
1047 case 0xa1: /* LDA (ab,x) */ 1047 case 0xa1: /* LDA (ab,x) */
1048 INDIRECT_X; 1048 INDIRECT_X;
1049 LDA; 1049 LDA;
1050 break; 1050 break;
1051 case 0xa2: /* LDX #ab */ 1051 case 0xa2: /* LDX #ab */
1052 nz = x = FETCH; 1052 nz = x = FETCH;
1053 break; 1053 break;
1054 case 0xa4: /* LDY ab */ 1054 case 0xa4: /* LDY ab */
1055 ZPAGE; 1055 ZPAGE;
1056 LDY_ZP; 1056 LDY_ZP;
1057 break; 1057 break;
1058 case 0xa5: /* LDA ab */ 1058 case 0xa5: /* LDA ab */
1059 ZPAGE; 1059 ZPAGE;
1060 LDA_ZP; 1060 LDA_ZP;
1061 break; 1061 break;
1062 case 0xa6: /* LDX ab */ 1062 case 0xa6: /* LDX ab */
1063 ZPAGE; 1063 ZPAGE;
1064 LDX_ZP; 1064 LDX_ZP;
1065 break; 1065 break;
1066 case 0xa8: /* TAY */ 1066 case 0xa8: /* TAY */
1067 nz = y = a; 1067 nz = y = a;
1068 break; 1068 break;
1069 case 0xa9: /* LDA #ab */ 1069 case 0xa9: /* LDA #ab */
1070 nz = a = FETCH; 1070 nz = a = FETCH;
1071 break; 1071 break;
1072 case 0xaa: /* TAX */ 1072 case 0xaa: /* TAX */
1073 nz = x = a; 1073 nz = x = a;
1074 break; 1074 break;
1075 case 0xac: /* LDY abcd */ 1075 case 0xac: /* LDY abcd */
1076 ABSOLUTE; 1076 ABSOLUTE;
1077 LDY; 1077 LDY;
1078 break; 1078 break;
1079 case 0xad: /* LDA abcd */ 1079 case 0xad: /* LDA abcd */
1080 ABSOLUTE; 1080 ABSOLUTE;
1081 LDA; 1081 LDA;
1082 break; 1082 break;
1083 case 0xae: /* LDX abcd */ 1083 case 0xae: /* LDX abcd */
1084 ABSOLUTE; 1084 ABSOLUTE;
1085 LDX; 1085 LDX;
1086 break; 1086 break;
1087 case 0xb0: /* BCS */ 1087 case 0xb0: /* BCS */
1088 BRANCH(c != 0); 1088 BRANCH(c != 0);
1089 case 0xb1: /* LDA (ab),y */ 1089 case 0xb1: /* LDA (ab),y */
1090 INDIRECT_Y; 1090 INDIRECT_Y;
1091 NCYCLES_Y; 1091 NCYCLES_Y;
1092 LDA; 1092 LDA;
1093 break; 1093 break;
1094 case 0xb4: /* LDY ab,x */ 1094 case 0xb4: /* LDY ab,x */
1095 ZPAGE_X; 1095 ZPAGE_X;
1096 LDY_ZP; 1096 LDY_ZP;
1097 break; 1097 break;
1098 case 0xb5: /* LDA ab,x */ 1098 case 0xb5: /* LDA ab,x */
1099 ZPAGE_X; 1099 ZPAGE_X;
1100 LDA_ZP; 1100 LDA_ZP;
1101 break; 1101 break;
1102 case 0xb6: /* LDX ab,y */ 1102 case 0xb6: /* LDX ab,y */
1103 ZPAGE_Y; 1103 ZPAGE_Y;
1104 LDX_ZP; 1104 LDX_ZP;
1105 break; 1105 break;
1106 case 0xb8: /* CLV */ 1106 case 0xb8: /* CLV */
1107 vdi &= D_FLAG | I_FLAG; 1107 vdi &= D_FLAG | I_FLAG;
1108 break; 1108 break;
1109 case 0xb9: /* LDA abcd,y */ 1109 case 0xb9: /* LDA abcd,y */
1110 ABSOLUTE_Y; 1110 ABSOLUTE_Y;
1111 NCYCLES_Y; 1111 NCYCLES_Y;
1112 LDA; 1112 LDA;
1113 break; 1113 break;
1114 case 0xba: /* TSX */ 1114 case 0xba: /* TSX */
1115 nz = x = s; 1115 nz = x = s;
1116 break; 1116 break;
1117 case 0xbc: /* LDY abcd,x */ 1117 case 0xbc: /* LDY abcd,x */
1118 ABSOLUTE_X; 1118 ABSOLUTE_X;
1119 NCYCLES_X; 1119 NCYCLES_X;
1120 LDY; 1120 LDY;
1121 break; 1121 break;
1122 case 0xbd: /* LDA abcd,x */ 1122 case 0xbd: /* LDA abcd,x */
1123 ABSOLUTE_X; 1123 ABSOLUTE_X;
1124 NCYCLES_X; 1124 NCYCLES_X;
1125 LDA; 1125 LDA;
1126 break; 1126 break;
1127 case 0xbe: /* LDX abcd,y */ 1127 case 0xbe: /* LDX abcd,y */
1128 ABSOLUTE_Y; 1128 ABSOLUTE_Y;
1129 NCYCLES_Y; 1129 NCYCLES_Y;
1130 LDX; 1130 LDX;
1131 break; 1131 break;
1132 case 0xc0: /* CPY #ab */ 1132 case 0xc0: /* CPY #ab */
1133 nz = FETCH; 1133 nz = FETCH;
1134 c = (y >= nz) ? 1 : 0; 1134 c = (y >= nz) ? 1 : 0;
1135 nz = (y - nz) & 0xff; 1135 nz = (y - nz) & 0xff;
1136 break; 1136 break;
1137 case 0xc1: /* CMP (ab,x) */ 1137 case 0xc1: /* CMP (ab,x) */
1138 INDIRECT_X; 1138 INDIRECT_X;
1139 CMP; 1139 CMP;
1140 break; 1140 break;
1141 case 0xc4: /* CPY ab */ 1141 case 0xc4: /* CPY ab */
1142 ZPAGE; 1142 ZPAGE;
1143 CPY_ZP; 1143 CPY_ZP;
1144 break; 1144 break;
1145 case 0xc5: /* CMP ab */ 1145 case 0xc5: /* CMP ab */
1146 ZPAGE; 1146 ZPAGE;
1147 CMP_ZP; 1147 CMP_ZP;
1148 break; 1148 break;
1149 case 0xc6: /* DEC ab */ 1149 case 0xc6: /* DEC ab */
1150 ZPAGE; 1150 ZPAGE;
1151 DEC_ZP; 1151 DEC_ZP;
1152 break; 1152 break;
1153 case 0xc8: /* INY */ 1153 case 0xc8: /* INY */
1154 nz = y = (y + 1) & 0xff; 1154 nz = y = (y + 1) & 0xff;
1155 break; 1155 break;
1156 case 0xc9: /* CMP #ab */ 1156 case 0xc9: /* CMP #ab */
1157 nz = FETCH; 1157 nz = FETCH;
1158 c = (a >= nz) ? 1 : 0; 1158 c = (a >= nz) ? 1 : 0;
1159 nz = (a - nz) & 0xff; 1159 nz = (a - nz) & 0xff;
1160 break; 1160 break;
1161 case 0xca: /* DEX */ 1161 case 0xca: /* DEX */
1162 nz = x = (x - 1) & 0xff; 1162 nz = x = (x - 1) & 0xff;
1163 break; 1163 break;
1164 case 0xcc: /* CPY abcd */ 1164 case 0xcc: /* CPY abcd */
1165 ABSOLUTE; 1165 ABSOLUTE;
1166 CPY; 1166 CPY;
1167 break; 1167 break;
1168 case 0xcd: /* CMP abcd */ 1168 case 0xcd: /* CMP abcd */
1169 ABSOLUTE; 1169 ABSOLUTE;
1170 CMP; 1170 CMP;
1171 break; 1171 break;
1172 case 0xce: /* DEC abcd */ 1172 case 0xce: /* DEC abcd */
1173 ABSOLUTE; 1173 ABSOLUTE;
1174 DEC; 1174 DEC;
1175 break; 1175 break;
1176 case 0xd0: /* BNE */ 1176 case 0xd0: /* BNE */
1177 BRANCH((nz & 0xff) != 0); 1177 BRANCH((nz & 0xff) != 0);
1178 case 0xd1: /* CMP (ab),y */ 1178 case 0xd1: /* CMP (ab),y */
1179 INDIRECT_Y; 1179 INDIRECT_Y;
1180 NCYCLES_Y; 1180 NCYCLES_Y;
1181 CMP; 1181 CMP;
1182 break; 1182 break;
1183 case 0xd5: /* CMP ab,x */ 1183 case 0xd5: /* CMP ab,x */
1184 ZPAGE_X; 1184 ZPAGE_X;
1185 CMP_ZP; 1185 CMP_ZP;
1186 break; 1186 break;
1187 case 0xd6: /* DEC ab,x */ 1187 case 0xd6: /* DEC ab,x */
1188 ZPAGE_X; 1188 ZPAGE_X;
1189 DEC_ZP; 1189 DEC_ZP;
1190 break; 1190 break;
1191 case 0xd8: /* CLD */ 1191 case 0xd8: /* CLD */
1192 vdi &= V_FLAG | I_FLAG; 1192 vdi &= V_FLAG | I_FLAG;
1193 break; 1193 break;
1194 case 0xd9: /* CMP abcd,y */ 1194 case 0xd9: /* CMP abcd,y */
1195 ABSOLUTE_Y; 1195 ABSOLUTE_Y;
1196 NCYCLES_Y; 1196 NCYCLES_Y;
1197 CMP; 1197 CMP;
1198 break; 1198 break;
1199 case 0xdd: /* CMP abcd,x */ 1199 case 0xdd: /* CMP abcd,x */
1200 ABSOLUTE_X; 1200 ABSOLUTE_X;
1201 NCYCLES_X; 1201 NCYCLES_X;
1202 CMP; 1202 CMP;
1203 break; 1203 break;
1204 case 0xde: /* DEC abcd,x */ 1204 case 0xde: /* DEC abcd,x */
1205 ABSOLUTE_X; 1205 ABSOLUTE_X;
1206 DEC; 1206 DEC;
1207 break; 1207 break;
1208 case 0xe0: /* CPX #ab */ 1208 case 0xe0: /* CPX #ab */
1209 nz = FETCH; 1209 nz = FETCH;
1210 c = (x >= nz) ? 1 : 0; 1210 c = (x >= nz) ? 1 : 0;
1211 nz = (x - nz) & 0xff; 1211 nz = (x - nz) & 0xff;
1212 break; 1212 break;
1213 case 0xe1: /* SBC (ab,x) */ 1213 case 0xe1: /* SBC (ab,x) */
1214 INDIRECT_X; 1214 INDIRECT_X;
1215 SBC; 1215 SBC;
1216 break; 1216 break;
1217 case 0xe4: /* CPX ab */ 1217 case 0xe4: /* CPX ab */
1218 ZPAGE; 1218 ZPAGE;
1219 CPX_ZP; 1219 CPX_ZP;
1220 break; 1220 break;
1221 case 0xe5: /* SBC ab */ 1221 case 0xe5: /* SBC ab */
1222 ZPAGE; 1222 ZPAGE;
1223 SBC_ZP; 1223 SBC_ZP;
1224 break; 1224 break;
1225 case 0xe6: /* INC ab */ 1225 case 0xe6: /* INC ab */
1226 ZPAGE; 1226 ZPAGE;
1227 INC_ZP; 1227 INC_ZP;
1228 break; 1228 break;
1229 case 0xe8: /* INX */ 1229 case 0xe8: /* INX */
1230 nz = x = (x + 1) & 0xff; 1230 nz = x = (x + 1) & 0xff;
1231 break; 1231 break;
1232 case 0xe9: /* SBC #ab */ 1232 case 0xe9: /* SBC #ab */
1233 case 0xeb: /* SBC #ab [unofficial] */ 1233 case 0xeb: /* SBC #ab [unofficial] */
1234 data = FETCH; 1234 data = FETCH;
1235 DO_SBC; 1235 DO_SBC;
1236 break; 1236 break;
1237 case 0xea: /* NOP */ 1237 case 0xea: /* NOP */
1238 case 0x1a: /* NOP [unofficial] */ 1238 case 0x1a: /* NOP [unofficial] */
1239 case 0x3a: 1239 case 0x3a:
1240 case 0x5a: 1240 case 0x5a:
1241 case 0x7a: 1241 case 0x7a:
1242 case 0xda: 1242 case 0xda:
1243 case 0xfa: 1243 case 0xfa:
1244 break; 1244 break;
1245 case 0xec: /* CPX abcd */ 1245 case 0xec: /* CPX abcd */
1246 ABSOLUTE; 1246 ABSOLUTE;
1247 CPX; 1247 CPX;
1248 break; 1248 break;
1249 case 0xed: /* SBC abcd */ 1249 case 0xed: /* SBC abcd */
1250 ABSOLUTE; 1250 ABSOLUTE;
1251 SBC; 1251 SBC;
1252 break; 1252 break;
1253 case 0xee: /* INC abcd */ 1253 case 0xee: /* INC abcd */
1254 ABSOLUTE; 1254 ABSOLUTE;
1255 INC; 1255 INC;
1256 break; 1256 break;
1257 case 0xf0: /* BEQ */ 1257 case 0xf0: /* BEQ */
1258 BRANCH((nz & 0xff) == 0); 1258 BRANCH((nz & 0xff) == 0);
1259 case 0xf1: /* SBC (ab),y */ 1259 case 0xf1: /* SBC (ab),y */
1260 INDIRECT_Y; 1260 INDIRECT_Y;
1261 NCYCLES_Y; 1261 NCYCLES_Y;
1262 SBC; 1262 SBC;
1263 break; 1263 break;
1264 case 0xf5: /* SBC ab,x */ 1264 case 0xf5: /* SBC ab,x */
1265 ZPAGE_X; 1265 ZPAGE_X;
1266 SBC_ZP; 1266 SBC_ZP;
1267 break; 1267 break;
1268 case 0xf6: /* INC ab,x */ 1268 case 0xf6: /* INC ab,x */
1269 ZPAGE_X; 1269 ZPAGE_X;
1270 INC_ZP; 1270 INC_ZP;
1271 break; 1271 break;
1272 case 0xf8: /* SED */ 1272 case 0xf8: /* SED */
1273 vdi |= D_FLAG; 1273 vdi |= D_FLAG;
1274 break; 1274 break;
1275 case 0xf9: /* SBC abcd,y */ 1275 case 0xf9: /* SBC abcd,y */
1276 ABSOLUTE_Y; 1276 ABSOLUTE_Y;
1277 NCYCLES_Y; 1277 NCYCLES_Y;
1278 SBC; 1278 SBC;
1279 break; 1279 break;
1280 case 0xfd: /* SBC abcd,x */ 1280 case 0xfd: /* SBC abcd,x */
1281 ABSOLUTE_X; 1281 ABSOLUTE_X;
1282 NCYCLES_X; 1282 NCYCLES_X;
1283 SBC; 1283 SBC;
1284 break; 1284 break;
1285 case 0xfe: /* INC abcd,x */ 1285 case 0xfe: /* INC abcd,x */
1286 ABSOLUTE_X; 1286 ABSOLUTE_X;
1287 INC; 1287 INC;
1288 break; 1288 break;
1289 } 1289 }
1290 } 1290 }
1291 ast _ cpu_pc = pc; 1291 ast _ cpu_pc = pc;
1292 ast _ cpu_nz = nz; 1292 ast _ cpu_nz = nz;
1293 ast _ cpu_a = a; 1293 ast _ cpu_a = a;
1294 ast _ cpu_x = x; 1294 ast _ cpu_x = x;
1295 ast _ cpu_y = y; 1295 ast _ cpu_y = y;
1296 ast _ cpu_c = c; 1296 ast _ cpu_c = c;
1297 ast _ cpu_s = s; 1297 ast _ cpu_s = s;
1298 ast _ cpu_vdi = vdi; 1298 ast _ cpu_vdi = vdi;
1299 ast _ cycle -= cycle_limit; 1299 ast _ cycle -= cycle_limit;
1300 if (ast _ timer1_cycle != NEVER) 1300 if (ast _ timer1_cycle != NEVER)
1301 ast _ timer1_cycle -= cycle_limit; 1301 ast _ timer1_cycle -= cycle_limit;
1302 if (ast _ timer2_cycle != NEVER) 1302 if (ast _ timer2_cycle != NEVER)
1303 ast _ timer2_cycle -= cycle_limit; 1303 ast _ timer2_cycle -= cycle_limit;
1304 if (ast _ timer4_cycle != NEVER) 1304 if (ast _ timer4_cycle != NEVER)
1305 ast _ timer4_cycle -= cycle_limit; 1305 ast _ timer4_cycle -= cycle_limit;
1306} 1306}
diff --git a/apps/codecs/libasap/apokeysnd.c b/apps/codecs/libasap/apokeysnd.c
index a461fa96da..ead611be5f 100644
--- a/apps/codecs/libasap/apokeysnd.c
+++ b/apps/codecs/libasap/apokeysnd.c
@@ -30,178 +30,178 @@
30#define MUTE_USER 4 30#define MUTE_USER 4
31 31
32CONST_ARRAY(byte, poly4_lookup) 32CONST_ARRAY(byte, poly4_lookup)
33 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1 33 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1
34END_CONST_ARRAY; 34END_CONST_ARRAY;
35CONST_ARRAY(byte, poly5_lookup) 35CONST_ARRAY(byte, poly5_lookup)
36 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 36 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1,
37 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1 37 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1
38END_CONST_ARRAY; 38END_CONST_ARRAY;
39 39
40PRIVATE FUNC(void, PokeySound_InitializeChip, (P(PokeyState PTR, pst))) 40PRIVATE FUNC(void, PokeySound_InitializeChip, (P(PokeyState PTR, pst)))
41{ 41{
42 pst _ audctl = 0; 42 pst _ audctl = 0;
43 pst _ init = FALSE; 43 pst _ init = FALSE;
44 pst _ poly_index = 15 * 31 * 131071; 44 pst _ poly_index = 15 * 31 * 131071;
45 pst _ div_cycles = 28; 45 pst _ div_cycles = 28;
46 pst _ mute1 = MUTE_FREQUENCY | MUTE_USER; 46 pst _ mute1 = MUTE_FREQUENCY | MUTE_USER;
47 pst _ mute2 = MUTE_FREQUENCY | MUTE_USER; 47 pst _ mute2 = MUTE_FREQUENCY | MUTE_USER;
48 pst _ mute3 = MUTE_FREQUENCY | MUTE_USER; 48 pst _ mute3 = MUTE_FREQUENCY | MUTE_USER;
49 pst _ mute4 = MUTE_FREQUENCY | MUTE_USER; 49 pst _ mute4 = MUTE_FREQUENCY | MUTE_USER;
50 pst _ audf1 = 0; 50 pst _ audf1 = 0;
51 pst _ audf2 = 0; 51 pst _ audf2 = 0;
52 pst _ audf3 = 0; 52 pst _ audf3 = 0;
53 pst _ audf4 = 0; 53 pst _ audf4 = 0;
54 pst _ audc1 = 0; 54 pst _ audc1 = 0;
55 pst _ audc2 = 0; 55 pst _ audc2 = 0;
56 pst _ audc3 = 0; 56 pst _ audc3 = 0;
57 pst _ audc4 = 0; 57 pst _ audc4 = 0;
58 pst _ tick_cycle1 = NEVER; 58 pst _ tick_cycle1 = NEVER;
59 pst _ tick_cycle2 = NEVER; 59 pst _ tick_cycle2 = NEVER;
60 pst _ tick_cycle3 = NEVER; 60 pst _ tick_cycle3 = NEVER;
61 pst _ tick_cycle4 = NEVER; 61 pst _ tick_cycle4 = NEVER;
62 pst _ period_cycles1 = 28; 62 pst _ period_cycles1 = 28;
63 pst _ period_cycles2 = 28; 63 pst _ period_cycles2 = 28;
64 pst _ period_cycles3 = 28; 64 pst _ period_cycles3 = 28;
65 pst _ period_cycles4 = 28; 65 pst _ period_cycles4 = 28;
66 pst _ reload_cycles1 = 28; 66 pst _ reload_cycles1 = 28;
67 pst _ reload_cycles3 = 28; 67 pst _ reload_cycles3 = 28;
68 pst _ out1 = 0; 68 pst _ out1 = 0;
69 pst _ out2 = 0; 69 pst _ out2 = 0;
70 pst _ out3 = 0; 70 pst _ out3 = 0;
71 pst _ out4 = 0; 71 pst _ out4 = 0;
72 pst _ delta1 = 0; 72 pst _ delta1 = 0;
73 pst _ delta2 = 0; 73 pst _ delta2 = 0;
74 pst _ delta3 = 0; 74 pst _ delta3 = 0;
75 pst _ delta4 = 0; 75 pst _ delta4 = 0;
76 pst _ skctl = 3; 76 pst _ skctl = 3;
77 ZERO_ARRAY(pst _ delta_buffer); 77 ZERO_ARRAY(pst _ delta_buffer);
78} 78}
79 79
80FUNC(void, PokeySound_Initialize, (P(ASAP_State PTR, ast))) 80FUNC(void, PokeySound_Initialize, (P(ASAP_State PTR, ast)))
81{ 81{
82 V(int, i); 82 V(int, i);
83 V(int, reg); 83 V(int, reg);
84 reg = 0x1ff; 84 reg = 0x1ff;
85 for (i = 0; i < 511; i++) { 85 for (i = 0; i < 511; i++) {
86 reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1); 86 reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1);
87 ast _ poly9_lookup[i] = TO_BYTE(reg); 87 ast _ poly9_lookup[i] = TO_BYTE(reg);
88 } 88 }
89 reg = 0x1ffff; 89 reg = 0x1ffff;
90 for (i = 0; i < 16385; i++) { 90 for (i = 0; i < 16385; i++) {
91 reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8); 91 reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8);
92 ast _ poly17_lookup[i] = TO_BYTE(reg >> 1); 92 ast _ poly17_lookup[i] = TO_BYTE(reg >> 1);
93 } 93 }
94 ast _ sample_offset = 0; 94 ast _ sample_offset = 0;
95 ast _ sample_index = 0; 95 ast _ sample_index = 0;
96 ast _ samples = 0; 96 ast _ samples = 0;
97 ast _ iir_acc_left = 0; 97 ast _ iir_acc_left = 0;
98 ast _ iir_acc_right = 0; 98 ast _ iir_acc_right = 0;
99 PokeySound_InitializeChip(ADDRESSOF ast _ base_pokey); 99 PokeySound_InitializeChip(ADDRESSOF ast _ base_pokey);
100 PokeySound_InitializeChip(ADDRESSOF ast _ extra_pokey); 100 PokeySound_InitializeChip(ADDRESSOF ast _ extra_pokey);
101} 101}
102 102
103#define DO_TICK(ch) \ 103#define DO_TICK(ch) \
104 if (pst _ init) { \ 104 if (pst _ init) { \
105 switch (pst _ audc##ch >> 4) { \ 105 switch (pst _ audc##ch >> 4) { \
106 case 10: \ 106 case 10: \
107 case 14: \ 107 case 14: \
108 pst _ out##ch ^= 1; \ 108 pst _ out##ch ^= 1; \
109 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ 109 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \
110 break; \ 110 break; \
111 default: \ 111 default: \
112 break; \ 112 break; \
113 } \ 113 } \
114 } \ 114 } \
115 else { \ 115 else { \
116 V(int, poly) = cycle + pst _ poly_index - (ch - 1); \ 116 V(int, poly) = cycle + pst _ poly_index - (ch - 1); \
117 V(int, newout) = pst _ out##ch; \ 117 V(int, newout) = pst _ out##ch; \
118 switch (pst _ audc##ch >> 4) { \ 118 switch (pst _ audc##ch >> 4) { \
119 case 0: \ 119 case 0: \
120 if (poly5_lookup[poly % 31] != 0) { \ 120 if (poly5_lookup[poly % 31] != 0) { \
121 if ((pst _ audctl & 0x80) != 0) \ 121 if ((pst _ audctl & 0x80) != 0) \
122 newout = ast _ poly9_lookup[poly % 511] & 1; \ 122 newout = ast _ poly9_lookup[poly % 511] & 1; \
123 else { \ 123 else { \
124 poly %= 131071; \ 124 poly %= 131071; \
125 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ 125 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \
126 } \ 126 } \
127 } \ 127 } \
128 break; \ 128 break; \
129 case 2: \ 129 case 2: \
130 case 6: \ 130 case 6: \
131 newout ^= poly5_lookup[poly % 31]; \ 131 newout ^= poly5_lookup[poly % 31]; \
132 break; \ 132 break; \
133 case 4: \ 133 case 4: \
134 if (poly5_lookup[poly % 31] != 0) \ 134 if (poly5_lookup[poly % 31] != 0) \
135 newout = poly4_lookup[poly % 15]; \ 135 newout = poly4_lookup[poly % 15]; \
136 break; \ 136 break; \
137 case 8: \ 137 case 8: \
138 if ((pst _ audctl & 0x80) != 0) \ 138 if ((pst _ audctl & 0x80) != 0) \
139 newout = ast _ poly9_lookup[poly % 511] & 1; \ 139 newout = ast _ poly9_lookup[poly % 511] & 1; \
140 else { \ 140 else { \
141 poly %= 131071; \ 141 poly %= 131071; \
142 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ 142 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \
143 } \ 143 } \
144 break; \ 144 break; \
145 case 10: \ 145 case 10: \
146 case 14: \ 146 case 14: \
147 newout ^= 1; \ 147 newout ^= 1; \
148 break; \ 148 break; \
149 case 12: \ 149 case 12: \
150 newout = poly4_lookup[poly % 15]; \ 150 newout = poly4_lookup[poly % 15]; \
151 break; \ 151 break; \
152 default: \ 152 default: \
153 break; \ 153 break; \
154 } \ 154 } \
155 if (newout != pst _ out##ch) { \ 155 if (newout != pst _ out##ch) { \
156 pst _ out##ch = newout; \ 156 pst _ out##ch = newout; \
157 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ 157 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \
158 } \ 158 } \
159 } 159 }
160 160
161/* Fills delta_buffer up to current_cycle basing on current AUDF/AUDC/AUDCTL values. */ 161/* Fills delta_buffer up to current_cycle basing on current AUDF/AUDC/AUDCTL values. */
162PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, current_cycle))) 162PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, current_cycle)))
163{ 163{
164 for (;;) { 164 for (;;) {
165 V(int, cycle) = current_cycle; 165 V(int, cycle) = current_cycle;
166 if (cycle > pst _ tick_cycle1) 166 if (cycle > pst _ tick_cycle1)
167 cycle = pst _ tick_cycle1; 167 cycle = pst _ tick_cycle1;
168 if (cycle > pst _ tick_cycle2) 168 if (cycle > pst _ tick_cycle2)
169 cycle = pst _ tick_cycle2; 169 cycle = pst _ tick_cycle2;
170 if (cycle > pst _ tick_cycle3) 170 if (cycle > pst _ tick_cycle3)
171 cycle = pst _ tick_cycle3; 171 cycle = pst _ tick_cycle3;
172 if (cycle > pst _ tick_cycle4) 172 if (cycle > pst _ tick_cycle4)
173 cycle = pst _ tick_cycle4; 173 cycle = pst _ tick_cycle4;
174 if (cycle == current_cycle) 174 if (cycle == current_cycle)
175 break; 175 break;
176 if (cycle == pst _ tick_cycle3) { 176 if (cycle == pst _ tick_cycle3) {
177 pst _ tick_cycle3 += pst _ period_cycles3; 177 pst _ tick_cycle3 += pst _ period_cycles3;
178 if ((pst _ audctl & 4) != 0 && pst _ delta1 > 0 && pst _ mute1 == 0) 178 if ((pst _ audctl & 4) != 0 && pst _ delta1 > 0 && pst _ mute1 == 0)
179 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta1 = -pst _ delta1; 179 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta1 = -pst _ delta1;
180 DO_TICK(3); 180 DO_TICK(3);
181 } 181 }
182 if (cycle == pst _ tick_cycle4) { 182 if (cycle == pst _ tick_cycle4) {
183 pst _ tick_cycle4 += pst _ period_cycles4; 183 pst _ tick_cycle4 += pst _ period_cycles4;
184 if ((pst _ audctl & 8) != 0) 184 if ((pst _ audctl & 8) != 0)
185 pst _ tick_cycle3 = cycle + pst _ reload_cycles3; 185 pst _ tick_cycle3 = cycle + pst _ reload_cycles3;
186 if ((pst _ audctl & 2) != 0 && pst _ delta2 > 0 && pst _ mute2 == 0) 186 if ((pst _ audctl & 2) != 0 && pst _ delta2 > 0 && pst _ mute2 == 0)
187 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta2 = -pst _ delta2; 187 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta2 = -pst _ delta2;
188 DO_TICK(4); 188 DO_TICK(4);
189 } 189 }
190 if (cycle == pst _ tick_cycle1) { 190 if (cycle == pst _ tick_cycle1) {
191 pst _ tick_cycle1 += pst _ period_cycles1; 191 pst _ tick_cycle1 += pst _ period_cycles1;
192 if ((pst _ skctl & 0x88) == 8) /* two-tone, sending 1 (i.e. timer1) */ 192 if ((pst _ skctl & 0x88) == 8) /* two-tone, sending 1 (i.e. timer1) */
193 pst _ tick_cycle2 = cycle + pst _ period_cycles2; 193 pst _ tick_cycle2 = cycle + pst _ period_cycles2;
194 DO_TICK(1); 194 DO_TICK(1);
195 } 195 }
196 if (cycle == pst _ tick_cycle2) { 196 if (cycle == pst _ tick_cycle2) {
197 pst _ tick_cycle2 += pst _ period_cycles2; 197 pst _ tick_cycle2 += pst _ period_cycles2;
198 if ((pst _ audctl & 0x10) != 0) 198 if ((pst _ audctl & 0x10) != 0)
199 pst _ tick_cycle1 = cycle + pst _ reload_cycles1; 199 pst _ tick_cycle1 = cycle + pst _ reload_cycles1;
200 else if ((pst _ skctl & 8) != 0) /* two-tone */ 200 else if ((pst _ skctl & 8) != 0) /* two-tone */
201 pst _ tick_cycle1 = cycle + pst _ period_cycles1; 201 pst _ tick_cycle1 = cycle + pst _ period_cycles1;
202 DO_TICK(2); 202 DO_TICK(2);
203 } 203 }
204 } 204 }
205} 205}
206 206
207#ifdef APOKEYSND 207#ifdef APOKEYSND
@@ -209,351 +209,351 @@ PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(Pok
209#define CURRENT_CYCLE 0 209#define CURRENT_CYCLE 0
210#define CURRENT_SAMPLE 0 210#define CURRENT_SAMPLE 0
211#define DO_STORE(reg) \ 211#define DO_STORE(reg) \
212 if (data == pst _ reg) \ 212 if (data == pst _ reg) \
213 break; \ 213 break; \
214 pst _ reg = data; 214 pst _ reg = data;
215 215
216#else 216#else
217 217
218#define CURRENT_CYCLE ast _ cycle 218#define CURRENT_CYCLE ast _ cycle
219#define CURRENT_SAMPLE CYCLE_TO_SAMPLE(ast _ cycle) 219#define CURRENT_SAMPLE CYCLE_TO_SAMPLE(ast _ cycle)
220#define DO_STORE(reg) \ 220#define DO_STORE(reg) \
221 if (data == pst _ reg) \ 221 if (data == pst _ reg) \
222 break; \ 222 break; \
223 PokeySound_GenerateUntilCycle(ast, pst, ast _ cycle); \ 223 PokeySound_GenerateUntilCycle(ast, pst, ast _ cycle); \
224 pst _ reg = data; 224 pst _ reg = data;
225 225
226#endif /* APOKEYSND */ 226#endif /* APOKEYSND */
227 227
228#define MUTE_CHANNEL(ch, cond, mask) \ 228#define MUTE_CHANNEL(ch, cond, mask) \
229 if (cond) { \ 229 if (cond) { \
230 pst _ mute##ch |= mask; \ 230 pst _ mute##ch |= mask; \
231 pst _ tick_cycle##ch = NEVER; \ 231 pst _ tick_cycle##ch = NEVER; \
232 } \ 232 } \
233 else { \ 233 else { \
234 pst _ mute##ch &= ~mask; \ 234 pst _ mute##ch &= ~mask; \
235 if (pst _ tick_cycle##ch == NEVER && pst _ mute##ch == 0) \ 235 if (pst _ tick_cycle##ch == NEVER && pst _ mute##ch == 0) \
236 pst _ tick_cycle##ch = CURRENT_CYCLE; \ 236 pst _ tick_cycle##ch = CURRENT_CYCLE; \
237 } 237 }
238 238
239#define DO_ULTRASOUND(ch) \ 239#define DO_ULTRASOUND(ch) \
240 MUTE_CHANNEL(ch, pst _ period_cycles##ch <= ULTRASOUND_CYCLES && (pst _ audc##ch >> 4 == 10 || pst _ audc##ch >> 4 == 14), MUTE_FREQUENCY) 240 MUTE_CHANNEL(ch, pst _ period_cycles##ch <= ULTRASOUND_CYCLES && (pst _ audc##ch >> 4 == 10 || pst _ audc##ch >> 4 == 14), MUTE_FREQUENCY)
241 241
242#define DO_AUDC(ch) \ 242#define DO_AUDC(ch) \
243 DO_STORE(audc##ch); \ 243 DO_STORE(audc##ch); \
244 if ((data & 0x10) != 0) { \ 244 if ((data & 0x10) != 0) { \
245 data = (data & 0xf) << DELTA_SHIFT_POKEY; \ 245 data = (data & 0xf) << DELTA_SHIFT_POKEY; \
246 if ((pst _ mute##ch & MUTE_USER) == 0) \ 246 if ((pst _ mute##ch & MUTE_USER) == 0) \
247 pst _ delta_buffer[CURRENT_SAMPLE] \ 247 pst _ delta_buffer[CURRENT_SAMPLE] \
248 += pst _ delta##ch > 0 ? data - pst _ delta##ch : data; \ 248 += pst _ delta##ch > 0 ? data - pst _ delta##ch : data; \
249 pst _ delta##ch = data; \ 249 pst _ delta##ch = data; \
250 } \ 250 } \
251 else { \ 251 else { \
252 data = (data & 0xf) << DELTA_SHIFT_POKEY; \ 252 data = (data & 0xf) << DELTA_SHIFT_POKEY; \
253 DO_ULTRASOUND(ch); \ 253 DO_ULTRASOUND(ch); \
254 if (pst _ delta##ch > 0) { \ 254 if (pst _ delta##ch > 0) { \
255 if ((pst _ mute##ch & MUTE_USER) == 0) \ 255 if ((pst _ mute##ch & MUTE_USER) == 0) \
256 pst _ delta_buffer[CURRENT_SAMPLE] \ 256 pst _ delta_buffer[CURRENT_SAMPLE] \
257 += data - pst _ delta##ch; \ 257 += data - pst _ delta##ch; \
258 pst _ delta##ch = data; \ 258 pst _ delta##ch = data; \
259 } \ 259 } \
260 else \ 260 else \
261 pst _ delta##ch = -data; \ 261 pst _ delta##ch = -data; \
262 } \ 262 } \
263 break; 263 break;
264 264
265#define DO_INIT(ch, cond) \ 265#define DO_INIT(ch, cond) \
266 MUTE_CHANNEL(ch, pst _ init && cond, MUTE_INIT) 266 MUTE_CHANNEL(ch, pst _ init && cond, MUTE_INIT)
267 267
268FUNC(void, PokeySound_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) 268FUNC(void, PokeySound_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data)))
269{ 269{
270 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 270 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0
271 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; 271 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey;
272 switch (addr & 0xf) { 272 switch (addr & 0xf) {
273 case 0x00: 273 case 0x00:
274 DO_STORE(audf1); 274 DO_STORE(audf1);
275 switch (pst _ audctl & 0x50) { 275 switch (pst _ audctl & 0x50) {
276 case 0x00: 276 case 0x00:
277 pst _ period_cycles1 = pst _ div_cycles * (data + 1); 277 pst _ period_cycles1 = pst _ div_cycles * (data + 1);
278 break; 278 break;
279 case 0x10: 279 case 0x10:
280 pst _ period_cycles2 = pst _ div_cycles * (data + 256 * pst _ audf2 + 1); 280 pst _ period_cycles2 = pst _ div_cycles * (data + 256 * pst _ audf2 + 1);
281 pst _ reload_cycles1 = pst _ div_cycles * (data + 1); 281 pst _ reload_cycles1 = pst _ div_cycles * (data + 1);
282 DO_ULTRASOUND(2); 282 DO_ULTRASOUND(2);
283 break; 283 break;
284 case 0x40: 284 case 0x40:
285 pst _ period_cycles1 = data + 4; 285 pst _ period_cycles1 = data + 4;
286 break; 286 break;
287 case 0x50: 287 case 0x50:
288 pst _ period_cycles2 = data + 256 * pst _ audf2 + 7; 288 pst _ period_cycles2 = data + 256 * pst _ audf2 + 7;
289 pst _ reload_cycles1 = data + 4; 289 pst _ reload_cycles1 = data + 4;
290 DO_ULTRASOUND(2); 290 DO_ULTRASOUND(2);
291 break; 291 break;
292 } 292 }
293 DO_ULTRASOUND(1); 293 DO_ULTRASOUND(1);
294 break; 294 break;
295 case 0x01: 295 case 0x01:
296 DO_AUDC(1) 296 DO_AUDC(1)
297 case 0x02: 297 case 0x02:
298 DO_STORE(audf2); 298 DO_STORE(audf2);
299 switch (pst _ audctl & 0x50) { 299 switch (pst _ audctl & 0x50) {
300 case 0x00: 300 case 0x00:
301 case 0x40: 301 case 0x40:
302 pst _ period_cycles2 = pst _ div_cycles * (data + 1); 302 pst _ period_cycles2 = pst _ div_cycles * (data + 1);
303 break; 303 break;
304 case 0x10: 304 case 0x10:
305 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * data + 1); 305 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * data + 1);
306 break; 306 break;
307 case 0x50: 307 case 0x50:
308 pst _ period_cycles2 = pst _ audf1 + 256 * data + 7; 308 pst _ period_cycles2 = pst _ audf1 + 256 * data + 7;
309 break; 309 break;
310 } 310 }
311 DO_ULTRASOUND(2); 311 DO_ULTRASOUND(2);
312 break; 312 break;
313 case 0x03: 313 case 0x03:
314 DO_AUDC(2) 314 DO_AUDC(2)
315 case 0x04: 315 case 0x04:
316 DO_STORE(audf3); 316 DO_STORE(audf3);
317 switch (pst _ audctl & 0x28) { 317 switch (pst _ audctl & 0x28) {
318 case 0x00: 318 case 0x00:
319 pst _ period_cycles3 = pst _ div_cycles * (data + 1); 319 pst _ period_cycles3 = pst _ div_cycles * (data + 1);
320 break; 320 break;
321 case 0x08: 321 case 0x08:
322 pst _ period_cycles4 = pst _ div_cycles * (data + 256 * pst _ audf4 + 1); 322 pst _ period_cycles4 = pst _ div_cycles * (data + 256 * pst _ audf4 + 1);
323 pst _ reload_cycles3 = pst _ div_cycles * (data + 1); 323 pst _ reload_cycles3 = pst _ div_cycles * (data + 1);
324 DO_ULTRASOUND(4); 324 DO_ULTRASOUND(4);
325 break; 325 break;
326 case 0x20: 326 case 0x20:
327 pst _ period_cycles3 = data + 4; 327 pst _ period_cycles3 = data + 4;
328 break; 328 break;
329 case 0x28: 329 case 0x28:
330 pst _ period_cycles4 = data + 256 * pst _ audf4 + 7; 330 pst _ period_cycles4 = data + 256 * pst _ audf4 + 7;
331 pst _ reload_cycles3 = data + 4; 331 pst _ reload_cycles3 = data + 4;
332 DO_ULTRASOUND(4); 332 DO_ULTRASOUND(4);
333 break; 333 break;
334 } 334 }
335 DO_ULTRASOUND(3); 335 DO_ULTRASOUND(3);
336 break; 336 break;
337 case 0x05: 337 case 0x05:
338 DO_AUDC(3) 338 DO_AUDC(3)
339 case 0x06: 339 case 0x06:
340 DO_STORE(audf4); 340 DO_STORE(audf4);
341 switch (pst _ audctl & 0x28) { 341 switch (pst _ audctl & 0x28) {
342 case 0x00: 342 case 0x00:
343 case 0x20: 343 case 0x20:
344 pst _ period_cycles4 = pst _ div_cycles * (data + 1); 344 pst _ period_cycles4 = pst _ div_cycles * (data + 1);
345 break; 345 break;
346 case 0x08: 346 case 0x08:
347 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * data + 1); 347 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * data + 1);
348 break; 348 break;
349 case 0x28: 349 case 0x28:
350 pst _ period_cycles4 = pst _ audf3 + 256 * data + 7; 350 pst _ period_cycles4 = pst _ audf3 + 256 * data + 7;
351 break; 351 break;
352 } 352 }
353 DO_ULTRASOUND(4); 353 DO_ULTRASOUND(4);
354 break; 354 break;
355 case 0x07: 355 case 0x07:
356 DO_AUDC(4) 356 DO_AUDC(4)
357 case 0x08: 357 case 0x08:
358 DO_STORE(audctl); 358 DO_STORE(audctl);
359 pst _ div_cycles = ((data & 1) != 0) ? 114 : 28; 359 pst _ div_cycles = ((data & 1) != 0) ? 114 : 28;
360 /* TODO: tick_cycles */ 360 /* TODO: tick_cycles */
361 switch (data & 0x50) { 361 switch (data & 0x50) {
362 case 0x00: 362 case 0x00:
363 pst _ period_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); 363 pst _ period_cycles1 = pst _ div_cycles * (pst _ audf1 + 1);
364 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); 364 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1);
365 break; 365 break;
366 case 0x10: 366 case 0x10:
367 pst _ period_cycles1 = pst _ div_cycles * 256; 367 pst _ period_cycles1 = pst _ div_cycles * 256;
368 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * pst _ audf2 + 1); 368 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * pst _ audf2 + 1);
369 pst _ reload_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); 369 pst _ reload_cycles1 = pst _ div_cycles * (pst _ audf1 + 1);
370 break; 370 break;
371 case 0x40: 371 case 0x40:
372 pst _ period_cycles1 = pst _ audf1 + 4; 372 pst _ period_cycles1 = pst _ audf1 + 4;
373 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); 373 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1);
374 break; 374 break;
375 case 0x50: 375 case 0x50:
376 pst _ period_cycles1 = 256; 376 pst _ period_cycles1 = 256;
377 pst _ period_cycles2 = pst _ audf1 + 256 * pst _ audf2 + 7; 377 pst _ period_cycles2 = pst _ audf1 + 256 * pst _ audf2 + 7;
378 pst _ reload_cycles1 = pst _ audf1 + 4; 378 pst _ reload_cycles1 = pst _ audf1 + 4;
379 break; 379 break;
380 } 380 }
381 DO_ULTRASOUND(1); 381 DO_ULTRASOUND(1);
382 DO_ULTRASOUND(2); 382 DO_ULTRASOUND(2);
383 switch (data & 0x28) { 383 switch (data & 0x28) {
384 case 0x00: 384 case 0x00:
385 pst _ period_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); 385 pst _ period_cycles3 = pst _ div_cycles * (pst _ audf3 + 1);
386 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); 386 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1);
387 break; 387 break;
388 case 0x08: 388 case 0x08:
389 pst _ period_cycles3 = pst _ div_cycles * 256; 389 pst _ period_cycles3 = pst _ div_cycles * 256;
390 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * pst _ audf4 + 1); 390 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * pst _ audf4 + 1);
391 pst _ reload_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); 391 pst _ reload_cycles3 = pst _ div_cycles * (pst _ audf3 + 1);
392 break; 392 break;
393 case 0x20: 393 case 0x20:
394 pst _ period_cycles3 = pst _ audf3 + 4; 394 pst _ period_cycles3 = pst _ audf3 + 4;
395 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); 395 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1);
396 break; 396 break;
397 case 0x28: 397 case 0x28:
398 pst _ period_cycles3 = 256; 398 pst _ period_cycles3 = 256;
399 pst _ period_cycles4 = pst _ audf3 + 256 * pst _ audf4 + 7; 399 pst _ period_cycles4 = pst _ audf3 + 256 * pst _ audf4 + 7;
400 pst _ reload_cycles3 = pst _ audf3 + 4; 400 pst _ reload_cycles3 = pst _ audf3 + 4;
401 break; 401 break;
402 } 402 }
403 DO_ULTRASOUND(3); 403 DO_ULTRASOUND(3);
404 DO_ULTRASOUND(4); 404 DO_ULTRASOUND(4);
405 DO_INIT(1, (data & 0x40) == 0); 405 DO_INIT(1, (data & 0x40) == 0);
406 DO_INIT(2, (data & 0x50) != 0x50); 406 DO_INIT(2, (data & 0x50) != 0x50);
407 DO_INIT(3, (data & 0x20) == 0); 407 DO_INIT(3, (data & 0x20) == 0);
408 DO_INIT(4, (data & 0x28) != 0x28); 408 DO_INIT(4, (data & 0x28) != 0x28);
409 break; 409 break;
410 case 0x09: 410 case 0x09:
411 /* TODO: STIMER */ 411 /* TODO: STIMER */
412 break; 412 break;
413 case 0x0f: 413 case 0x0f:
414 DO_STORE(skctl); 414 DO_STORE(skctl);
415 pst _ init = ((data & 3) == 0); 415 pst _ init = ((data & 3) == 0);
416 DO_INIT(1, (pst _ audctl & 0x40) == 0); 416 DO_INIT(1, (pst _ audctl & 0x40) == 0);
417 DO_INIT(2, (pst _ audctl & 0x50) != 0x50); 417 DO_INIT(2, (pst _ audctl & 0x50) != 0x50);
418 DO_INIT(3, (pst _ audctl & 0x20) == 0); 418 DO_INIT(3, (pst _ audctl & 0x20) == 0);
419 DO_INIT(4, (pst _ audctl & 0x28) != 0x28); 419 DO_INIT(4, (pst _ audctl & 0x28) != 0x28);
420 break; 420 break;
421 default: 421 default:
422 break; 422 break;
423 } 423 }
424} 424}
425 425
426FUNC(int, PokeySound_GetRandom, (P(ASAP_State PTR, ast), P(int, addr), P(int, cycle))) 426FUNC(int, PokeySound_GetRandom, (P(ASAP_State PTR, ast), P(int, addr), P(int, cycle)))
427{ 427{
428 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 428 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0
429 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; 429 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey;
430 V(int, i); 430 V(int, i);
431 if (pst _ init) 431 if (pst _ init)
432 return 0xff; 432 return 0xff;
433 i = cycle + pst _ poly_index; 433 i = cycle + pst _ poly_index;
434 if ((pst _ audctl & 0x80) != 0) 434 if ((pst _ audctl & 0x80) != 0)
435 return ast _ poly9_lookup[i % 511]; 435 return ast _ poly9_lookup[i % 511];
436 else { 436 else {
437 V(int, j); 437 V(int, j);
438 i %= 131071; 438 i %= 131071;
439 j = i >> 3; 439 j = i >> 3;
440 i &= 7; 440 i &= 7;
441 return ((ast _ poly17_lookup[j] >> i) + (ast _ poly17_lookup[j + 1] << (8 - i))) & 0xff; 441 return ((ast _ poly17_lookup[j] >> i) + (ast _ poly17_lookup[j + 1] << (8 - i))) & 0xff;
442 } 442 }
443} 443}
444 444
445PRIVATE FUNC(void, end_frame, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, cycle_limit))) 445PRIVATE FUNC(void, end_frame, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, cycle_limit)))
446{ 446{
447 V(int, m); 447 V(int, m);
448 PokeySound_GenerateUntilCycle(ast, pst, cycle_limit); 448 PokeySound_GenerateUntilCycle(ast, pst, cycle_limit);
449 pst _ poly_index += cycle_limit; 449 pst _ poly_index += cycle_limit;
450 m = ((pst _ audctl & 0x80) != 0) ? 15 * 31 * 511 : 15 * 31 * 131071; 450 m = ((pst _ audctl & 0x80) != 0) ? 15 * 31 * 511 : 15 * 31 * 131071;
451 if (pst _ poly_index >= 2 * m) 451 if (pst _ poly_index >= 2 * m)
452 pst _ poly_index -= m; 452 pst _ poly_index -= m;
453 if (pst _ tick_cycle1 != NEVER) 453 if (pst _ tick_cycle1 != NEVER)
454 pst _ tick_cycle1 -= cycle_limit; 454 pst _ tick_cycle1 -= cycle_limit;
455 if (pst _ tick_cycle2 != NEVER) 455 if (pst _ tick_cycle2 != NEVER)
456 pst _ tick_cycle2 -= cycle_limit; 456 pst _ tick_cycle2 -= cycle_limit;
457 if (pst _ tick_cycle3 != NEVER) 457 if (pst _ tick_cycle3 != NEVER)
458 pst _ tick_cycle3 -= cycle_limit; 458 pst _ tick_cycle3 -= cycle_limit;
459 if (pst _ tick_cycle4 != NEVER) 459 if (pst _ tick_cycle4 != NEVER)
460 pst _ tick_cycle4 -= cycle_limit; 460 pst _ tick_cycle4 -= cycle_limit;
461} 461}
462 462
463FUNC(void, PokeySound_StartFrame, (P(ASAP_State PTR, ast))) 463FUNC(void, PokeySound_StartFrame, (P(ASAP_State PTR, ast)))
464{ 464{
465 ZERO_ARRAY(ast _ base_pokey.delta_buffer); 465 ZERO_ARRAY(ast _ base_pokey.delta_buffer);
466 if (ast _ extra_pokey_mask != 0) 466 if (ast _ extra_pokey_mask != 0)
467 ZERO_ARRAY(ast _ extra_pokey.delta_buffer); 467 ZERO_ARRAY(ast _ extra_pokey.delta_buffer);
468} 468}
469 469
470FUNC(void, PokeySound_EndFrame, (P(ASAP_State PTR, ast), P(int, current_cycle))) 470FUNC(void, PokeySound_EndFrame, (P(ASAP_State PTR, ast), P(int, current_cycle)))
471{ 471{
472 end_frame(ast, ADDRESSOF ast _ base_pokey, current_cycle); 472 end_frame(ast, ADDRESSOF ast _ base_pokey, current_cycle);
473 if (ast _ extra_pokey_mask != 0) 473 if (ast _ extra_pokey_mask != 0)
474 end_frame(ast, ADDRESSOF ast _ extra_pokey, current_cycle); 474 end_frame(ast, ADDRESSOF ast _ extra_pokey, current_cycle);
475 ast _ sample_offset += current_cycle * ASAP_SAMPLE_RATE; 475 ast _ sample_offset += current_cycle * ASAP_SAMPLE_RATE;
476 ast _ sample_index = 0; 476 ast _ sample_index = 0;
477 ast _ samples = TO_INT(ast _ sample_offset / ASAP_MAIN_CLOCK); 477 ast _ samples = TO_INT(ast _ sample_offset / ASAP_MAIN_CLOCK);
478 ast _ sample_offset %= ASAP_MAIN_CLOCK; 478 ast _ sample_offset %= ASAP_MAIN_CLOCK;
479} 479}
480 480
481/* Fills buffer with samples from delta_buffer. */ 481/* Fills buffer with samples from delta_buffer. */
482FUNC(int, PokeySound_Generate, (P(ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(int, buffer_offset), P(int, blocks), P(ASAP_SampleFormat, format))) 482FUNC(int, PokeySound_Generate, (P(ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(int, buffer_offset), P(int, blocks), P(ASAP_SampleFormat, format)))
483{ 483{
484 V(int, i) = ast _ sample_index; 484 V(int, i) = ast _ sample_index;
485 V(int, samples) = ast _ samples; 485 V(int, samples) = ast _ samples;
486 V(int, acc_left) = ast _ iir_acc_left; 486 V(int, acc_left) = ast _ iir_acc_left;
487 V(int, acc_right) = ast _ iir_acc_right; 487 V(int, acc_right) = ast _ iir_acc_right;
488 if (blocks < samples - i) 488 if (blocks < samples - i)
489 samples = i + blocks; 489 samples = i + blocks;
490 else 490 else
491 blocks = samples - i; 491 blocks = samples - i;
492 for (; i < samples; i++) { 492 for (; i < samples; i++) {
493#ifdef ACTIONSCRIPT 493#ifdef ACTIONSCRIPT
494 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); 494 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10);
495 var sample : Number = acc_left / 33553408; 495 var sample : Number = acc_left / 33553408;
496 buffer.writeFloat(sample); 496 buffer.writeFloat(sample);
497 if (ast.extra_pokey_mask != 0) { 497 if (ast.extra_pokey_mask != 0) {
498 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); 498 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10);
499 sample = acc_right / 33553408; 499 sample = acc_right / 33553408;
500 } 500 }
501 buffer.writeFloat(sample); 501 buffer.writeFloat(sample);
502#else 502#else
503 V(int, sample); 503 V(int, sample);
504 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); 504 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10);
505 sample = acc_left >> 10; 505 sample = acc_left >> 10;
506#define STORE_SAMPLE \ 506#define STORE_SAMPLE \
507 if (sample < -32767) \ 507 if (sample < -32767) \
508 sample = -32767; \ 508 sample = -32767; \
509 else if (sample > 32767) \ 509 else if (sample > 32767) \
510 sample = 32767; \ 510 sample = 32767; \
511 switch (format) { \ 511 switch (format) { \
512 case ASAP_FORMAT_U8: \ 512 case ASAP_FORMAT_U8: \
513 buffer[buffer_offset++] = CAST(byte) ((sample >> 8) + 128); \ 513 buffer[buffer_offset++] = CAST(byte) ((sample >> 8) + 128); \
514 break; \ 514 break; \
515 case ASAP_FORMAT_S16_LE: \ 515 case ASAP_FORMAT_S16_LE: \
516 buffer[buffer_offset++] = TO_BYTE(sample); \ 516 buffer[buffer_offset++] = TO_BYTE(sample); \
517 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ 517 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \
518 break; \ 518 break; \
519 case ASAP_FORMAT_S16_BE: \ 519 case ASAP_FORMAT_S16_BE: \
520 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ 520 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \
521 buffer[buffer_offset++] = TO_BYTE(sample); \ 521 buffer[buffer_offset++] = TO_BYTE(sample); \
522 break; \ 522 break; \
523 } 523 }
524 STORE_SAMPLE; 524 STORE_SAMPLE;
525 if (ast _ extra_pokey_mask != 0) { 525 if (ast _ extra_pokey_mask != 0) {
526 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); 526 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10);
527 sample = acc_right >> 10; 527 sample = acc_right >> 10;
528 STORE_SAMPLE; 528 STORE_SAMPLE;
529 } 529 }
530#endif /* ACTIONSCRIPT */ 530#endif /* ACTIONSCRIPT */
531 } 531 }
532 if (i == ast _ samples) { 532 if (i == ast _ samples) {
533 acc_left += ast _ base_pokey.delta_buffer[i]; 533 acc_left += ast _ base_pokey.delta_buffer[i];
534 acc_right += ast _ extra_pokey.delta_buffer[i]; 534 acc_right += ast _ extra_pokey.delta_buffer[i];
535 } 535 }
536 ast _ sample_index = i; 536 ast _ sample_index = i;
537 ast _ iir_acc_left = acc_left; 537 ast _ iir_acc_left = acc_left;
538 ast _ iir_acc_right = acc_right; 538 ast _ iir_acc_right = acc_right;
539#ifdef APOKEYSND 539#ifdef APOKEYSND
540 return buffer_offset; 540 return buffer_offset;
541#else 541#else
542 return blocks; 542 return blocks;
543#endif 543#endif
544} 544}
545 545
546FUNC(abool, PokeySound_IsSilent, (P(CONST PokeyState PTR, pst))) 546FUNC(abool, PokeySound_IsSilent, (P(CONST PokeyState PTR, pst)))
547{ 547{
548 return ((pst _ audc1 | pst _ audc2 | pst _ audc3 | pst _ audc4) & 0xf) == 0; 548 return ((pst _ audc1 | pst _ audc2 | pst _ audc3 | pst _ audc4) & 0xf) == 0;
549} 549}
550 550
551FUNC(void, PokeySound_Mute, (P(CONST ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, mask))) 551FUNC(void, PokeySound_Mute, (P(CONST ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, mask)))
552{ 552{
553 MUTE_CHANNEL(1, (mask & 1) != 0, MUTE_USER); 553 MUTE_CHANNEL(1, (mask & 1) != 0, MUTE_USER);
554 MUTE_CHANNEL(2, (mask & 2) != 0, MUTE_USER); 554 MUTE_CHANNEL(2, (mask & 2) != 0, MUTE_USER);
555 MUTE_CHANNEL(3, (mask & 4) != 0, MUTE_USER); 555 MUTE_CHANNEL(3, (mask & 4) != 0, MUTE_USER);
556 MUTE_CHANNEL(4, (mask & 8) != 0, MUTE_USER); 556 MUTE_CHANNEL(4, (mask & 8) != 0, MUTE_USER);
557} 557}
558 558
559#ifdef APOKEYSND 559#ifdef APOKEYSND
@@ -562,37 +562,37 @@ static ASAP_State asap;
562 562
563__declspec(dllexport) void APokeySound_Initialize(abool stereo) 563__declspec(dllexport) void APokeySound_Initialize(abool stereo)
564{ 564{
565 asap.extra_pokey_mask = stereo ? 0x10 : 0; 565 asap.extra_pokey_mask = stereo ? 0x10 : 0;
566 PokeySound_Initialize(&asap); 566 PokeySound_Initialize(&asap);
567 PokeySound_Mute(&asap, &asap.base_pokey, 0); 567 PokeySound_Mute(&asap, &asap.base_pokey, 0);
568 PokeySound_Mute(&asap, &asap.extra_pokey, 0); 568 PokeySound_Mute(&asap, &asap.extra_pokey, 0);
569 PokeySound_StartFrame(&asap); 569 PokeySound_StartFrame(&asap);
570} 570}
571 571
572__declspec(dllexport) void APokeySound_PutByte(int addr, int data) 572__declspec(dllexport) void APokeySound_PutByte(int addr, int data)
573{ 573{
574 PokeySound_PutByte(&asap, addr, data); 574 PokeySound_PutByte(&asap, addr, data);
575} 575}
576 576
577__declspec(dllexport) int APokeySound_GetRandom(int addr, int cycle) 577__declspec(dllexport) int APokeySound_GetRandom(int addr, int cycle)
578{ 578{
579 return PokeySound_GetRandom(&asap, addr, cycle); 579 return PokeySound_GetRandom(&asap, addr, cycle);
580} 580}
581 581
582__declspec(dllexport) int APokeySound_Generate(int cycles, byte buffer[], ASAP_SampleFormat format) 582__declspec(dllexport) int APokeySound_Generate(int cycles, byte buffer[], ASAP_SampleFormat format)
583{ 583{
584 int len; 584 int len;
585 PokeySound_EndFrame(&asap, cycles); 585 PokeySound_EndFrame(&asap, cycles);
586 len = PokeySound_Generate(&asap, buffer, 0, asap.samples, format); 586 len = PokeySound_Generate(&asap, buffer, 0, asap.samples, format);
587 PokeySound_StartFrame(&asap); 587 PokeySound_StartFrame(&asap);
588 return len; 588 return len;
589} 589}
590 590
591__declspec(dllexport) void APokeySound_About(const char **name, const char **author, const char **description) 591__declspec(dllexport) void APokeySound_About(const char **name, const char **author, const char **description)
592{ 592{
593 *name = "Another POKEY sound emulator, v" ASAP_VERSION; 593 *name = "Another POKEY sound emulator, v" ASAP_VERSION;
594 *author = "Piotr Fusik, (C) " ASAP_YEARS; 594 *author = "Piotr Fusik, (C) " ASAP_YEARS;
595 *description = "Part of ASAP, http://asap.sourceforge.net"; 595 *description = "Part of ASAP, http://asap.sourceforge.net";
596} 596}
597 597
598#endif /* APOKEYSND */ 598#endif /* APOKEYSND */
diff --git a/apps/codecs/libasap/asap.c b/apps/codecs/libasap/asap.c
index 87b537ef63..c79682c38b 100644
--- a/apps/codecs/libasap/asap.c
+++ b/apps/codecs/libasap/asap.c
@@ -25,78 +25,78 @@
25 25
26FUNC(int, ASAP_GetByte, (P(ASAP_State PTR, ast), P(int, addr))) 26FUNC(int, ASAP_GetByte, (P(ASAP_State PTR, ast), P(int, addr)))
27{ 27{
28 switch (addr & 0xff0f) { 28 switch (addr & 0xff0f) {
29 case 0xd20a: 29 case 0xd20a:
30 return PokeySound_GetRandom(ast, addr, ast _ cycle); 30 return PokeySound_GetRandom(ast, addr, ast _ cycle);
31 case 0xd20e: 31 case 0xd20e:
32 if ((addr & ast _ extra_pokey_mask) != 0) { 32 if ((addr & ast _ extra_pokey_mask) != 0) {
33 /* interrupts in the extra POKEY not emulated at the moment */ 33 /* interrupts in the extra POKEY not emulated at the moment */
34 return 0xff; 34 return 0xff;
35 } 35 }
36 return ast _ irqst; 36 return ast _ irqst;
37 case 0xd20f: 37 case 0xd20f:
38 /* just because some SAP files rely on this */ 38 /* just because some SAP files rely on this */
39 return 0xff; 39 return 0xff;
40 case 0xd40b: 40 case 0xd40b:
41 return ast _ scanline_number >> 1; 41 return ast _ scanline_number >> 1;
42 default: 42 default:
43 return dGetByte(addr); 43 return dGetByte(addr);
44 } 44 }
45} 45}
46 46
47FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) 47FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data)))
48{ 48{
49 if ((addr >> 8) == 0xd2) { 49 if ((addr >> 8) == 0xd2) {
50 if ((addr & (ast _ extra_pokey_mask + 0xf)) == 0xe) { 50 if ((addr & (ast _ extra_pokey_mask + 0xf)) == 0xe) {
51 ast _ irqst |= data ^ 0xff; 51 ast _ irqst |= data ^ 0xff;
52#define SET_TIMER_IRQ(ch) \ 52#define SET_TIMER_IRQ(ch) \
53 if ((data & ast _ irqst & ch) != 0) { \ 53 if ((data & ast _ irqst & ch) != 0) { \
54 if (ast _ timer##ch##_cycle == NEVER) { \ 54 if (ast _ timer##ch##_cycle == NEVER) { \
55 V(int, t) = ast _ base_pokey.tick_cycle##ch; \ 55 V(int, t) = ast _ base_pokey.tick_cycle##ch; \
56 while (t < ast _ cycle) \ 56 while (t < ast _ cycle) \
57 t += ast _ base_pokey.period_cycles##ch; \ 57 t += ast _ base_pokey.period_cycles##ch; \
58 ast _ timer##ch##_cycle = t; \ 58 ast _ timer##ch##_cycle = t; \
59 if (ast _ nearest_event_cycle > t) \ 59 if (ast _ nearest_event_cycle > t) \
60 ast _ nearest_event_cycle = t; \ 60 ast _ nearest_event_cycle = t; \
61 } \ 61 } \
62 } \ 62 } \
63 else \ 63 else \
64 ast _ timer##ch##_cycle = NEVER; 64 ast _ timer##ch##_cycle = NEVER;
65 SET_TIMER_IRQ(1); 65 SET_TIMER_IRQ(1);
66 SET_TIMER_IRQ(2); 66 SET_TIMER_IRQ(2);
67 SET_TIMER_IRQ(4); 67 SET_TIMER_IRQ(4);
68 } 68 }
69 else 69 else
70 PokeySound_PutByte(ast, addr, data); 70 PokeySound_PutByte(ast, addr, data);
71 } 71 }
72 else if ((addr & 0xff0f) == 0xd40a) { 72 else if ((addr & 0xff0f) == 0xd40a) {
73 if (ast _ cycle <= ast _ next_scanline_cycle - 8) 73 if (ast _ cycle <= ast _ next_scanline_cycle - 8)
74 ast _ cycle = ast _ next_scanline_cycle - 8; 74 ast _ cycle = ast _ next_scanline_cycle - 8;
75 else 75 else
76 ast _ cycle = ast _ next_scanline_cycle + 106; 76 ast _ cycle = ast _ next_scanline_cycle + 106;
77 } 77 }
78 else if ((addr & 0xff00) == ast _ module_info.covox_addr) { 78 else if ((addr & 0xff00) == ast _ module_info.covox_addr) {
79 V(PokeyState PTR, pst); 79 V(PokeyState PTR, pst);
80 addr &= 3; 80 addr &= 3;
81 if (addr == 0 || addr == 3) 81 if (addr == 0 || addr == 3)
82 pst = ADDRESSOF ast _ base_pokey; 82 pst = ADDRESSOF ast _ base_pokey;
83 else 83 else
84 pst = ADDRESSOF ast _ extra_pokey; 84 pst = ADDRESSOF ast _ extra_pokey;
85 pst _ delta_buffer[CYCLE_TO_SAMPLE(ast _ cycle)] += (data - UBYTE(ast _ covox[addr])) << DELTA_SHIFT_COVOX; 85 pst _ delta_buffer[CYCLE_TO_SAMPLE(ast _ cycle)] += (data - UBYTE(ast _ covox[addr])) << DELTA_SHIFT_COVOX;
86 ast _ covox[addr] = CAST(byte) (data); 86 ast _ covox[addr] = CAST(byte) (data);
87 } 87 }
88 else if ((addr & 0xff1f) == 0xd01f) { 88 else if ((addr & 0xff1f) == 0xd01f) {
89 V(int, sample) = CYCLE_TO_SAMPLE(ast _ cycle); 89 V(int, sample) = CYCLE_TO_SAMPLE(ast _ cycle);
90 V(int, delta); 90 V(int, delta);
91 data &= 8; 91 data &= 8;
92 /* NOT data - ast _ consol; reverse to the POKEY sound */ 92 /* NOT data - ast _ consol; reverse to the POKEY sound */
93 delta = (ast _ consol - data) << DELTA_SHIFT_GTIA; 93 delta = (ast _ consol - data) << DELTA_SHIFT_GTIA;
94 ast _ consol = data; 94 ast _ consol = data;
95 ast _ base_pokey.delta_buffer[sample] += delta; 95 ast _ base_pokey.delta_buffer[sample] += delta;
96 ast _ extra_pokey.delta_buffer[sample] += delta; 96 ast _ extra_pokey.delta_buffer[sample] += delta;
97 } 97 }
98 else 98 else
99 dPutByte(addr, data); 99 dPutByte(addr, data);
100} 100}
101 101
102#define UWORD(array, index) (UBYTE(array[index]) + (UBYTE(array[(index) + 1]) << 8)) 102#define UWORD(array, index) (UBYTE(array[index]) + (UBYTE(array[(index) + 1]) << 8))
@@ -110,61 +110,61 @@ FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data)))
110#define CMR_BASS_TABLE_OFFSET 0x70f 110#define CMR_BASS_TABLE_OFFSET 0x70f
111 111
112CONST_ARRAY(byte, cmr_bass_table) 112CONST_ARRAY(byte, cmr_bass_table)
113 0x5C, 0x56, 0x50, 0x4D, 0x47, 0x44, 0x41, 0x3E, 113 0x5C, 0x56, 0x50, 0x4D, 0x47, 0x44, 0x41, 0x3E,
114 0x38, 0x35, CAST(byte) (0x88), 0x7F, 0x79, 0x73, 0x6C, 0x67, 114 0x38, 0x35, CAST(byte) (0x88), 0x7F, 0x79, 0x73, 0x6C, 0x67,
115 0x60, 0x5A, 0x55, 0x51, 0x4C, 0x48, 0x43, 0x3F, 115 0x60, 0x5A, 0x55, 0x51, 0x4C, 0x48, 0x43, 0x3F,
116 0x3D, 0x39, 0x34, 0x33, 0x30, 0x2D, 0x2A, 0x28, 116 0x3D, 0x39, 0x34, 0x33, 0x30, 0x2D, 0x2A, 0x28,
117 0x25, 0x24, 0x21, 0x1F, 0x1E 117 0x25, 0x24, 0x21, 0x1F, 0x1E
118END_CONST_ARRAY; 118END_CONST_ARRAY;
119 119
120CONST_ARRAY(int, perframe2fastplay) 120CONST_ARRAY(int, perframe2fastplay)
121 312, 312 / 2, 312 / 3, 312 / 4 121 312, 312 / 2, 312 / 3, 312 / 4
122END_CONST_ARRAY; 122END_CONST_ARRAY;
123 123
124/* Loads native module (anything except SAP) and 6502 player routine. */ 124/* Loads native module (anything except SAP) and 6502 player routine. */
125PRIVATE FUNC(abool, load_native, ( 125PRIVATE FUNC(abool, load_native, (
126 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 126 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
127 P(CONST BYTEARRAY, module), P(int, module_len), P(RESOURCE, player))) 127 P(CONST BYTEARRAY, module), P(int, module_len), P(RESOURCE, player)))
128{ 128{
129 V(int, player_last_byte); 129 V(int, player_last_byte);
130 V(int, music_last_byte); 130 V(int, music_last_byte);
131 V(int, block_len); 131 V(int, block_len);
132 if ((UBYTE(module[0]) != 0xff || UBYTE(module[1]) != 0xff) 132 if ((UBYTE(module[0]) != 0xff || UBYTE(module[1]) != 0xff)
133 && (module[0] != 0 || module[1] != 0)) /* some CMC and clones start with zeros */ 133 && (module[0] != 0 || module[1] != 0)) /* some CMC and clones start with zeros */
134 return FALSE; 134 return FALSE;
135 module_info _ player = UWORD(player, 2); 135 module_info _ player = UWORD(player, 2);
136 player_last_byte = UWORD(player, 4); 136 player_last_byte = UWORD(player, 4);
137 module_info _ music = UWORD(module, 2); 137 module_info _ music = UWORD(module, 2);
138 if (module_info _ music <= player_last_byte) 138 if (module_info _ music <= player_last_byte)
139 return FALSE; 139 return FALSE;
140 music_last_byte = UWORD(module, 4); 140 music_last_byte = UWORD(module, 4);
141 if (module_info _ music <= 0xd7ff && music_last_byte >= 0xd000) 141 if (module_info _ music <= 0xd7ff && music_last_byte >= 0xd000)
142 return FALSE; 142 return FALSE;
143 block_len = music_last_byte + 1 - module_info _ music; 143 block_len = music_last_byte + 1 - module_info _ music;
144 if (6 + block_len != module_len) { 144 if (6 + block_len != module_len) {
145 V(int, info_addr); 145 V(int, info_addr);
146 V(int, info_len); 146 V(int, info_len);
147 if (module_info _ type != ASAP_TYPE_RMT || 11 + block_len > module_len) 147 if (module_info _ type != ASAP_TYPE_RMT || 11 + block_len > module_len)
148 return FALSE; 148 return FALSE;
149 /* allow optional info for Raster Music Tracker */ 149 /* allow optional info for Raster Music Tracker */
150 info_addr = UWORD(module, 6 + block_len); 150 info_addr = UWORD(module, 6 + block_len);
151 if (info_addr != module_info _ music + block_len) 151 if (info_addr != module_info _ music + block_len)
152 return FALSE; 152 return FALSE;
153 info_len = UWORD(module, 8 + block_len) + 1 - info_addr; 153 info_len = UWORD(module, 8 + block_len) + 1 - info_addr;
154 if (10 + block_len + info_len != module_len) 154 if (10 + block_len + info_len != module_len)
155 return FALSE; 155 return FALSE;
156 } 156 }
157 if (ast != NULL) { 157 if (ast != NULL) {
158 COPY_ARRAY(ast _ memory, module_info _ music, module, 6, block_len); 158 COPY_ARRAY(ast _ memory, module_info _ music, module, 6, block_len);
159 COPY_ARRAY(ast _ memory, module_info _ player, player, 6, player_last_byte + 1 - module_info _ player); 159 COPY_ARRAY(ast _ memory, module_info _ player, player, 6, player_last_byte + 1 - module_info _ player);
160 } 160 }
161 return TRUE; 161 return TRUE;
162} 162}
163 163
164PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(int, player_calls))) 164PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(int, player_calls)))
165{ 165{
166 module_info _ durations[module_info _ songs] = TO_INT(player_calls * module_info _ fastplay * 114000.0 / 1773447); 166 module_info _ durations[module_info _ songs] = TO_INT(player_calls * module_info _ fastplay * 114000.0 / 1773447);
167 module_info _ songs++; 167 module_info _ songs++;
168} 168}
169 169
170#define SEEN_THIS_CALL 1 170#define SEEN_THIS_CALL 1
@@ -173,901 +173,901 @@ PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(in
173 173
174PRIVATE FUNC(void, parse_cmc_song, (P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) 174PRIVATE FUNC(void, parse_cmc_song, (P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos)))
175{ 175{
176 V(int, tempo) = UBYTE(module[0x19]); 176 V(int, tempo) = UBYTE(module[0x19]);
177 V(int, player_calls) = 0; 177 V(int, player_calls) = 0;
178 V(int, rep_start_pos) = 0; 178 V(int, rep_start_pos) = 0;
179 V(int, rep_end_pos) = 0; 179 V(int, rep_end_pos) = 0;
180 V(int, rep_times) = 0; 180 V(int, rep_times) = 0;
181 NEW_ARRAY(byte, seen, 0x55); 181 NEW_ARRAY(byte, seen, 0x55);
182 INIT_ARRAY(seen); 182 INIT_ARRAY(seen);
183 while (pos >= 0 && pos < 0x55) { 183 while (pos >= 0 && pos < 0x55) {
184 V(int, p1); 184 V(int, p1);
185 V(int, p2); 185 V(int, p2);
186 V(int, p3); 186 V(int, p3);
187 if (pos == rep_end_pos && rep_times > 0) { 187 if (pos == rep_end_pos && rep_times > 0) {
188 for (p1 = 0; p1 < 0x55; p1++) 188 for (p1 = 0; p1 < 0x55; p1++)
189 if (seen[p1] == SEEN_THIS_CALL || seen[p1] == SEEN_REPEAT) 189 if (seen[p1] == SEEN_THIS_CALL || seen[p1] == SEEN_REPEAT)
190 seen[p1] = 0; 190 seen[p1] = 0;
191 rep_times--; 191 rep_times--;
192 pos = rep_start_pos; 192 pos = rep_start_pos;
193 } 193 }
194 if (seen[pos] != 0) { 194 if (seen[pos] != 0) {
195 if (seen[pos] != SEEN_THIS_CALL) 195 if (seen[pos] != SEEN_THIS_CALL)
196 module_info _ loops[module_info _ songs] = TRUE; 196 module_info _ loops[module_info _ songs] = TRUE;
197 break; 197 break;
198 } 198 }
199 seen[pos] = SEEN_THIS_CALL; 199 seen[pos] = SEEN_THIS_CALL;
200 p1 = UBYTE(module[0x206 + pos]); 200 p1 = UBYTE(module[0x206 + pos]);
201 p2 = UBYTE(module[0x25b + pos]); 201 p2 = UBYTE(module[0x25b + pos]);
202 p3 = UBYTE(module[0x2b0 + pos]); 202 p3 = UBYTE(module[0x2b0 + pos]);
203 if (p1 == 0xfe || p2 == 0xfe || p3 == 0xfe) { 203 if (p1 == 0xfe || p2 == 0xfe || p3 == 0xfe) {
204 pos++; 204 pos++;
205 continue; 205 continue;
206 } 206 }
207 p1 >>= 4; 207 p1 >>= 4;
208 if (p1 == 8) 208 if (p1 == 8)
209 break; 209 break;
210 if (p1 == 9) { 210 if (p1 == 9) {
211 pos = p2; 211 pos = p2;
212 continue; 212 continue;
213 } 213 }
214 if (p1 == 0xa) { 214 if (p1 == 0xa) {
215 pos -= p2; 215 pos -= p2;
216 continue; 216 continue;
217 } 217 }
218 if (p1 == 0xb) { 218 if (p1 == 0xb) {
219 pos += p2; 219 pos += p2;
220 continue; 220 continue;
221 } 221 }
222 if (p1 == 0xc) { 222 if (p1 == 0xc) {
223 tempo = p2; 223 tempo = p2;
224 pos++; 224 pos++;
225 continue; 225 continue;
226 } 226 }
227 if (p1 == 0xd) { 227 if (p1 == 0xd) {
228 pos++; 228 pos++;
229 rep_start_pos = pos; 229 rep_start_pos = pos;
230 rep_end_pos = pos + p2; 230 rep_end_pos = pos + p2;
231 rep_times = p3 - 1; 231 rep_times = p3 - 1;
232 continue; 232 continue;
233 } 233 }
234 if (p1 == 0xe) { 234 if (p1 == 0xe) {
235 module_info _ loops[module_info _ songs] = TRUE; 235 module_info _ loops[module_info _ songs] = TRUE;
236 break; 236 break;
237 } 237 }
238 p2 = rep_times > 0 ? SEEN_REPEAT : SEEN_BEFORE; 238 p2 = rep_times > 0 ? SEEN_REPEAT : SEEN_BEFORE;
239 for (p1 = 0; p1 < 0x55; p1++) 239 for (p1 = 0; p1 < 0x55; p1++)
240 if (seen[p1] == SEEN_THIS_CALL) 240 if (seen[p1] == SEEN_THIS_CALL)
241 seen[p1] = CAST(byte) p2; 241 seen[p1] = CAST(byte) p2;
242 player_calls += tempo * (module_info _ type == ASAP_TYPE_CM3 ? 48 : 64); 242 player_calls += tempo * (module_info _ type == ASAP_TYPE_CM3 ? 48 : 64);
243 pos++; 243 pos++;
244 } 244 }
245 set_song_duration(module_info, player_calls); 245 set_song_duration(module_info, player_calls);
246} 246}
247 247
248PRIVATE FUNC(abool, parse_cmc, ( 248PRIVATE FUNC(abool, parse_cmc, (
249 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 249 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
250 P(CONST BYTEARRAY, module), P(int, module_len), P(int, type), P(RESOURCE, player))) 250 P(CONST BYTEARRAY, module), P(int, module_len), P(int, type), P(RESOURCE, player)))
251{ 251{
252 V(int, last_pos); 252 V(int, last_pos);
253 V(int, pos); 253 V(int, pos);
254 if (module_len < 0x306) 254 if (module_len < 0x306)
255 return FALSE; 255 return FALSE;
256 module_info _ type = type; 256 module_info _ type = type;
257 if (!load_native(ast, module_info, module, module_len, player)) 257 if (!load_native(ast, module_info, module, module_len, player))
258 return FALSE; 258 return FALSE;
259 if (ast != NULL && type == ASAP_TYPE_CMR) 259 if (ast != NULL && type == ASAP_TYPE_CMR)
260 COPY_ARRAY(ast _ memory, 0x500 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, 0, sizeof(cmr_bass_table)); 260 COPY_ARRAY(ast _ memory, 0x500 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, 0, sizeof(cmr_bass_table));
261 last_pos = 0x54; 261 last_pos = 0x54;
262 while (--last_pos >= 0) { 262 while (--last_pos >= 0) {
263 if (UBYTE(module[0x206 + last_pos]) < 0xb0 263 if (UBYTE(module[0x206 + last_pos]) < 0xb0
264 || UBYTE(module[0x25b + last_pos]) < 0x40 264 || UBYTE(module[0x25b + last_pos]) < 0x40
265 || UBYTE(module[0x2b0 + last_pos]) < 0x40) 265 || UBYTE(module[0x2b0 + last_pos]) < 0x40)
266 break; 266 break;
267 if (module_info _ channels == 2) { 267 if (module_info _ channels == 2) {
268 if (UBYTE(module[0x306 + last_pos]) < 0xb0 268 if (UBYTE(module[0x306 + last_pos]) < 0xb0
269 || UBYTE(module[0x35b + last_pos]) < 0x40 269 || UBYTE(module[0x35b + last_pos]) < 0x40
270 || UBYTE(module[0x3b0 + last_pos]) < 0x40) 270 || UBYTE(module[0x3b0 + last_pos]) < 0x40)
271 break; 271 break;
272 } 272 }
273 } 273 }
274 module_info _ songs = 0; 274 module_info _ songs = 0;
275 parse_cmc_song(module_info, module, 0); 275 parse_cmc_song(module_info, module, 0);
276 for (pos = 0; pos < last_pos && module_info _ songs < ASAP_SONGS_MAX; pos++) 276 for (pos = 0; pos < last_pos && module_info _ songs < ASAP_SONGS_MAX; pos++)
277 if (UBYTE(module[0x206 + pos]) == 0x8f || UBYTE(module[0x206 + pos]) == 0xef) 277 if (UBYTE(module[0x206 + pos]) == 0x8f || UBYTE(module[0x206 + pos]) == 0xef)
278 parse_cmc_song(module_info, module, pos + 1); 278 parse_cmc_song(module_info, module, pos + 1);
279 return TRUE; 279 return TRUE;
280} 280}
281 281
282PRIVATE FUNC(abool, is_dlt_track_empty, (P(CONST BYTEARRAY, module), P(int, pos))) 282PRIVATE FUNC(abool, is_dlt_track_empty, (P(CONST BYTEARRAY, module), P(int, pos)))
283{ 283{
284 return UBYTE(module[0x2006 + pos]) >= 0x43 284 return UBYTE(module[0x2006 + pos]) >= 0x43
285 && UBYTE(module[0x2106 + pos]) >= 0x40 285 && UBYTE(module[0x2106 + pos]) >= 0x40
286 && UBYTE(module[0x2206 + pos]) >= 0x40 286 && UBYTE(module[0x2206 + pos]) >= 0x40
287 && UBYTE(module[0x2306 + pos]) >= 0x40; 287 && UBYTE(module[0x2306 + pos]) >= 0x40;
288} 288}
289 289
290PRIVATE FUNC(abool, is_dlt_pattern_end, (P(CONST BYTEARRAY, module), P(int, pos), P(int, i))) 290PRIVATE FUNC(abool, is_dlt_pattern_end, (P(CONST BYTEARRAY, module), P(int, pos), P(int, i)))
291{ 291{
292 V(int, ch); 292 V(int, ch);
293 for (ch = 0; ch < 4; ch++) { 293 for (ch = 0; ch < 4; ch++) {
294 V(int, pattern) = UBYTE(module[0x2006 + (ch << 8) + pos]); 294 V(int, pattern) = UBYTE(module[0x2006 + (ch << 8) + pos]);
295 if (pattern < 64) { 295 if (pattern < 64) {
296 V(int, offset) = 6 + (pattern << 7) + (i << 1); 296 V(int, offset) = 6 + (pattern << 7) + (i << 1);
297 if ((module[offset] & 0x80) == 0 && (module[offset + 1] & 0x80) != 0) 297 if ((module[offset] & 0x80) == 0 && (module[offset + 1] & 0x80) != 0)
298 return TRUE; 298 return TRUE;
299 } 299 }
300 } 300 }
301 return FALSE; 301 return FALSE;
302} 302}
303 303
304PRIVATE FUNC(void, parse_dlt_song, ( 304PRIVATE FUNC(void, parse_dlt_song, (
305 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), 305 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module),
306 P(BOOLARRAY, seen), P(int, pos))) 306 P(BOOLARRAY, seen), P(int, pos)))
307{ 307{
308 V(int, player_calls) = 0; 308 V(int, player_calls) = 0;
309 V(abool, loop) = FALSE; 309 V(abool, loop) = FALSE;
310 V(int, tempo) = 6; 310 V(int, tempo) = 6;
311 while (pos < 128 && !seen[pos] && is_dlt_track_empty(module, pos)) 311 while (pos < 128 && !seen[pos] && is_dlt_track_empty(module, pos))
312 seen[pos++] = TRUE; 312 seen[pos++] = TRUE;
313 module_info _ song_pos[module_info _ songs] = CAST(byte) pos; 313 module_info _ song_pos[module_info _ songs] = CAST(byte) pos;
314 while (pos < 128) { 314 while (pos < 128) {
315 V(int, p1); 315 V(int, p1);
316 if (seen[pos]) { 316 if (seen[pos]) {
317 loop = TRUE; 317 loop = TRUE;
318 break; 318 break;
319 } 319 }
320 seen[pos] = TRUE; 320 seen[pos] = TRUE;
321 p1 = module[0x2006 + pos]; 321 p1 = module[0x2006 + pos];
322 if (p1 == 0x40 || is_dlt_track_empty(module, pos)) 322 if (p1 == 0x40 || is_dlt_track_empty(module, pos))
323 break; 323 break;
324 if (p1 == 0x41) 324 if (p1 == 0x41)
325 pos = UBYTE(module[0x2086 + pos]); 325 pos = UBYTE(module[0x2086 + pos]);
326 else if (p1 == 0x42) 326 else if (p1 == 0x42)
327 tempo = UBYTE(module[0x2086 + pos++]); 327 tempo = UBYTE(module[0x2086 + pos++]);
328 else { 328 else {
329 V(int, i); 329 V(int, i);
330 for (i = 0; i < 64 && !is_dlt_pattern_end(module, pos, i); i++) 330 for (i = 0; i < 64 && !is_dlt_pattern_end(module, pos, i); i++)
331 player_calls += tempo; 331 player_calls += tempo;
332 pos++; 332 pos++;
333 } 333 }
334 } 334 }
335 if (player_calls > 0) { 335 if (player_calls > 0) {
336 module_info _ loops[module_info _ songs] = loop; 336 module_info _ loops[module_info _ songs] = loop;
337 set_song_duration(module_info, player_calls); 337 set_song_duration(module_info, player_calls);
338 } 338 }
339} 339}
340 340
341PRIVATE FUNC(abool, parse_dlt, ( 341PRIVATE FUNC(abool, parse_dlt, (
342 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 342 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
343 P(CONST BYTEARRAY, module), P(int, module_len))) 343 P(CONST BYTEARRAY, module), P(int, module_len)))
344{ 344{
345 V(int, pos); 345 V(int, pos);
346 NEW_ARRAY(abool, seen, 128); 346 NEW_ARRAY(abool, seen, 128);
347 if (module_len == 0x2c06) { 347 if (module_len == 0x2c06) {
348 if (ast != NULL) 348 if (ast != NULL)
349 ast _ memory[0x4c00] = 0; 349 ast _ memory[0x4c00] = 0;
350 } 350 }
351 else if (module_len != 0x2c07) 351 else if (module_len != 0x2c07)
352 return FALSE; 352 return FALSE;
353 module_info _ type = ASAP_TYPE_DLT; 353 module_info _ type = ASAP_TYPE_DLT;
354 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(dlt, obx)) 354 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(dlt, obx))
355 || module_info _ music != 0x2000) { 355 || module_info _ music != 0x2000) {
356 return FALSE; 356 return FALSE;
357 } 357 }
358 INIT_ARRAY(seen); 358 INIT_ARRAY(seen);
359 module_info _ songs = 0; 359 module_info _ songs = 0;
360 for (pos = 0; pos < 128 && module_info _ songs < ASAP_SONGS_MAX; pos++) { 360 for (pos = 0; pos < 128 && module_info _ songs < ASAP_SONGS_MAX; pos++) {
361 if (!seen[pos]) 361 if (!seen[pos])
362 parse_dlt_song(module_info, module, seen, pos); 362 parse_dlt_song(module_info, module, seen, pos);
363 } 363 }
364 return module_info _ songs > 0; 364 return module_info _ songs > 0;
365} 365}
366 366
367PRIVATE FUNC(void, parse_mpt_song, ( 367PRIVATE FUNC(void, parse_mpt_song, (
368 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), 368 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module),
369 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos))) 369 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos)))
370{ 370{
371 V(int, addr_to_offset) = UWORD(module, 2) - 6; 371 V(int, addr_to_offset) = UWORD(module, 2) - 6;
372 V(int, tempo) = UBYTE(module[0x1cf]); 372 V(int, tempo) = UBYTE(module[0x1cf]);
373 V(int, player_calls) = 0; 373 V(int, player_calls) = 0;
374 NEW_ARRAY(byte, seen, 256); 374 NEW_ARRAY(byte, seen, 256);
375 NEW_ARRAY(int, pattern_offset, 4); 375 NEW_ARRAY(int, pattern_offset, 4);
376 NEW_ARRAY(int, blank_rows, 4); 376 NEW_ARRAY(int, blank_rows, 4);
377 NEW_ARRAY(int, blank_rows_counter, 4); 377 NEW_ARRAY(int, blank_rows_counter, 4);
378 INIT_ARRAY(seen); 378 INIT_ARRAY(seen);
379 INIT_ARRAY(blank_rows); 379 INIT_ARRAY(blank_rows);
380 while (pos < song_len) { 380 while (pos < song_len) {
381 V(int, i); 381 V(int, i);
382 V(int, ch); 382 V(int, ch);
383 V(int, pattern_rows); 383 V(int, pattern_rows);
384 if (seen[pos] != 0) { 384 if (seen[pos] != 0) {
385 if (seen[pos] != SEEN_THIS_CALL) 385 if (seen[pos] != SEEN_THIS_CALL)
386 module_info _ loops[module_info _ songs] = TRUE; 386 module_info _ loops[module_info _ songs] = TRUE;
387 break; 387 break;
388 } 388 }
389 seen[pos] = SEEN_THIS_CALL; 389 seen[pos] = SEEN_THIS_CALL;
390 global_seen[pos] = TRUE; 390 global_seen[pos] = TRUE;
391 i = UBYTE(module[0x1d0 + pos * 2]); 391 i = UBYTE(module[0x1d0 + pos * 2]);
392 if (i == 0xff) { 392 if (i == 0xff) {
393 pos = UBYTE(module[0x1d1 + pos * 2]); 393 pos = UBYTE(module[0x1d1 + pos * 2]);
394 continue; 394 continue;
395 } 395 }
396 for (ch = 3; ch >= 0; ch--) { 396 for (ch = 3; ch >= 0; ch--) {
397 i = UBYTE(module[0x1c6 + ch]) + (UBYTE(module[0x1ca + ch]) << 8) - addr_to_offset; 397 i = UBYTE(module[0x1c6 + ch]) + (UBYTE(module[0x1ca + ch]) << 8) - addr_to_offset;
398 i = UBYTE(module[i + pos * 2]); 398 i = UBYTE(module[i + pos * 2]);
399 if (i >= 0x40) 399 if (i >= 0x40)
400 break; 400 break;
401 i <<= 1; 401 i <<= 1;
402 i = UWORD(module, 0x46 + i); 402 i = UWORD(module, 0x46 + i);
403 pattern_offset[ch] = i == 0 ? 0 : i - addr_to_offset; 403 pattern_offset[ch] = i == 0 ? 0 : i - addr_to_offset;
404 blank_rows_counter[ch] = 0; 404 blank_rows_counter[ch] = 0;
405 } 405 }
406 if (ch >= 0) 406 if (ch >= 0)
407 break; 407 break;
408 for (i = 0; i < song_len; i++) 408 for (i = 0; i < song_len; i++)
409 if (seen[i] == SEEN_THIS_CALL) 409 if (seen[i] == SEEN_THIS_CALL)
410 seen[i] = SEEN_BEFORE; 410 seen[i] = SEEN_BEFORE;
411 for (pattern_rows = UBYTE(module[0x1ce]); --pattern_rows >= 0; ) { 411 for (pattern_rows = UBYTE(module[0x1ce]); --pattern_rows >= 0; ) {
412 for (ch = 3; ch >= 0; ch--) { 412 for (ch = 3; ch >= 0; ch--) {
413 if (pattern_offset[ch] == 0 || --blank_rows_counter[ch] >= 0) 413 if (pattern_offset[ch] == 0 || --blank_rows_counter[ch] >= 0)
414 continue; 414 continue;
415 for (;;) { 415 for (;;) {
416 i = UBYTE(module[pattern_offset[ch]++]); 416 i = UBYTE(module[pattern_offset[ch]++]);
417 if (i < 0x40 || i == 0xfe) 417 if (i < 0x40 || i == 0xfe)
418 break; 418 break;
419 if (i < 0x80) 419 if (i < 0x80)
420 continue; 420 continue;
421 if (i < 0xc0) { 421 if (i < 0xc0) {
422 blank_rows[ch] = i - 0x80; 422 blank_rows[ch] = i - 0x80;
423 continue; 423 continue;
424 } 424 }
425 if (i < 0xd0) 425 if (i < 0xd0)
426 continue; 426 continue;
427 if (i < 0xe0) { 427 if (i < 0xe0) {
428 tempo = i - 0xcf; 428 tempo = i - 0xcf;
429 continue; 429 continue;
430 } 430 }
431 pattern_rows = 0; 431 pattern_rows = 0;
432 } 432 }
433 blank_rows_counter[ch] = blank_rows[ch]; 433 blank_rows_counter[ch] = blank_rows[ch];
434 } 434 }
435 player_calls += tempo; 435 player_calls += tempo;
436 } 436 }
437 pos++; 437 pos++;
438 } 438 }
439 if (player_calls > 0) 439 if (player_calls > 0)
440 set_song_duration(module_info, player_calls); 440 set_song_duration(module_info, player_calls);
441} 441}
442 442
443PRIVATE FUNC(abool, parse_mpt, ( 443PRIVATE FUNC(abool, parse_mpt, (
444 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 444 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
445 P(CONST BYTEARRAY, module), P(int, module_len))) 445 P(CONST BYTEARRAY, module), P(int, module_len)))
446{ 446{
447 V(int, track0_addr); 447 V(int, track0_addr);
448 V(int, pos); 448 V(int, pos);
449 V(int, song_len); 449 V(int, song_len);
450 /* seen[i] == TRUE if the track position i has been processed */ 450 /* seen[i] == TRUE if the track position i has been processed */
451 NEW_ARRAY(abool, global_seen, 256); 451 NEW_ARRAY(abool, global_seen, 256);
452 if (module_len < 0x1d0) 452 if (module_len < 0x1d0)
453 return FALSE; 453 return FALSE;
454 module_info _ type = ASAP_TYPE_MPT; 454 module_info _ type = ASAP_TYPE_MPT;
455 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(mpt, obx))) 455 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(mpt, obx)))
456 return FALSE; 456 return FALSE;
457 track0_addr = UWORD(module, 2) + 0x1ca; 457 track0_addr = UWORD(module, 2) + 0x1ca;
458 if (UBYTE(module[0x1c6]) + (UBYTE(module[0x1ca]) << 8) != track0_addr) 458 if (UBYTE(module[0x1c6]) + (UBYTE(module[0x1ca]) << 8) != track0_addr)
459 return FALSE; 459 return FALSE;
460 /* Calculate the length of the first track. Address of the second track minus 460 /* Calculate the length of the first track. Address of the second track minus
461 address of the first track equals the length of the first track in bytes. 461 address of the first track equals the length of the first track in bytes.
462 Divide by two to get number of track positions. */ 462 Divide by two to get number of track positions. */
463 song_len = (UBYTE(module[0x1c7]) + (UBYTE(module[0x1cb]) << 8) - track0_addr) >> 1; 463 song_len = (UBYTE(module[0x1c7]) + (UBYTE(module[0x1cb]) << 8) - track0_addr) >> 1;
464 if (song_len > 0xfe) 464 if (song_len > 0xfe)
465 return FALSE; 465 return FALSE;
466 INIT_ARRAY(global_seen); 466 INIT_ARRAY(global_seen);
467 module_info _ songs = 0; 467 module_info _ songs = 0;
468 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { 468 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) {
469 if (!global_seen[pos]) { 469 if (!global_seen[pos]) {
470 module_info _ song_pos[module_info _ songs] = CAST(byte) pos; 470 module_info _ song_pos[module_info _ songs] = CAST(byte) pos;
471 parse_mpt_song(module_info, module, global_seen, song_len, pos); 471 parse_mpt_song(module_info, module, global_seen, song_len, pos);
472 } 472 }
473 } 473 }
474 return module_info _ songs > 0; 474 return module_info _ songs > 0;
475} 475}
476 476
477CONST_ARRAY(byte, rmt_volume_silent) 477CONST_ARRAY(byte, rmt_volume_silent)
478 16, 8, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 478 16, 8, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1
479END_CONST_ARRAY; 479END_CONST_ARRAY;
480 480
481PRIVATE FUNC(int, rmt_instrument_frames, ( 481PRIVATE FUNC(int, rmt_instrument_frames, (
482 P(CONST BYTEARRAY, module), P(int, instrument), 482 P(CONST BYTEARRAY, module), P(int, instrument),
483 P(int, volume), P(int, volume_frame), P(abool, extra_pokey))) 483 P(int, volume), P(int, volume_frame), P(abool, extra_pokey)))
484{ 484{
485 V(int, addr_to_offset) = UWORD(module, 2) - 6; 485 V(int, addr_to_offset) = UWORD(module, 2) - 6;
486 V(int, per_frame) = module[0xc]; 486 V(int, per_frame) = module[0xc];
487 V(int, player_call); 487 V(int, player_call);
488 V(int, player_calls); 488 V(int, player_calls);
489 V(int, index); 489 V(int, index);
490 V(int, index_end); 490 V(int, index_end);
491 V(int, index_loop); 491 V(int, index_loop);
492 V(int, volume_slide_depth); 492 V(int, volume_slide_depth);
493 V(int, volume_min); 493 V(int, volume_min);
494 V(int, volume_slide); 494 V(int, volume_slide);
495 V(abool, silent_loop); 495 V(abool, silent_loop);
496 instrument = UWORD(module, 0xe) - addr_to_offset + (instrument << 1); 496 instrument = UWORD(module, 0xe) - addr_to_offset + (instrument << 1);
497 if (module[instrument + 1] == 0) 497 if (module[instrument + 1] == 0)
498 return 0; 498 return 0;
499 instrument = UWORD(module, instrument) - addr_to_offset; 499 instrument = UWORD(module, instrument) - addr_to_offset;
500 player_calls = player_call = volume_frame * per_frame; 500 player_calls = player_call = volume_frame * per_frame;
501 index = UBYTE(module[instrument]) + 1 + player_call * 3; 501 index = UBYTE(module[instrument]) + 1 + player_call * 3;
502 index_end = UBYTE(module[instrument + 2]) + 3; 502 index_end = UBYTE(module[instrument + 2]) + 3;
503 index_loop = UBYTE(module[instrument + 3]); 503 index_loop = UBYTE(module[instrument + 3]);
504 if (index_loop >= index_end) 504 if (index_loop >= index_end)
505 return 0; /* error */ 505 return 0; /* error */
506 volume_slide_depth = UBYTE(module[instrument + 6]); 506 volume_slide_depth = UBYTE(module[instrument + 6]);
507 volume_min = UBYTE(module[instrument + 7]); 507 volume_min = UBYTE(module[instrument + 7]);
508 if (index >= index_end) 508 if (index >= index_end)
509 index = (index - index_end) % (index_end - index_loop) + index_loop; 509 index = (index - index_end) % (index_end - index_loop) + index_loop;
510 else { 510 else {
511 do { 511 do {
512 V(int, vol) = module[instrument + index]; 512 V(int, vol) = module[instrument + index];
513 if (extra_pokey) 513 if (extra_pokey)
514 vol >>= 4; 514 vol >>= 4;
515 if ((vol & 0xf) >= rmt_volume_silent[volume]) 515 if ((vol & 0xf) >= rmt_volume_silent[volume])
516 player_calls = player_call + 1; 516 player_calls = player_call + 1;
517 player_call++; 517 player_call++;
518 index += 3; 518 index += 3;
519 } while (index < index_end); 519 } while (index < index_end);
520 } 520 }
521 if (volume_slide_depth == 0) 521 if (volume_slide_depth == 0)
522 return player_calls / per_frame; 522 return player_calls / per_frame;
523 volume_slide = 128; 523 volume_slide = 128;
524 silent_loop = FALSE; 524 silent_loop = FALSE;
525 for (;;) { 525 for (;;) {
526 V(int, vol); 526 V(int, vol);
527 if (index >= index_end) { 527 if (index >= index_end) {
528 if (silent_loop) 528 if (silent_loop)
529 break; 529 break;
530 silent_loop = TRUE; 530 silent_loop = TRUE;
531 index = index_loop; 531 index = index_loop;
532 } 532 }
533 vol = module[instrument + index]; 533 vol = module[instrument + index];
534 if (extra_pokey) 534 if (extra_pokey)
535 vol >>= 4; 535 vol >>= 4;
536 if ((vol & 0xf) >= rmt_volume_silent[volume]) { 536 if ((vol & 0xf) >= rmt_volume_silent[volume]) {
537 player_calls = player_call + 1; 537 player_calls = player_call + 1;
538 silent_loop = FALSE; 538 silent_loop = FALSE;
539 } 539 }
540 player_call++; 540 player_call++;
541 index += 3; 541 index += 3;
542 volume_slide -= volume_slide_depth; 542 volume_slide -= volume_slide_depth;
543 if (volume_slide < 0) { 543 if (volume_slide < 0) {
544 volume_slide += 256; 544 volume_slide += 256;
545 if (--volume <= volume_min) 545 if (--volume <= volume_min)
546 break; 546 break;
547 } 547 }
548 } 548 }
549 return player_calls / per_frame; 549 return player_calls / per_frame;
550} 550}
551 551
552PRIVATE FUNC(void, parse_rmt_song, ( 552PRIVATE FUNC(void, parse_rmt_song, (
553 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), 553 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module),
554 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos_shift), P(int, pos))) 554 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos_shift), P(int, pos)))
555{ 555{
556 V(int, ch); 556 V(int, ch);
557 V(int, addr_to_offset) = UWORD(module, 2) - 6; 557 V(int, addr_to_offset) = UWORD(module, 2) - 6;
558 V(int, tempo) = UBYTE(module[0xb]); 558 V(int, tempo) = UBYTE(module[0xb]);
559 V(int, frames) = 0; 559 V(int, frames) = 0;
560 V(int, song_offset) = UWORD(module, 0x14) - addr_to_offset; 560 V(int, song_offset) = UWORD(module, 0x14) - addr_to_offset;
561 V(int, pattern_lo_offset) = UWORD(module, 0x10) - addr_to_offset; 561 V(int, pattern_lo_offset) = UWORD(module, 0x10) - addr_to_offset;
562 V(int, pattern_hi_offset) = UWORD(module, 0x12) - addr_to_offset; 562 V(int, pattern_hi_offset) = UWORD(module, 0x12) - addr_to_offset;
563 V(int, instrument_frames); 563 V(int, instrument_frames);
564 NEW_ARRAY(byte, seen, 256); 564 NEW_ARRAY(byte, seen, 256);
565 NEW_ARRAY(int, pattern_begin, 8); 565 NEW_ARRAY(int, pattern_begin, 8);
566 NEW_ARRAY(int, pattern_offset, 8); 566 NEW_ARRAY(int, pattern_offset, 8);
567 NEW_ARRAY(int, blank_rows, 8); 567 NEW_ARRAY(int, blank_rows, 8);
568 NEW_ARRAY(int, instrument_no, 8); 568 NEW_ARRAY(int, instrument_no, 8);
569 NEW_ARRAY(int, instrument_frame, 8); 569 NEW_ARRAY(int, instrument_frame, 8);
570 NEW_ARRAY(int, volume_value, 8); 570 NEW_ARRAY(int, volume_value, 8);
571 NEW_ARRAY(int, volume_frame, 8); 571 NEW_ARRAY(int, volume_frame, 8);
572 INIT_ARRAY(seen); 572 INIT_ARRAY(seen);
573 INIT_ARRAY(instrument_no); 573 INIT_ARRAY(instrument_no);
574 INIT_ARRAY(instrument_frame); 574 INIT_ARRAY(instrument_frame);
575 INIT_ARRAY(volume_value); 575 INIT_ARRAY(volume_value);
576 INIT_ARRAY(volume_frame); 576 INIT_ARRAY(volume_frame);
577 while (pos < song_len) { 577 while (pos < song_len) {
578 V(int, i); 578 V(int, i);
579 V(int, pattern_rows); 579 V(int, pattern_rows);
580 if (seen[pos] != 0) { 580 if (seen[pos] != 0) {
581 if (seen[pos] != SEEN_THIS_CALL) 581 if (seen[pos] != SEEN_THIS_CALL)
582 module_info _ loops[module_info _ songs] = TRUE; 582 module_info _ loops[module_info _ songs] = TRUE;
583 break; 583 break;
584 } 584 }
585 seen[pos] = SEEN_THIS_CALL; 585 seen[pos] = SEEN_THIS_CALL;
586 global_seen[pos] = TRUE; 586 global_seen[pos] = TRUE;
587 if (UBYTE(module[song_offset + (pos << pos_shift)]) == 0xfe) { 587 if (UBYTE(module[song_offset + (pos << pos_shift)]) == 0xfe) {
588 pos = UBYTE(module[song_offset + (pos << pos_shift) + 1]); 588 pos = UBYTE(module[song_offset + (pos << pos_shift) + 1]);
589 continue; 589 continue;
590 } 590 }
591 for (ch = 0; ch < 1 << pos_shift; ch++) { 591 for (ch = 0; ch < 1 << pos_shift; ch++) {
592 i = UBYTE(module[song_offset + (pos << pos_shift) + ch]); 592 i = UBYTE(module[song_offset + (pos << pos_shift) + ch]);
593 if (i == 0xff) 593 if (i == 0xff)
594 blank_rows[ch] = 256; 594 blank_rows[ch] = 256;
595 else { 595 else {
596 pattern_offset[ch] = pattern_begin[ch] = UBYTE(module[pattern_lo_offset + i]) 596 pattern_offset[ch] = pattern_begin[ch] = UBYTE(module[pattern_lo_offset + i])
597 + (UBYTE(module[pattern_hi_offset + i]) << 8) - addr_to_offset; 597 + (UBYTE(module[pattern_hi_offset + i]) << 8) - addr_to_offset;
598 blank_rows[ch] = 0; 598 blank_rows[ch] = 0;
599 } 599 }
600 } 600 }
601 for (i = 0; i < song_len; i++) 601 for (i = 0; i < song_len; i++)
602 if (seen[i] == SEEN_THIS_CALL) 602 if (seen[i] == SEEN_THIS_CALL)
603 seen[i] = SEEN_BEFORE; 603 seen[i] = SEEN_BEFORE;
604 for (pattern_rows = UBYTE(module[0xa]); --pattern_rows >= 0; ) { 604 for (pattern_rows = UBYTE(module[0xa]); --pattern_rows >= 0; ) {
605 for (ch = 0; ch < 1 << pos_shift; ch++) { 605 for (ch = 0; ch < 1 << pos_shift; ch++) {
606 if (--blank_rows[ch] > 0) 606 if (--blank_rows[ch] > 0)
607 continue; 607 continue;
608 for (;;) { 608 for (;;) {
609 i = UBYTE(module[pattern_offset[ch]++]); 609 i = UBYTE(module[pattern_offset[ch]++]);
610 if ((i & 0x3f) < 62) { 610 if ((i & 0x3f) < 62) {
611 i += UBYTE(module[pattern_offset[ch]++]) << 8; 611 i += UBYTE(module[pattern_offset[ch]++]) << 8;
612 if ((i & 0x3f) != 61) { 612 if ((i & 0x3f) != 61) {
613 instrument_no[ch] = i >> 10; 613 instrument_no[ch] = i >> 10;
614 instrument_frame[ch] = frames; 614 instrument_frame[ch] = frames;
615 } 615 }
616 volume_value[ch] = (i >> 6) & 0xf; 616 volume_value[ch] = (i >> 6) & 0xf;
617 volume_frame[ch] = frames; 617 volume_frame[ch] = frames;
618 break; 618 break;
619 } 619 }
620 if (i == 62) { 620 if (i == 62) {
621 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); 621 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]);
622 break; 622 break;
623 } 623 }
624 if ((i & 0x3f) == 62) { 624 if ((i & 0x3f) == 62) {
625 blank_rows[ch] = i >> 6; 625 blank_rows[ch] = i >> 6;
626 break; 626 break;
627 } 627 }
628 if ((i & 0xbf) == 63) { 628 if ((i & 0xbf) == 63) {
629 tempo = UBYTE(module[pattern_offset[ch]++]); 629 tempo = UBYTE(module[pattern_offset[ch]++]);
630 continue; 630 continue;
631 } 631 }
632 if (i == 0xbf) { 632 if (i == 0xbf) {
633 pattern_offset[ch] = pattern_begin[ch] + UBYTE(module[pattern_offset[ch]]); 633 pattern_offset[ch] = pattern_begin[ch] + UBYTE(module[pattern_offset[ch]]);
634 continue; 634 continue;
635 } 635 }
636 /* assert(i == 0xff); */ 636 /* assert(i == 0xff); */
637 pattern_rows = -1; 637 pattern_rows = -1;
638 break; 638 break;
639 } 639 }
640 if (pattern_rows < 0) 640 if (pattern_rows < 0)
641 break; 641 break;
642 } 642 }
643 if (pattern_rows >= 0) 643 if (pattern_rows >= 0)
644 frames += tempo; 644 frames += tempo;
645 } 645 }
646 pos++; 646 pos++;
647 } 647 }
648 instrument_frames = 0; 648 instrument_frames = 0;
649 for (ch = 0; ch < 1 << pos_shift; ch++) { 649 for (ch = 0; ch < 1 << pos_shift; ch++) {
650 V(int, frame) = instrument_frame[ch]; 650 V(int, frame) = instrument_frame[ch];
651 frame += rmt_instrument_frames(module, instrument_no[ch], volume_value[ch], volume_frame[ch] - frame, ch >= 4); 651 frame += rmt_instrument_frames(module, instrument_no[ch], volume_value[ch], volume_frame[ch] - frame, ch >= 4);
652 if (instrument_frames < frame) 652 if (instrument_frames < frame)
653 instrument_frames = frame; 653 instrument_frames = frame;
654 } 654 }
655 if (frames > instrument_frames) { 655 if (frames > instrument_frames) {
656 if (frames - instrument_frames > 100) 656 if (frames - instrument_frames > 100)
657 module_info _ loops[module_info _ songs] = FALSE; 657 module_info _ loops[module_info _ songs] = FALSE;
658 frames = instrument_frames; 658 frames = instrument_frames;
659 } 659 }
660 if (frames > 0) 660 if (frames > 0)
661 set_song_duration(module_info, frames); 661 set_song_duration(module_info, frames);
662} 662}
663 663
664PRIVATE FUNC(abool, parse_rmt, ( 664PRIVATE FUNC(abool, parse_rmt, (
665 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 665 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
666 P(CONST BYTEARRAY, module), P(int, module_len))) 666 P(CONST BYTEARRAY, module), P(int, module_len)))
667{ 667{
668 V(int, per_frame); 668 V(int, per_frame);
669 V(int, pos_shift); 669 V(int, pos_shift);
670 V(int, song_len); 670 V(int, song_len);
671 V(int, pos); 671 V(int, pos);
672 NEW_ARRAY(abool, global_seen, 256); 672 NEW_ARRAY(abool, global_seen, 256);
673 if (module_len < 0x30 || module[6] != CHARCODE('R') || module[7] != CHARCODE('M') 673 if (module_len < 0x30 || module[6] != CHARCODE('R') || module[7] != CHARCODE('M')
674 || module[8] != CHARCODE('T') || module[0xd] != 1) 674 || module[8] != CHARCODE('T') || module[0xd] != 1)
675 return FALSE; 675 return FALSE;
676 switch (CAST(char) module[9]) { 676 switch (CAST(char) module[9]) {
677 case CHARCODE('4'): 677 case CHARCODE('4'):
678 pos_shift = 2; 678 pos_shift = 2;
679 break; 679 break;
680 case CHARCODE('8'): 680 case CHARCODE('8'):
681 module_info _ channels = 2; 681 module_info _ channels = 2;
682 pos_shift = 3; 682 pos_shift = 3;
683 break; 683 break;
684 default: 684 default:
685 return FALSE; 685 return FALSE;
686 } 686 }
687 per_frame = module[0xc]; 687 per_frame = module[0xc];
688 if (per_frame < 1 || per_frame > 4) 688 if (per_frame < 1 || per_frame > 4)
689 return FALSE; 689 return FALSE;
690 module_info _ type = ASAP_TYPE_RMT; 690 module_info _ type = ASAP_TYPE_RMT;
691 if (!load_native(ast, module_info, module, module_len, 691 if (!load_native(ast, module_info, module, module_len,
692 module_info _ channels == 2 ? GET_RESOURCE(rmt8, obx) : GET_RESOURCE(rmt4, obx))) 692 module_info _ channels == 2 ? GET_RESOURCE(rmt8, obx) : GET_RESOURCE(rmt4, obx)))
693 return FALSE; 693 return FALSE;
694 song_len = UWORD(module, 4) + 1 - UWORD(module, 0x14); 694 song_len = UWORD(module, 4) + 1 - UWORD(module, 0x14);
695 if (pos_shift == 3 && (song_len & 4) != 0 695 if (pos_shift == 3 && (song_len & 4) != 0
696 && UBYTE(module[6 + UWORD(module, 4) - UWORD(module, 2) - 3]) == 0xfe) 696 && UBYTE(module[6 + UWORD(module, 4) - UWORD(module, 2) - 3]) == 0xfe)
697 song_len += 4; 697 song_len += 4;
698 song_len >>= pos_shift; 698 song_len >>= pos_shift;
699 if (song_len >= 0x100) 699 if (song_len >= 0x100)
700 return FALSE; 700 return FALSE;
701 INIT_ARRAY(global_seen); 701 INIT_ARRAY(global_seen);
702 module_info _ songs = 0; 702 module_info _ songs = 0;
703 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { 703 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) {
704 if (!global_seen[pos]) { 704 if (!global_seen[pos]) {
705 module_info _ song_pos[module_info _ songs] = CAST(byte) pos; 705 module_info _ song_pos[module_info _ songs] = CAST(byte) pos;
706 parse_rmt_song(module_info, module, global_seen, song_len, pos_shift, pos); 706 parse_rmt_song(module_info, module, global_seen, song_len, pos_shift, pos);
707 } 707 }
708 } 708 }
709 /* must set fastplay after song durations calculations, so they assume 312 */ 709 /* must set fastplay after song durations calculations, so they assume 312 */
710 module_info _ fastplay = perframe2fastplay[per_frame - 1]; 710 module_info _ fastplay = perframe2fastplay[per_frame - 1];
711 module_info _ player = 0x600; 711 module_info _ player = 0x600;
712 return module_info _ songs > 0; 712 return module_info _ songs > 0;
713} 713}
714 714
715PRIVATE FUNC(void, parse_tmc_song, ( 715PRIVATE FUNC(void, parse_tmc_song, (
716 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) 716 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos)))
717{ 717{
718 V(int, addr_to_offset) = UWORD(module, 2) - 6; 718 V(int, addr_to_offset) = UWORD(module, 2) - 6;
719 V(int, tempo) = UBYTE(module[0x24]) + 1; 719 V(int, tempo) = UBYTE(module[0x24]) + 1;
720 V(int, frames) = 0; 720 V(int, frames) = 0;
721 NEW_ARRAY(int, pattern_offset, 8); 721 NEW_ARRAY(int, pattern_offset, 8);
722 NEW_ARRAY(int, blank_rows, 8); 722 NEW_ARRAY(int, blank_rows, 8);
723 while (UBYTE(module[0x1a6 + 15 + pos]) < 0x80) { 723 while (UBYTE(module[0x1a6 + 15 + pos]) < 0x80) {
724 V(int, ch); 724 V(int, ch);
725 V(int, pattern_rows); 725 V(int, pattern_rows);
726 for (ch = 7; ch >= 0; ch--) { 726 for (ch = 7; ch >= 0; ch--) {
727 V(int, pat) = UBYTE(module[0x1a6 + 15 + pos - 2 * ch]); 727 V(int, pat) = UBYTE(module[0x1a6 + 15 + pos - 2 * ch]);
728 pattern_offset[ch] = UBYTE(module[0xa6 + pat]) + (UBYTE(module[0x126 + pat]) << 8) - addr_to_offset; 728 pattern_offset[ch] = UBYTE(module[0xa6 + pat]) + (UBYTE(module[0x126 + pat]) << 8) - addr_to_offset;
729 blank_rows[ch] = 0; 729 blank_rows[ch] = 0;
730 } 730 }
731 for (pattern_rows = 64; --pattern_rows >= 0; ) { 731 for (pattern_rows = 64; --pattern_rows >= 0; ) {
732 for (ch = 7; ch >= 0; ch--) { 732 for (ch = 7; ch >= 0; ch--) {
733 if (--blank_rows[ch] >= 0) 733 if (--blank_rows[ch] >= 0)
734 continue; 734 continue;
735 for (;;) { 735 for (;;) {
736 V(int, i) = UBYTE(module[pattern_offset[ch]++]); 736 V(int, i) = UBYTE(module[pattern_offset[ch]++]);
737 if (i < 0x40) { 737 if (i < 0x40) {
738 pattern_offset[ch]++; 738 pattern_offset[ch]++;
739 break; 739 break;
740 } 740 }
741 if (i == 0x40) { 741 if (i == 0x40) {
742 i = UBYTE(module[pattern_offset[ch]++]); 742 i = UBYTE(module[pattern_offset[ch]++]);
743 if ((i & 0x7f) == 0) 743 if ((i & 0x7f) == 0)
744 pattern_rows = 0; 744 pattern_rows = 0;
745 else 745 else
746 tempo = (i & 0x7f) + 1; 746 tempo = (i & 0x7f) + 1;
747 if (i >= 0x80) 747 if (i >= 0x80)
748 pattern_offset[ch]++; 748 pattern_offset[ch]++;
749 break; 749 break;
750 } 750 }
751 if (i < 0x80) { 751 if (i < 0x80) {
752 i = module[pattern_offset[ch]++] & 0x7f; 752 i = module[pattern_offset[ch]++] & 0x7f;
753 if (i == 0) 753 if (i == 0)
754 pattern_rows = 0; 754 pattern_rows = 0;
755 else 755 else
756 tempo = i + 1; 756 tempo = i + 1;
757 pattern_offset[ch]++; 757 pattern_offset[ch]++;
758 break; 758 break;
759 } 759 }
760 if (i < 0xc0) 760 if (i < 0xc0)
761 continue; 761 continue;
762 blank_rows[ch] = i - 0xbf; 762 blank_rows[ch] = i - 0xbf;
763 break; 763 break;
764 } 764 }
765 } 765 }
766 frames += tempo; 766 frames += tempo;
767 } 767 }
768 pos += 16; 768 pos += 16;
769 } 769 }
770 if (UBYTE(module[0x1a6 + 14 + pos]) < 0x80) 770 if (UBYTE(module[0x1a6 + 14 + pos]) < 0x80)
771 module_info _ loops[module_info _ songs] = TRUE; 771 module_info _ loops[module_info _ songs] = TRUE;
772 set_song_duration(module_info, frames); 772 set_song_duration(module_info, frames);
773} 773}
774 774
775PRIVATE FUNC(abool, parse_tmc, ( 775PRIVATE FUNC(abool, parse_tmc, (
776 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 776 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
777 P(CONST BYTEARRAY, module), P(int, module_len))) 777 P(CONST BYTEARRAY, module), P(int, module_len)))
778{ 778{
779 V(int, i); 779 V(int, i);
780 V(int, last_pos); 780 V(int, last_pos);
781 if (module_len < 0x1d0) 781 if (module_len < 0x1d0)
782 return FALSE; 782 return FALSE;
783 module_info _ type = ASAP_TYPE_TMC; 783 module_info _ type = ASAP_TYPE_TMC;
784 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tmc, obx))) 784 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tmc, obx)))
785 return FALSE; 785 return FALSE;
786 module_info _ channels = 2; 786 module_info _ channels = 2;
787 i = 0; 787 i = 0;
788 /* find first instrument */ 788 /* find first instrument */
789 while (module[0x66 + i] == 0) { 789 while (module[0x66 + i] == 0) {
790 if (++i >= 64) 790 if (++i >= 64)
791 return FALSE; /* no instrument */ 791 return FALSE; /* no instrument */
792 } 792 }
793 last_pos = (UBYTE(module[0x66 + i]) << 8) + UBYTE(module[0x26 + i]) 793 last_pos = (UBYTE(module[0x66 + i]) << 8) + UBYTE(module[0x26 + i])
794 - UWORD(module, 2) - 0x1b0; 794 - UWORD(module, 2) - 0x1b0;
795 if (0x1b5 + last_pos >= module_len) 795 if (0x1b5 + last_pos >= module_len)
796 return FALSE; 796 return FALSE;
797 /* skip trailing jumps */ 797 /* skip trailing jumps */
798 do { 798 do {
799 if (last_pos <= 0) 799 if (last_pos <= 0)
800 return FALSE; /* no pattern to play */ 800 return FALSE; /* no pattern to play */
801 last_pos -= 16; 801 last_pos -= 16;
802 } while (UBYTE(module[0x1b5 + last_pos]) >= 0x80); 802 } while (UBYTE(module[0x1b5 + last_pos]) >= 0x80);
803 module_info _ songs = 0; 803 module_info _ songs = 0;
804 parse_tmc_song(module_info, module, 0); 804 parse_tmc_song(module_info, module, 0);
805 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 16) 805 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 16)
806 if (UBYTE(module[0x1b5 + i]) >= 0x80) 806 if (UBYTE(module[0x1b5 + i]) >= 0x80)
807 parse_tmc_song(module_info, module, i + 16); 807 parse_tmc_song(module_info, module, i + 16);
808 /* must set fastplay after song durations calculations, so they assume 312 */ 808 /* must set fastplay after song durations calculations, so they assume 312 */
809 i = module[0x25]; 809 i = module[0x25];
810 if (i < 1 || i > 4) 810 if (i < 1 || i > 4)
811 return FALSE; 811 return FALSE;
812 if (ast != NULL) 812 if (ast != NULL)
813 ast _ tmc_per_frame = module[0x25]; 813 ast _ tmc_per_frame = module[0x25];
814 module_info _ fastplay = perframe2fastplay[i - 1]; 814 module_info _ fastplay = perframe2fastplay[i - 1];
815 return TRUE; 815 return TRUE;
816} 816}
817 817
818PRIVATE FUNC(void, parse_tm2_song, ( 818PRIVATE FUNC(void, parse_tm2_song, (
819 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) 819 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos)))
820{ 820{
821 V(int, addr_to_offset) = UWORD(module, 2) - 6; 821 V(int, addr_to_offset) = UWORD(module, 2) - 6;
822 V(int, tempo) = UBYTE(module[0x24]) + 1; 822 V(int, tempo) = UBYTE(module[0x24]) + 1;
823 V(int, player_calls) = 0; 823 V(int, player_calls) = 0;
824 NEW_ARRAY(int, pattern_offset, 8); 824 NEW_ARRAY(int, pattern_offset, 8);
825 NEW_ARRAY(int, blank_rows, 8); 825 NEW_ARRAY(int, blank_rows, 8);
826 for (;;) { 826 for (;;) {
827 V(int, ch); 827 V(int, ch);
828 V(int, pattern_rows) = UBYTE(module[0x386 + 16 + pos]); 828 V(int, pattern_rows) = UBYTE(module[0x386 + 16 + pos]);
829 if (pattern_rows == 0) 829 if (pattern_rows == 0)
830 break; 830 break;
831 if (pattern_rows >= 0x80) { 831 if (pattern_rows >= 0x80) {
832 module_info _ loops[module_info _ songs] = TRUE; 832 module_info _ loops[module_info _ songs] = TRUE;
833 break; 833 break;
834 } 834 }
835 for (ch = 7; ch >= 0; ch--) { 835 for (ch = 7; ch >= 0; ch--) {
836 V(int, pat) = UBYTE(module[0x386 + 15 + pos - 2 * ch]); 836 V(int, pat) = UBYTE(module[0x386 + 15 + pos - 2 * ch]);
837 pattern_offset[ch] = UBYTE(module[0x106 + pat]) + (UBYTE(module[0x206 + pat]) << 8) - addr_to_offset; 837 pattern_offset[ch] = UBYTE(module[0x106 + pat]) + (UBYTE(module[0x206 + pat]) << 8) - addr_to_offset;
838 blank_rows[ch] = 0; 838 blank_rows[ch] = 0;
839 } 839 }
840 while (--pattern_rows >= 0) { 840 while (--pattern_rows >= 0) {
841 for (ch = 7; ch >= 0; ch--) { 841 for (ch = 7; ch >= 0; ch--) {
842 if (--blank_rows[ch] >= 0) 842 if (--blank_rows[ch] >= 0)
843 continue; 843 continue;
844 for (;;) { 844 for (;;) {
845 V(int, i) = UBYTE(module[pattern_offset[ch]++]); 845 V(int, i) = UBYTE(module[pattern_offset[ch]++]);
846 if (i == 0) { 846 if (i == 0) {
847 pattern_offset[ch]++; 847 pattern_offset[ch]++;
848 break; 848 break;
849 } 849 }
850 if (i < 0x40) { 850 if (i < 0x40) {
851 if (UBYTE(module[pattern_offset[ch]++]) >= 0x80) 851 if (UBYTE(module[pattern_offset[ch]++]) >= 0x80)
852 pattern_offset[ch]++; 852 pattern_offset[ch]++;
853 break; 853 break;
854 } 854 }
855 if (i < 0x80) { 855 if (i < 0x80) {
856 pattern_offset[ch]++; 856 pattern_offset[ch]++;
857 break; 857 break;
858 } 858 }
859 if (i == 0x80) { 859 if (i == 0x80) {
860 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); 860 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]);
861 break; 861 break;
862 } 862 }
863 if (i < 0xc0) 863 if (i < 0xc0)
864 break; 864 break;
865 if (i < 0xd0) { 865 if (i < 0xd0) {
866 tempo = i - 0xbf; 866 tempo = i - 0xbf;
867 continue; 867 continue;
868 } 868 }
869 if (i < 0xe0) { 869 if (i < 0xe0) {
870 pattern_offset[ch]++; 870 pattern_offset[ch]++;
871 break; 871 break;
872 } 872 }
873 if (i < 0xf0) { 873 if (i < 0xf0) {
874 pattern_offset[ch] += 2; 874 pattern_offset[ch] += 2;
875 break; 875 break;
876 } 876 }
877 if (i < 0xff) { 877 if (i < 0xff) {
878 blank_rows[ch] = i - 0xf0; 878 blank_rows[ch] = i - 0xf0;
879 break; 879 break;
880 } 880 }
881 blank_rows[ch] = 64; 881 blank_rows[ch] = 64;
882 break; 882 break;
883 } 883 }
884 } 884 }
885 player_calls += tempo; 885 player_calls += tempo;
886 } 886 }
887 pos += 17; 887 pos += 17;
888 } 888 }
889 set_song_duration(module_info, player_calls); 889 set_song_duration(module_info, player_calls);
890} 890}
891 891
892PRIVATE FUNC(abool, parse_tm2, ( 892PRIVATE FUNC(abool, parse_tm2, (
893 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 893 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
894 P(CONST BYTEARRAY, module), P(int, module_len))) 894 P(CONST BYTEARRAY, module), P(int, module_len)))
895{ 895{
896 V(int, i); 896 V(int, i);
897 V(int, last_pos); 897 V(int, last_pos);
898 V(int, c); 898 V(int, c);
899 if (module_len < 0x3a4) 899 if (module_len < 0x3a4)
900 return FALSE; 900 return FALSE;
901 module_info _ type = ASAP_TYPE_TM2; 901 module_info _ type = ASAP_TYPE_TM2;
902 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tm2, obx))) 902 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tm2, obx)))
903 return FALSE; 903 return FALSE;
904 i = module[0x25]; 904 i = module[0x25];
905 if (i < 1 || i > 4) 905 if (i < 1 || i > 4)
906 return FALSE; 906 return FALSE;
907 module_info _ fastplay = perframe2fastplay[i - 1]; 907 module_info _ fastplay = perframe2fastplay[i - 1];
908 module_info _ player = 0x500; 908 module_info _ player = 0x500;
909 if (module[0x1f] != 0) 909 if (module[0x1f] != 0)
910 module_info _ channels = 2; 910 module_info _ channels = 2;
911 last_pos = 0xffff; 911 last_pos = 0xffff;
912 for (i = 0; i < 0x80; i++) { 912 for (i = 0; i < 0x80; i++) {
913 V(int, instr_addr) = UBYTE(module[0x86 + i]) + (UBYTE(module[0x306 + i]) << 8); 913 V(int, instr_addr) = UBYTE(module[0x86 + i]) + (UBYTE(module[0x306 + i]) << 8);
914 if (instr_addr != 0 && instr_addr < last_pos) 914 if (instr_addr != 0 && instr_addr < last_pos)
915 last_pos = instr_addr; 915 last_pos = instr_addr;
916 } 916 }
917 for (i = 0; i < 0x100; i++) { 917 for (i = 0; i < 0x100; i++) {
918 V(int, pattern_addr) = UBYTE(module[0x106 + i]) + (UBYTE(module[0x206 + i]) << 8); 918 V(int, pattern_addr) = UBYTE(module[0x106 + i]) + (UBYTE(module[0x206 + i]) << 8);
919 if (pattern_addr != 0 && pattern_addr < last_pos) 919 if (pattern_addr != 0 && pattern_addr < last_pos)
920 last_pos = pattern_addr; 920 last_pos = pattern_addr;
921 } 921 }
922 last_pos -= UWORD(module, 2) + 0x380; 922 last_pos -= UWORD(module, 2) + 0x380;
923 if (0x386 + last_pos >= module_len) 923 if (0x386 + last_pos >= module_len)
924 return FALSE; 924 return FALSE;
925 /* skip trailing stop/jump commands */ 925 /* skip trailing stop/jump commands */
926 do { 926 do {
927 if (last_pos <= 0) 927 if (last_pos <= 0)
928 return FALSE; 928 return FALSE;
929 last_pos -= 17; 929 last_pos -= 17;
930 c = UBYTE(module[0x386 + 16 + last_pos]); 930 c = UBYTE(module[0x386 + 16 + last_pos]);
931 } while (c == 0 || c >= 0x80); 931 } while (c == 0 || c >= 0x80);
932 module_info _ songs = 0; 932 module_info _ songs = 0;
933 parse_tm2_song(module_info, module, 0); 933 parse_tm2_song(module_info, module, 0);
934 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 17) { 934 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 17) {
935 c = UBYTE(module[0x386 + 16 + i]); 935 c = UBYTE(module[0x386 + 16 + i]);
936 if (c == 0 || c >= 0x80) 936 if (c == 0 || c >= 0x80)
937 parse_tm2_song(module_info, module, i + 17); 937 parse_tm2_song(module_info, module, i + 17);
938 } 938 }
939 return TRUE; 939 return TRUE;
940} 940}
941 941
942#endif /* ASAP_ONLY_SAP */ 942#endif /* ASAP_ONLY_SAP */
943 943
944PRIVATE FUNC(abool, has_string_at, (P(CONST BYTEARRAY, module), P(int, module_index), P(STRING, s))) 944PRIVATE FUNC(abool, has_string_at, (P(CONST BYTEARRAY, module), P(int, module_index), P(STRING, s)))
945{ 945{
946 V(int, i); 946 V(int, i);
947 V(int, n) = strlen(s); 947 V(int, n) = strlen(s);
948 for (i = 0; i < n; i++) 948 for (i = 0; i < n; i++)
949 if (module[module_index + i] != CHARCODEAT(s, i)) 949 if (module[module_index + i] != CHARCODEAT(s, i))
950 return FALSE; 950 return FALSE;
951 return TRUE; 951 return TRUE;
952} 952}
953 953
954PRIVATE FUNC(STRING, parse_text, (P(OUT_STRING, dest), P(CONST BYTEARRAY, module), P(int, module_index))) 954PRIVATE FUNC(STRING, parse_text, (P(OUT_STRING, dest), P(CONST BYTEARRAY, module), P(int, module_index)))
955{ 955{
956 V(int, i); 956 V(int, i);
957 if (module[module_index] != CHARCODE('"')) 957 if (module[module_index] != CHARCODE('"'))
958 return NULL; 958 return NULL;
959 if (has_string_at(module, module_index + 1, "<?>\"")) 959 if (has_string_at(module, module_index + 1, "<?>\""))
960 return dest; 960 return dest;
961 for (i = 0; ; i++) { 961 for (i = 0; ; i++) {
962 V(int, c) = module[module_index + 1 + i]; 962 V(int, c) = module[module_index + 1 + i];
963 if (c == CHARCODE('"')) 963 if (c == CHARCODE('"'))
964 break; 964 break;
965 if (c < 32 || c >= 127) 965 if (c < 32 || c >= 127)
966 return NULL; 966 return NULL;
967 } 967 }
968 BYTES_TO_STRING(dest, module, module_index + 1, i); 968 BYTES_TO_STRING(dest, module, module_index + 1, i);
969 return dest; 969 return dest;
970} 970}
971 971
972PRIVATE FUNC(int, parse_dec, (P(CONST BYTEARRAY, module), P(int, module_index), P(int, maxval))) 972PRIVATE FUNC(int, parse_dec, (P(CONST BYTEARRAY, module), P(int, module_index), P(int, maxval)))
973{ 973{
974 V(int, r); 974 V(int, r);
975 if (module[module_index] == 0xd) 975 if (module[module_index] == 0xd)
976 return -1; 976 return -1;
977 for (r = 0;;) { 977 for (r = 0;;) {
978 V(int, c) = module[module_index++]; 978 V(int, c) = module[module_index++];
979 if (c == 0xd) 979 if (c == 0xd)
980 break; 980 break;
981 if (c < CHARCODE('0') || c > CHARCODE('9')) 981 if (c < CHARCODE('0') || c > CHARCODE('9'))
982 return -1; 982 return -1;
983 r = 10 * r + c - 48; 983 r = 10 * r + c - 48;
984 if (r > maxval) 984 if (r > maxval)
985 return -1; 985 return -1;
986 } 986 }
987 return r; 987 return r;
988} 988}
989 989
990PRIVATE FUNC(int, parse_hex, (P(CONST BYTEARRAY, module), P(int, module_index))) 990PRIVATE FUNC(int, parse_hex, (P(CONST BYTEARRAY, module), P(int, module_index)))
991{ 991{
992 V(int, r); 992 V(int, r);
993 if (module[module_index] == 0xd) 993 if (module[module_index] == 0xd)
994 return -1; 994 return -1;
995 for (r = 0;;) { 995 for (r = 0;;) {
996 V(int, c) = module[module_index++]; 996 V(int, c) = module[module_index++];
997 if (c == 0xd) 997 if (c == 0xd)
998 break; 998 break;
999 if (r > 0xfff) 999 if (r > 0xfff)
1000 return -1; 1000 return -1;
1001 r <<= 4; 1001 r <<= 4;
1002 if (c >= CHARCODE('0') && c <= CHARCODE('9')) 1002 if (c >= CHARCODE('0') && c <= CHARCODE('9'))
1003 r += c - CHARCODE('0'); 1003 r += c - CHARCODE('0');
1004 else if (c >= CHARCODE('A') && c <= CHARCODE('F')) 1004 else if (c >= CHARCODE('A') && c <= CHARCODE('F'))
1005 r += c - CHARCODE('A') + 10; 1005 r += c - CHARCODE('A') + 10;
1006 else if (c >= CHARCODE('a') && c <= CHARCODE('f')) 1006 else if (c >= CHARCODE('a') && c <= CHARCODE('f'))
1007 r += c - CHARCODE('a') + 10; 1007 r += c - CHARCODE('a') + 10;
1008 else 1008 else
1009 return -1; 1009 return -1;
1010 } 1010 }
1011 return r; 1011 return r;
1012} 1012}
1013 1013
1014FUNC(int, ASAP_ParseDuration, (P(STRING, s))) 1014FUNC(int, ASAP_ParseDuration, (P(STRING, s)))
1015{ 1015{
1016 V(int, i) = 0; 1016 V(int, i) = 0;
1017 V(int, r); 1017 V(int, r);
1018 V(int, d); 1018 V(int, d);
1019 V(int, n) = strlen(s); 1019 V(int, n) = strlen(s);
1020#define PARSE_DIGIT(maxdig, retifnot) \ 1020#define PARSE_DIGIT(maxdig, retifnot) \
1021 if (i >= n) \ 1021 if (i >= n) \
1022 return retifnot; \ 1022 return retifnot; \
1023 d = CHARCODEAT(s, i) - 48; \ 1023 d = CHARCODEAT(s, i) - 48; \
1024 if (d < 0 || d > maxdig) \ 1024 if (d < 0 || d > maxdig) \
1025 return -1; \ 1025 return -1; \
1026 i++; 1026 i++;
1027 1027
1028 PARSE_DIGIT(9, -1); 1028 PARSE_DIGIT(9, -1);
1029 r = d; 1029 r = d;
1030 if (i < n) { 1030 if (i < n) {
1031 d = CHARCODEAT(s, i) - 48; 1031 d = CHARCODEAT(s, i) - 48;
1032 if (d >= 0 && d <= 9) { 1032 if (d >= 0 && d <= 9) {
1033 i++; 1033 i++;
1034 r = 10 * r + d; 1034 r = 10 * r + d;
1035 } 1035 }
1036 if (i < n && CHARAT(s, i) == ':') { 1036 if (i < n && CHARAT(s, i) == ':') {
1037 i++; 1037 i++;
1038 PARSE_DIGIT(5, -1); 1038 PARSE_DIGIT(5, -1);
1039 r = (6 * r + d) * 10; 1039 r = (6 * r + d) * 10;
1040 PARSE_DIGIT(9, -1); 1040 PARSE_DIGIT(9, -1);
1041 r += d; 1041 r += d;
1042 } 1042 }
1043 } 1043 }
1044 r *= 1000; 1044 r *= 1000;
1045 if (i >= n) 1045 if (i >= n)
1046 return r; 1046 return r;
1047 if (CHARAT(s, i) != '.') 1047 if (CHARAT(s, i) != '.')
1048 return -1; 1048 return -1;
1049 i++; 1049 i++;
1050 PARSE_DIGIT(9, -1); 1050 PARSE_DIGIT(9, -1);
1051 r += 100 * d; 1051 r += 100 * d;
1052 PARSE_DIGIT(9, r); 1052 PARSE_DIGIT(9, r);
1053 r += 10 * d; 1053 r += 10 * d;
1054 PARSE_DIGIT(9, r); 1054 PARSE_DIGIT(9, r);
1055 r += d; 1055 r += d;
1056 return r; 1056 return r;
1057} 1057}
1058 1058
1059PRIVATE FUNC(abool, parse_sap_header, ( 1059PRIVATE FUNC(abool, parse_sap_header, (
1060 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, module_len))) 1060 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, module_len)))
1061{ 1061{
1062 V(int, module_index); 1062 V(int, module_index);
1063 V(int, type) = 0; 1063 V(int, type) = 0;
1064 V(int, duration_index) = 0; 1064 V(int, duration_index) = 0;
1065 if (!has_string_at(module, 0, "SAP\r\n")) 1065 if (!has_string_at(module, 0, "SAP\r\n"))
1066 return FALSE; 1066 return FALSE;
1067 module_index = 5; 1067 module_index = 5;
1068 while (UBYTE(module[module_index]) != 0xff) { 1068 while (UBYTE(module[module_index]) != 0xff) {
1069 if (module_index + 8 >= module_len) 1069 if (module_index + 8 >= module_len)
1070 return FALSE; 1070 return FALSE;
1071#define TAG_IS(s) has_string_at(module, module_index, s) 1071#define TAG_IS(s) has_string_at(module, module_index, s)
1072#ifdef C 1072#ifdef C
1073#define SET_TEXT(v, i) if (parse_text(v, module, module_index + i) == NULL) return FALSE 1073#define SET_TEXT(v, i) if (parse_text(v, module, module_index + i) == NULL) return FALSE
@@ -1076,287 +1076,287 @@ PRIVATE FUNC(abool, parse_sap_header, (
1076#endif 1076#endif
1077#define SET_DEC(v, i, min, max) v = parse_dec(module, module_index + i, max); if (v < min) return FALSE 1077#define SET_DEC(v, i, min, max) v = parse_dec(module, module_index + i, max); if (v < min) return FALSE
1078#define SET_HEX(v, i) v = parse_hex(module, module_index + i) 1078#define SET_HEX(v, i) v = parse_hex(module, module_index + i)
1079 if (TAG_IS("AUTHOR ")) { 1079 if (TAG_IS("AUTHOR ")) {
1080 SET_TEXT(module_info _ author, 7); 1080 SET_TEXT(module_info _ author, 7);
1081 } 1081 }
1082 else if (TAG_IS("NAME ")) { 1082 else if (TAG_IS("NAME ")) {
1083 SET_TEXT(module_info _ name, 5); 1083 SET_TEXT(module_info _ name, 5);
1084 } 1084 }
1085 else if (TAG_IS("DATE ")) { 1085 else if (TAG_IS("DATE ")) {
1086 SET_TEXT(module_info _ date, 5); 1086 SET_TEXT(module_info _ date, 5);
1087 } 1087 }
1088 else if (TAG_IS("SONGS ")) { 1088 else if (TAG_IS("SONGS ")) {
1089 SET_DEC(module_info _ songs, 6, 1, ASAP_SONGS_MAX); 1089 SET_DEC(module_info _ songs, 6, 1, ASAP_SONGS_MAX);
1090 } 1090 }
1091 else if (TAG_IS("DEFSONG ")) { 1091 else if (TAG_IS("DEFSONG ")) {
1092 SET_DEC(module_info _ default_song, 8, 0, ASAP_SONGS_MAX - 1); 1092 SET_DEC(module_info _ default_song, 8, 0, ASAP_SONGS_MAX - 1);
1093 } 1093 }
1094 else if (TAG_IS("STEREO\r")) 1094 else if (TAG_IS("STEREO\r"))
1095 module_info _ channels = 2; 1095 module_info _ channels = 2;
1096 else if (TAG_IS("TIME ")) { 1096 else if (TAG_IS("TIME ")) {
1097 V(int, i); 1097 V(int, i);
1098#ifdef C 1098#ifdef C
1099 char s[ASAP_DURATION_CHARS]; 1099 char s[ASAP_DURATION_CHARS];
1100#else 1100#else
1101 V(STRING, s); 1101 V(STRING, s);
1102#endif 1102#endif
1103 module_index += 5; 1103 module_index += 5;
1104 for (i = 0; module[module_index + i] != 0xd; i++); 1104 for (i = 0; module[module_index + i] != 0xd; i++);
1105 if (i > 5 && has_string_at(module, module_index + i - 5, " LOOP")) { 1105 if (i > 5 && has_string_at(module, module_index + i - 5, " LOOP")) {
1106 module_info _ loops[duration_index] = TRUE; 1106 module_info _ loops[duration_index] = TRUE;
1107 i -= 5; 1107 i -= 5;
1108 } 1108 }
1109#ifdef C 1109#ifdef C
1110 if (i >= ASAP_DURATION_CHARS) 1110 if (i >= ASAP_DURATION_CHARS)
1111 return FALSE; 1111 return FALSE;
1112#endif 1112#endif
1113 BYTES_TO_STRING(s, module, module_index, i); 1113 BYTES_TO_STRING(s, module, module_index, i);
1114 i = ASAP_ParseDuration(s); 1114 i = ASAP_ParseDuration(s);
1115 if (i < 0 || duration_index >= ASAP_SONGS_MAX) 1115 if (i < 0 || duration_index >= ASAP_SONGS_MAX)
1116 return FALSE; 1116 return FALSE;
1117 module_info _ durations[duration_index++] = i; 1117 module_info _ durations[duration_index++] = i;
1118 } 1118 }
1119 else if (TAG_IS("TYPE ")) 1119 else if (TAG_IS("TYPE "))
1120 type = module[module_index + 5]; 1120 type = module[module_index + 5];
1121 else if (TAG_IS("FASTPLAY ")) { 1121 else if (TAG_IS("FASTPLAY ")) {
1122 SET_DEC(module_info _ fastplay, 9, 1, 312); 1122 SET_DEC(module_info _ fastplay, 9, 1, 312);
1123 } 1123 }
1124 else if (TAG_IS("MUSIC ")) { 1124 else if (TAG_IS("MUSIC ")) {
1125 SET_HEX(module_info _ music, 6); 1125 SET_HEX(module_info _ music, 6);
1126 } 1126 }
1127 else if (TAG_IS("INIT ")) { 1127 else if (TAG_IS("INIT ")) {
1128 SET_HEX(module_info _ init, 5); 1128 SET_HEX(module_info _ init, 5);
1129 } 1129 }
1130 else if (TAG_IS("PLAYER ")) { 1130 else if (TAG_IS("PLAYER ")) {
1131 SET_HEX(module_info _ player, 7); 1131 SET_HEX(module_info _ player, 7);
1132 } 1132 }
1133 else if (TAG_IS("COVOX ")) { 1133 else if (TAG_IS("COVOX ")) {
1134 SET_HEX(module_info _ covox_addr, 6); 1134 SET_HEX(module_info _ covox_addr, 6);
1135 if (module_info _ covox_addr != 0xd600) 1135 if (module_info _ covox_addr != 0xd600)
1136 return FALSE; 1136 return FALSE;
1137 module_info _ channels = 2; 1137 module_info _ channels = 2;
1138 } 1138 }
1139 1139
1140 while (module[module_index++] != 0x0d) { 1140 while (module[module_index++] != 0x0d) {
1141 if (module_index >= module_len) 1141 if (module_index >= module_len)
1142 return FALSE; 1142 return FALSE;
1143 } 1143 }
1144 if (module[module_index++] != 0x0a) 1144 if (module[module_index++] != 0x0a)
1145 return FALSE; 1145 return FALSE;
1146 } 1146 }
1147 if (module_info _ default_song >= module_info _ songs) 1147 if (module_info _ default_song >= module_info _ songs)
1148 return FALSE; 1148 return FALSE;
1149 switch (type) { 1149 switch (type) {
1150 case CHARCODE('B'): 1150 case CHARCODE('B'):
1151 if (module_info _ player < 0 || module_info _ init < 0) 1151 if (module_info _ player < 0 || module_info _ init < 0)
1152 return FALSE; 1152 return FALSE;
1153 module_info _ type = ASAP_TYPE_SAP_B; 1153 module_info _ type = ASAP_TYPE_SAP_B;
1154 break; 1154 break;
1155 case CHARCODE('C'): 1155 case CHARCODE('C'):
1156 if (module_info _ player < 0 || module_info _ music < 0) 1156 if (module_info _ player < 0 || module_info _ music < 0)
1157 return FALSE; 1157 return FALSE;
1158 module_info _ type = ASAP_TYPE_SAP_C; 1158 module_info _ type = ASAP_TYPE_SAP_C;
1159 break; 1159 break;
1160 case CHARCODE('D'): 1160 case CHARCODE('D'):
1161 if (module_info _ init < 0) 1161 if (module_info _ init < 0)
1162 return FALSE; 1162 return FALSE;
1163 module_info _ type = ASAP_TYPE_SAP_D; 1163 module_info _ type = ASAP_TYPE_SAP_D;
1164 break; 1164 break;
1165 case CHARCODE('S'): 1165 case CHARCODE('S'):
1166 if (module_info _ init < 0) 1166 if (module_info _ init < 0)
1167 return FALSE; 1167 return FALSE;
1168 module_info _ type = ASAP_TYPE_SAP_S; 1168 module_info _ type = ASAP_TYPE_SAP_S;
1169 module_info _ fastplay = 78; 1169 module_info _ fastplay = 78;
1170 break; 1170 break;
1171 default: 1171 default:
1172 return FALSE; 1172 return FALSE;
1173 } 1173 }
1174 if (UBYTE(module[module_index + 1]) != 0xff) 1174 if (UBYTE(module[module_index + 1]) != 0xff)
1175 return FALSE; 1175 return FALSE;
1176 module_info _ header_len = module_index; 1176 module_info _ header_len = module_index;
1177 return TRUE; 1177 return TRUE;
1178} 1178}
1179 1179
1180PRIVATE FUNC(abool, parse_sap, ( 1180PRIVATE FUNC(abool, parse_sap, (
1181 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 1181 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
1182 P(CONST BYTEARRAY, module), P(int, module_len))) 1182 P(CONST BYTEARRAY, module), P(int, module_len)))
1183{ 1183{
1184 V(int, module_index); 1184 V(int, module_index);
1185 if (!parse_sap_header(module_info, module, module_len)) 1185 if (!parse_sap_header(module_info, module, module_len))
1186 return FALSE; 1186 return FALSE;
1187 if (ast == NULL) 1187 if (ast == NULL)
1188 return TRUE; 1188 return TRUE;
1189 ZERO_ARRAY(ast _ memory); 1189 ZERO_ARRAY(ast _ memory);
1190 module_index = module_info _ header_len + 2; 1190 module_index = module_info _ header_len + 2;
1191 while (module_index + 5 <= module_len) { 1191 while (module_index + 5 <= module_len) {
1192 V(int, start_addr) = UWORD(module, module_index); 1192 V(int, start_addr) = UWORD(module, module_index);
1193 V(int, block_len) = UWORD(module, module_index + 2) + 1 - start_addr; 1193 V(int, block_len) = UWORD(module, module_index + 2) + 1 - start_addr;
1194 if (block_len <= 0 || module_index + block_len > module_len) 1194 if (block_len <= 0 || module_index + block_len > module_len)
1195 return FALSE; 1195 return FALSE;
1196 module_index += 4; 1196 module_index += 4;
1197 COPY_ARRAY(ast _ memory, start_addr, module, module_index, block_len); 1197 COPY_ARRAY(ast _ memory, start_addr, module, module_index, block_len);
1198 module_index += block_len; 1198 module_index += block_len;
1199 if (module_index == module_len) 1199 if (module_index == module_len)
1200 return TRUE; 1200 return TRUE;
1201 if (module_index + 7 <= module_len 1201 if (module_index + 7 <= module_len
1202 && UBYTE(module[module_index]) == 0xff && UBYTE(module[module_index + 1]) == 0xff) 1202 && UBYTE(module[module_index]) == 0xff && UBYTE(module[module_index + 1]) == 0xff)
1203 module_index += 2; 1203 module_index += 2;
1204 } 1204 }
1205 return FALSE; 1205 return FALSE;
1206} 1206}
1207 1207
1208#define ASAP_EXT(c1, c2, c3) ((CHARCODE(c1) + (CHARCODE(c2) << 8) + (CHARCODE(c3) << 16)) | 0x202020) 1208#define ASAP_EXT(c1, c2, c3) ((CHARCODE(c1) + (CHARCODE(c2) << 8) + (CHARCODE(c3) << 16)) | 0x202020)
1209 1209
1210PRIVATE FUNC(int, get_packed_ext, (P(STRING, filename))) 1210PRIVATE FUNC(int, get_packed_ext, (P(STRING, filename)))
1211{ 1211{
1212 V(int, i) = strlen(filename); 1212 V(int, i) = strlen(filename);
1213 V(int, ext) = 0; 1213 V(int, ext) = 0;
1214 while (--i > 0) { 1214 while (--i > 0) {
1215 V(char, c) = CHARAT(filename, i); 1215 V(char, c) = CHARAT(filename, i);
1216 if (c <= ' ' || c > 'z') 1216 if (c <= ' ' || c > 'z')
1217 return 0; 1217 return 0;
1218 if (c == '.') 1218 if (c == '.')
1219 return ext | 0x202020; 1219 return ext | 0x202020;
1220 ext = (ext << 8) + CHARCODE(c); 1220 ext = (ext << 8) + CHARCODE(c);
1221 } 1221 }
1222 return 0; 1222 return 0;
1223} 1223}
1224 1224
1225PRIVATE FUNC(abool, is_our_ext, (P(int, ext))) 1225PRIVATE FUNC(abool, is_our_ext, (P(int, ext)))
1226{ 1226{
1227 switch (ext) { 1227 switch (ext) {
1228 case ASAP_EXT('S', 'A', 'P'): 1228 case ASAP_EXT('S', 'A', 'P'):
1229#ifndef ASAP_ONLY_SAP 1229#ifndef ASAP_ONLY_SAP
1230 case ASAP_EXT('C', 'M', 'C'): 1230 case ASAP_EXT('C', 'M', 'C'):
1231 case ASAP_EXT('C', 'M', '3'): 1231 case ASAP_EXT('C', 'M', '3'):
1232 case ASAP_EXT('C', 'M', 'R'): 1232 case ASAP_EXT('C', 'M', 'R'):
1233 case ASAP_EXT('C', 'M', 'S'): 1233 case ASAP_EXT('C', 'M', 'S'):
1234 case ASAP_EXT('D', 'M', 'C'): 1234 case ASAP_EXT('D', 'M', 'C'):
1235 case ASAP_EXT('D', 'L', 'T'): 1235 case ASAP_EXT('D', 'L', 'T'):
1236 case ASAP_EXT('M', 'P', 'T'): 1236 case ASAP_EXT('M', 'P', 'T'):
1237 case ASAP_EXT('M', 'P', 'D'): 1237 case ASAP_EXT('M', 'P', 'D'):
1238 case ASAP_EXT('R', 'M', 'T'): 1238 case ASAP_EXT('R', 'M', 'T'):
1239 case ASAP_EXT('T', 'M', 'C'): 1239 case ASAP_EXT('T', 'M', 'C'):
1240 case ASAP_EXT('T', 'M', '8'): 1240 case ASAP_EXT('T', 'M', '8'):
1241 case ASAP_EXT('T', 'M', '2'): 1241 case ASAP_EXT('T', 'M', '2'):
1242#endif 1242#endif
1243 return TRUE; 1243 return TRUE;
1244 default: 1244 default:
1245 return FALSE; 1245 return FALSE;
1246 } 1246 }
1247} 1247}
1248 1248
1249FUNC(abool, ASAP_IsOurFile, (P(STRING, filename))) 1249FUNC(abool, ASAP_IsOurFile, (P(STRING, filename)))
1250{ 1250{
1251 V(int, ext) = get_packed_ext(filename); 1251 V(int, ext) = get_packed_ext(filename);
1252 return is_our_ext(ext); 1252 return is_our_ext(ext);
1253} 1253}
1254 1254
1255FUNC(abool, ASAP_IsOurExt, (P(STRING, ext))) 1255FUNC(abool, ASAP_IsOurExt, (P(STRING, ext)))
1256{ 1256{
1257 return strlen(ext) == 3 1257 return strlen(ext) == 3
1258 && is_our_ext(ASAP_EXT(CHARAT(ext, 0), CHARAT(ext, 1), CHARAT(ext, 2))); 1258 && is_our_ext(ASAP_EXT(CHARAT(ext, 0), CHARAT(ext, 1), CHARAT(ext, 2)));
1259} 1259}
1260 1260
1261PRIVATE FUNC(abool, parse_file, ( 1261PRIVATE FUNC(abool, parse_file, (
1262 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 1262 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
1263 P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len))) 1263 P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len)))
1264{ 1264{
1265 V(int, i); 1265 V(int, i);
1266 V(int, len) = strlen(filename); 1266 V(int, len) = strlen(filename);
1267 V(int, basename) = 0; 1267 V(int, basename) = 0;
1268 V(int, ext) = -1; 1268 V(int, ext) = -1;
1269 for (i = 0; i < len; i++) { 1269 for (i = 0; i < len; i++) {
1270 V(char, c) = CHARAT(filename, i); 1270 V(char, c) = CHARAT(filename, i);
1271 if (c == '/' || c == '\\') { 1271 if (c == '/' || c == '\\') {
1272 basename = i + 1; 1272 basename = i + 1;
1273 ext = -1; 1273 ext = -1;
1274 } 1274 }
1275 else if (c == '.') 1275 else if (c == '.')
1276 ext = i; 1276 ext = i;
1277 } 1277 }
1278 if (ext < 0) 1278 if (ext < 0)
1279 return FALSE; 1279 return FALSE;
1280 EMPTY_STRING(module_info _ author); 1280 EMPTY_STRING(module_info _ author);
1281 SUBSTRING(module_info _ name, filename, basename, ext - basename); 1281 SUBSTRING(module_info _ name, filename, basename, ext - basename);
1282 EMPTY_STRING(module_info _ date); 1282 EMPTY_STRING(module_info _ date);
1283 module_info _ channels = 1; 1283 module_info _ channels = 1;
1284 module_info _ songs = 1; 1284 module_info _ songs = 1;
1285 module_info _ default_song = 0; 1285 module_info _ default_song = 0;
1286 for (i = 0; i < ASAP_SONGS_MAX; i++) { 1286 for (i = 0; i < ASAP_SONGS_MAX; i++) {
1287 module_info _ durations[i] = -1; 1287 module_info _ durations[i] = -1;
1288 module_info _ loops[i] = FALSE; 1288 module_info _ loops[i] = FALSE;
1289 } 1289 }
1290 module_info _ fastplay = 312; 1290 module_info _ fastplay = 312;
1291 module_info _ music = -1; 1291 module_info _ music = -1;
1292 module_info _ init = -1; 1292 module_info _ init = -1;
1293 module_info _ player = -1; 1293 module_info _ player = -1;
1294 module_info _ covox_addr = -1; 1294 module_info _ covox_addr = -1;
1295 switch (get_packed_ext(filename)) { 1295 switch (get_packed_ext(filename)) {
1296 case ASAP_EXT('S', 'A', 'P'): 1296 case ASAP_EXT('S', 'A', 'P'):
1297 return parse_sap(ast, module_info, module, module_len); 1297 return parse_sap(ast, module_info, module, module_len);
1298#ifndef ASAP_ONLY_SAP 1298#ifndef ASAP_ONLY_SAP
1299 case ASAP_EXT('C', 'M', 'C'): 1299 case ASAP_EXT('C', 'M', 'C'):
1300 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx)); 1300 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx));
1301 case ASAP_EXT('C', 'M', '3'): 1301 case ASAP_EXT('C', 'M', '3'):
1302 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CM3, GET_RESOURCE(cm3, obx)); 1302 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CM3, GET_RESOURCE(cm3, obx));
1303 case ASAP_EXT('C', 'M', 'R'): 1303 case ASAP_EXT('C', 'M', 'R'):
1304 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMR, GET_RESOURCE(cmc, obx)); 1304 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMR, GET_RESOURCE(cmc, obx));
1305 case ASAP_EXT('C', 'M', 'S'): 1305 case ASAP_EXT('C', 'M', 'S'):
1306 module_info _ channels = 2; 1306 module_info _ channels = 2;
1307 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMS, GET_RESOURCE(cms, obx)); 1307 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMS, GET_RESOURCE(cms, obx));
1308 case ASAP_EXT('D', 'M', 'C'): 1308 case ASAP_EXT('D', 'M', 'C'):
1309 module_info _ fastplay = 156; 1309 module_info _ fastplay = 156;
1310 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx)); 1310 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx));
1311 case ASAP_EXT('D', 'L', 'T'): 1311 case ASAP_EXT('D', 'L', 'T'):
1312 return parse_dlt(ast, module_info, module, module_len); 1312 return parse_dlt(ast, module_info, module, module_len);
1313 case ASAP_EXT('M', 'P', 'T'): 1313 case ASAP_EXT('M', 'P', 'T'):
1314 return parse_mpt(ast, module_info, module, module_len); 1314 return parse_mpt(ast, module_info, module, module_len);
1315 case ASAP_EXT('M', 'P', 'D'): 1315 case ASAP_EXT('M', 'P', 'D'):
1316 module_info _ fastplay = 156; 1316 module_info _ fastplay = 156;
1317 return parse_mpt(ast, module_info, module, module_len); 1317 return parse_mpt(ast, module_info, module, module_len);
1318 case ASAP_EXT('R', 'M', 'T'): 1318 case ASAP_EXT('R', 'M', 'T'):
1319 return parse_rmt(ast, module_info, module, module_len); 1319 return parse_rmt(ast, module_info, module, module_len);
1320 case ASAP_EXT('T', 'M', 'C'): 1320 case ASAP_EXT('T', 'M', 'C'):
1321 case ASAP_EXT('T', 'M', '8'): 1321 case ASAP_EXT('T', 'M', '8'):
1322 return parse_tmc(ast, module_info, module, module_len); 1322 return parse_tmc(ast, module_info, module, module_len);
1323 case ASAP_EXT('T', 'M', '2'): 1323 case ASAP_EXT('T', 'M', '2'):
1324 return parse_tm2(ast, module_info, module, module_len); 1324 return parse_tm2(ast, module_info, module, module_len);
1325#endif 1325#endif
1326 default: 1326 default:
1327 return FALSE; 1327 return FALSE;
1328 } 1328 }
1329} 1329}
1330 1330
1331FUNC(abool, ASAP_GetModuleInfo, ( 1331FUNC(abool, ASAP_GetModuleInfo, (
1332 P(ASAP_ModuleInfo PTR, module_info), P(STRING, filename), 1332 P(ASAP_ModuleInfo PTR, module_info), P(STRING, filename),
1333 P(CONST BYTEARRAY, module), P(int, module_len))) 1333 P(CONST BYTEARRAY, module), P(int, module_len)))
1334{ 1334{
1335 return parse_file(NULL, module_info, filename, module, module_len); 1335 return parse_file(NULL, module_info, filename, module, module_len);
1336} 1336}
1337 1337
1338FUNC(abool, ASAP_Load, ( 1338FUNC(abool, ASAP_Load, (
1339 P(ASAP_State PTR, ast), P(STRING, filename), 1339 P(ASAP_State PTR, ast), P(STRING, filename),
1340 P(CONST BYTEARRAY, module), P(int, module_len))) 1340 P(CONST BYTEARRAY, module), P(int, module_len)))
1341{ 1341{
1342 ast _ silence_cycles = 0; 1342 ast _ silence_cycles = 0;
1343 return parse_file(ast, ADDRESSOF ast _ module_info, filename, module, module_len); 1343 return parse_file(ast, ADDRESSOF ast _ module_info, filename, module, module_len);
1344} 1344}
1345 1345
1346FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds))) 1346FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds)))
1347{ 1347{
1348 ast _ silence_cycles = seconds * ASAP_MAIN_CLOCK; 1348 ast _ silence_cycles = seconds * ASAP_MAIN_CLOCK;
1349} 1349}
1350 1350
1351PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_scanlines))) 1351PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_scanlines)))
1352{ 1352{
1353 ast _ cpu_pc = addr; 1353 ast _ cpu_pc = addr;
1354 /* put a CIM at 0xd20a and a return address on stack */ 1354 /* put a CIM at 0xd20a and a return address on stack */
1355 dPutByte(0xd20a, 0xd2); 1355 dPutByte(0xd20a, 0xd2);
1356 dPutByte(0x01fe, 0x09); 1356 dPutByte(0x01fe, 0x09);
1357 dPutByte(0x01ff, 0xd2); 1357 dPutByte(0x01ff, 0xd2);
1358 ast _ cpu_s = 0xfd; 1358 ast _ cpu_s = 0xfd;
1359 Cpu_RunScanlines(ast, max_scanlines); 1359 Cpu_RunScanlines(ast, max_scanlines);
1360} 1360}
1361 1361
1362/* 50 Atari frames for the initialization routine - some SAPs are self-extracting. */ 1362/* 50 Atari frames for the initialization routine - some SAPs are self-extracting. */
@@ -1364,843 +1364,843 @@ PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_
1364 1364
1365PRIVATE FUNC(void, call_6502_init, (P(ASAP_State PTR, ast), P(int, addr), P(int, a), P(int, x), P(int, y))) 1365PRIVATE FUNC(void, call_6502_init, (P(ASAP_State PTR, ast), P(int, addr), P(int, a), P(int, x), P(int, y)))
1366{ 1366{
1367 ast _ cpu_a = a & 0xff; 1367 ast _ cpu_a = a & 0xff;
1368 ast _ cpu_x = x & 0xff; 1368 ast _ cpu_x = x & 0xff;
1369 ast _ cpu_y = y & 0xff; 1369 ast _ cpu_y = y & 0xff;
1370 call_6502(ast, addr, SCANLINES_FOR_INIT); 1370 call_6502(ast, addr, SCANLINES_FOR_INIT);
1371} 1371}
1372 1372
1373FUNC(void, ASAP_PlaySong, (P(ASAP_State PTR, ast), P(int, song), P(int, duration))) 1373FUNC(void, ASAP_PlaySong, (P(ASAP_State PTR, ast), P(int, song), P(int, duration)))
1374{ 1374{
1375 ast _ current_song = song; 1375 ast _ current_song = song;
1376 ast _ current_duration = duration; 1376 ast _ current_duration = duration;
1377 ast _ blocks_played = 0; 1377 ast _ blocks_played = 0;
1378 ast _ silence_cycles_counter = ast _ silence_cycles; 1378 ast _ silence_cycles_counter = ast _ silence_cycles;
1379 ast _ extra_pokey_mask = ast _ module_info.channels > 1 ? 0x10 : 0; 1379 ast _ extra_pokey_mask = ast _ module_info.channels > 1 ? 0x10 : 0;
1380 ast _ consol = 8; 1380 ast _ consol = 8;
1381 ast _ covox[0] = CAST(byte) 0x80; 1381 ast _ covox[0] = CAST(byte) 0x80;
1382 ast _ covox[1] = CAST(byte) 0x80; 1382 ast _ covox[1] = CAST(byte) 0x80;
1383 ast _ covox[2] = CAST(byte) 0x80; 1383 ast _ covox[2] = CAST(byte) 0x80;
1384 ast _ covox[3] = CAST(byte) 0x80; 1384 ast _ covox[3] = CAST(byte) 0x80;
1385 PokeySound_Initialize(ast); 1385 PokeySound_Initialize(ast);
1386 ast _ cycle = 0; 1386 ast _ cycle = 0;
1387 ast _ cpu_nz = 0; 1387 ast _ cpu_nz = 0;
1388 ast _ cpu_c = 0; 1388 ast _ cpu_c = 0;
1389 ast _ cpu_vdi = 0; 1389 ast _ cpu_vdi = 0;
1390 ast _ scanline_number = 0; 1390 ast _ scanline_number = 0;
1391 ast _ next_scanline_cycle = 0; 1391 ast _ next_scanline_cycle = 0;
1392 ast _ timer1_cycle = NEVER; 1392 ast _ timer1_cycle = NEVER;
1393 ast _ timer2_cycle = NEVER; 1393 ast _ timer2_cycle = NEVER;
1394 ast _ timer4_cycle = NEVER; 1394 ast _ timer4_cycle = NEVER;
1395 ast _ irqst = 0xff; 1395 ast _ irqst = 0xff;
1396 switch (ast _ module_info.type) { 1396 switch (ast _ module_info.type) {
1397 case ASAP_TYPE_SAP_B: 1397 case ASAP_TYPE_SAP_B:
1398 call_6502_init(ast, ast _ module_info.init, song, 0, 0); 1398 call_6502_init(ast, ast _ module_info.init, song, 0, 0);
1399 break; 1399 break;
1400 case ASAP_TYPE_SAP_C: 1400 case ASAP_TYPE_SAP_C:
1401#ifndef ASAP_ONLY_SAP 1401#ifndef ASAP_ONLY_SAP
1402 case ASAP_TYPE_CMC: 1402 case ASAP_TYPE_CMC:
1403 case ASAP_TYPE_CM3: 1403 case ASAP_TYPE_CM3:
1404 case ASAP_TYPE_CMR: 1404 case ASAP_TYPE_CMR:
1405 case ASAP_TYPE_CMS: 1405 case ASAP_TYPE_CMS:
1406#endif 1406#endif
1407 call_6502_init(ast, ast _ module_info.player + 3, 0x70, ast _ module_info.music, ast _ module_info.music >> 8); 1407 call_6502_init(ast, ast _ module_info.player + 3, 0x70, ast _ module_info.music, ast _ module_info.music >> 8);
1408 call_6502_init(ast, ast _ module_info.player + 3, 0x00, song, 0); 1408 call_6502_init(ast, ast _ module_info.player + 3, 0x00, song, 0);
1409 break; 1409 break;
1410 case ASAP_TYPE_SAP_D: 1410 case ASAP_TYPE_SAP_D:
1411 case ASAP_TYPE_SAP_S: 1411 case ASAP_TYPE_SAP_S:
1412 ast _ cpu_a = song; 1412 ast _ cpu_a = song;
1413 ast _ cpu_x = 0x00; 1413 ast _ cpu_x = 0x00;
1414 ast _ cpu_y = 0x00; 1414 ast _ cpu_y = 0x00;
1415 ast _ cpu_s = 0xff; 1415 ast _ cpu_s = 0xff;
1416 ast _ cpu_pc = ast _ module_info.init; 1416 ast _ cpu_pc = ast _ module_info.init;
1417 break; 1417 break;
1418#ifndef ASAP_ONLY_SAP 1418#ifndef ASAP_ONLY_SAP
1419 case ASAP_TYPE_DLT: 1419 case ASAP_TYPE_DLT:
1420 call_6502_init(ast, ast _ module_info.player + 0x100, 0x00, 0x00, ast _ module_info.song_pos[song]); 1420 call_6502_init(ast, ast _ module_info.player + 0x100, 0x00, 0x00, ast _ module_info.song_pos[song]);
1421 break; 1421 break;
1422 case ASAP_TYPE_MPT: 1422 case ASAP_TYPE_MPT:
1423 call_6502_init(ast, ast _ module_info.player, 0x00, ast _ module_info.music >> 8, ast _ module_info.music); 1423 call_6502_init(ast, ast _ module_info.player, 0x00, ast _ module_info.music >> 8, ast _ module_info.music);
1424 call_6502_init(ast, ast _ module_info.player, 0x02, ast _ module_info.song_pos[song], 0); 1424 call_6502_init(ast, ast _ module_info.player, 0x02, ast _ module_info.song_pos[song], 0);
1425 break; 1425 break;
1426 case ASAP_TYPE_RMT: 1426 case ASAP_TYPE_RMT:
1427 call_6502_init(ast, ast _ module_info.player, ast _ module_info.song_pos[song], ast _ module_info.music, ast _ module_info.music >> 8); 1427 call_6502_init(ast, ast _ module_info.player, ast _ module_info.song_pos[song], ast _ module_info.music, ast _ module_info.music >> 8);
1428 break; 1428 break;
1429 case ASAP_TYPE_TMC: 1429 case ASAP_TYPE_TMC:
1430 case ASAP_TYPE_TM2: 1430 case ASAP_TYPE_TM2:
1431 call_6502_init(ast, ast _ module_info.player, 0x70, ast _ module_info.music >> 8, ast _ module_info.music); 1431 call_6502_init(ast, ast _ module_info.player, 0x70, ast _ module_info.music >> 8, ast _ module_info.music);
1432 call_6502_init(ast, ast _ module_info.player, 0x00, song, 0); 1432 call_6502_init(ast, ast _ module_info.player, 0x00, song, 0);
1433 ast _ tmc_per_frame_counter = 1; 1433 ast _ tmc_per_frame_counter = 1;
1434 break; 1434 break;
1435#endif 1435#endif
1436 } 1436 }
1437 ASAP_MutePokeyChannels(ast, 0); 1437 ASAP_MutePokeyChannels(ast, 0);
1438} 1438}
1439 1439
1440FUNC(void, ASAP_MutePokeyChannels, (P(ASAP_State PTR, ast), P(int, mask))) 1440FUNC(void, ASAP_MutePokeyChannels, (P(ASAP_State PTR, ast), P(int, mask)))
1441{ 1441{
1442 PokeySound_Mute(ast, ADDRESSOF ast _ base_pokey, mask); 1442 PokeySound_Mute(ast, ADDRESSOF ast _ base_pokey, mask);
1443 PokeySound_Mute(ast, ADDRESSOF ast _ extra_pokey, mask >> 4); 1443 PokeySound_Mute(ast, ADDRESSOF ast _ extra_pokey, mask >> 4);
1444} 1444}
1445 1445
1446FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast))) 1446FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast)))
1447{ 1447{
1448 V(int, player) = ast _ module_info.player; 1448 V(int, player) = ast _ module_info.player;
1449 PokeySound_StartFrame(ast); 1449 PokeySound_StartFrame(ast);
1450 switch (ast _ module_info.type) { 1450 switch (ast _ module_info.type) {
1451 case ASAP_TYPE_SAP_B: 1451 case ASAP_TYPE_SAP_B:
1452 call_6502(ast, player, ast _ module_info.fastplay); 1452 call_6502(ast, player, ast _ module_info.fastplay);
1453 break; 1453 break;
1454 case ASAP_TYPE_SAP_C: 1454 case ASAP_TYPE_SAP_C:
1455#ifndef ASAP_ONLY_SAP 1455#ifndef ASAP_ONLY_SAP
1456 case ASAP_TYPE_CMC: 1456 case ASAP_TYPE_CMC:
1457 case ASAP_TYPE_CM3: 1457 case ASAP_TYPE_CM3:
1458 case ASAP_TYPE_CMR: 1458 case ASAP_TYPE_CMR:
1459 case ASAP_TYPE_CMS: 1459 case ASAP_TYPE_CMS:
1460#endif 1460#endif
1461 call_6502(ast, player + 6, ast _ module_info.fastplay); 1461 call_6502(ast, player + 6, ast _ module_info.fastplay);
1462 break; 1462 break;
1463 case ASAP_TYPE_SAP_D: 1463 case ASAP_TYPE_SAP_D:
1464 if (player >= 0) { 1464 if (player >= 0) {
1465 V(int, s)= ast _ cpu_s; 1465 V(int, s)= ast _ cpu_s;
1466#define PUSH_ON_6502_STACK(x) dPutByte(0x100 + s, x); s = (s - 1) & 0xff 1466#define PUSH_ON_6502_STACK(x) dPutByte(0x100 + s, x); s = (s - 1) & 0xff
1467#define RETURN_FROM_PLAYER_ADDR 0xd200 1467#define RETURN_FROM_PLAYER_ADDR 0xd200
1468 /* save 6502 state on 6502 stack */ 1468 /* save 6502 state on 6502 stack */
1469 PUSH_ON_6502_STACK(ast _ cpu_pc >> 8); 1469 PUSH_ON_6502_STACK(ast _ cpu_pc >> 8);
1470 PUSH_ON_6502_STACK(ast _ cpu_pc & 0xff); 1470 PUSH_ON_6502_STACK(ast _ cpu_pc & 0xff);
1471 PUSH_ON_6502_STACK(((ast _ cpu_nz | (ast _ cpu_nz >> 1)) & 0x80) + ast _ cpu_vdi + \ 1471 PUSH_ON_6502_STACK(((ast _ cpu_nz | (ast _ cpu_nz >> 1)) & 0x80) + ast _ cpu_vdi + \
1472 ((ast _ cpu_nz & 0xff) == 0 ? Z_FLAG : 0) + ast _ cpu_c + 0x20); 1472 ((ast _ cpu_nz & 0xff) == 0 ? Z_FLAG : 0) + ast _ cpu_c + 0x20);
1473 PUSH_ON_6502_STACK(ast _ cpu_a); 1473 PUSH_ON_6502_STACK(ast _ cpu_a);
1474 PUSH_ON_6502_STACK(ast _ cpu_x); 1474 PUSH_ON_6502_STACK(ast _ cpu_x);
1475 PUSH_ON_6502_STACK(ast _ cpu_y); 1475 PUSH_ON_6502_STACK(ast _ cpu_y);
1476 /* RTS will jump to 6502 code that restores the state */ 1476 /* RTS will jump to 6502 code that restores the state */
1477 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) >> 8); 1477 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) >> 8);
1478 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) & 0xff); 1478 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) & 0xff);
1479 ast _ cpu_s = s; 1479 ast _ cpu_s = s;
1480 dPutByte(RETURN_FROM_PLAYER_ADDR, 0x68); /* PLA */ 1480 dPutByte(RETURN_FROM_PLAYER_ADDR, 0x68); /* PLA */
1481 dPutByte(RETURN_FROM_PLAYER_ADDR + 1, 0xa8); /* TAY */ 1481 dPutByte(RETURN_FROM_PLAYER_ADDR + 1, 0xa8); /* TAY */
1482 dPutByte(RETURN_FROM_PLAYER_ADDR + 2, 0x68); /* PLA */ 1482 dPutByte(RETURN_FROM_PLAYER_ADDR + 2, 0x68); /* PLA */
1483 dPutByte(RETURN_FROM_PLAYER_ADDR + 3, 0xaa); /* TAX */ 1483 dPutByte(RETURN_FROM_PLAYER_ADDR + 3, 0xaa); /* TAX */
1484 dPutByte(RETURN_FROM_PLAYER_ADDR + 4, 0x68); /* PLA */ 1484 dPutByte(RETURN_FROM_PLAYER_ADDR + 4, 0x68); /* PLA */
1485 dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */ 1485 dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */
1486 ast _ cpu_pc = player; 1486 ast _ cpu_pc = player;
1487 } 1487 }
1488 Cpu_RunScanlines(ast, ast _ module_info.fastplay); 1488 Cpu_RunScanlines(ast, ast _ module_info.fastplay);
1489 break; 1489 break;
1490 case ASAP_TYPE_SAP_S: 1490 case ASAP_TYPE_SAP_S:
1491 Cpu_RunScanlines(ast, ast _ module_info.fastplay); 1491 Cpu_RunScanlines(ast, ast _ module_info.fastplay);
1492 { 1492 {
1493 V(int, i) = dGetByte(0x45) - 1; 1493 V(int, i) = dGetByte(0x45) - 1;
1494 dPutByte(0x45, i); 1494 dPutByte(0x45, i);
1495 if (i == 0) 1495 if (i == 0)
1496 dPutByte(0xb07b, dGetByte(0xb07b) + 1); 1496 dPutByte(0xb07b, dGetByte(0xb07b) + 1);
1497 } 1497 }
1498 break; 1498 break;
1499#ifndef ASAP_ONLY_SAP 1499#ifndef ASAP_ONLY_SAP
1500 case ASAP_TYPE_DLT: 1500 case ASAP_TYPE_DLT:
1501 call_6502(ast, player + 0x103, ast _ module_info.fastplay); 1501 call_6502(ast, player + 0x103, ast _ module_info.fastplay);
1502 break; 1502 break;
1503 case ASAP_TYPE_MPT: 1503 case ASAP_TYPE_MPT:
1504 case ASAP_TYPE_RMT: 1504 case ASAP_TYPE_RMT:
1505 case ASAP_TYPE_TM2: 1505 case ASAP_TYPE_TM2:
1506 call_6502(ast, player + 3, ast _ module_info.fastplay); 1506 call_6502(ast, player + 3, ast _ module_info.fastplay);
1507 break; 1507 break;
1508 case ASAP_TYPE_TMC: 1508 case ASAP_TYPE_TMC:
1509 if (--ast _ tmc_per_frame_counter <= 0) { 1509 if (--ast _ tmc_per_frame_counter <= 0) {
1510 ast _ tmc_per_frame_counter = ast _ tmc_per_frame; 1510 ast _ tmc_per_frame_counter = ast _ tmc_per_frame;
1511 call_6502(ast, player + 3, ast _ module_info.fastplay); 1511 call_6502(ast, player + 3, ast _ module_info.fastplay);
1512 } 1512 }
1513 else 1513 else
1514 call_6502(ast, player + 6, ast _ module_info.fastplay); 1514 call_6502(ast, player + 6, ast _ module_info.fastplay);
1515 break; 1515 break;
1516#endif 1516#endif
1517 } 1517 }
1518 PokeySound_EndFrame(ast, ast _ module_info.fastplay * 114); 1518 PokeySound_EndFrame(ast, ast _ module_info.fastplay * 114);
1519 if (ast _ silence_cycles > 0) { 1519 if (ast _ silence_cycles > 0) {
1520 if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey) 1520 if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey)
1521 && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) { 1521 && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) {
1522 ast _ silence_cycles_counter -= ast _ module_info.fastplay * 114; 1522 ast _ silence_cycles_counter -= ast _ module_info.fastplay * 114;
1523 if (ast _ silence_cycles_counter <= 0) 1523 if (ast _ silence_cycles_counter <= 0)
1524 return FALSE; 1524 return FALSE;
1525 } 1525 }
1526 else 1526 else
1527 ast _ silence_cycles_counter = ast _ silence_cycles; 1527 ast _ silence_cycles_counter = ast _ silence_cycles;
1528 } 1528 }
1529 return TRUE; 1529 return TRUE;
1530} 1530}
1531 1531
1532FUNC(int, ASAP_GetPosition, (P(CONST ASAP_State PTR, ast))) 1532FUNC(int, ASAP_GetPosition, (P(CONST ASAP_State PTR, ast)))
1533{ 1533{
1534 return ast _ blocks_played * 10 / (ASAP_SAMPLE_RATE / 100); 1534 return ast _ blocks_played * 10 / (ASAP_SAMPLE_RATE / 100);
1535} 1535}
1536 1536
1537FUNC(int, milliseconds_to_blocks, (P(int, milliseconds))) 1537FUNC(int, milliseconds_to_blocks, (P(int, milliseconds)))
1538{ 1538{
1539 return milliseconds * (ASAP_SAMPLE_RATE / 100) / 10; 1539 return milliseconds * (ASAP_SAMPLE_RATE / 100) / 10;
1540} 1540}
1541 1541
1542#ifndef ACTIONSCRIPT 1542#ifndef ACTIONSCRIPT
1543 1543
1544FUNC(void, ASAP_Seek, (P(ASAP_State PTR, ast), P(int, position))) 1544FUNC(void, ASAP_Seek, (P(ASAP_State PTR, ast), P(int, position)))
1545{ 1545{
1546 V(int, block) = milliseconds_to_blocks(position); 1546 V(int, block) = milliseconds_to_blocks(position);
1547 if (block < ast _ blocks_played) 1547 if (block < ast _ blocks_played)
1548 ASAP_PlaySong(ast, ast _ current_song, ast _ current_duration); 1548 ASAP_PlaySong(ast, ast _ current_song, ast _ current_duration);
1549 while (ast _ blocks_played + ast _ samples - ast _ sample_index < block) { 1549 while (ast _ blocks_played + ast _ samples - ast _ sample_index < block) {
1550 ast _ blocks_played += ast _ samples - ast _ sample_index; 1550 ast _ blocks_played += ast _ samples - ast _ sample_index;
1551 call_6502_player(ast); 1551 call_6502_player(ast);
1552 } 1552 }
1553 ast _ sample_index += block - ast _ blocks_played; 1553 ast _ sample_index += block - ast _ blocks_played;
1554 ast _ blocks_played = block; 1554 ast _ blocks_played = block;
1555} 1555}
1556 1556
1557PRIVATE FUNC(void, serialize_int, (P(BYTEARRAY, buffer), P(int, offset), P(int, value))) 1557PRIVATE FUNC(void, serialize_int, (P(BYTEARRAY, buffer), P(int, offset), P(int, value)))
1558{ 1558{
1559 buffer[offset] = TO_BYTE(value); 1559 buffer[offset] = TO_BYTE(value);
1560 buffer[offset + 1] = TO_BYTE(value >> 8); 1560 buffer[offset + 1] = TO_BYTE(value >> 8);
1561 buffer[offset + 2] = TO_BYTE(value >> 16); 1561 buffer[offset + 2] = TO_BYTE(value >> 16);
1562 buffer[offset + 3] = TO_BYTE(value >> 24); 1562 buffer[offset + 3] = TO_BYTE(value >> 24);
1563} 1563}
1564 1564
1565FUNC(void, ASAP_GetWavHeaderForPart, ( 1565FUNC(void, ASAP_GetWavHeaderForPart, (
1566 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), 1566 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer),
1567 P(ASAP_SampleFormat, format), P(int, blocks))) 1567 P(ASAP_SampleFormat, format), P(int, blocks)))
1568{ 1568{
1569 V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0; 1569 V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0;
1570 V(int, block_size) = ast _ module_info.channels << use_16bit; 1570 V(int, block_size) = ast _ module_info.channels << use_16bit;
1571 V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size; 1571 V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size;
1572 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played; 1572 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played;
1573 V(int, n_bytes); 1573 V(int, n_bytes);
1574 if (blocks > remaining_blocks) 1574 if (blocks > remaining_blocks)
1575 blocks = remaining_blocks; 1575 blocks = remaining_blocks;
1576 n_bytes = blocks * block_size; 1576 n_bytes = blocks * block_size;
1577 buffer[0] = CAST(byte) CHARCODE('R'); 1577 buffer[0] = CAST(byte) CHARCODE('R');
1578 buffer[1] = CAST(byte) CHARCODE('I'); 1578 buffer[1] = CAST(byte) CHARCODE('I');
1579 buffer[2] = CAST(byte) CHARCODE('F'); 1579 buffer[2] = CAST(byte) CHARCODE('F');
1580 buffer[3] = CAST(byte) CHARCODE('F'); 1580 buffer[3] = CAST(byte) CHARCODE('F');
1581 serialize_int(buffer, 4, n_bytes + 36); 1581 serialize_int(buffer, 4, n_bytes + 36);
1582 buffer[8] = CAST(byte) CHARCODE('W'); 1582 buffer[8] = CAST(byte) CHARCODE('W');
1583 buffer[9] = CAST(byte) CHARCODE('A'); 1583 buffer[9] = CAST(byte) CHARCODE('A');
1584 buffer[10] = CAST(byte) CHARCODE('V'); 1584 buffer[10] = CAST(byte) CHARCODE('V');
1585 buffer[11] = CAST(byte) CHARCODE('E'); 1585 buffer[11] = CAST(byte) CHARCODE('E');
1586 buffer[12] = CAST(byte) CHARCODE('f'); 1586 buffer[12] = CAST(byte) CHARCODE('f');
1587 buffer[13] = CAST(byte) CHARCODE('m'); 1587 buffer[13] = CAST(byte) CHARCODE('m');
1588 buffer[14] = CAST(byte) CHARCODE('t'); 1588 buffer[14] = CAST(byte) CHARCODE('t');
1589 buffer[15] = CAST(byte) CHARCODE(' '); 1589 buffer[15] = CAST(byte) CHARCODE(' ');
1590 buffer[16] = 16; 1590 buffer[16] = 16;
1591 buffer[17] = 0; 1591 buffer[17] = 0;
1592 buffer[18] = 0; 1592 buffer[18] = 0;
1593 buffer[19] = 0; 1593 buffer[19] = 0;
1594 buffer[20] = 1; 1594 buffer[20] = 1;
1595 buffer[21] = 0; 1595 buffer[21] = 0;
1596 buffer[22] = CAST(byte) ast _ module_info.channels; 1596 buffer[22] = CAST(byte) ast _ module_info.channels;
1597 buffer[23] = 0; 1597 buffer[23] = 0;
1598 serialize_int(buffer, 24, ASAP_SAMPLE_RATE); 1598 serialize_int(buffer, 24, ASAP_SAMPLE_RATE);
1599 serialize_int(buffer, 28, bytes_per_second); 1599 serialize_int(buffer, 28, bytes_per_second);
1600 buffer[32] = CAST(byte) block_size; 1600 buffer[32] = CAST(byte) block_size;
1601 buffer[33] = 0; 1601 buffer[33] = 0;
1602 buffer[34] = CAST(byte) (8 << use_16bit); 1602 buffer[34] = CAST(byte) (8 << use_16bit);
1603 buffer[35] = 0; 1603 buffer[35] = 0;
1604 buffer[36] = CAST(byte) CHARCODE('d'); 1604 buffer[36] = CAST(byte) CHARCODE('d');
1605 buffer[37] = CAST(byte) CHARCODE('a'); 1605 buffer[37] = CAST(byte) CHARCODE('a');
1606 buffer[38] = CAST(byte) CHARCODE('t'); 1606 buffer[38] = CAST(byte) CHARCODE('t');
1607 buffer[39] = CAST(byte) CHARCODE('a'); 1607 buffer[39] = CAST(byte) CHARCODE('a');
1608 serialize_int(buffer, 40, n_bytes); 1608 serialize_int(buffer, 40, n_bytes);
1609} 1609}
1610 1610
1611FUNC(void, ASAP_GetWavHeader, ( 1611FUNC(void, ASAP_GetWavHeader, (
1612 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format))) 1612 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format)))
1613{ 1613{
1614 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played; 1614 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played;
1615 ASAP_GetWavHeaderForPart(ast, buffer, format, remaining_blocks); 1615 ASAP_GetWavHeaderForPart(ast, buffer, format, remaining_blocks);
1616} 1616}
1617 1617
1618#endif /* ACTIONSCRIPT */ 1618#endif /* ACTIONSCRIPT */
1619 1619
1620PRIVATE FUNC(int, ASAP_GenerateAt, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_offset), P(int, buffer_len), P(ASAP_SampleFormat, format))) 1620PRIVATE FUNC(int, ASAP_GenerateAt, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_offset), P(int, buffer_len), P(ASAP_SampleFormat, format)))
1621{ 1621{
1622 V(int, block_shift); 1622 V(int, block_shift);
1623 V(int, buffer_blocks); 1623 V(int, buffer_blocks);
1624 V(int, block); 1624 V(int, block);
1625 if (ast _ silence_cycles > 0 && ast _ silence_cycles_counter <= 0) 1625 if (ast _ silence_cycles > 0 && ast _ silence_cycles_counter <= 0)
1626 return 0; 1626 return 0;
1627#ifdef ACTIONSCRIPT 1627#ifdef ACTIONSCRIPT
1628 block_shift = 0; 1628 block_shift = 0;
1629#else 1629#else
1630 block_shift = (ast _ module_info.channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0); 1630 block_shift = (ast _ module_info.channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0);
1631#endif 1631#endif
1632 buffer_blocks = buffer_len >> block_shift; 1632 buffer_blocks = buffer_len >> block_shift;
1633 if (ast _ current_duration > 0) { 1633 if (ast _ current_duration > 0) {
1634 V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); 1634 V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration);
1635 if (buffer_blocks > total_blocks - ast _ blocks_played) 1635 if (buffer_blocks > total_blocks - ast _ blocks_played)
1636 buffer_blocks = total_blocks - ast _ blocks_played; 1636 buffer_blocks = total_blocks - ast _ blocks_played;
1637 } 1637 }
1638 block = 0; 1638 block = 0;
1639 do { 1639 do {
1640 V(int, blocks) = PokeySound_Generate(ast, CAST(BYTEARRAY) buffer, 1640 V(int, blocks) = PokeySound_Generate(ast, CAST(BYTEARRAY) buffer,
1641 buffer_offset + (block << block_shift), buffer_blocks - block, format); 1641 buffer_offset + (block << block_shift), buffer_blocks - block, format);
1642 ast _ blocks_played += blocks; 1642 ast _ blocks_played += blocks;
1643 block += blocks; 1643 block += blocks;
1644 } while (block < buffer_blocks && call_6502_player(ast)); 1644 } while (block < buffer_blocks && call_6502_player(ast));
1645 return block << block_shift; 1645 return block << block_shift;
1646} 1646}
1647 1647
1648FUNC(int, ASAP_Generate, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_len), P(ASAP_SampleFormat, format))) 1648FUNC(int, ASAP_Generate, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_len), P(ASAP_SampleFormat, format)))
1649{ 1649{
1650 return ASAP_GenerateAt(ast, buffer, 0, buffer_len, format); 1650 return ASAP_GenerateAt(ast, buffer, 0, buffer_len, format);
1651} 1651}
1652 1652
1653#if defined(C) && !defined(ASAP_ONLY_SAP) 1653#if defined(C) && !defined(ASAP_ONLY_SAP)
1654 1654
1655abool ASAP_ChangeExt(char *filename, const char *ext) 1655abool ASAP_ChangeExt(char *filename, const char *ext)
1656{ 1656{
1657 char *dest = NULL; 1657 char *dest = NULL;
1658 while (*filename != '\0') { 1658 while (*filename != '\0') {
1659 if (*filename == '/' || *filename == '\\') 1659 if (*filename == '/' || *filename == '\\')
1660 dest = NULL; 1660 dest = NULL;
1661 else if (*filename == '.') 1661 else if (*filename == '.')
1662 dest = filename + 1; 1662 dest = filename + 1;
1663 filename++; 1663 filename++;
1664 } 1664 }
1665 if (dest == NULL) 1665 if (dest == NULL)
1666 return FALSE; 1666 return FALSE;
1667 strcpy(dest, ext); 1667 strcpy(dest, ext);
1668 return TRUE; 1668 return TRUE;
1669} 1669}
1670 1670
1671abool ASAP_CanSetModuleInfo(const char *filename) 1671abool ASAP_CanSetModuleInfo(const char *filename)
1672{ 1672{
1673 int ext = get_packed_ext(filename); 1673 int ext = get_packed_ext(filename);
1674 return ext == ASAP_EXT('S', 'A', 'P'); 1674 return ext == ASAP_EXT('S', 'A', 'P');
1675} 1675}
1676 1676
1677static byte *put_string(byte *dest, const char *str) 1677static byte *put_string(byte *dest, const char *str)
1678{ 1678{
1679 while (*str != '\0') 1679 while (*str != '\0')
1680 *dest++ = *str++; 1680 *dest++ = *str++;
1681 return dest; 1681 return dest;
1682} 1682}
1683 1683
1684static byte *put_dec(byte *dest, int value) 1684static byte *put_dec(byte *dest, int value)
1685{ 1685{
1686 if (value >= 10) { 1686 if (value >= 10) {
1687 dest = put_dec(dest, value / 10); 1687 dest = put_dec(dest, value / 10);
1688 value %= 10; 1688 value %= 10;
1689 } 1689 }
1690 *dest++ = '0' + value; 1690 *dest++ = '0' + value;
1691 return dest; 1691 return dest;
1692} 1692}
1693 1693
1694static byte *put_text_tag(byte *dest, const char *tag, const char *value) 1694static byte *put_text_tag(byte *dest, const char *tag, const char *value)
1695{ 1695{
1696 dest = put_string(dest, tag); 1696 dest = put_string(dest, tag);
1697 *dest++ = '"'; 1697 *dest++ = '"';
1698 if (*value == '\0') 1698 if (*value == '\0')
1699 value = "<?>"; 1699 value = "<?>";
1700 while (*value != '\0') { 1700 while (*value != '\0') {
1701 if (*value < ' ' || *value > 'z' || *value == '"' || *value == '`') 1701 if (*value < ' ' || *value > 'z' || *value == '"' || *value == '`')
1702 return NULL; 1702 return NULL;
1703 *dest++ = *value++; 1703 *dest++ = *value++;
1704 } 1704 }
1705 *dest++ = '"'; 1705 *dest++ = '"';
1706 *dest++ = '\r'; 1706 *dest++ = '\r';
1707 *dest++ = '\n'; 1707 *dest++ = '\n';
1708 return dest; 1708 return dest;
1709} 1709}
1710 1710
1711static byte *put_dec_tag(byte *dest, const char *tag, int value) 1711static byte *put_dec_tag(byte *dest, const char *tag, int value)
1712{ 1712{
1713 dest = put_string(dest, tag); 1713 dest = put_string(dest, tag);
1714 dest = put_dec(dest, value); 1714 dest = put_dec(dest, value);
1715 *dest++ = '\r'; 1715 *dest++ = '\r';
1716 *dest++ = '\n'; 1716 *dest++ = '\n';
1717 return dest; 1717 return dest;
1718} 1718}
1719 1719
1720static byte *put_hex_tag(byte *dest, const char *tag, int value) 1720static byte *put_hex_tag(byte *dest, const char *tag, int value)
1721{ 1721{
1722 int i; 1722 int i;
1723 if (value < 0) 1723 if (value < 0)
1724 return dest; 1724 return dest;
1725 dest = put_string(dest, tag); 1725 dest = put_string(dest, tag);
1726 for (i = 12; i >= 0; i -= 4) { 1726 for (i = 12; i >= 0; i -= 4) {
1727 int digit = (value >> i) & 0xf; 1727 int digit = (value >> i) & 0xf;
1728 *dest++ = (byte) (digit + (digit < 10 ? '0' : 'A' - 10)); 1728 *dest++ = (byte) (digit + (digit < 10 ? '0' : 'A' - 10));
1729 } 1729 }
1730 *dest++ = '\r'; 1730 *dest++ = '\r';
1731 *dest++ = '\n'; 1731 *dest++ = '\n';
1732 return dest; 1732 return dest;
1733} 1733}
1734 1734
1735static byte *start_sap_header(byte *dest, const ASAP_ModuleInfo *module_info) 1735static byte *start_sap_header(byte *dest, const ASAP_ModuleInfo *module_info)
1736{ 1736{
1737 dest = put_string(dest, "SAP\r\n"); 1737 dest = put_string(dest, "SAP\r\n");
1738 dest = put_text_tag(dest, "AUTHOR ", module_info->author); 1738 dest = put_text_tag(dest, "AUTHOR ", module_info->author);
1739 if (dest == NULL) 1739 if (dest == NULL)
1740 return NULL; 1740 return NULL;
1741 dest = put_text_tag(dest, "NAME ", module_info->name); 1741 dest = put_text_tag(dest, "NAME ", module_info->name);
1742 if (dest == NULL) 1742 if (dest == NULL)
1743 return NULL; 1743 return NULL;
1744 dest = put_text_tag(dest, "DATE ", module_info->date); 1744 dest = put_text_tag(dest, "DATE ", module_info->date);
1745 if (dest == NULL) 1745 if (dest == NULL)
1746 return NULL; 1746 return NULL;
1747 if (module_info->songs > 1) { 1747 if (module_info->songs > 1) {
1748 dest = put_dec_tag(dest, "SONGS ", module_info->songs); 1748 dest = put_dec_tag(dest, "SONGS ", module_info->songs);
1749 if (module_info->default_song > 0) 1749 if (module_info->default_song > 0)
1750 dest = put_dec_tag(dest, "DEFSONG ", module_info->default_song); 1750 dest = put_dec_tag(dest, "DEFSONG ", module_info->default_song);
1751 } 1751 }
1752 if (module_info->channels > 1) 1752 if (module_info->channels > 1)
1753 dest = put_string(dest, "STEREO\r\n"); 1753 dest = put_string(dest, "STEREO\r\n");
1754 return dest; 1754 return dest;
1755} 1755}
1756 1756
1757static char *two_digits(char *s, int x) 1757static char *two_digits(char *s, int x)
1758{ 1758{
1759 s[0] = '0' + x / 10; 1759 s[0] = '0' + x / 10;
1760 s[1] = '0' + x % 10; 1760 s[1] = '0' + x % 10;
1761 return s + 2; 1761 return s + 2;
1762} 1762}
1763 1763
1764void ASAP_DurationToString(char *s, int duration) 1764void ASAP_DurationToString(char *s, int duration)
1765{ 1765{
1766 if (duration >= 0 && duration < 100 * 60 * 1000) { 1766 if (duration >= 0 && duration < 100 * 60 * 1000) {
1767 int seconds = duration / 1000; 1767 int seconds = duration / 1000;
1768 s = two_digits(s, seconds / 60); 1768 s = two_digits(s, seconds / 60);
1769 *s++ = ':'; 1769 *s++ = ':';
1770 s = two_digits(s, seconds % 60); 1770 s = two_digits(s, seconds % 60);
1771 duration %= 1000; 1771 duration %= 1000;
1772 if (duration != 0) { 1772 if (duration != 0) {
1773 *s++ = '.'; 1773 *s++ = '.';
1774 s = two_digits(s, duration / 10); 1774 s = two_digits(s, duration / 10);
1775 duration %= 10; 1775 duration %= 10;
1776 if (duration != 0) 1776 if (duration != 0)
1777 *s++ = '0' + duration; 1777 *s++ = '0' + duration;
1778 } 1778 }
1779 } 1779 }
1780 *s = '\0'; 1780 *s = '\0';
1781} 1781}
1782 1782
1783static byte *put_durations(byte *dest, const ASAP_ModuleInfo *module_info) 1783static byte *put_durations(byte *dest, const ASAP_ModuleInfo *module_info)
1784{ 1784{
1785 int song; 1785 int song;
1786 for (song = 0; song < module_info->songs; song++) { 1786 for (song = 0; song < module_info->songs; song++) {
1787 if (module_info->durations[song] < 0) 1787 if (module_info->durations[song] < 0)
1788 break; 1788 break;
1789 dest = put_string(dest, "TIME "); 1789 dest = put_string(dest, "TIME ");
1790 ASAP_DurationToString((char *) dest, module_info->durations[song]); 1790 ASAP_DurationToString((char *) dest, module_info->durations[song]);
1791 while (*dest != '\0') 1791 while (*dest != '\0')
1792 dest++; 1792 dest++;
1793 if (module_info->loops[song]) 1793 if (module_info->loops[song])
1794 dest = put_string(dest, " LOOP"); 1794 dest = put_string(dest, " LOOP");
1795 *dest++ = '\r'; 1795 *dest++ = '\r';
1796 *dest++ = '\n'; 1796 *dest++ = '\n';
1797 } 1797 }
1798 return dest; 1798 return dest;
1799} 1799}
1800 1800
1801static byte *put_sap_header(byte *dest, const ASAP_ModuleInfo *module_info, char type, int music, int init, int player) 1801static byte *put_sap_header(byte *dest, const ASAP_ModuleInfo *module_info, char type, int music, int init, int player)
1802{ 1802{
1803 dest = start_sap_header(dest, module_info); 1803 dest = start_sap_header(dest, module_info);
1804 if (dest == NULL) 1804 if (dest == NULL)
1805 return NULL; 1805 return NULL;
1806 dest = put_string(dest, "TYPE "); 1806 dest = put_string(dest, "TYPE ");
1807 *dest++ = type; 1807 *dest++ = type;
1808 *dest++ = '\r'; 1808 *dest++ = '\r';
1809 *dest++ = '\n'; 1809 *dest++ = '\n';
1810 if (module_info->fastplay != 312) 1810 if (module_info->fastplay != 312)
1811 dest = put_dec_tag(dest, "FASTPLAY ", module_info->fastplay); 1811 dest = put_dec_tag(dest, "FASTPLAY ", module_info->fastplay);
1812 dest = put_hex_tag(dest, "MUSIC ", music); 1812 dest = put_hex_tag(dest, "MUSIC ", music);
1813 dest = put_hex_tag(dest, "INIT ", init); 1813 dest = put_hex_tag(dest, "INIT ", init);
1814 dest = put_hex_tag(dest, "PLAYER ", player); 1814 dest = put_hex_tag(dest, "PLAYER ", player);
1815 dest = put_durations(dest, module_info); 1815 dest = put_durations(dest, module_info);
1816 return dest; 1816 return dest;
1817} 1817}
1818 1818
1819int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const BYTEARRAY module, int module_len, BYTEARRAY out_module) 1819int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const BYTEARRAY module, int module_len, BYTEARRAY out_module)
1820{ 1820{
1821 byte *dest; 1821 byte *dest;
1822 int i; 1822 int i;
1823 if (memcmp(module, "SAP\r\n", 5) != 0) 1823 if (memcmp(module, "SAP\r\n", 5) != 0)
1824 return -1; 1824 return -1;
1825 dest = start_sap_header(out_module, module_info); 1825 dest = start_sap_header(out_module, module_info);
1826 if (dest == NULL) 1826 if (dest == NULL)
1827 return -1; 1827 return -1;
1828 i = 5; 1828 i = 5;
1829 while (i < module_len && module[i] != 0xff) { 1829 while (i < module_len && module[i] != 0xff) {
1830 if (memcmp(module + i, "AUTHOR ", 7) == 0 1830 if (memcmp(module + i, "AUTHOR ", 7) == 0
1831 || memcmp(module + i, "NAME ", 5) == 0 1831 || memcmp(module + i, "NAME ", 5) == 0
1832 || memcmp(module + i, "DATE ", 5) == 0 1832 || memcmp(module + i, "DATE ", 5) == 0
1833 || memcmp(module + i, "SONGS ", 6) == 0 1833 || memcmp(module + i, "SONGS ", 6) == 0
1834 || memcmp(module + i, "DEFSONG ", 8) == 0 1834 || memcmp(module + i, "DEFSONG ", 8) == 0
1835 || memcmp(module + i, "STEREO\r", 7) == 0 1835 || memcmp(module + i, "STEREO\r", 7) == 0
1836 || memcmp(module + i, "TIME ", 5) == 0) { 1836 || memcmp(module + i, "TIME ", 5) == 0) {
1837 while (i < module_len && module[i++] != 0x0a); 1837 while (i < module_len && module[i++] != 0x0a);
1838 } 1838 }
1839 else { 1839 else {
1840 int b; 1840 int b;
1841 do { 1841 do {
1842 b = module[i++]; 1842 b = module[i++];
1843 *dest++ = b; 1843 *dest++ = b;
1844 } while (i < module_len && b != 0x0a); 1844 } while (i < module_len && b != 0x0a);
1845 } 1845 }
1846 } 1846 }
1847 dest = put_durations(dest, module_info); 1847 dest = put_durations(dest, module_info);
1848 module_len -= i; 1848 module_len -= i;
1849 memcpy(dest, module + i, module_len); 1849 memcpy(dest, module + i, module_len);
1850 dest += module_len; 1850 dest += module_len;
1851 return dest - out_module; 1851 return dest - out_module;
1852} 1852}
1853 1853
1854#define RMT_INIT 0x0c80 1854#define RMT_INIT 0x0c80
1855#define TM2_INIT 0x1080 1855#define TM2_INIT 0x1080
1856 1856
1857const char *ASAP_CanConvert( 1857const char *ASAP_CanConvert(
1858 const char *filename, const ASAP_ModuleInfo *module_info, 1858 const char *filename, const ASAP_ModuleInfo *module_info,
1859 const BYTEARRAY module, int module_len) 1859 const BYTEARRAY module, int module_len)
1860{ 1860{
1861 (void) filename; 1861 (void) filename;
1862 switch (module_info->type) { 1862 switch (module_info->type) {
1863 case ASAP_TYPE_SAP_B: 1863 case ASAP_TYPE_SAP_B:
1864 if ((module_info->init == 0x3fb || module_info->init == 0x3f9) && module_info->player == 0x503) 1864 if ((module_info->init == 0x3fb || module_info->init == 0x3f9) && module_info->player == 0x503)
1865 return "dlt"; 1865 return "dlt";
1866 if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef) 1866 if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef)
1867 return module_info->fastplay == 156 ? "mpd" : "mpt"; 1867 return module_info->fastplay == 156 ? "mpd" : "mpt";
1868 if (module_info->init == RMT_INIT) 1868 if (module_info->init == RMT_INIT)
1869 return "rmt"; 1869 return "rmt";
1870 if ((module_info->init == 0x4f5 || module_info->init == 0xf4f5 || module_info->init == 0x4f2) 1870 if ((module_info->init == 0x4f5 || module_info->init == 0xf4f5 || module_info->init == 0x4f2)
1871 || ((module_info->init == 0x4e7 || module_info->init == 0xf4e7 || module_info->init == 0x4e4) && module_info->fastplay == 156) 1871 || ((module_info->init == 0x4e7 || module_info->init == 0xf4e7 || module_info->init == 0x4e4) && module_info->fastplay == 156)
1872 || ((module_info->init == 0x4e5 || module_info->init == 0xf4e5 || module_info->init == 0x4e2) && (module_info->fastplay == 104 || module_info->fastplay == 78))) 1872 || ((module_info->init == 0x4e5 || module_info->init == 0xf4e5 || module_info->init == 0x4e2) && (module_info->fastplay == 104 || module_info->fastplay == 78)))
1873 return "tmc"; 1873 return "tmc";
1874 if (module_info->init == TM2_INIT) 1874 if (module_info->init == TM2_INIT)
1875 return "tm2"; 1875 return "tm2";
1876 break; 1876 break;
1877 case ASAP_TYPE_SAP_C: 1877 case ASAP_TYPE_SAP_C:
1878 if (module_info->player == 0x500 || module_info->player == 0xf500) { 1878 if (module_info->player == 0x500 || module_info->player == 0xf500) {
1879 if (module_info->fastplay == 156) 1879 if (module_info->fastplay == 156)
1880 return "dmc"; 1880 return "dmc";
1881 if (module_info->channels > 1) 1881 if (module_info->channels > 1)
1882 return "cms"; 1882 return "cms";
1883 if (module[module_len - 170] == 0x1e) 1883 if (module[module_len - 170] == 0x1e)
1884 return "cmr"; 1884 return "cmr";
1885 if (module[module_len - 909] == 0x30) 1885 if (module[module_len - 909] == 0x30)
1886 return "cm3"; 1886 return "cm3";
1887 return "cmc"; 1887 return "cmc";
1888 } 1888 }
1889 break; 1889 break;
1890 case ASAP_TYPE_CMC: 1890 case ASAP_TYPE_CMC:
1891 case ASAP_TYPE_CM3: 1891 case ASAP_TYPE_CM3:
1892 case ASAP_TYPE_CMR: 1892 case ASAP_TYPE_CMR:
1893 case ASAP_TYPE_CMS: 1893 case ASAP_TYPE_CMS:
1894 case ASAP_TYPE_DLT: 1894 case ASAP_TYPE_DLT:
1895 case ASAP_TYPE_MPT: 1895 case ASAP_TYPE_MPT:
1896 case ASAP_TYPE_RMT: 1896 case ASAP_TYPE_RMT:
1897 case ASAP_TYPE_TMC: 1897 case ASAP_TYPE_TMC:
1898 case ASAP_TYPE_TM2: 1898 case ASAP_TYPE_TM2:
1899 return "sap"; 1899 return "sap";
1900 default: 1900 default:
1901 break; 1901 break;
1902 } 1902 }
1903 return NULL; 1903 return NULL;
1904} 1904}
1905 1905
1906int ASAP_Convert( 1906int ASAP_Convert(
1907 const char *filename, const ASAP_ModuleInfo *module_info, 1907 const char *filename, const ASAP_ModuleInfo *module_info,
1908 const BYTEARRAY module, int module_len, BYTEARRAY out_module) 1908 const BYTEARRAY module, int module_len, BYTEARRAY out_module)
1909{ 1909{
1910 (void) filename; 1910 (void) filename;
1911 int out_len; 1911 int out_len;
1912 byte *dest; 1912 byte *dest;
1913 int addr; 1913 int addr;
1914 int player; 1914 int player;
1915 static const int tmc_player[4] = { 3, -9, -10, -10 }; 1915 static const int tmc_player[4] = { 3, -9, -10, -10 };
1916 static const int tmc_init[4] = { -14, -16, -17, -17 }; 1916 static const int tmc_init[4] = { -14, -16, -17, -17 };
1917 switch (module_info->type) { 1917 switch (module_info->type) {
1918 case ASAP_TYPE_SAP_B: 1918 case ASAP_TYPE_SAP_B:
1919 case ASAP_TYPE_SAP_C: 1919 case ASAP_TYPE_SAP_C:
1920 out_len = UWORD(module, module_info->header_len + 4) - UWORD(module, module_info->header_len + 2) + 7; 1920 out_len = UWORD(module, module_info->header_len + 4) - UWORD(module, module_info->header_len + 2) + 7;
1921 if (out_len < 7 || module_info->header_len + out_len >= module_len) 1921 if (out_len < 7 || module_info->header_len + out_len >= module_len)
1922 return -1; 1922 return -1;
1923 memcpy(out_module, module + module_info->header_len, out_len); 1923 memcpy(out_module, module + module_info->header_len, out_len);
1924 return out_len; 1924 return out_len;
1925 case ASAP_TYPE_CMC: 1925 case ASAP_TYPE_CMC:
1926 case ASAP_TYPE_CM3: 1926 case ASAP_TYPE_CM3:
1927 case ASAP_TYPE_CMR: 1927 case ASAP_TYPE_CMR:
1928 case ASAP_TYPE_CMS: 1928 case ASAP_TYPE_CMS:
1929 dest = put_sap_header(out_module, module_info, 'C', module_info->music, -1, module_info->player); 1929 dest = put_sap_header(out_module, module_info, 'C', module_info->music, -1, module_info->player);
1930 if (dest == NULL) 1930 if (dest == NULL)
1931 return -1; 1931 return -1;
1932 memcpy(dest, module, module_len); 1932 memcpy(dest, module, module_len);
1933 dest[0] = 0xff; /* some modules start with zeros */ 1933 dest[0] = 0xff; /* some modules start with zeros */
1934 dest[1] = 0xff; 1934 dest[1] = 0xff;
1935 dest += module_len; 1935 dest += module_len;
1936 if (module_info->type == ASAP_TYPE_CM3) { 1936 if (module_info->type == ASAP_TYPE_CM3) {
1937 memcpy(dest, cm3_obx + 2, sizeof(cm3_obx) - 2); 1937 memcpy(dest, cm3_obx + 2, sizeof(cm3_obx) - 2);
1938 dest += sizeof(cm3_obx) - 2; 1938 dest += sizeof(cm3_obx) - 2;
1939 } 1939 }
1940 else if (module_info->type == ASAP_TYPE_CMS) { 1940 else if (module_info->type == ASAP_TYPE_CMS) {
1941 memcpy(dest, cms_obx + 2, sizeof(cms_obx) - 2); 1941 memcpy(dest, cms_obx + 2, sizeof(cms_obx) - 2);
1942 dest += sizeof(cms_obx) - 2; 1942 dest += sizeof(cms_obx) - 2;
1943 } 1943 }
1944 else { 1944 else {
1945 memcpy(dest, cmc_obx + 2, sizeof(cmc_obx) - 2); 1945 memcpy(dest, cmc_obx + 2, sizeof(cmc_obx) - 2);
1946 if (module_info->type == ASAP_TYPE_CMR) 1946 if (module_info->type == ASAP_TYPE_CMR)
1947 memcpy(dest + 4 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, sizeof(cmr_bass_table)); 1947 memcpy(dest + 4 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, sizeof(cmr_bass_table));
1948 dest += sizeof(cmc_obx) - 2; 1948 dest += sizeof(cmc_obx) - 2;
1949 } 1949 }
1950 return dest - out_module; 1950 return dest - out_module;
1951 case ASAP_TYPE_DLT: 1951 case ASAP_TYPE_DLT:
1952 if (module_info->songs != 1) { 1952 if (module_info->songs != 1) {
1953 addr = module_info->player - 7 - module_info->songs; 1953 addr = module_info->player - 7 - module_info->songs;
1954 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 7, module_info->player + 0x103); 1954 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 7, module_info->player + 0x103);
1955 } 1955 }
1956 else { 1956 else {
1957 addr = module_info->player - 5; 1957 addr = module_info->player - 5;
1958 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 0x103); 1958 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 0x103);
1959 } 1959 }
1960 if (dest == NULL) 1960 if (dest == NULL)
1961 return -1; 1961 return -1;
1962 memcpy(dest, module, module_len); 1962 memcpy(dest, module, module_len);
1963 if (module_len == 0x2c06) { 1963 if (module_len == 0x2c06) {
1964 dest[4] = 0; 1964 dest[4] = 0;
1965 dest[5] = 0x4c; 1965 dest[5] = 0x4c;
1966 dest[0x2c06] = 0; 1966 dest[0x2c06] = 0;
1967 } 1967 }
1968 dest += 0x2c07; 1968 dest += 0x2c07;
1969 *dest++ = (byte) addr; 1969 *dest++ = (byte) addr;
1970 *dest++ = (byte) (addr >> 8); 1970 *dest++ = (byte) (addr >> 8);
1971 *dest++ = dlt_obx[4]; 1971 *dest++ = dlt_obx[4];
1972 *dest++ = dlt_obx[5]; 1972 *dest++ = dlt_obx[5];
1973 if (module_info->songs != 1) { 1973 if (module_info->songs != 1) {
1974 memcpy(dest, module_info->song_pos, module_info->songs); 1974 memcpy(dest, module_info->song_pos, module_info->songs);
1975 dest += module_info->songs; 1975 dest += module_info->songs;
1976 *dest++ = 0xaa; /* tax */ 1976 *dest++ = 0xaa; /* tax */
1977 *dest++ = 0xbc; /* ldy song2pos,x */ 1977 *dest++ = 0xbc; /* ldy song2pos,x */
1978 *dest++ = (byte) addr; 1978 *dest++ = (byte) addr;
1979 *dest++ = (byte) (addr >> 8); 1979 *dest++ = (byte) (addr >> 8);
1980 } 1980 }
1981 else { 1981 else {
1982 *dest++ = 0xa0; /* ldy #0 */ 1982 *dest++ = 0xa0; /* ldy #0 */
1983 *dest++ = 0; 1983 *dest++ = 0;
1984 } 1984 }
1985 *dest++ = 0x4c; /* jmp init */ 1985 *dest++ = 0x4c; /* jmp init */
1986 *dest++ = (byte) module_info->player; 1986 *dest++ = (byte) module_info->player;
1987 *dest++ = (byte) ((module_info->player >> 8) + 1); 1987 *dest++ = (byte) ((module_info->player >> 8) + 1);
1988 memcpy(dest, dlt_obx + 6, sizeof(dlt_obx) - 6); 1988 memcpy(dest, dlt_obx + 6, sizeof(dlt_obx) - 6);
1989 dest += sizeof(dlt_obx) - 6; 1989 dest += sizeof(dlt_obx) - 6;
1990 return dest - out_module; 1990 return dest - out_module;
1991 case ASAP_TYPE_MPT: 1991 case ASAP_TYPE_MPT:
1992 if (module_info->songs != 1) { 1992 if (module_info->songs != 1) {
1993 addr = module_info->player - 17 - module_info->songs; 1993 addr = module_info->player - 17 - module_info->songs;
1994 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 17, module_info->player + 3); 1994 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 17, module_info->player + 3);
1995 } 1995 }
1996 else { 1996 else {
1997 addr = module_info->player - 13; 1997 addr = module_info->player - 13;
1998 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 3); 1998 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 3);
1999 } 1999 }
2000 if (dest == NULL) 2000 if (dest == NULL)
2001 return -1; 2001 return -1;
2002 memcpy(dest, module, module_len); 2002 memcpy(dest, module, module_len);
2003 dest += module_len; 2003 dest += module_len;
2004 *dest++ = (byte) addr; 2004 *dest++ = (byte) addr;
2005 *dest++ = (byte) (addr >> 8); 2005 *dest++ = (byte) (addr >> 8);
2006 *dest++ = mpt_obx[4]; 2006 *dest++ = mpt_obx[4];
2007 *dest++ = mpt_obx[5]; 2007 *dest++ = mpt_obx[5];
2008 if (module_info->songs != 1) { 2008 if (module_info->songs != 1) {
2009 memcpy(dest, module_info->song_pos, module_info->songs); 2009 memcpy(dest, module_info->song_pos, module_info->songs);
2010 dest += module_info->songs; 2010 dest += module_info->songs;
2011 *dest++ = 0x48; /* pha */ 2011 *dest++ = 0x48; /* pha */
2012 } 2012 }
2013 *dest++ = 0xa0; /* ldy #<music */ 2013 *dest++ = 0xa0; /* ldy #<music */
2014 *dest++ = (byte) module_info->music; 2014 *dest++ = (byte) module_info->music;
2015 *dest++ = 0xa2; /* ldx #>music */ 2015 *dest++ = 0xa2; /* ldx #>music */
2016 *dest++ = (byte) (module_info->music >> 8); 2016 *dest++ = (byte) (module_info->music >> 8);
2017 *dest++ = 0xa9; /* lda #0 */ 2017 *dest++ = 0xa9; /* lda #0 */
2018 *dest++ = 0; 2018 *dest++ = 0;
2019 *dest++ = 0x20; /* jsr player */ 2019 *dest++ = 0x20; /* jsr player */
2020 *dest++ = (byte) module_info->player; 2020 *dest++ = (byte) module_info->player;
2021 *dest++ = (byte) (module_info->player >> 8); 2021 *dest++ = (byte) (module_info->player >> 8);
2022 if (module_info->songs != 1) { 2022 if (module_info->songs != 1) {
2023 *dest++ = 0x68; /* pla */ 2023 *dest++ = 0x68; /* pla */
2024 *dest++ = 0xa8; /* tay */ 2024 *dest++ = 0xa8; /* tay */
2025 *dest++ = 0xbe; /* ldx song2pos,y */ 2025 *dest++ = 0xbe; /* ldx song2pos,y */
2026 *dest++ = (byte) addr; 2026 *dest++ = (byte) addr;
2027 *dest++ = (byte) (addr >> 8); 2027 *dest++ = (byte) (addr >> 8);
2028 } 2028 }
2029 else { 2029 else {
2030 *dest++ = 0xa2; /* ldx #0 */ 2030 *dest++ = 0xa2; /* ldx #0 */
2031 *dest++ = 0; 2031 *dest++ = 0;
2032 } 2032 }
2033 *dest++ = 0xa9; /* lda #2 */ 2033 *dest++ = 0xa9; /* lda #2 */
2034 *dest++ = 2; 2034 *dest++ = 2;
2035 memcpy(dest, mpt_obx + 6, sizeof(mpt_obx) - 6); 2035 memcpy(dest, mpt_obx + 6, sizeof(mpt_obx) - 6);
2036 dest += sizeof(mpt_obx) - 6; 2036 dest += sizeof(mpt_obx) - 6;
2037 return dest - out_module; 2037 return dest - out_module;
2038 case ASAP_TYPE_RMT: 2038 case ASAP_TYPE_RMT:
2039 dest = put_sap_header(out_module, module_info, 'B', -1, RMT_INIT, module_info->player + 3); 2039 dest = put_sap_header(out_module, module_info, 'B', -1, RMT_INIT, module_info->player + 3);
2040 if (dest == NULL) 2040 if (dest == NULL)
2041 return -1; 2041 return -1;
2042 memcpy(dest, module, module_len); 2042 memcpy(dest, module, module_len);
2043 dest += module_len; 2043 dest += module_len;
2044 *dest++ = (byte) RMT_INIT; 2044 *dest++ = (byte) RMT_INIT;
2045 *dest++ = (byte) (RMT_INIT >> 8); 2045 *dest++ = (byte) (RMT_INIT >> 8);
2046 if (module_info->songs != 1) { 2046 if (module_info->songs != 1) {
2047 addr = RMT_INIT + 10 + module_info->songs; 2047 addr = RMT_INIT + 10 + module_info->songs;
2048 *dest++ = (byte) addr; 2048 *dest++ = (byte) addr;
2049 *dest++ = (byte) (addr >> 8); 2049 *dest++ = (byte) (addr >> 8);
2050 *dest++ = 0xa8; /* tay */ 2050 *dest++ = 0xa8; /* tay */
2051 *dest++ = 0xb9; /* lda song2pos,y */ 2051 *dest++ = 0xb9; /* lda song2pos,y */
2052 *dest++ = (byte) (RMT_INIT + 11); 2052 *dest++ = (byte) (RMT_INIT + 11);
2053 *dest++ = (byte) ((RMT_INIT + 11) >> 8); 2053 *dest++ = (byte) ((RMT_INIT + 11) >> 8);
2054 } 2054 }
2055 else { 2055 else {
2056 *dest++ = (byte) (RMT_INIT + 8); 2056 *dest++ = (byte) (RMT_INIT + 8);
2057 *dest++ = (byte) ((RMT_INIT + 8) >> 8); 2057 *dest++ = (byte) ((RMT_INIT + 8) >> 8);
2058 *dest++ = 0xa9; /* lda #0 */ 2058 *dest++ = 0xa9; /* lda #0 */
2059 *dest++ = 0; 2059 *dest++ = 0;
2060 } 2060 }
2061 *dest++ = 0xa2; /* ldx #<music */ 2061 *dest++ = 0xa2; /* ldx #<music */
2062 *dest++ = (byte) module_info->music; 2062 *dest++ = (byte) module_info->music;
2063 *dest++ = 0xa0; /* ldy #>music */ 2063 *dest++ = 0xa0; /* ldy #>music */
2064 *dest++ = (byte) (module_info->music >> 8); 2064 *dest++ = (byte) (module_info->music >> 8);
2065 *dest++ = 0x4c; /* jmp player */ 2065 *dest++ = 0x4c; /* jmp player */
2066 *dest++ = (byte) module_info->player; 2066 *dest++ = (byte) module_info->player;
2067 *dest++ = (byte) (module_info->player >> 8); 2067 *dest++ = (byte) (module_info->player >> 8);
2068 if (module_info->songs != 1) { 2068 if (module_info->songs != 1) {
2069 memcpy(dest, module_info->song_pos, module_info->songs); 2069 memcpy(dest, module_info->song_pos, module_info->songs);
2070 dest += module_info->songs; 2070 dest += module_info->songs;
2071 } 2071 }
2072 if (module_info->channels == 1) { 2072 if (module_info->channels == 1) {
2073 memcpy(dest, rmt4_obx + 2, sizeof(rmt4_obx) - 2); 2073 memcpy(dest, rmt4_obx + 2, sizeof(rmt4_obx) - 2);
2074 dest += sizeof(rmt4_obx) - 2; 2074 dest += sizeof(rmt4_obx) - 2;
2075 } 2075 }
2076 else { 2076 else {
2077 memcpy(dest, rmt8_obx + 2, sizeof(rmt8_obx) - 2); 2077 memcpy(dest, rmt8_obx + 2, sizeof(rmt8_obx) - 2);
2078 dest += sizeof(rmt8_obx) - 2; 2078 dest += sizeof(rmt8_obx) - 2;
2079 } 2079 }
2080 return dest - out_module; 2080 return dest - out_module;
2081 case ASAP_TYPE_TMC: 2081 case ASAP_TYPE_TMC:
2082 player = module_info->player + tmc_player[module[0x25] - 1]; 2082 player = module_info->player + tmc_player[module[0x25] - 1];
2083 addr = player + tmc_init[module[0x25] - 1]; 2083 addr = player + tmc_init[module[0x25] - 1];
2084 if (module_info->songs != 1) 2084 if (module_info->songs != 1)
2085 addr -= 3; 2085 addr -= 3;
2086 dest = put_sap_header(out_module, module_info, 'B', -1, addr, player); 2086 dest = put_sap_header(out_module, module_info, 'B', -1, addr, player);
2087 if (dest == NULL) 2087 if (dest == NULL)
2088 return -1; 2088 return -1;
2089 memcpy(dest, module, module_len); 2089 memcpy(dest, module, module_len);
2090 dest += module_len; 2090 dest += module_len;
2091 *dest++ = (byte) addr; 2091 *dest++ = (byte) addr;
2092 *dest++ = (byte) (addr >> 8); 2092 *dest++ = (byte) (addr >> 8);
2093 *dest++ = tmc_obx[4]; 2093 *dest++ = tmc_obx[4];
2094 *dest++ = tmc_obx[5]; 2094 *dest++ = tmc_obx[5];
2095 if (module_info->songs != 1) 2095 if (module_info->songs != 1)
2096 *dest++ = 0x48; /* pha */ 2096 *dest++ = 0x48; /* pha */
2097 *dest++ = 0xa0; /* ldy #<music */ 2097 *dest++ = 0xa0; /* ldy #<music */
2098 *dest++ = (byte) module_info->music; 2098 *dest++ = (byte) module_info->music;
2099 *dest++ = 0xa2; /* ldx #>music */ 2099 *dest++ = 0xa2; /* ldx #>music */
2100 *dest++ = (byte) (module_info->music >> 8); 2100 *dest++ = (byte) (module_info->music >> 8);
2101 *dest++ = 0xa9; /* lda #$70 */ 2101 *dest++ = 0xa9; /* lda #$70 */
2102 *dest++ = 0x70; 2102 *dest++ = 0x70;
2103 *dest++ = 0x20; /* jsr player */ 2103 *dest++ = 0x20; /* jsr player */
2104 *dest++ = (byte) module_info->player; 2104 *dest++ = (byte) module_info->player;
2105 *dest++ = (byte) (module_info->player >> 8); 2105 *dest++ = (byte) (module_info->player >> 8);
2106 if (module_info->songs != 1) { 2106 if (module_info->songs != 1) {
2107 *dest++ = 0x68; /* pla */ 2107 *dest++ = 0x68; /* pla */
2108 *dest++ = 0xaa; /* tax */ 2108 *dest++ = 0xaa; /* tax */
2109 *dest++ = 0xa9; /* lda #0 */ 2109 *dest++ = 0xa9; /* lda #0 */
2110 *dest++ = 0; 2110 *dest++ = 0;
2111 } 2111 }
2112 else { 2112 else {
2113 *dest++ = 0xa9; /* lda #$60 */ 2113 *dest++ = 0xa9; /* lda #$60 */
2114 *dest++ = 0x60; 2114 *dest++ = 0x60;
2115 } 2115 }
2116 switch (module[0x25]) { 2116 switch (module[0x25]) {
2117 case 2: 2117 case 2:
2118 *dest++ = 0x06; /* asl 0 */ 2118 *dest++ = 0x06; /* asl 0 */
2119 *dest++ = 0; 2119 *dest++ = 0;
2120 *dest++ = 0x4c; /* jmp player */ 2120 *dest++ = 0x4c; /* jmp player */
2121 *dest++ = (byte) module_info->player; 2121 *dest++ = (byte) module_info->player;
2122 *dest++ = (byte) (module_info->player >> 8); 2122 *dest++ = (byte) (module_info->player >> 8);
2123 *dest++ = 0xa5; /* lda 0 */ 2123 *dest++ = 0xa5; /* lda 0 */
2124 *dest++ = 0; 2124 *dest++ = 0;
2125 *dest++ = 0xe6; /* inc 0 */ 2125 *dest++ = 0xe6; /* inc 0 */
2126 *dest++ = 0; 2126 *dest++ = 0;
2127 *dest++ = 0x4a; /* lsr @ */ 2127 *dest++ = 0x4a; /* lsr @ */
2128 *dest++ = 0x90; /* bcc player+3 */ 2128 *dest++ = 0x90; /* bcc player+3 */
2129 *dest++ = 5; 2129 *dest++ = 5;
2130 *dest++ = 0xb0; /* bcs player+6 */ 2130 *dest++ = 0xb0; /* bcs player+6 */
2131 *dest++ = 6; 2131 *dest++ = 6;
2132 break; 2132 break;
2133 case 3: 2133 case 3:
2134 case 4: 2134 case 4:
2135 *dest++ = 0xa0; /* ldy #1 */ 2135 *dest++ = 0xa0; /* ldy #1 */
2136 *dest++ = 1; 2136 *dest++ = 1;
2137 *dest++ = 0x84; /* sty 0 */ 2137 *dest++ = 0x84; /* sty 0 */
2138 *dest++ = 0; 2138 *dest++ = 0;
2139 *dest++ = 0xd0; /* bne player */ 2139 *dest++ = 0xd0; /* bne player */
2140 *dest++ = 10; 2140 *dest++ = 10;
2141 *dest++ = 0xc6; /* dec 0 */ 2141 *dest++ = 0xc6; /* dec 0 */
2142 *dest++ = 0; 2142 *dest++ = 0;
2143 *dest++ = 0xd0; /* bne player+6 */ 2143 *dest++ = 0xd0; /* bne player+6 */
2144 *dest++ = 12; 2144 *dest++ = 12;
2145 *dest++ = 0xa0; /* ldy #3 */ 2145 *dest++ = 0xa0; /* ldy #3 */
2146 *dest++ = module[0x25]; 2146 *dest++ = module[0x25];
2147 *dest++ = 0x84; /* sty 0 */ 2147 *dest++ = 0x84; /* sty 0 */
2148 *dest++ = 0; 2148 *dest++ = 0;
2149 *dest++ = 0xd0; /* bne player+3 */ 2149 *dest++ = 0xd0; /* bne player+3 */
2150 *dest++ = 3; 2150 *dest++ = 3;
2151 break; 2151 break;
2152 default: 2152 default:
2153 break; 2153 break;
2154 } 2154 }
2155 memcpy(dest, tmc_obx + 6, sizeof(tmc_obx) - 6); 2155 memcpy(dest, tmc_obx + 6, sizeof(tmc_obx) - 6);
2156 dest += sizeof(tmc_obx) - 6; 2156 dest += sizeof(tmc_obx) - 6;
2157 return dest - out_module; 2157 return dest - out_module;
2158 case ASAP_TYPE_TM2: 2158 case ASAP_TYPE_TM2:
2159 dest = put_sap_header(out_module, module_info, 'B', -1, TM2_INIT, module_info->player + 3); 2159 dest = put_sap_header(out_module, module_info, 'B', -1, TM2_INIT, module_info->player + 3);
2160 if (dest == NULL) 2160 if (dest == NULL)
2161 return -1; 2161 return -1;
2162 memcpy(dest, module, module_len); 2162 memcpy(dest, module, module_len);
2163 dest += module_len; 2163 dest += module_len;
2164 *dest++ = (byte) TM2_INIT; 2164 *dest++ = (byte) TM2_INIT;
2165 *dest++ = (byte) (TM2_INIT >> 8); 2165 *dest++ = (byte) (TM2_INIT >> 8);
2166 if (module_info->songs != 1) { 2166 if (module_info->songs != 1) {
2167 *dest++ = (byte) (TM2_INIT + 16); 2167 *dest++ = (byte) (TM2_INIT + 16);
2168 *dest++ = (byte) ((TM2_INIT + 16) >> 8); 2168 *dest++ = (byte) ((TM2_INIT + 16) >> 8);
2169 *dest++ = 0x48; /* pha */ 2169 *dest++ = 0x48; /* pha */
2170 } 2170 }
2171 else { 2171 else {
2172 *dest++ = (byte) (TM2_INIT + 14); 2172 *dest++ = (byte) (TM2_INIT + 14);
2173 *dest++ = (byte) ((TM2_INIT + 14) >> 8); 2173 *dest++ = (byte) ((TM2_INIT + 14) >> 8);
2174 } 2174 }
2175 *dest++ = 0xa0; /* ldy #<music */ 2175 *dest++ = 0xa0; /* ldy #<music */
2176 *dest++ = (byte) module_info->music; 2176 *dest++ = (byte) module_info->music;
2177 *dest++ = 0xa2; /* ldx #>music */ 2177 *dest++ = 0xa2; /* ldx #>music */
2178 *dest++ = (byte) (module_info->music >> 8); 2178 *dest++ = (byte) (module_info->music >> 8);
2179 *dest++ = 0xa9; /* lda #$70 */ 2179 *dest++ = 0xa9; /* lda #$70 */
2180 *dest++ = 0x70; 2180 *dest++ = 0x70;
2181 *dest++ = 0x20; /* jsr player */ 2181 *dest++ = 0x20; /* jsr player */
2182 *dest++ = (byte) module_info->player; 2182 *dest++ = (byte) module_info->player;
2183 *dest++ = (byte) (module_info->player >> 8); 2183 *dest++ = (byte) (module_info->player >> 8);
2184 if (module_info->songs != 1) { 2184 if (module_info->songs != 1) {
2185 *dest++ = 0x68; /* pla */ 2185 *dest++ = 0x68; /* pla */
2186 *dest++ = 0xaa; /* tax */ 2186 *dest++ = 0xaa; /* tax */
2187 *dest++ = 0xa9; /* lda #0 */ 2187 *dest++ = 0xa9; /* lda #0 */
2188 *dest++ = 0; 2188 *dest++ = 0;
2189 } 2189 }
2190 else { 2190 else {
2191 *dest++ = 0xa9; /* lda #0 */ 2191 *dest++ = 0xa9; /* lda #0 */
2192 *dest++ = 0; 2192 *dest++ = 0;
2193 *dest++ = 0xaa; /* tax */ 2193 *dest++ = 0xaa; /* tax */
2194 } 2194 }
2195 *dest++ = 0x4c; /* jmp player */ 2195 *dest++ = 0x4c; /* jmp player */
2196 *dest++ = (byte) module_info->player; 2196 *dest++ = (byte) module_info->player;
2197 *dest++ = (byte) (module_info->player >> 8); 2197 *dest++ = (byte) (module_info->player >> 8);
2198 memcpy(dest, tm2_obx + 2, sizeof(tm2_obx) - 2); 2198 memcpy(dest, tm2_obx + 2, sizeof(tm2_obx) - 2);
2199 dest += sizeof(tm2_obx) - 2; 2199 dest += sizeof(tm2_obx) - 2;
2200 return dest - out_module; 2200 return dest - out_module;
2201 default: 2201 default:
2202 return -1; 2202 return -1;
2203 } 2203 }
2204} 2204}
2205 2205
2206#endif /* defined(C) && !defined(ASAP_ONLY_SAP) */ 2206#endif /* defined(C) && !defined(ASAP_ONLY_SAP) */
diff --git a/apps/codecs/libasap/asap.h b/apps/codecs/libasap/asap.h
index 02f6e680f2..b43b3ce0c2 100644
--- a/apps/codecs/libasap/asap.h
+++ b/apps/codecs/libasap/asap.h
@@ -37,19 +37,19 @@ extern "C" {
37/* Short credits of the ASAP engine. */ 37/* Short credits of the ASAP engine. */
38#define ASAP_YEARS "2005-2010" 38#define ASAP_YEARS "2005-2010"
39#define ASAP_CREDITS \ 39#define ASAP_CREDITS \
40 "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \ 40 "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \
41 "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \ 41 "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \
42 "RMT player (C) 2002-2005 Radek Sterba\n" \ 42 "RMT player (C) 2002-2005 Radek Sterba\n" \
43 "DLT player (C) 2009 Marek Konopka\n" \ 43 "DLT player (C) 2009 Marek Konopka\n" \
44 "CMS player (C) 1999 David Spilka\n" 44 "CMS player (C) 1999 David Spilka\n"
45 45
46/* Short GPL notice. 46/* Short GPL notice.
47 Display after the credits. */ 47 Display after the credits. */
48#define ASAP_COPYRIGHT \ 48#define ASAP_COPYRIGHT \
49 "This program is free software; you can redistribute it and/or modify\n" \ 49 "This program is free software; you can redistribute it and/or modify\n" \
50 "it under the terms of the GNU General Public License as published\n" \ 50 "it under the terms of the GNU General Public License as published\n" \
51 "by the Free Software Foundation; either version 2 of the License,\n" \ 51 "by the Free Software Foundation; either version 2 of the License,\n" \
52 "or (at your option) any later version." 52 "or (at your option) any later version."
53 53
54/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */ 54/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */
55#define ASAP_INFO_CHARS 128 55#define ASAP_INFO_CHARS 128
@@ -72,9 +72,9 @@ extern "C" {
72 72
73/* Output formats. */ 73/* Output formats. */
74typedef enum { 74typedef enum {
75 ASAP_FORMAT_U8 = 8, /* unsigned char */ 75 ASAP_FORMAT_U8 = 8, /* unsigned char */
76 ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */ 76 ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */
77 ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */ 77 ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */
78} ASAP_SampleFormat; 78} ASAP_SampleFormat;
79 79
80/* Useful type definitions. */ 80/* Useful type definitions. */
@@ -89,106 +89,106 @@ typedef unsigned char byte;
89 89
90/* Information about a music file. */ 90/* Information about a music file. */
91typedef struct { 91typedef struct {
92 char author[ASAP_INFO_CHARS]; /* author's name */ 92 char author[ASAP_INFO_CHARS]; /* author's name */
93 char name[ASAP_INFO_CHARS]; /* title */ 93 char name[ASAP_INFO_CHARS]; /* title */
94 char date[ASAP_INFO_CHARS]; /* creation date */ 94 char date[ASAP_INFO_CHARS]; /* creation date */
95 int channels; /* 1 for mono or 2 for stereo */ 95 int channels; /* 1 for mono or 2 for stereo */
96 int songs; /* number of subsongs */ 96 int songs; /* number of subsongs */
97 int default_song; /* 0-based index of the "main" subsong */ 97 int default_song; /* 0-based index of the "main" subsong */
98 int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */ 98 int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */
99 abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */ 99 abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */
100 /* the following technical information should not be used outside ASAP. */ 100 /* the following technical information should not be used outside ASAP. */
101 int type; 101 int type;
102 int fastplay; 102 int fastplay;
103 int music; 103 int music;
104 int init; 104 int init;
105 int player; 105 int player;
106 int covox_addr; 106 int covox_addr;
107 int header_len; 107 int header_len;
108 byte song_pos[ASAP_SONGS_MAX]; 108 byte song_pos[ASAP_SONGS_MAX];
109} ASAP_ModuleInfo; 109} ASAP_ModuleInfo;
110 110
111/* POKEY state. 111/* POKEY state.
112 Not for use outside the ASAP engine. */ 112 Not for use outside the ASAP engine. */
113typedef struct { 113typedef struct {
114 int audctl; 114 int audctl;
115 abool init; 115 abool init;
116 int poly_index; 116 int poly_index;
117 int div_cycles; 117 int div_cycles;
118 int mute1; 118 int mute1;
119 int mute2; 119 int mute2;
120 int mute3; 120 int mute3;
121 int mute4; 121 int mute4;
122 int audf1; 122 int audf1;
123 int audf2; 123 int audf2;
124 int audf3; 124 int audf3;
125 int audf4; 125 int audf4;
126 int audc1; 126 int audc1;
127 int audc2; 127 int audc2;
128 int audc3; 128 int audc3;
129 int audc4; 129 int audc4;
130 int tick_cycle1; 130 int tick_cycle1;
131 int tick_cycle2; 131 int tick_cycle2;
132 int tick_cycle3; 132 int tick_cycle3;
133 int tick_cycle4; 133 int tick_cycle4;
134 int period_cycles1; 134 int period_cycles1;
135 int period_cycles2; 135 int period_cycles2;
136 int period_cycles3; 136 int period_cycles3;
137 int period_cycles4; 137 int period_cycles4;
138 int reload_cycles1; 138 int reload_cycles1;
139 int reload_cycles3; 139 int reload_cycles3;
140 int out1; 140 int out1;
141 int out2; 141 int out2;
142 int out3; 142 int out3;
143 int out4; 143 int out4;
144 int delta1; 144 int delta1;
145 int delta2; 145 int delta2;
146 int delta3; 146 int delta3;
147 int delta4; 147 int delta4;
148 int skctl; 148 int skctl;
149 int delta_buffer[888]; 149 int delta_buffer[888];
150} PokeyState; 150} PokeyState;
151 151
152/* Player state. 152/* Player state.
153 Only module_info is meant to be read outside the ASAP engine. */ 153 Only module_info is meant to be read outside the ASAP engine. */
154typedef struct { 154typedef struct {
155 int cycle; 155 int cycle;
156 int cpu_pc; 156 int cpu_pc;
157 int cpu_a; 157 int cpu_a;
158 int cpu_x; 158 int cpu_x;
159 int cpu_y; 159 int cpu_y;
160 int cpu_s; 160 int cpu_s;
161 int cpu_nz; 161 int cpu_nz;
162 int cpu_c; 162 int cpu_c;
163 int cpu_vdi; 163 int cpu_vdi;
164 int scanline_number; 164 int scanline_number;
165 int nearest_event_cycle; 165 int nearest_event_cycle;
166 int next_scanline_cycle; 166 int next_scanline_cycle;
167 int timer1_cycle; 167 int timer1_cycle;
168 int timer2_cycle; 168 int timer2_cycle;
169 int timer4_cycle; 169 int timer4_cycle;
170 int irqst; 170 int irqst;
171 int extra_pokey_mask; 171 int extra_pokey_mask;
172 int consol; 172 int consol;
173 byte covox[4]; 173 byte covox[4];
174 PokeyState base_pokey; 174 PokeyState base_pokey;
175 PokeyState extra_pokey; 175 PokeyState extra_pokey;
176 int sample_offset; 176 int sample_offset;
177 int sample_index; 177 int sample_index;
178 int samples; 178 int samples;
179 int iir_acc_left; 179 int iir_acc_left;
180 int iir_acc_right; 180 int iir_acc_right;
181 ASAP_ModuleInfo module_info; 181 ASAP_ModuleInfo module_info;
182 int tmc_per_frame; 182 int tmc_per_frame;
183 int tmc_per_frame_counter; 183 int tmc_per_frame_counter;
184 int current_song; 184 int current_song;
185 int current_duration; 185 int current_duration;
186 int blocks_played; 186 int blocks_played;
187 int silence_cycles; 187 int silence_cycles;
188 int silence_cycles_counter; 188 int silence_cycles_counter;
189 byte poly9_lookup[511]; 189 byte poly9_lookup[511];
190 byte poly17_lookup[16385]; 190 byte poly17_lookup[16385];
191 byte memory[65536]; 191 byte memory[65536];
192} ASAP_State; 192} ASAP_State;
193 193
194/* Parses the string in the "mm:ss.xxx" format 194/* Parses the string in the "mm:ss.xxx" format
diff --git a/apps/codecs/libasap/players.h b/apps/codecs/libasap/players.h
index 893de67821..fb90b0c76a 100644
--- a/apps/codecs/libasap/players.h
+++ b/apps/codecs/libasap/players.h
@@ -1,1386 +1,1386 @@
1CONST_ARRAY(byte, cmc_obx) 1CONST_ARRAY(byte, cmc_obx)
2 255,255,0,5,220,12,76,15,11,76,120,5,76,203,7,0, 2 255,255,0,5,220,12,76,15,11,76,120,5,76,203,7,0,
3 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, 3 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225,
4 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, 4 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0,
5 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 5 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
6 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
7 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, 7 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0,
8 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 8 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, 9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110,
10 5,142,111,5,140,112,5,41,112,74,74,74,170,189,145,11, 10 5,142,111,5,140,112,5,41,112,74,74,74,170,189,145,11,
11 141,169,5,189,146,11,141,170,5,169,3,141,15,210,216,165, 11 141,169,5,189,146,11,141,170,5,169,3,141,15,210,216,165,
12 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, 12 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178,
13 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, 13 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5,
14 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, 14 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208,
15 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, 15 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84,
16 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, 16 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5,
17 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, 17 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5,
18 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, 18 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173,
19 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, 19 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207,
20 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, 20 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201,
21 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, 21 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5,
22 96,41,15,240,245,142,218,10,142,240,10,142,255,10,140,219, 22 96,41,15,240,245,142,218,10,142,240,10,142,255,10,140,219,
23 10,140,241,10,140,0,11,96,142,114,5,134,254,140,115,5, 23 10,140,241,10,140,0,11,96,142,114,5,134,254,140,115,5,
24 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, 24 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142,
25 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, 25 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109,
26 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, 26 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157,
27 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, 27 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75,
28 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, 28 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3,
29 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, 29 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157,
30 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, 30 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5,
31 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, 31 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105,
32 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, 32 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152,
33 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, 33 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5,
34 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, 34 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157,
35 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, 35 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254,
36 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, 36 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200,
37 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, 37 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2,
38 201,7,208,2,160,4,185,175,11,133,254,185,176,11,133,255, 38 201,7,208,2,160,4,185,175,11,133,254,185,176,11,133,255,
39 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, 39 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194,
40 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, 40 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45,
41 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, 41 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5,
42 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, 42 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201,
43 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, 43 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157,
44 48,5,189,79,5,72,41,3,168,185,181,11,157,54,5,104, 44 48,5,189,79,5,72,41,3,168,185,181,11,157,54,5,104,
45 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, 45 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10,
46 160,48,201,13,240,4,24,105,0,168,185,185,11,157,51,5, 46 160,48,201,13,240,4,24,105,0,168,185,185,11,157,51,5,
47 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, 47 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113,
48 5,208,3,76,2,11,173,78,5,240,3,76,107,9,173,108, 48 5,208,3,76,2,11,173,78,5,240,3,76,107,9,173,108,
49 5,205,109,5,240,3,76,88,9,173,103,5,240,3,76,220, 49 5,205,109,5,240,3,76,88,9,173,103,5,240,3,76,220,
50 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, 50 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16,
51 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, 51 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254,
52 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, 52 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5,
53 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, 53 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0,
54 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, 54 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104,
55 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, 55 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144,
56 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, 56 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41,
57 14,170,189,161,11,141,126,8,189,162,11,141,127,8,173,67, 57 14,170,189,161,11,141,126,8,189,162,11,141,127,8,173,67,
58 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, 58 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208,
59 143,164,254,140,104,5,76,2,11,32,148,6,160,255,96,48, 59 143,164,254,140,104,5,76,2,11,32,148,6,160,255,96,48,
60 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, 60 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101,
61 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, 61 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173,
62 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, 62 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141,
63 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, 63 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243,
64 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, 64 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75,
65 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, 65 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173,
66 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, 66 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133,
67 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, 67 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12,
68 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, 68 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19,
69 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, 69 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6,
70 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, 70 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69,
71 5,202,16,144,174,103,5,232,138,41,63,141,103,5,206,109, 71 5,202,16,144,174,103,5,232,138,41,63,141,103,5,206,109,
72 5,208,14,173,108,5,141,109,5,173,103,5,208,3,238,104, 72 5,208,14,173,108,5,141,109,5,173,103,5,208,3,238,104,
73 5,172,48,5,173,82,5,41,7,201,5,240,4,201,6,208, 73 5,172,48,5,173,82,5,41,7,201,5,240,4,201,6,208,
74 1,136,140,39,5,160,0,201,5,240,4,201,6,208,2,160, 74 1,136,140,39,5,160,0,201,5,240,4,201,6,208,2,160,
75 2,201,7,208,2,160,40,140,44,5,162,2,189,82,5,41, 75 2,201,7,208,2,160,40,140,44,5,162,2,189,82,5,41,
76 224,157,40,5,189,97,5,133,252,189,100,5,133,253,189,57, 76 224,157,40,5,189,97,5,133,252,189,100,5,133,253,189,57,
77 5,201,255,240,54,201,15,208,32,189,63,5,240,45,222,63, 77 5,201,255,240,54,201,15,208,32,189,63,5,240,45,222,63,
78 5,189,63,5,208,37,188,9,5,240,1,136,152,157,9,5, 78 5,189,63,5,208,37,188,9,5,240,1,136,152,157,9,5,
79 189,88,5,157,63,5,76,229,9,189,57,5,74,168,177,252, 79 189,88,5,157,63,5,76,229,9,189,57,5,74,168,177,252,
80 144,4,74,74,74,74,41,15,157,9,5,188,45,5,189,82, 80 144,4,74,74,74,74,41,15,157,9,5,188,45,5,189,82,
81 5,41,7,201,1,208,31,136,152,200,221,48,5,8,169,1, 81 5,41,7,201,1,208,31,136,152,200,221,48,5,8,169,1,
82 40,208,2,10,10,61,60,5,240,12,188,48,5,192,255,208, 82 40,208,2,10,10,61,60,5,240,12,188,48,5,192,255,208,
83 5,169,0,157,9,5,152,157,36,5,169,1,141,110,5,189, 83 5,169,0,157,9,5,152,157,36,5,169,1,141,110,5,189,
84 57,5,201,15,240,56,41,7,168,185,205,12,133,254,189,57, 84 57,5,201,15,240,56,41,7,168,185,205,12,133,254,189,57,
85 5,41,8,8,138,40,24,240,2,105,3,168,185,91,5,37, 85 5,41,8,8,138,40,24,240,2,105,3,168,185,91,5,37,
86 254,240,27,189,51,5,157,36,5,142,110,5,202,16,8,141, 86 254,240,27,189,51,5,157,36,5,142,110,5,202,16,8,141,
87 39,5,169,0,141,44,5,232,189,54,5,157,40,5,189,57, 87 39,5,169,0,141,44,5,232,189,54,5,157,40,5,189,57,
88 5,41,15,201,15,240,16,254,57,5,189,57,5,201,15,208, 88 5,41,15,201,15,240,16,254,57,5,189,57,5,201,15,208,
89 6,189,88,5,157,63,5,189,75,5,16,10,189,9,5,208, 89 6,189,88,5,157,63,5,189,75,5,16,10,189,9,5,208,
90 5,169,64,157,75,5,254,60,5,160,0,189,82,5,74,74, 90 5,169,64,157,75,5,254,60,5,160,0,189,82,5,74,74,
91 74,74,144,1,136,74,144,1,200,24,152,125,45,5,157,45, 91 74,74,144,1,136,74,144,1,200,24,152,125,45,5,157,45,
92 5,189,48,5,201,255,208,2,160,0,24,152,125,48,5,157, 92 5,189,48,5,201,255,208,2,160,0,24,152,125,48,5,157,
93 48,5,202,48,3,76,150,9,173,40,5,141,43,5,173,82, 93 48,5,202,48,3,76,150,9,173,40,5,141,43,5,173,82,
94 5,41,7,170,160,3,173,110,5,240,3,188,213,12,152,72, 94 5,41,7,170,160,3,173,110,5,240,3,188,213,12,152,72,
95 185,185,12,8,41,127,170,152,41,3,10,168,189,36,5,153, 95 185,185,12,8,41,127,170,152,41,3,10,168,189,36,5,153,
96 0,210,200,189,9,5,224,3,208,3,173,9,5,29,40,5, 96 0,210,200,189,9,5,224,3,208,3,173,9,5,29,40,5,
97 40,16,2,169,0,153,0,210,104,168,136,41,3,208,207,160, 97 40,16,2,169,0,153,0,210,104,168,136,41,3,208,207,160,
98 8,173,44,5,153,0,210,24,104,133,255,104,133,254,104,133, 98 8,173,44,5,153,0,210,24,104,133,255,104,133,254,104,133,
99 253,104,133,252,96,104,170,240,78,201,2,240,6,104,104,202, 99 253,104,133,252,96,104,170,240,78,201,2,240,6,104,104,202,
100 208,251,96,165,20,197,20,240,252,173,36,2,201,134,208,7, 100 208,251,96,165,20,197,20,240,252,173,36,2,201,134,208,7,
101 173,37,2,201,11,240,230,173,36,2,141,143,11,173,37,2, 101 173,37,2,201,11,240,230,173,36,2,141,143,11,173,37,2,
102 141,144,11,169,134,141,36,2,169,11,141,37,2,104,104,240, 102 141,144,11,169,134,141,36,2,169,11,141,37,2,104,104,240,
103 3,56,233,1,141,93,11,104,168,104,170,169,112,32,120,5, 103 3,56,233,1,141,93,11,104,168,104,170,169,112,32,120,5,
104 169,0,162,0,76,120,5,165,20,197,20,240,252,173,36,2, 104 169,0,162,0,76,120,5,165,20,197,20,240,252,173,36,2,
105 201,134,208,174,173,37,2,201,11,208,167,173,143,11,141,36, 105 201,134,208,174,173,37,2,201,11,208,167,173,143,11,141,36,
106 2,173,144,11,141,37,2,169,64,76,120,5,32,203,7,144, 106 2,173,144,11,141,37,2,169,64,76,120,5,32,203,7,144,
107 3,32,117,11,76,255,255,178,5,221,5,168,6,59,6,123, 107 3,32,117,11,76,255,255,178,5,221,5,168,6,59,6,123,
108 6,148,6,159,6,82,6,147,8,153,8,157,8,165,8,173, 108 6,148,6,159,6,82,6,147,8,153,8,157,8,165,8,173,
109 8,183,8,205,8,185,11,250,11,59,12,128,160,32,64,255, 109 8,183,8,205,8,185,11,250,11,59,12,128,160,32,64,255,
110 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, 110 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101,
111 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, 111 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39,
112 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, 112 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15,
113 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, 113 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0,
114 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, 114 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128,
115 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, 115 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67,
116 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, 116 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0,
117 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, 117 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
118 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, 118 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128,
119 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, 119 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176,
120 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, 120 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244,
121 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, 121 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216,
122 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, 122 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39,
123 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, 123 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184,
124 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, 124 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112,
125 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, 125 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0,
126 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, 126 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1,
127 2,128,3,128,64,32,16,8,4,2,1,3,3,3,3,7, 127 2,128,3,128,64,32,16,8,4,2,1,3,3,3,3,7,
128 11,15,19 128 11,15,19
129END_CONST_ARRAY; 129END_CONST_ARRAY;
130CONST_ARRAY(byte, cm3_obx) 130CONST_ARRAY(byte, cm3_obx)
131 255,255,0,5,223,12,76,18,11,76,120,5,76,203,7,0, 131 255,255,0,5,223,12,76,18,11,76,120,5,76,203,7,0,
132 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, 132 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225,
133 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, 133 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0,
134 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 134 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
135 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 135 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
136 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, 136 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0,
137 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 137 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
138 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, 138 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110,
139 5,142,111,5,140,112,5,41,112,74,74,74,170,189,148,11, 139 5,142,111,5,140,112,5,41,112,74,74,74,170,189,148,11,
140 141,169,5,189,149,11,141,170,5,169,3,141,15,210,216,165, 140 141,169,5,189,149,11,141,170,5,169,3,141,15,210,216,165,
141 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, 141 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178,
142 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, 142 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5,
143 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, 143 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208,
144 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, 144 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84,
145 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, 145 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5,
146 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, 146 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5,
147 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, 147 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173,
148 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, 148 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207,
149 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, 149 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201,
150 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, 150 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5,
151 96,41,15,240,245,142,221,10,142,243,10,142,2,11,140,222, 151 96,41,15,240,245,142,221,10,142,243,10,142,2,11,140,222,
152 10,140,244,10,140,3,11,96,142,114,5,134,254,140,115,5, 152 10,140,244,10,140,3,11,96,142,114,5,134,254,140,115,5,
153 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, 153 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142,
154 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, 154 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109,
155 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, 155 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157,
156 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, 156 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75,
157 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, 157 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3,
158 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, 158 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157,
159 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, 159 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5,
160 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, 160 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105,
161 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, 161 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152,
162 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, 162 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5,
163 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, 163 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157,
164 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, 164 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254,
165 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, 165 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200,
166 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, 166 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2,
167 201,7,208,2,160,4,185,178,11,133,254,185,179,11,133,255, 167 201,7,208,2,160,4,185,178,11,133,254,185,179,11,133,255,
168 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, 168 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194,
169 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, 169 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45,
170 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, 170 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5,
171 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, 171 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201,
172 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, 172 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157,
173 48,5,189,79,5,72,41,3,168,185,184,11,157,54,5,104, 173 48,5,189,79,5,72,41,3,168,185,184,11,157,54,5,104,
174 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, 174 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10,
175 160,48,201,13,240,4,24,105,0,168,185,188,11,157,51,5, 175 160,48,201,13,240,4,24,105,0,168,185,188,11,157,51,5,
176 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, 176 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113,
177 5,208,3,76,5,11,173,78,5,240,3,76,110,9,173,108, 177 5,208,3,76,5,11,173,78,5,240,3,76,110,9,173,108,
178 5,205,109,5,240,3,76,91,9,173,103,5,240,3,76,220, 178 5,205,109,5,240,3,76,91,9,173,103,5,240,3,76,220,
179 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, 179 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16,
180 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, 180 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254,
181 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, 181 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5,
182 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, 182 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0,
183 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, 183 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104,
184 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, 184 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144,
185 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, 185 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41,
186 14,170,189,164,11,141,126,8,189,165,11,141,127,8,173,67, 186 14,170,189,164,11,141,126,8,189,165,11,141,127,8,173,67,
187 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, 187 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208,
188 143,164,254,140,104,5,76,5,11,32,148,6,160,255,96,48, 188 143,164,254,140,104,5,76,5,11,32,148,6,160,255,96,48,
189 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, 189 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101,
190 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, 190 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173,
191 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, 191 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141,
192 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, 192 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243,
193 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, 193 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75,
194 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, 194 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173,
195 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, 195 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133,
196 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, 196 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12,
197 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, 197 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19,
198 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, 198 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6,
199 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, 199 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69,
200 5,202,16,144,174,103,5,232,224,48,144,2,162,0,142,103, 200 5,202,16,144,174,103,5,232,224,48,144,2,162,0,142,103,
201 5,206,109,5,208,14,173,108,5,141,109,5,173,103,5,208, 201 5,206,109,5,208,14,173,108,5,141,109,5,173,103,5,208,
202 3,238,104,5,172,48,5,173,82,5,41,7,201,5,240,4, 202 3,238,104,5,172,48,5,173,82,5,41,7,201,5,240,4,
203 201,6,208,1,136,140,39,5,160,0,201,5,240,4,201,6, 203 201,6,208,1,136,140,39,5,160,0,201,5,240,4,201,6,
204 208,2,160,2,201,7,208,2,160,40,140,44,5,162,2,189, 204 208,2,160,2,201,7,208,2,160,40,140,44,5,162,2,189,
205 82,5,41,224,157,40,5,189,97,5,133,252,189,100,5,133, 205 82,5,41,224,157,40,5,189,97,5,133,252,189,100,5,133,
206 253,189,57,5,201,255,240,54,201,15,208,32,189,63,5,240, 206 253,189,57,5,201,255,240,54,201,15,208,32,189,63,5,240,
207 45,222,63,5,189,63,5,208,37,188,9,5,240,1,136,152, 207 45,222,63,5,189,63,5,208,37,188,9,5,240,1,136,152,
208 157,9,5,189,88,5,157,63,5,76,232,9,189,57,5,74, 208 157,9,5,189,88,5,157,63,5,76,232,9,189,57,5,74,
209 168,177,252,144,4,74,74,74,74,41,15,157,9,5,188,45, 209 168,177,252,144,4,74,74,74,74,41,15,157,9,5,188,45,
210 5,189,82,5,41,7,201,1,208,31,136,152,200,221,48,5, 210 5,189,82,5,41,7,201,1,208,31,136,152,200,221,48,5,
211 8,169,1,40,208,2,10,10,61,60,5,240,12,188,48,5, 211 8,169,1,40,208,2,10,10,61,60,5,240,12,188,48,5,
212 192,255,208,5,169,0,157,9,5,152,157,36,5,169,1,141, 212 192,255,208,5,169,0,157,9,5,152,157,36,5,169,1,141,
213 110,5,189,57,5,201,15,240,56,41,7,168,185,208,12,133, 213 110,5,189,57,5,201,15,240,56,41,7,168,185,208,12,133,
214 254,189,57,5,41,8,8,138,40,24,240,2,105,3,168,185, 214 254,189,57,5,41,8,8,138,40,24,240,2,105,3,168,185,
215 91,5,37,254,240,27,189,51,5,157,36,5,142,110,5,202, 215 91,5,37,254,240,27,189,51,5,157,36,5,142,110,5,202,
216 16,8,141,39,5,169,0,141,44,5,232,189,54,5,157,40, 216 16,8,141,39,5,169,0,141,44,5,232,189,54,5,157,40,
217 5,189,57,5,41,15,201,15,240,16,254,57,5,189,57,5, 217 5,189,57,5,41,15,201,15,240,16,254,57,5,189,57,5,
218 201,15,208,6,189,88,5,157,63,5,189,75,5,16,10,189, 218 201,15,208,6,189,88,5,157,63,5,189,75,5,16,10,189,
219 9,5,208,5,169,64,157,75,5,254,60,5,160,0,189,82, 219 9,5,208,5,169,64,157,75,5,254,60,5,160,0,189,82,
220 5,74,74,74,74,144,1,136,74,144,1,200,24,152,125,45, 220 5,74,74,74,74,144,1,136,74,144,1,200,24,152,125,45,
221 5,157,45,5,189,48,5,201,255,208,2,160,0,24,152,125, 221 5,157,45,5,189,48,5,201,255,208,2,160,0,24,152,125,
222 48,5,157,48,5,202,48,3,76,153,9,173,40,5,141,43, 222 48,5,157,48,5,202,48,3,76,153,9,173,40,5,141,43,
223 5,173,82,5,41,7,170,160,3,173,110,5,240,3,188,216, 223 5,173,82,5,41,7,170,160,3,173,110,5,240,3,188,216,
224 12,152,72,185,188,12,8,41,127,170,152,41,3,10,168,189, 224 12,152,72,185,188,12,8,41,127,170,152,41,3,10,168,189,
225 36,5,153,0,210,200,189,9,5,224,3,208,3,173,9,5, 225 36,5,153,0,210,200,189,9,5,224,3,208,3,173,9,5,
226 29,40,5,40,16,2,169,0,153,0,210,104,168,136,41,3, 226 29,40,5,40,16,2,169,0,153,0,210,104,168,136,41,3,
227 208,207,160,8,173,44,5,153,0,210,24,104,133,255,104,133, 227 208,207,160,8,173,44,5,153,0,210,24,104,133,255,104,133,
228 254,104,133,253,104,133,252,96,104,170,240,78,201,2,240,6, 228 254,104,133,253,104,133,252,96,104,170,240,78,201,2,240,6,
229 104,104,202,208,251,96,165,20,197,20,240,252,173,36,2,201, 229 104,104,202,208,251,96,165,20,197,20,240,252,173,36,2,201,
230 137,208,7,173,37,2,201,11,240,230,173,36,2,141,146,11, 230 137,208,7,173,37,2,201,11,240,230,173,36,2,141,146,11,
231 173,37,2,141,147,11,169,137,141,36,2,169,11,141,37,2, 231 173,37,2,141,147,11,169,137,141,36,2,169,11,141,37,2,
232 104,104,240,3,56,233,1,141,96,11,104,168,104,170,169,112, 232 104,104,240,3,56,233,1,141,96,11,104,168,104,170,169,112,
233 32,120,5,169,0,162,0,76,120,5,165,20,197,20,240,252, 233 32,120,5,169,0,162,0,76,120,5,165,20,197,20,240,252,
234 173,36,2,201,137,208,174,173,37,2,201,11,208,167,173,146, 234 173,36,2,201,137,208,174,173,37,2,201,11,208,167,173,146,
235 11,141,36,2,173,147,11,141,37,2,169,64,76,120,5,32, 235 11,141,36,2,173,147,11,141,37,2,169,64,76,120,5,32,
236 203,7,144,3,32,120,11,76,255,255,178,5,221,5,168,6, 236 203,7,144,3,32,120,11,76,255,255,178,5,221,5,168,6,
237 59,6,123,6,148,6,159,6,82,6,147,8,153,8,157,8, 237 59,6,123,6,148,6,159,6,82,6,147,8,153,8,157,8,
238 165,8,173,8,183,8,205,8,188,11,253,11,62,12,128,160, 238 165,8,173,8,183,8,205,8,188,11,253,11,62,12,128,160,
239 32,64,255,241,228,215,203,192,181,170,161,152,143,135,127,120, 239 32,64,255,241,228,215,203,192,181,170,161,152,143,135,127,120,
240 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, 240 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47,
241 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, 241 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18,
242 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 242 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
243 1,0,0,0,0,0,0,242,233,218,206,191,182,170,161,152, 243 1,0,0,0,0,0,0,242,233,218,206,191,182,170,161,152,
244 143,137,128,122,113,107,101,95,0,86,80,103,96,90,85,81, 244 143,137,128,122,113,107,101,95,0,86,80,103,96,90,85,81,
245 76,72,67,63,61,57,52,51,57,45,42,40,37,36,33,31, 245 76,72,67,63,61,57,52,51,57,45,42,40,37,36,33,31,
246 30,0,0,15,14,13,12,11,10,9,8,7,6,5,4,3, 246 30,0,0,15,14,13,12,11,10,9,8,7,6,5,4,3,
247 2,1,0,0,56,11,140,10,0,10,106,9,232,8,106,8, 247 2,1,0,0,56,11,140,10,0,10,106,9,232,8,106,8,
248 239,7,128,7,8,7,174,6,70,6,230,5,149,5,65,5, 248 239,7,128,7,8,7,174,6,70,6,230,5,149,5,65,5,
249 246,4,176,4,110,4,48,4,246,3,187,3,132,3,82,3, 249 246,4,176,4,110,4,48,4,246,3,187,3,132,3,82,3,
250 34,3,244,2,200,2,160,2,122,2,85,2,52,2,20,2, 250 34,3,244,2,200,2,160,2,122,2,85,2,52,2,20,2,
251 245,1,216,1,189,1,164,1,141,1,119,1,96,1,78,1, 251 245,1,216,1,189,1,164,1,141,1,119,1,96,1,78,1,
252 56,1,39,1,21,1,6,1,247,0,232,0,219,0,207,0, 252 56,1,39,1,21,1,6,1,247,0,232,0,219,0,207,0,
253 195,0,184,0,172,0,162,0,154,0,144,0,136,0,127,0, 253 195,0,184,0,172,0,162,0,154,0,144,0,136,0,127,0,
254 120,0,112,0,106,0,100,0,94,0,87,0,82,0,50,0, 254 120,0,112,0,106,0,100,0,94,0,87,0,82,0,50,0,
255 10,0,0,1,2,131,0,1,2,3,1,0,2,131,1,0, 255 10,0,0,1,2,131,0,1,2,3,1,0,2,131,1,0,
256 2,3,1,2,128,3,128,64,32,16,8,4,2,1,3,3, 256 2,3,1,2,128,3,128,64,32,16,8,4,2,1,3,3,
257 3,3,7,11,15,19 257 3,3,7,11,15,19
258END_CONST_ARRAY; 258END_CONST_ARRAY;
259CONST_ARRAY(byte, cms_obx) 259CONST_ARRAY(byte, cms_obx)
260 255,255,0,5,186,15,234,234,234,76,21,8,76,92,15,35, 260 255,255,0,5,186,15,234,234,234,76,21,8,76,92,15,35,
261 5,169,5,173,5,184,5,0,0,0,0,0,0,0,0,0, 261 5,169,5,173,5,184,5,0,0,0,0,0,0,0,0,0,
262 0,0,0,128,128,128,128,128,128,0,0,0,0,0,0,255, 262 0,0,0,128,128,128,128,128,128,0,0,0,0,0,0,255,
263 255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0, 263 255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,
264 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 264 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
265 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 265 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
266 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 266 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
267 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 267 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
268 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 268 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
269 0,0,0,0,0,0,0,0,0,0,130,0,0,6,6,0, 269 0,0,0,0,0,0,0,0,0,0,130,0,0,6,6,0,
270 128,20,128,128,0,0,0,0,0,0,0,0,0,0,0,15, 270 128,20,128,128,0,0,0,0,0,0,0,0,0,0,0,15,
271 15,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0, 271 15,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,
272 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, 272 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1,
273 2,128,3,128,64,32,16,8,4,2,1,75,8,118,8,133, 273 2,128,3,128,64,32,16,8,4,2,1,75,8,118,8,133,
274 9,19,9,80,9,110,9,124,9,26,9,128,160,32,64,255, 274 9,19,9,80,9,110,9,124,9,26,9,128,160,32,64,255,
275 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, 275 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101,
276 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, 276 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39,
277 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, 277 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15,
278 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, 278 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0,
279 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, 279 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128,
280 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, 280 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67,
281 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, 281 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0,
282 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, 282 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
283 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, 283 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128,
284 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, 284 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176,
285 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, 285 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244,
286 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, 286 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216,
287 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, 287 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39,
288 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, 288 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184,
289 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, 289 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112,
290 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, 290 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0,
291 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 291 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
292 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0, 292 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,
293 0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,0, 293 0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,0,
294 0,0,0,1,1,1,1,2,2,2,2,2,3,3,3,0, 294 0,0,0,1,1,1,1,2,2,2,2,2,3,3,3,0,
295 0,1,1,1,2,2,2,2,2,3,3,3,3,4,4,0, 295 0,1,1,1,2,2,2,2,2,3,3,3,3,4,4,0,
296 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,0, 296 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,0,
297 0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,0, 297 0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,0,
298 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,0, 298 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,0,
299 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,0, 299 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,0,
300 1,1,2,2,3,4,4,5,5,6,7,7,8,8,9,0, 300 1,1,2,2,3,4,4,5,5,6,7,7,8,8,9,0,
301 1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,0, 301 1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,0,
302 1,1,2,3,4,4,5,6,7,7,8,9,10,10,11,0, 302 1,1,2,3,4,4,5,6,7,7,8,9,10,10,11,0,
303 1,2,2,3,4,5,6,7,8,9,9,10,11,11,12,0, 303 1,2,2,3,4,5,6,7,8,9,9,10,11,11,12,0,
304 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,0, 304 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,0,
305 1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,0, 305 1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,0,
306 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,6, 306 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,6,
307 12,12,12,18,12,28,12,38,12,50,12,79,12,233,5,42, 307 12,12,12,18,12,28,12,38,12,50,12,79,12,233,5,42,
308 6,107,6,161,11,196,11,185,11,0,0,0,0,0,0,0, 308 6,107,6,161,11,196,11,185,11,0,0,0,0,0,0,0,
309 0,0,0,3,3,3,3,7,11,15,19,141,143,5,142,144, 309 0,0,0,3,3,3,3,7,11,15,19,141,143,5,142,144,
310 5,140,145,5,41,112,74,74,74,170,169,3,141,15,210,189, 310 5,140,145,5,41,112,74,74,74,170,169,3,141,15,210,189,
311 213,5,141,73,8,189,214,5,141,74,8,169,3,141,31,210, 311 213,5,141,73,8,189,214,5,141,74,8,169,3,141,31,210,
312 169,1,141,146,5,172,145,5,174,144,5,173,143,5,76,72, 312 169,1,141,146,5,172,145,5,174,144,5,173,143,5,76,72,
313 8,173,147,5,133,252,173,148,5,133,253,160,0,138,240,28, 313 8,173,147,5,133,252,173,148,5,133,253,160,0,138,240,28,
314 177,252,201,143,240,4,201,239,208,12,202,208,9,200,192,84, 314 177,252,201,143,240,4,201,239,208,12,202,208,9,200,192,84,
315 176,9,152,170,16,6,200,192,84,144,229,96,142,149,5,169, 315 176,9,152,170,16,6,200,192,84,144,229,96,142,149,5,169,
316 0,162,5,157,17,5,157,23,5,157,29,5,202,16,244,141, 316 0,162,5,157,17,5,157,23,5,157,29,5,202,16,244,141,
317 150,5,141,157,5,160,255,140,159,5,173,153,5,133,252,173, 317 150,5,141,157,5,160,255,140,159,5,173,153,5,133,252,173,
318 154,5,133,253,160,19,177,252,170,173,147,5,133,252,173,148, 318 154,5,133,253,160,19,177,252,170,173,147,5,133,252,173,148,
319 5,133,253,172,149,5,152,72,169,15,141,169,5,141,170,5, 319 5,133,253,172,149,5,152,72,169,15,141,169,5,141,170,5,
320 177,252,201,135,208,35,152,72,24,105,85,168,177,252,16,2, 320 177,252,201,135,208,35,152,72,24,105,85,168,177,252,16,2,
321 169,15,41,15,141,169,5,152,24,105,85,168,177,252,16,3, 321 169,15,41,15,141,169,5,152,24,105,85,168,177,252,16,3,
322 173,169,5,41,15,141,170,5,104,76,243,8,177,252,201,143, 322 173,169,5,41,15,141,170,5,104,76,243,8,177,252,201,143,
323 240,7,201,239,240,3,136,16,199,104,168,177,252,201,207,208, 323 240,7,201,239,240,3,136,16,199,104,168,177,252,201,207,208,
324 13,152,24,105,85,168,177,252,48,15,170,76,19,9,201,143, 324 13,152,24,105,85,168,177,252,48,15,170,76,19,9,201,143,
325 240,7,201,239,240,3,136,16,226,142,151,5,142,152,5,96, 325 240,7,201,239,240,3,136,16,226,142,151,5,142,152,5,96,
326 142,153,5,134,252,140,154,5,132,253,24,138,105,20,141,155, 326 142,153,5,134,252,140,154,5,132,253,24,138,105,20,141,155,
327 5,152,105,0,141,156,5,24,138,105,0,141,147,5,152,105, 327 5,152,105,0,141,156,5,24,138,105,0,141,147,5,152,105,
328 2,141,148,5,160,19,177,252,141,151,5,141,152,5,162,3, 328 2,141,148,5,160,19,177,252,141,151,5,141,152,5,162,3,
329 142,31,210,142,15,210,169,0,141,146,5,160,8,169,0,153, 329 142,31,210,142,15,210,169,0,141,146,5,160,8,169,0,153,
330 0,210,153,16,210,192,6,176,8,153,35,5,169,255,153,41, 330 0,210,153,16,210,192,6,176,8,153,35,5,169,255,153,41,
331 5,136,16,233,169,128,162,5,157,29,5,202,16,250,141,157, 331 5,136,16,233,169,128,162,5,157,29,5,202,16,250,141,157,
332 5,96,169,0,240,240,141,157,5,240,11,173,143,5,41,7, 332 5,96,169,0,240,240,141,157,5,240,11,173,143,5,41,7,
333 170,169,128,157,29,5,172,145,5,173,144,5,141,143,5,140, 333 170,169,128,157,29,5,172,145,5,173,144,5,141,143,5,140,
334 145,5,169,0,157,83,5,157,41,5,157,77,5,152,10,10, 334 145,5,169,0,157,83,5,157,41,5,157,77,5,152,10,10,
335 10,133,254,24,173,153,5,105,48,72,173,154,5,105,1,168, 335 10,133,254,24,173,153,5,105,48,72,173,154,5,105,1,168,
336 104,24,101,254,157,101,5,152,105,0,157,71,5,24,173,153, 336 104,24,101,254,157,101,5,152,105,0,157,71,5,24,173,153,
337 5,105,148,133,252,173,154,5,105,0,133,253,173,145,5,10, 337 5,105,148,133,252,173,154,5,105,0,133,253,173,145,5,10,
338 109,145,5,10,168,140,145,5,200,200,200,200,200,177,252,157, 338 109,145,5,10,168,140,145,5,200,200,200,200,200,177,252,157,
339 113,5,136,177,252,157,107,5,136,177,252,157,119,5,136,136, 339 113,5,136,177,252,157,107,5,136,177,252,157,119,5,136,136,
340 177,252,157,59,5,160,0,41,7,201,3,208,2,160,2,201, 340 177,252,157,59,5,160,0,41,7,201,3,208,2,160,2,201,
341 7,208,2,160,4,185,247,7,133,254,185,248,7,133,255,172, 341 7,208,2,160,4,185,247,7,133,254,185,248,7,133,255,172,
342 145,5,200,200,177,252,74,74,74,74,24,109,143,5,141,143, 342 145,5,200,200,177,252,74,74,74,74,24,109,143,5,141,143,
343 5,141,159,10,168,189,59,5,41,7,201,7,208,15,152,10, 343 5,141,159,10,168,189,59,5,41,7,201,7,208,15,152,10,
344 168,177,254,157,125,5,200,140,143,5,76,92,10,177,254,157, 344 168,177,254,157,125,5,200,140,143,5,76,92,10,177,254,157,
345 125,5,172,145,5,200,200,177,252,41,15,24,109,143,5,141, 345 125,5,172,145,5,200,200,177,252,41,15,24,109,143,5,141,
346 143,5,172,143,5,189,59,5,41,7,201,5,8,177,254,40, 346 143,5,172,143,5,189,59,5,41,7,201,5,8,177,254,40,
347 240,8,221,125,5,208,3,56,233,1,157,89,5,172,145,5, 347 240,8,221,125,5,208,3,56,233,1,157,89,5,172,145,5,
348 177,252,72,41,3,168,185,229,5,157,131,5,104,74,74,74, 348 177,252,72,41,3,168,185,229,5,157,131,5,104,74,74,74,
349 74,160,62,201,15,240,16,160,55,201,14,240,10,160,48,201, 349 74,160,62,201,15,240,16,160,55,201,14,240,10,160,48,201,
350 13,240,4,24,105,50,168,185,233,5,157,137,5,96,216,165, 350 13,240,4,24,105,50,168,185,233,5,157,137,5,96,216,165,
351 252,72,165,253,72,165,254,72,165,255,72,173,146,5,208,3, 351 252,72,165,253,72,165,254,72,165,255,72,173,146,5,208,3,
352 76,47,15,173,157,5,240,3,76,225,12,173,152,5,205,151, 352 76,47,15,173,157,5,240,3,76,225,12,173,152,5,205,151,
353 5,176,3,76,206,12,173,150,5,240,3,76,158,11,162,5, 353 5,176,3,76,206,12,173,150,5,240,3,76,158,11,162,5,
354 169,0,188,29,5,48,3,157,29,5,157,17,5,202,16,242, 354 169,0,188,29,5,48,3,157,29,5,157,17,5,202,16,242,
355 173,147,5,133,252,173,148,5,133,253,172,149,5,140,161,5, 355 173,147,5,133,252,173,148,5,133,253,172,149,5,140,161,5,
356 204,159,5,208,25,173,160,5,240,20,173,149,5,172,158,5, 356 204,159,5,208,25,173,160,5,240,20,173,149,5,172,158,5,
357 140,149,5,206,160,5,208,232,141,149,5,168,16,226,162,0, 357 140,149,5,206,160,5,208,232,141,149,5,168,16,226,162,0,
358 177,252,201,254,240,28,157,53,5,230,253,177,252,198,253,201, 358 177,252,201,254,240,28,157,53,5,230,253,177,252,198,253,201,
359 254,240,15,157,56,5,24,152,105,85,168,232,224,3,144,224, 359 254,240,15,157,56,5,24,152,105,85,168,232,224,3,144,224,
360 176,34,172,149,5,200,204,161,5,240,80,140,149,5,76,250, 360 176,34,172,149,5,200,204,161,5,240,80,140,149,5,76,250,
361 10,104,41,14,170,189,253,7,141,135,11,189,254,7,141,136, 361 10,104,41,14,170,189,253,7,141,135,11,189,254,7,141,136,
362 11,76,129,11,172,149,5,177,252,16,57,201,255,240,53,74, 362 11,76,129,11,172,149,5,177,252,16,57,201,255,240,53,74,
363 74,74,72,41,1,240,218,104,41,14,170,189,233,7,141,135, 363 74,74,72,41,1,240,218,104,41,14,170,189,233,7,141,135,
364 11,189,234,7,141,136,11,173,54,5,133,254,32,134,11,140, 364 11,189,234,7,141,136,11,173,54,5,133,254,32,134,11,140,
365 149,5,192,85,176,5,204,161,5,208,179,172,161,5,140,149, 365 149,5,192,85,176,5,204,161,5,208,179,172,161,5,140,149,
366 5,76,47,15,76,94,12,165,254,48,18,41,15,141,169,5, 366 5,76,47,15,76,94,12,165,254,48,18,41,15,141,169,5,
367 173,55,5,16,3,173,169,5,41,15,141,170,5,200,96,165, 367 173,55,5,16,3,173,169,5,41,15,141,170,5,200,96,165,
368 254,48,250,41,1,141,184,5,200,96,173,179,5,48,20,206, 368 254,48,250,41,1,141,184,5,200,96,173,179,5,48,20,206,
369 180,5,208,51,169,50,141,180,5,206,179,5,208,41,206,179, 369 180,5,208,51,169,50,141,180,5,206,179,5,208,41,206,179,
370 5,200,96,165,254,48,214,141,180,5,238,180,5,165,254,48, 370 5,200,96,165,254,48,214,141,180,5,238,180,5,165,254,48,
371 204,141,180,5,238,180,5,173,55,5,141,179,5,16,5,169, 371 204,141,180,5,238,180,5,173,55,5,141,179,5,16,5,169,
372 0,141,179,5,238,179,5,104,104,76,225,12,32,110,9,160, 372 0,141,179,5,238,179,5,104,104,76,225,12,32,110,9,160,
373 255,96,165,254,48,249,168,96,165,254,48,243,56,152,229,254, 373 255,96,165,254,48,249,168,96,165,254,48,243,56,152,229,254,
374 168,96,165,254,48,233,24,152,101,254,168,96,165,254,48,223, 374 168,96,165,254,48,233,24,152,101,254,168,96,165,254,48,223,
375 141,151,5,141,152,5,200,96,165,254,48,211,173,55,5,48, 375 141,151,5,141,152,5,200,96,165,254,48,211,173,55,5,48,
376 206,200,140,158,5,24,152,101,254,141,159,5,173,55,5,141, 376 206,200,140,158,5,24,152,101,254,141,159,5,173,55,5,141,
377 160,5,192,84,96,136,48,10,177,252,201,143,240,4,201,239, 377 160,5,192,84,96,136,48,10,177,252,201,143,240,4,201,239,
378 208,243,200,96,162,5,189,23,5,240,5,222,23,5,16,87, 378 208,243,200,96,162,5,189,23,5,240,5,222,23,5,16,87,
379 189,29,5,208,82,188,53,5,201,64,176,75,173,155,5,133, 379 189,29,5,208,82,188,53,5,201,64,176,75,173,155,5,133,
380 252,173,156,5,133,253,177,252,133,254,24,152,105,64,168,177, 380 252,173,156,5,133,253,177,252,133,254,24,152,105,64,168,177,
381 252,133,255,188,17,5,177,254,41,192,208,12,177,254,41,63, 381 252,133,255,188,17,5,177,254,41,192,208,12,177,254,41,63,
382 157,47,5,254,17,5,16,235,201,64,208,13,177,254,41,63, 382 157,47,5,254,17,5,16,235,201,64,208,13,177,254,41,63,
383 188,47,5,32,150,9,76,190,12,201,128,208,10,177,254,41, 383 188,47,5,32,150,9,76,190,12,201,128,208,10,177,254,41,
384 63,157,23,5,254,17,5,202,16,156,174,150,5,232,138,41, 384 63,157,23,5,254,17,5,202,16,156,174,150,5,232,138,41,
385 63,141,150,5,206,152,5,208,14,173,151,5,141,152,5,173, 385 63,141,150,5,206,152,5,208,14,173,151,5,141,152,5,173,
386 150,5,208,3,238,149,5,172,89,5,173,59,5,41,7,201, 386 150,5,208,3,238,149,5,172,89,5,173,59,5,41,7,201,
387 5,240,4,201,6,208,1,136,140,162,5,160,0,201,5,240, 387 5,240,4,201,6,208,1,136,140,162,5,160,0,201,5,240,
388 4,201,6,208,2,160,2,201,7,208,2,160,40,140,164,5, 388 4,201,6,208,2,160,2,201,7,208,2,160,40,140,164,5,
389 172,92,5,173,62,5,41,7,201,5,240,4,201,6,208,1, 389 172,92,5,173,62,5,41,7,201,5,240,4,201,6,208,1,
390 136,140,163,5,160,0,201,5,240,4,201,6,208,2,160,2, 390 136,140,163,5,160,0,201,5,240,4,201,6,208,2,160,2,
391 201,7,208,2,160,40,140,165,5,162,5,189,59,5,41,224, 391 201,7,208,2,160,40,140,165,5,162,5,189,59,5,41,224,
392 157,65,5,189,101,5,133,252,189,71,5,133,253,189,41,5, 392 157,65,5,189,101,5,133,252,189,71,5,133,253,189,41,5,
393 201,255,240,55,201,15,208,33,189,77,5,240,46,222,77,5, 393 201,255,240,55,201,15,208,33,189,77,5,240,46,222,77,5,
394 189,77,5,208,38,188,35,5,240,1,136,152,157,35,5,189, 394 189,77,5,208,38,188,35,5,240,1,136,152,157,35,5,189,
395 119,5,157,77,5,136,76,133,13,189,41,5,74,168,177,252, 395 119,5,157,77,5,136,76,133,13,189,41,5,74,168,177,252,
396 144,4,74,74,74,74,41,15,157,35,5,188,125,5,189,59, 396 144,4,74,74,74,74,41,15,157,35,5,188,125,5,189,59,
397 5,41,7,201,1,208,31,136,152,200,221,89,5,8,169,1, 397 5,41,7,201,1,208,31,136,152,200,221,89,5,8,169,1,
398 40,208,2,10,10,61,83,5,240,12,188,89,5,192,255,208, 398 40,208,2,10,10,61,83,5,240,12,188,89,5,192,255,208,
399 5,169,0,157,35,5,152,157,95,5,169,1,141,168,5,189, 399 5,169,0,157,35,5,152,157,95,5,169,1,141,168,5,189,
400 41,5,201,15,240,76,41,7,168,185,205,5,133,254,189,41, 400 41,5,201,15,240,76,41,7,168,185,205,5,133,254,189,41,
401 5,41,8,8,138,40,24,240,2,105,6,168,185,107,5,37, 401 5,41,8,8,138,40,24,240,2,105,6,168,185,107,5,37,
402 254,240,47,189,137,5,157,95,5,142,168,5,202,224,2,240, 402 254,240,47,189,137,5,157,95,5,142,168,5,202,224,2,240,
403 15,224,255,208,22,141,162,5,169,0,141,164,5,76,5,14, 403 15,224,255,208,22,141,162,5,169,0,141,164,5,76,5,14,
404 173,140,5,141,163,5,169,0,141,165,5,232,189,131,5,157, 404 173,140,5,141,163,5,169,0,141,165,5,232,189,131,5,157,
405 65,5,189,41,5,41,15,201,15,240,18,254,41,5,189,41, 405 65,5,189,41,5,41,15,201,15,240,18,254,41,5,189,41,
406 5,41,15,201,15,208,6,189,119,5,157,77,5,189,29,5, 406 5,41,15,201,15,208,6,189,119,5,157,77,5,189,29,5,
407 16,10,189,35,5,208,5,169,64,157,29,5,254,83,5,160, 407 16,10,189,35,5,208,5,169,64,157,29,5,254,83,5,160,
408 0,189,59,5,74,74,74,74,144,1,136,74,144,1,200,24, 408 0,189,59,5,74,74,74,74,144,1,136,74,144,1,200,24,
409 152,125,125,5,157,125,5,189,89,5,201,255,208,2,160,0, 409 152,125,125,5,157,125,5,189,89,5,201,255,208,2,160,0,
410 24,152,125,89,5,157,89,5,202,48,3,76,53,13,32,123, 410 24,152,125,89,5,157,89,5,202,48,3,76,53,13,32,123,
411 15,173,65,5,141,166,5,173,68,5,141,167,5,173,59,5, 411 15,173,65,5,141,166,5,173,68,5,141,167,5,173,59,5,
412 41,7,32,181,15,152,72,185,185,5,8,41,127,170,152,41, 412 41,7,32,181,15,152,72,185,185,5,8,41,127,170,152,41,
413 3,10,168,224,3,208,3,76,196,14,189,173,5,208,39,189, 413 3,10,168,224,3,208,3,76,196,14,189,173,5,208,39,189,
414 95,5,153,0,210,189,35,5,29,65,5,40,16,2,169,0, 414 95,5,153,0,210,189,35,5,29,65,5,40,16,2,169,0,
415 153,1,210,104,168,136,41,3,240,3,76,127,14,173,164,5, 415 153,1,210,104,168,136,41,3,240,3,76,127,14,173,164,5,
416 141,8,210,76,228,14,40,76,173,14,173,173,5,208,23,173, 416 141,8,210,76,228,14,40,76,173,14,173,173,5,208,23,173,
417 162,5,153,0,210,173,35,5,13,166,5,40,16,2,169,0, 417 162,5,153,0,210,173,35,5,13,166,5,40,16,2,169,0,
418 153,1,210,76,173,14,40,76,173,14,173,62,5,41,7,32, 418 153,1,210,76,173,14,40,76,173,14,173,62,5,41,7,32,
419 181,15,152,72,185,185,5,8,41,127,170,152,41,3,10,168, 419 181,15,152,72,185,185,5,8,41,127,170,152,41,3,10,168,
420 224,3,208,3,76,60,15,189,176,5,208,30,189,98,5,153, 420 224,3,208,3,76,60,15,189,176,5,208,30,189,98,5,153,
421 16,210,189,38,5,29,68,5,40,16,2,169,0,153,17,210, 421 16,210,189,38,5,29,68,5,40,16,2,169,0,153,17,210,
422 104,168,136,41,3,240,7,76,236,14,40,76,26,15,173,165, 422 104,168,136,41,3,240,7,76,236,14,40,76,26,15,173,165,
423 5,141,24,210,24,104,133,255,104,133,254,104,133,253,104,133, 423 5,141,24,210,24,104,133,255,104,133,254,104,133,253,104,133,
424 252,96,173,176,5,208,23,173,163,5,153,16,210,173,38,5, 424 252,96,173,176,5,208,23,173,163,5,153,16,210,173,38,5,
425 13,167,5,40,16,2,169,0,153,17,210,76,26,15,40,76, 425 13,167,5,40,16,2,169,0,153,17,210,76,26,15,40,76,
426 26,15,32,168,10,176,25,173,184,5,240,20,173,157,5,141, 426 26,15,32,168,10,176,25,173,184,5,240,20,173,157,5,141,
427 183,5,169,1,141,157,5,32,168,10,173,183,5,141,157,5, 427 183,5,169,1,141,157,5,32,168,10,173,183,5,141,157,5,
428 96,173,169,5,10,10,10,10,141,171,5,173,170,5,10,10, 428 96,173,169,5,10,10,10,10,141,171,5,173,170,5,10,10,
429 10,10,141,172,5,162,2,134,200,173,171,5,29,35,5,170, 429 10,10,141,172,5,162,2,134,200,173,171,5,29,35,5,170,
430 189,233,6,166,200,157,35,5,173,172,5,29,38,5,170,189, 430 189,233,6,166,200,157,35,5,173,172,5,29,38,5,170,189,
431 233,6,166,200,157,38,5,202,16,221,96,168,185,13,8,168, 431 233,6,166,200,157,38,5,202,16,221,96,168,185,13,8,168,
432 96 432 96
433END_CONST_ARRAY; 433END_CONST_ARRAY;
434CONST_ARRAY(byte, dlt_obx) 434CONST_ARRAY(byte, dlt_obx)
435 255,255,0,4,70,12,255,241,228,215,203,192,181,170,161,152, 435 255,255,0,4,70,12,255,241,228,215,203,192,181,170,161,152,
436 143,135,127,121,114,107,101,95,90,85,80,75,71,67,63,60, 436 143,135,127,121,114,107,101,95,90,85,80,75,71,67,63,60,
437 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, 437 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23,
438 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 438 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
439 5,4,255,241,228,215,242,233,218,206,191,182,170,161,152,143, 439 5,4,255,241,228,215,242,233,218,206,191,182,170,161,152,143,
440 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, 440 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76,
441 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, 441 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30,
442 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, 442 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2,
443 1,0,242,233,218,206,242,233,218,206,191,182,170,161,152,143, 443 1,0,242,233,218,206,242,233,218,206,191,182,170,161,152,143,
444 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, 444 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76,
445 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, 445 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30,
446 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, 446 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2,
447 1,0,242,233,218,206,255,241,228,216,202,192,181,171,162,153, 447 1,0,242,233,218,206,255,241,228,216,202,192,181,171,162,153,
448 142,135,127,120,115,108,102,97,90,85,81,75,72,67,63,60, 448 142,135,127,120,115,108,102,97,90,85,81,75,72,67,63,60,
449 57,52,51,48,45,42,40,37,36,33,31,30,28,27,25,23, 449 57,52,51,48,45,42,40,37,36,33,31,30,28,27,25,23,
450 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 450 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
451 5,4,3,2,1,255,76,9,5,76,200,5,76,183,5,136, 451 5,4,3,2,1,255,76,9,5,76,200,5,76,183,5,136,
452 140,54,3,169,126,141,53,3,162,6,142,51,3,162,1,142, 452 140,54,3,169,126,141,53,3,162,6,142,51,3,162,1,142,
453 52,3,32,51,5,32,95,5,32,163,5,32,139,5,169,1, 453 52,3,32,51,5,32,95,5,32,163,5,32,139,5,169,1,
454 141,50,3,169,3,141,15,210,96,162,0,160,32,142,48,3, 454 141,50,3,169,3,141,15,210,96,162,0,160,32,142,48,3,
455 140,49,3,160,0,173,48,3,153,0,2,173,49,3,153,64, 455 140,49,3,160,0,173,48,3,153,0,2,173,49,3,153,64,
456 2,173,48,3,24,105,128,141,48,3,144,3,238,49,3,200, 456 2,173,48,3,24,105,128,141,48,3,144,3,238,49,3,200,
457 192,64,208,225,96,162,0,160,68,142,48,3,140,49,3,160, 457 192,64,208,225,96,162,0,160,68,142,48,3,140,49,3,160,
458 0,173,48,3,153,128,2,173,49,3,153,160,2,173,48,3, 458 0,173,48,3,153,128,2,173,49,3,153,160,2,173,48,3,
459 24,105,64,141,48,3,144,3,238,49,3,200,192,32,208,225, 459 24,105,64,141,48,3,144,3,238,49,3,200,192,32,208,225,
460 96,173,0,76,41,1,74,106,106,168,162,0,185,128,4,157, 460 96,173,0,76,41,1,74,106,106,168,162,0,185,128,4,157,
461 64,4,200,232,224,64,208,244,96,160,3,169,0,153,40,3, 461 64,4,200,232,224,64,208,244,96,160,3,169,0,153,40,3,
462 153,32,3,153,36,3,153,44,3,136,16,241,96,169,0,141, 462 153,32,3,153,36,3,153,44,3,136,16,241,96,169,0,141,
463 50,3,160,7,169,0,153,0,210,136,16,250,96,96,173,50, 463 50,3,160,7,169,0,153,0,210,136,16,250,96,96,173,50,
464 3,240,250,173,40,3,13,41,3,13,42,3,13,43,3,141, 464 3,240,250,173,40,3,13,41,3,13,42,3,13,43,3,141,
465 8,210,174,36,3,172,32,3,142,0,210,140,1,210,174,37, 465 8,210,174,36,3,172,32,3,142,0,210,140,1,210,174,37,
466 3,172,33,3,142,2,210,140,3,210,174,38,3,172,34,3, 466 3,172,33,3,142,2,210,140,3,210,174,38,3,172,34,3,
467 142,4,210,140,5,210,174,39,3,172,35,3,142,6,210,140, 467 142,4,210,140,5,210,174,39,3,172,35,3,142,6,210,140,
468 7,210,206,52,3,208,74,173,51,3,141,52,3,238,53,3, 468 7,210,206,52,3,208,74,173,51,3,141,52,3,238,53,3,
469 238,53,3,16,28,238,54,3,169,0,141,53,3,32,199,6, 469 238,53,3,16,28,238,54,3,169,0,141,53,3,32,199,6,
470 173,4,3,13,5,3,13,6,3,13,7,3,208,3,76,183, 470 173,4,3,13,5,3,13,6,3,13,7,3,208,3,76,183,
471 5,173,4,3,240,3,32,97,7,173,5,3,240,3,32,192, 471 5,173,4,3,240,3,32,97,7,173,5,3,240,3,32,192,
472 7,173,6,3,240,3,32,31,8,173,7,3,240,3,32,126, 472 7,173,6,3,240,3,32,31,8,173,7,3,240,3,32,126,
473 8,173,4,3,240,8,173,44,3,240,3,32,221,8,173,5, 473 8,173,4,3,240,8,173,44,3,240,3,32,221,8,173,5,
474 3,240,8,173,45,3,240,3,32,206,9,173,6,3,240,8, 474 3,240,8,173,45,3,240,3,32,206,9,173,6,3,240,8,
475 173,46,3,240,3,32,191,10,173,7,3,240,8,173,47,3, 475 173,46,3,240,3,32,191,10,173,7,3,240,8,173,47,3,
476 240,3,32,131,11,96,192,67,144,14,169,0,141,4,3,141, 476 240,3,32,131,11,96,192,67,144,14,169,0,141,4,3,141,
477 32,3,141,40,3,76,230,6,192,66,208,15,189,128,64,141, 477 32,3,141,40,3,76,230,6,192,66,208,15,189,128,64,141,
478 51,3,141,52,3,238,54,3,76,199,6,192,65,208,9,189, 478 51,3,141,52,3,238,54,3,76,199,6,192,65,208,9,189,
479 128,64,141,54,3,76,199,6,104,104,76,183,5,174,54,3, 479 128,64,141,54,3,76,199,6,104,104,76,183,5,174,54,3,
480 188,0,64,192,64,176,191,189,128,64,141,24,3,185,0,2, 480 188,0,64,192,64,176,191,189,128,64,141,24,3,185,0,2,
481 133,224,185,64,2,133,225,169,1,141,4,3,188,0,65,192, 481 133,224,185,64,2,133,225,169,1,141,4,3,188,0,65,192,
482 64,176,78,189,128,65,141,25,3,185,0,2,133,226,185,64, 482 64,176,78,189,128,65,141,25,3,185,0,2,133,226,185,64,
483 2,133,227,169,1,141,5,3,188,0,66,192,64,176,63,189, 483 2,133,227,169,1,141,5,3,188,0,66,192,64,176,63,189,
484 128,66,141,26,3,185,0,2,133,228,185,64,2,133,229,169, 484 128,66,141,26,3,185,0,2,133,228,185,64,2,133,229,169,
485 1,141,6,3,188,0,67,192,64,176,48,189,128,67,141,27, 485 1,141,6,3,188,0,67,192,64,176,48,189,128,67,141,27,
486 3,185,0,2,133,230,185,64,2,133,231,169,1,141,7,3, 486 3,185,0,2,133,230,185,64,2,133,231,169,1,141,7,3,
487 96,169,0,141,5,3,141,33,3,141,41,3,240,186,169,0, 487 96,169,0,141,5,3,141,33,3,141,41,3,240,186,169,0,
488 141,6,3,141,34,3,141,42,3,240,201,169,0,141,7,3, 488 141,6,3,141,34,3,141,42,3,240,201,169,0,141,7,3,
489 141,35,3,141,43,3,96,172,53,3,177,224,48,11,200,177, 489 141,35,3,141,43,3,96,172,53,3,177,224,48,11,200,177,
490 224,48,1,96,104,104,76,31,6,24,109,24,3,41,127,141, 490 224,48,1,96,104,104,76,31,6,24,109,24,3,41,127,141,
491 8,3,169,15,141,0,3,141,44,3,200,177,224,170,189,160, 491 8,3,169,15,141,0,3,141,44,3,200,177,224,170,189,160,
492 2,133,233,133,241,133,249,189,128,2,133,232,73,16,133,240, 492 2,133,233,133,241,133,249,189,128,2,133,232,73,16,133,240,
493 73,48,133,248,160,49,177,232,141,12,3,160,51,177,232,41, 493 73,48,133,248,160,49,177,232,141,12,3,160,51,177,232,41,
494 127,141,16,3,169,0,141,20,3,141,28,3,160,48,177,232, 494 127,141,16,3,169,0,141,20,3,141,28,3,160,48,177,232,
495 41,213,141,40,3,96,172,53,3,177,226,48,11,200,177,226, 495 41,213,141,40,3,96,172,53,3,177,226,48,11,200,177,226,
496 48,1,96,104,104,76,31,6,24,109,25,3,41,127,141,9, 496 48,1,96,104,104,76,31,6,24,109,25,3,41,127,141,9,
497 3,169,15,141,1,3,141,45,3,200,177,226,170,189,160,2, 497 3,169,15,141,1,3,141,45,3,200,177,226,170,189,160,2,
498 133,235,133,243,133,251,189,128,2,133,234,73,16,133,242,73, 498 133,235,133,243,133,251,189,128,2,133,234,73,16,133,242,73,
499 48,133,250,160,49,177,234,141,13,3,160,51,177,234,41,127, 499 48,133,250,160,49,177,234,141,13,3,160,51,177,234,41,127,
500 141,17,3,169,0,141,21,3,141,29,3,160,48,177,234,41, 500 141,17,3,169,0,141,21,3,141,29,3,160,48,177,234,41,
501 131,141,41,3,96,172,53,3,177,228,48,11,200,177,228,48, 501 131,141,41,3,96,172,53,3,177,228,48,11,200,177,228,48,
502 1,96,104,104,76,31,6,24,109,26,3,41,127,141,10,3, 502 1,96,104,104,76,31,6,24,109,26,3,41,127,141,10,3,
503 169,15,141,2,3,141,46,3,200,177,228,170,189,160,2,133, 503 169,15,141,2,3,141,46,3,200,177,228,170,189,160,2,133,
504 237,133,245,133,253,189,128,2,133,236,73,16,133,244,73,48, 504 237,133,245,133,253,189,128,2,133,236,73,16,133,244,73,48,
505 133,252,160,49,177,236,141,14,3,160,51,177,236,41,127,141, 505 133,252,160,49,177,236,141,14,3,160,51,177,236,41,127,141,
506 18,3,169,0,141,22,3,141,30,3,160,48,177,236,41,169, 506 18,3,169,0,141,22,3,141,30,3,160,48,177,236,41,169,
507 141,42,3,96,172,53,3,177,230,48,11,200,177,230,48,1, 507 141,42,3,96,172,53,3,177,230,48,11,200,177,230,48,1,
508 96,104,104,76,31,6,24,109,27,3,41,127,141,11,3,169, 508 96,104,104,76,31,6,24,109,27,3,41,127,141,11,3,169,
509 15,141,3,3,141,47,3,200,177,230,170,189,160,2,133,239, 509 15,141,3,3,141,47,3,200,177,230,170,189,160,2,133,239,
510 133,247,133,255,189,128,2,133,238,73,16,133,246,73,48,133, 510 133,247,133,255,189,128,2,133,238,73,16,133,246,73,48,133,
511 254,160,49,177,238,141,15,3,160,51,177,238,41,127,141,19, 511 254,160,49,177,238,141,15,3,160,51,177,238,41,127,141,19,
512 3,169,0,141,23,3,141,31,3,160,48,177,238,41,129,141, 512 3,169,0,141,23,3,141,31,3,160,48,177,238,41,129,141,
513 43,3,96,172,0,3,48,70,177,232,141,32,3,177,240,208, 513 43,3,96,172,0,3,48,70,177,232,141,32,3,177,240,208,
514 9,32,108,9,206,0,3,76,79,9,201,1,240,39,201,3, 514 9,32,108,9,206,0,3,76,79,9,201,1,240,39,201,3,
515 208,16,173,8,3,24,113,248,170,173,28,3,141,55,3,76, 515 208,16,173,8,3,24,113,248,170,173,28,3,141,55,3,76,
516 24,9,173,28,3,24,113,248,141,55,3,174,8,3,32,150, 516 24,9,173,28,3,24,113,248,141,55,3,174,8,3,32,150,
517 9,206,0,3,96,177,248,141,36,3,206,0,3,96,32,108, 517 9,206,0,3,96,177,248,141,36,3,206,0,3,96,32,108,
518 9,160,49,177,232,240,30,206,12,3,240,3,76,79,9,173, 518 9,160,49,177,232,240,30,206,12,3,240,3,76,79,9,173,
519 32,3,41,15,240,11,206,32,3,177,232,141,12,3,76,79, 519 32,3,41,15,240,11,206,32,3,177,232,141,12,3,76,79,
520 9,141,44,3,96,173,28,3,24,160,50,113,232,141,28,3, 520 9,141,44,3,96,173,28,3,24,160,50,113,232,141,28,3,
521 206,16,3,208,12,238,20,3,160,51,177,232,41,127,141,16, 521 206,16,3,208,12,238,20,3,160,51,177,232,41,127,141,16,
522 3,96,173,20,3,41,3,24,105,52,168,177,232,170,160,51, 522 3,96,173,20,3,41,3,24,105,52,168,177,232,170,160,51,
523 177,232,48,14,138,109,8,3,170,173,28,3,141,55,3,76, 523 177,232,48,14,138,109,8,3,170,173,28,3,141,55,3,76,
524 150,9,138,109,28,3,141,55,3,174,8,3,189,0,4,24, 524 150,9,138,109,28,3,141,55,3,174,8,3,189,0,4,24,
525 109,55,3,141,36,3,173,40,3,41,4,208,1,96,172,0, 525 109,55,3,141,36,3,173,40,3,41,4,208,1,96,172,0,
526 3,177,240,208,21,138,24,160,0,113,248,170,189,0,4,24, 526 3,177,240,208,21,138,24,160,0,113,248,170,189,0,4,24,
527 109,55,3,24,105,255,141,38,3,96,173,36,3,24,105,255, 527 109,55,3,24,105,255,141,38,3,96,173,36,3,24,105,255,
528 141,38,3,96,172,1,3,48,70,177,234,141,33,3,177,242, 528 141,38,3,96,172,1,3,48,70,177,234,141,33,3,177,242,
529 208,9,32,93,10,206,1,3,76,64,10,201,1,240,39,201, 529 208,9,32,93,10,206,1,3,76,64,10,201,1,240,39,201,
530 3,208,16,173,9,3,24,113,250,170,173,29,3,141,55,3, 530 3,208,16,173,9,3,24,113,250,170,173,29,3,141,55,3,
531 76,9,10,173,29,3,24,113,250,141,55,3,174,9,3,32, 531 76,9,10,173,29,3,24,113,250,141,55,3,174,9,3,32,
532 135,10,206,1,3,96,177,250,141,37,3,206,1,3,96,32, 532 135,10,206,1,3,96,177,250,141,37,3,206,1,3,96,32,
533 93,10,160,49,177,234,240,30,206,13,3,240,3,76,64,10, 533 93,10,160,49,177,234,240,30,206,13,3,240,3,76,64,10,
534 173,33,3,41,15,240,11,206,33,3,177,234,141,13,3,76, 534 173,33,3,41,15,240,11,206,33,3,177,234,141,13,3,76,
535 64,10,141,45,3,96,173,29,3,24,160,50,113,234,141,29, 535 64,10,141,45,3,96,173,29,3,24,160,50,113,234,141,29,
536 3,206,17,3,208,12,238,21,3,160,51,177,234,41,127,141, 536 3,206,17,3,208,12,238,21,3,160,51,177,234,41,127,141,
537 17,3,96,173,21,3,41,3,24,105,52,168,177,234,170,160, 537 17,3,96,173,21,3,41,3,24,105,52,168,177,234,170,160,
538 51,177,234,48,14,138,109,9,3,170,173,29,3,141,55,3, 538 51,177,234,48,14,138,109,9,3,170,173,29,3,141,55,3,
539 76,135,10,138,109,29,3,141,55,3,174,9,3,189,0,4, 539 76,135,10,138,109,29,3,141,55,3,174,9,3,189,0,4,
540 24,109,55,3,141,37,3,173,41,3,41,2,208,1,96,172, 540 24,109,55,3,141,37,3,173,41,3,41,2,208,1,96,172,
541 1,3,177,242,208,21,138,24,160,0,113,250,170,189,0,4, 541 1,3,177,242,208,21,138,24,160,0,113,250,170,189,0,4,
542 24,109,55,3,24,105,255,141,39,3,96,173,37,3,24,105, 542 24,109,55,3,24,105,255,141,39,3,96,173,37,3,24,105,
543 255,141,39,3,96,172,2,3,48,70,177,236,141,34,3,177, 543 255,141,39,3,96,172,2,3,48,70,177,236,141,34,3,177,
544 244,208,9,32,78,11,206,2,3,76,49,11,201,1,240,39, 544 244,208,9,32,78,11,206,2,3,76,49,11,201,1,240,39,
545 201,3,208,16,173,10,3,24,113,252,170,173,30,3,141,55, 545 201,3,208,16,173,10,3,24,113,252,170,173,30,3,141,55,
546 3,76,250,10,173,30,3,24,113,252,141,55,3,174,10,3, 546 3,76,250,10,173,30,3,24,113,252,141,55,3,174,10,3,
547 32,120,11,206,2,3,96,177,252,141,38,3,206,2,3,96, 547 32,120,11,206,2,3,96,177,252,141,38,3,206,2,3,96,
548 32,78,11,160,49,177,236,240,30,206,14,3,240,3,76,49, 548 32,78,11,160,49,177,236,240,30,206,14,3,240,3,76,49,
549 11,173,34,3,41,15,240,11,206,34,3,177,236,141,14,3, 549 11,173,34,3,41,15,240,11,206,34,3,177,236,141,14,3,
550 76,49,11,141,46,3,96,173,30,3,24,160,50,113,236,141, 550 76,49,11,141,46,3,96,173,30,3,24,160,50,113,236,141,
551 30,3,206,18,3,208,12,238,22,3,160,51,177,236,41,127, 551 30,3,206,18,3,208,12,238,22,3,160,51,177,236,41,127,
552 141,18,3,96,173,22,3,41,3,24,105,52,168,177,236,170, 552 141,18,3,96,173,22,3,41,3,24,105,52,168,177,236,170,
553 160,51,177,236,48,14,138,109,10,3,170,173,30,3,141,55, 553 160,51,177,236,48,14,138,109,10,3,170,173,30,3,141,55,
554 3,76,120,11,138,109,30,3,141,55,3,174,10,3,189,0, 554 3,76,120,11,138,109,30,3,141,55,3,174,10,3,189,0,
555 4,24,109,55,3,141,38,3,96,172,3,3,48,70,177,238, 555 4,24,109,55,3,141,38,3,96,172,3,3,48,70,177,238,
556 141,35,3,177,246,208,9,32,18,12,206,3,3,76,245,11, 556 141,35,3,177,246,208,9,32,18,12,206,3,3,76,245,11,
557 201,1,240,39,201,3,208,16,173,11,3,24,113,254,170,173, 557 201,1,240,39,201,3,208,16,173,11,3,24,113,254,170,173,
558 31,3,141,55,3,76,190,11,173,31,3,24,113,254,141,55, 558 31,3,141,55,3,76,190,11,173,31,3,24,113,254,141,55,
559 3,174,11,3,32,60,12,206,3,3,96,177,254,141,39,3, 559 3,174,11,3,32,60,12,206,3,3,96,177,254,141,39,3,
560 206,3,3,96,32,18,12,160,49,177,238,240,30,206,15,3, 560 206,3,3,96,32,18,12,160,49,177,238,240,30,206,15,3,
561 240,3,76,245,11,173,35,3,41,15,240,11,206,35,3,177, 561 240,3,76,245,11,173,35,3,41,15,240,11,206,35,3,177,
562 238,141,15,3,76,245,11,141,47,3,96,173,31,3,24,160, 562 238,141,15,3,76,245,11,141,47,3,96,173,31,3,24,160,
563 50,113,238,141,31,3,206,19,3,208,12,238,23,3,160,51, 563 50,113,238,141,31,3,206,19,3,208,12,238,23,3,160,51,
564 177,238,41,127,141,19,3,96,173,23,3,41,3,24,105,52, 564 177,238,41,127,141,19,3,96,173,23,3,41,3,24,105,52,
565 168,177,238,170,160,51,177,238,48,14,138,109,11,3,170,173, 565 168,177,238,170,160,51,177,238,48,14,138,109,11,3,170,173,
566 31,3,141,55,3,76,60,12,138,109,31,3,141,55,3,174, 566 31,3,141,55,3,76,60,12,138,109,31,3,141,55,3,174,
567 11,3,189,0,4,24,109,55,3,141,39,3,96 567 11,3,189,0,4,24,109,55,3,141,39,3,96
568END_CONST_ARRAY; 568END_CONST_ARRAY;
569CONST_ARRAY(byte, mpt_obx) 569CONST_ARRAY(byte, mpt_obx)
570 255,255,0,5,178,13,76,205,11,173,46,7,208,1,96,169, 570 255,255,0,5,178,13,76,205,11,173,46,7,208,1,96,169,
571 0,141,28,14,238,29,14,173,23,14,205,187,13,144,80,206, 571 0,141,28,14,238,29,14,173,23,14,205,187,13,144,80,206,
572 21,14,240,3,76,197,5,162,0,142,23,14,169,0,157,237, 572 21,14,240,3,76,197,5,162,0,142,23,14,169,0,157,237,
573 13,157,245,13,189,179,13,133,236,189,183,13,133,237,172,22, 573 13,157,245,13,189,179,13,133,236,189,183,13,133,237,172,22,
574 14,177,236,200,201,255,240,7,201,254,208,15,76,42,12,177, 574 14,177,236,200,201,255,240,7,201,254,208,15,76,42,12,177,
575 236,48,249,10,168,140,22,14,76,59,5,157,233,13,177,236, 575 236,48,249,10,168,140,22,14,76,59,5,157,233,13,177,236,
576 157,213,13,232,224,4,208,196,200,140,22,14,76,197,5,206, 576 157,213,13,232,224,4,208,196,200,140,22,14,76,197,5,206,
577 21,14,16,87,173,188,13,141,21,14,162,3,222,245,13,16, 577 21,14,16,87,173,188,13,141,21,14,162,3,222,245,13,16,
578 68,189,233,13,10,168,185,255,255,133,236,200,185,255,255,133, 578 68,189,233,13,10,168,185,255,255,133,236,200,185,255,255,133,
579 237,5,236,240,48,189,237,13,141,31,14,32,62,7,172,31, 579 237,5,236,240,48,189,237,13,141,31,14,32,62,7,172,31,
580 14,200,152,157,237,13,189,241,13,157,245,13,224,2,208,21, 580 14,200,152,157,237,13,189,241,13,157,245,13,224,2,208,21,
581 189,197,13,73,15,10,10,10,10,105,69,141,161,13,169,10, 581 189,197,13,73,15,10,10,10,10,105,69,141,161,13,169,10,
582 105,0,141,162,13,202,16,180,238,23,14,162,1,173,27,14, 582 105,0,141,162,13,202,16,180,238,23,14,162,1,173,27,14,
583 201,2,240,2,162,3,173,27,14,201,2,208,5,236,25,14, 583 201,2,240,2,162,3,173,27,14,201,2,208,5,236,25,14,
584 240,3,76,118,6,181,240,61,114,6,240,18,160,40,177,236, 584 240,3,76,118,6,181,240,61,114,6,240,18,160,40,177,236,
585 24,125,225,13,32,117,9,56,125,1,14,157,203,13,202,16, 585 24,125,225,13,32,117,9,56,125,1,14,157,203,13,202,16,
586 213,169,3,141,15,210,165,241,41,16,240,15,172,226,13,185, 586 213,169,3,141,15,210,165,241,41,16,240,15,172,226,13,185,
587 198,9,141,201,13,185,5,10,141,202,13,173,201,13,141,0, 587 198,9,141,201,13,185,5,10,141,202,13,173,201,13,141,0,
588 210,173,202,13,141,2,210,173,203,13,141,4,210,173,204,13, 588 210,173,202,13,141,2,210,173,203,13,141,4,210,173,204,13,
589 141,6,210,173,193,13,162,255,172,27,14,192,1,208,5,174, 589 141,6,210,173,193,13,162,255,172,27,14,192,1,208,5,174,
590 25,14,240,3,141,1,210,173,194,13,224,1,240,3,141,3, 590 25,14,240,3,141,1,210,173,194,13,224,1,240,3,141,3,
591 210,192,2,240,20,173,195,13,224,2,240,3,141,5,210,173, 591 210,192,2,240,20,173,195,13,224,2,240,3,141,5,210,173,
592 196,13,224,3,240,3,141,7,210,165,240,5,241,5,242,5, 592 196,13,224,3,240,3,141,7,210,165,240,5,241,5,242,5,
593 243,13,28,14,141,8,210,96,4,2,0,0,189,217,13,133, 593 243,13,28,14,141,8,210,96,4,2,0,0,189,217,13,133,
594 236,189,221,13,133,237,5,236,208,8,157,193,13,149,240,76, 594 236,189,221,13,133,237,5,236,208,8,157,193,13,149,240,76,
595 248,5,180,244,192,32,240,66,177,236,56,253,197,13,44,58, 595 248,5,180,244,192,32,240,66,177,236,56,253,197,13,44,58,
596 7,240,2,41,240,157,193,13,200,177,236,141,30,14,200,148, 596 7,240,2,41,240,157,193,13,200,177,236,141,30,14,200,148,
597 244,41,7,240,60,168,185,126,9,141,203,6,185,133,9,141, 597 244,41,7,240,60,168,185,126,9,141,203,6,185,133,9,141,
598 204,6,173,30,14,74,74,74,74,74,9,40,168,177,236,24, 598 204,6,173,30,14,74,74,74,74,74,9,40,168,177,236,24,
599 32,255,255,169,0,149,240,76,248,5,189,9,14,240,18,222, 599 32,255,255,169,0,149,240,76,248,5,189,9,14,240,18,222,
600 13,14,208,13,157,13,14,189,193,13,41,15,240,3,222,193, 600 13,14,208,13,157,13,14,189,193,13,41,15,240,3,222,193,
601 13,160,35,177,236,149,240,189,17,14,24,105,37,168,41,3, 601 13,160,35,177,236,149,240,189,17,14,24,105,37,168,41,3,
602 157,17,14,136,177,236,125,209,13,157,225,13,32,119,9,157, 602 157,17,14,136,177,236,125,209,13,157,225,13,32,119,9,157,
603 201,13,189,5,14,240,6,222,5,14,76,223,5,189,189,13, 603 201,13,189,5,14,240,6,222,5,14,76,223,5,189,189,13,
604 141,30,7,16,254,76,194,8,0,76,229,8,0,76,251,8, 604 141,30,7,16,254,76,194,8,0,76,229,8,0,76,251,8,
605 0,76,21,9,0,76,37,9,0,76,56,9,0,76,66,9, 605 0,76,21,9,0,76,37,9,0,76,56,9,0,76,66,9,
606 16,76,72,9,169,0,157,197,13,172,31,14,136,200,177,236, 606 16,76,72,9,169,0,157,197,13,172,31,14,136,200,177,236,
607 201,254,208,4,140,31,14,96,201,224,144,8,173,187,13,141, 607 201,254,208,4,140,31,14,96,201,224,144,8,173,187,13,141,
608 23,14,208,233,201,208,144,10,41,15,141,188,13,141,21,14, 608 23,14,208,233,201,208,144,10,41,15,141,188,13,141,21,14,
609 16,219,201,192,144,9,41,15,73,15,157,197,13,16,206,201, 609 16,219,201,192,144,9,41,15,73,15,157,197,13,16,206,201,
610 128,144,7,41,63,157,241,13,16,195,201,64,144,27,200,140, 610 128,144,7,41,63,157,241,13,16,195,201,64,144,27,200,140,
611 31,14,41,31,157,229,13,10,168,185,255,255,157,217,13,200, 611 31,14,41,31,157,229,13,10,168,185,255,255,157,217,13,200,
612 185,255,255,157,221,13,76,62,7,140,31,14,141,30,14,24, 612 185,255,255,157,221,13,76,62,7,140,31,14,141,30,14,24,
613 125,213,13,157,209,13,173,27,14,240,66,201,2,240,58,189, 613 125,213,13,157,209,13,173,27,14,240,66,201,2,240,58,189,
614 229,13,201,31,208,55,173,30,14,56,233,1,41,15,168,177, 614 229,13,201,31,208,55,173,30,14,56,233,1,41,15,168,177,
615 254,133,253,152,9,16,168,177,254,133,248,160,1,5,253,208, 615 254,133,253,152,9,16,168,177,254,133,248,160,1,5,253,208,
616 2,160,0,140,26,14,169,0,133,252,157,217,13,157,221,13, 616 2,160,0,140,26,14,169,0,133,252,157,217,13,157,221,13,
617 138,10,141,24,14,142,25,14,96,224,2,176,99,189,217,13, 617 138,10,141,24,14,142,25,14,96,224,2,176,99,189,217,13,
618 133,238,189,221,13,133,239,5,238,240,74,160,32,177,238,41, 618 133,238,189,221,13,133,239,5,238,240,74,160,32,177,238,41,
619 15,157,249,13,177,238,41,112,74,74,157,189,13,200,177,238, 619 15,157,249,13,177,238,41,112,74,74,157,189,13,200,177,238,
620 10,10,72,41,63,157,5,14,104,41,192,157,205,13,200,177, 620 10,10,72,41,63,157,5,14,104,41,192,157,205,13,200,177,
621 238,157,9,14,157,13,14,169,0,149,244,157,17,14,157,253, 621 238,157,9,14,157,13,14,169,0,149,244,157,17,14,157,253,
622 13,157,1,14,189,209,13,157,225,13,32,117,9,157,201,13, 622 13,157,1,14,189,209,13,157,225,13,32,117,9,157,201,13,
623 236,25,14,240,1,96,160,255,140,25,14,200,140,26,14,96, 623 236,25,14,240,1,96,160,255,140,25,14,200,140,26,14,96,
624 224,2,208,51,172,211,13,185,69,11,141,121,13,185,129,11, 624 224,2,208,51,172,211,13,185,69,11,141,121,13,185,129,11,
625 141,127,13,169,0,133,249,133,250,173,231,13,41,15,168,177, 625 141,127,13,169,0,133,249,133,250,173,231,13,41,15,168,177,
626 254,133,251,152,9,16,168,177,254,141,137,13,5,251,208,6, 626 254,133,251,152,9,16,168,177,254,141,137,13,5,251,208,6,
627 141,121,13,141,127,13,96,173,232,13,41,15,168,177,254,133, 627 141,121,13,141,127,13,96,173,232,13,41,15,168,177,254,133,
628 253,152,9,16,168,177,254,5,253,240,15,177,254,56,229,253, 628 253,152,9,16,168,177,254,5,253,240,15,177,254,56,229,253,
629 133,248,169,0,133,252,169,141,208,2,169,173,141,97,13,141, 629 133,248,169,0,133,252,169,141,208,2,169,173,141,97,13,141,
630 56,13,169,24,141,7,210,96,173,29,14,41,7,74,74,144, 630 56,13,169,24,141,7,210,96,173,29,14,41,7,74,74,144,
631 18,208,24,189,249,13,24,157,1,14,125,201,13,157,201,13, 631 18,208,24,189,249,13,24,157,1,14,125,201,13,157,201,13,
632 76,223,5,169,0,157,1,14,76,223,5,189,201,13,56,253, 632 76,223,5,169,0,157,1,14,76,223,5,189,201,13,56,253,
633 249,13,157,201,13,56,169,0,253,249,13,157,1,14,76,223, 633 249,13,157,201,13,56,169,0,253,249,13,157,1,14,76,223,
634 5,189,253,13,24,157,1,14,125,201,13,157,201,13,24,189, 634 5,189,253,13,24,157,1,14,125,201,13,157,201,13,24,189,
635 253,13,125,249,13,157,253,13,76,223,5,189,225,13,56,253, 635 253,13,125,249,13,157,253,13,76,223,5,189,225,13,56,253,
636 253,13,157,225,13,32,117,9,76,5,9,169,0,56,253,253, 636 253,13,157,225,13,32,117,9,76,5,9,169,0,56,253,253,
637 13,157,1,14,189,201,13,56,253,253,13,76,5,9,189,225, 637 13,157,1,14,189,201,13,56,253,253,13,76,5,9,189,225,
638 13,24,125,253,13,76,28,9,32,85,9,76,208,8,32,85, 638 13,24,125,253,13,76,28,9,32,85,9,76,208,8,32,85,
639 9,24,125,225,13,32,155,9,76,223,5,188,253,13,189,249, 639 9,24,125,225,13,32,155,9,76,223,5,188,253,13,189,249,
640 13,48,2,200,200,136,152,157,253,13,221,249,13,208,8,189, 640 13,48,2,200,200,136,152,157,253,13,221,249,13,208,8,189,
641 249,13,73,255,157,249,13,189,253,13,96,41,63,29,205,13, 641 249,13,73,255,157,249,13,189,253,13,96,41,63,29,205,13,
642 168,185,255,255,96,148,145,152,165,173,180,192,9,9,9,9, 642 168,185,255,255,96,148,145,152,165,173,180,192,9,9,9,9,
643 9,9,9,64,0,32,0,125,201,13,157,201,13,96,125,209, 643 9,9,9,64,0,32,0,125,201,13,157,201,13,96,125,209,
644 13,157,225,13,32,117,9,157,201,13,96,157,201,13,189,141, 644 13,157,225,13,32,117,9,157,201,13,96,157,201,13,189,141,
645 9,16,12,157,201,13,169,128,208,5,157,201,13,169,1,13, 645 9,16,12,157,201,13,169,128,208,5,157,201,13,169,1,13,
646 28,14,141,28,14,96,45,10,210,157,201,13,96,242,51,150, 646 28,14,141,28,14,96,45,10,210,157,201,13,96,242,51,150,
647 226,56,140,0,106,232,106,239,128,8,174,70,230,149,65,246, 647 226,56,140,0,106,232,106,239,128,8,174,70,230,149,65,246,
648 176,110,48,246,187,132,82,34,244,200,160,122,85,52,20,245, 648 176,110,48,246,187,132,82,34,244,200,160,122,85,52,20,245,
649 216,189,164,141,119,96,78,56,39,21,6,247,232,219,207,195, 649 216,189,164,141,119,96,78,56,39,21,6,247,232,219,207,195,
650 184,172,162,154,144,136,127,120,112,106,100,94,13,13,12,11, 650 184,172,162,154,144,136,127,120,112,106,100,94,13,13,12,11,
651 11,10,10,9,8,8,7,7,7,6,6,5,5,5,4,4, 651 11,10,10,9,8,8,7,7,7,6,6,5,5,5,4,4,
652 4,4,3,3,3,3,3,2,2,2,2,2,2,2,1,1, 652 4,4,3,3,3,3,3,2,2,2,2,2,2,2,1,1,
653 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, 653 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
654 0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24, 654 0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24,
655 24,24,24,24,24,24,24,24,24,24,24,22,22,23,23,23, 655 24,24,24,24,24,24,24,24,24,24,24,22,22,23,23,23,
656 23,24,24,24,24,24,25,25,25,25,26,21,21,22,22,22, 656 23,24,24,24,24,24,25,25,25,25,26,21,21,22,22,22,
657 23,23,24,24,24,25,25,26,26,26,27,20,21,21,22,22, 657 23,23,24,24,24,25,25,26,26,26,27,20,21,21,22,22,
658 23,23,24,24,24,25,25,26,26,27,27,20,20,21,21,22, 658 23,23,24,24,24,25,25,26,26,27,27,20,20,21,21,22,
659 22,23,23,24,25,25,26,26,27,27,28,19,20,20,21,22, 659 22,23,23,24,25,25,26,26,27,27,28,19,20,20,21,22,
660 22,23,23,24,25,25,26,26,27,28,28,19,19,20,21,21, 660 22,23,23,24,25,25,26,26,27,28,28,19,19,20,21,21,
661 22,23,23,24,25,25,26,27,27,28,29,18,19,20,20,21, 661 22,23,23,24,25,25,26,27,27,28,29,18,19,20,20,21,
662 22,23,23,24,25,25,26,27,28,28,29,18,19,19,20,21, 662 22,23,23,24,25,25,26,27,28,28,29,18,19,19,20,21,
663 22,22,23,24,25,26,26,27,28,29,29,18,18,19,20,21, 663 22,22,23,24,25,26,26,27,28,29,29,18,18,19,20,21,
664 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, 664 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21,
665 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, 665 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21,
666 21,22,23,24,25,26,27,27,28,29,30,17,18,19,20,20, 666 21,22,23,24,25,26,27,27,28,29,30,17,18,19,20,20,
667 21,22,23,24,25,26,27,28,28,29,30,17,18,19,19,20, 667 21,22,23,24,25,26,27,28,28,29,30,17,18,19,19,20,
668 21,22,23,24,25,26,27,28,29,29,30,17,18,18,19,20, 668 21,22,23,24,25,26,27,28,29,29,30,17,18,18,19,20,
669 21,22,23,24,25,26,27,28,29,30,30,16,17,18,19,20, 669 21,22,23,24,25,26,27,28,29,30,30,16,17,18,19,20,
670 21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,41, 670 21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,41,
671 43,46,48,51,55,58,61,65,69,73,77,82,87,92,97,103, 671 43,46,48,51,55,58,61,65,69,73,77,82,87,92,97,103,
672 110,116,123,130,138,146,155,164,174,184,195,207,220,233,246,5, 672 110,116,123,130,138,146,155,164,174,184,195,207,220,233,246,5,
673 21,37,55,73,93,113,135,159,184,210,237,11,42,75,110,147, 673 21,37,55,73,93,113,135,159,184,210,237,11,42,75,110,147,
674 186,227,15,62,112,164,219,0,0,0,0,0,0,0,0,0, 674 186,227,15,62,112,164,219,0,0,0,0,0,0,0,0,0,
675 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 675 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
676 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, 676 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,
677 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3, 677 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,
678 3,3,3,229,42,64,89,100,238,8,166,11,12,12,12,12, 678 3,3,3,229,42,64,89,100,238,8,166,11,12,12,12,12,
679 12,13,13,142,50,7,140,54,7,41,7,168,185,189,11,141, 679 12,13,13,142,50,7,140,54,7,41,7,168,185,189,11,141,
680 227,11,185,197,11,141,228,11,76,255,255,173,54,7,174,50, 680 227,11,185,197,11,141,228,11,76,255,255,173,54,7,174,50,
681 7,141,148,7,141,155,7,142,149,7,142,156,7,24,105,64, 681 7,141,148,7,141,155,7,142,149,7,142,156,7,24,105,64,
682 141,129,5,141,135,5,144,1,232,142,130,5,142,136,5,24, 682 141,129,5,141,135,5,144,1,232,142,130,5,142,136,5,24,
683 105,128,141,124,9,144,1,232,142,125,9,232,141,31,12,142, 683 105,128,141,124,9,144,1,232,142,125,9,232,141,31,12,142,
684 32,12,162,9,189,255,255,157,179,13,202,16,247,206,188,13, 684 32,12,162,9,189,255,255,157,179,13,202,16,247,206,188,13,
685 169,0,141,46,7,162,98,157,189,13,202,16,250,162,8,157, 685 169,0,141,46,7,162,98,157,189,13,202,16,250,162,8,157,
686 0,210,202,16,250,96,32,42,12,173,50,7,10,141,22,14, 686 0,210,202,16,250,96,32,42,12,173,50,7,10,141,22,14,
687 173,187,13,141,23,14,169,1,141,21,14,141,46,7,96,173, 687 173,187,13,141,23,14,169,1,141,21,14,141,46,7,96,173,
688 54,7,133,254,173,50,7,133,255,96,173,54,7,41,3,170, 688 54,7,133,254,173,50,7,133,255,96,173,54,7,41,3,170,
689 173,50,7,32,198,7,173,26,14,240,238,14,54,7,32,190, 689 173,50,7,32,198,7,173,26,14,240,238,14,54,7,32,190,
690 12,169,1,141,27,14,173,26,14,240,222,201,1,208,5,160, 690 12,169,1,141,27,14,173,26,14,240,222,201,1,208,5,160,
691 0,238,26,14,177,252,174,24,14,74,74,74,74,9,16,141, 691 0,238,26,14,177,252,174,24,14,74,74,74,74,9,16,141,
692 10,212,141,10,212,157,1,210,177,252,9,16,141,10,212,141, 692 10,212,141,10,212,157,1,210,177,252,9,16,141,10,212,141,
693 10,212,157,1,210,200,208,206,230,253,165,253,197,248,208,198, 693 10,212,157,1,210,200,208,206,230,253,165,253,197,248,208,198,
694 140,26,14,96,144,21,169,234,141,153,12,141,154,12,141,155, 694 140,26,14,96,144,21,169,234,141,153,12,141,154,12,141,155,
695 12,141,166,12,141,167,12,141,168,12,96,169,141,141,153,12, 695 12,141,166,12,141,167,12,141,168,12,96,169,141,141,153,12,
696 141,166,12,169,10,141,154,12,141,167,12,169,212,141,155,12, 696 141,166,12,169,10,141,154,12,141,167,12,169,212,141,155,12,
697 141,168,12,96,169,0,141,26,14,173,50,7,74,32,190,12, 697 141,168,12,96,169,0,141,26,14,173,50,7,74,32,190,12,
698 169,1,141,27,14,32,128,12,173,27,14,208,248,96,169,2, 698 169,1,141,27,14,32,128,12,173,27,14,208,248,96,169,2,
699 141,27,14,141,25,14,169,24,141,7,210,169,17,133,250,169, 699 141,27,14,141,25,14,169,24,141,7,210,169,17,133,250,169,
700 13,133,251,169,173,141,97,13,141,56,13,160,0,140,121,13, 700 13,133,251,169,173,141,97,13,141,56,13,160,0,140,121,13,
701 140,127,13,174,11,212,177,252,74,74,74,74,9,16,141,7, 701 140,127,13,174,11,212,177,252,74,74,74,74,9,16,141,7,
702 210,32,117,13,236,11,212,240,251,141,5,210,174,11,212,177, 702 210,32,117,13,236,11,212,240,251,141,5,210,174,11,212,177,
703 252,230,252,208,16,230,253,198,248,208,10,169,173,141,97,13, 703 252,230,252,208,16,230,253,198,248,208,10,169,173,141,97,13,
704 141,56,13,169,8,9,16,141,7,210,32,117,13,236,11,212, 704 141,56,13,169,8,9,16,141,7,210,32,117,13,236,11,212,
705 240,251,141,5,210,173,27,14,208,185,96,24,165,249,105,0, 705 240,251,141,5,210,173,27,14,208,185,96,24,165,249,105,0,
706 133,249,165,250,105,0,133,250,144,15,230,251,165,251,201,0, 706 133,249,165,250,105,0,133,250,144,15,230,251,165,251,201,0,
707 208,7,140,121,13,140,127,13,96,177,250,36,249,48,4,74, 707 208,7,140,121,13,140,127,13,96,177,250,36,249,48,4,74,
708 74,74,74,41,15,168,185,69,10,160,0,96,160,0,140,27, 708 74,74,74,41,15,168,185,69,10,160,0,96,160,0,140,27,
709 14,140,26,14,136,140,25,14,96 709 14,140,26,14,136,140,25,14,96
710END_CONST_ARRAY; 710END_CONST_ARRAY;
711CONST_ARRAY(byte, rmt4_obx) 711CONST_ARRAY(byte, rmt4_obx)
712 255,255,144,3,96,11,128,0,128,32,128,64,0,192,128,128, 712 255,255,144,3,96,11,128,0,128,32,128,64,0,192,128,128,
713 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, 713 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1,
714 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, 714 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1,
715 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, 715 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106,
716 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, 716 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82,
717 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, 717 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78,
718 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, 718 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127,
719 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, 719 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230,
720 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, 720 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92,
721 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, 721 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35,
722 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, 722 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13,
723 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, 723 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153,
724 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, 724 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60,
725 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, 725 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23,
726 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 726 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
727 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, 727 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144,
728 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, 728 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57,
729 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, 729 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22,
730 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, 730 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,
731 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, 731 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8,
732 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, 732 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3,
733 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, 733 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,
734 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 734 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
735 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 735 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
736 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 736 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
737 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, 737 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,
738 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, 738 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2,
739 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, 739 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2,
740 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, 740 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3,
741 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, 741 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4,
742 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, 742 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4,
743 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, 743 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5,
744 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, 744 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5,
745 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, 745 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6,
746 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, 746 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7,
747 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, 747 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7,
748 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, 748 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8,
749 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, 749 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8,
750 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, 750 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,
751 10,11,12,13,14,15,76,15,6,76,252,7,76,33,8,76, 751 10,11,12,13,14,15,76,15,6,76,252,7,76,33,8,76,
752 88,6,76,43,11,134,211,132,212,72,160,168,169,0,153,127, 752 88,6,76,43,11,134,211,132,212,72,160,168,169,0,153,127,
753 2,136,208,250,160,4,177,211,141,21,8,200,177,211,141,36, 753 2,136,208,250,160,4,177,211,141,21,8,200,177,211,141,36,
754 3,200,177,211,141,5,8,141,38,3,160,8,177,211,153,195, 754 3,200,177,211,141,5,8,141,38,3,160,8,177,211,153,195,
755 0,200,192,16,208,246,104,72,10,10,24,101,209,133,209,104, 755 0,200,192,16,208,246,104,72,10,10,24,101,209,133,209,104,
756 8,41,192,10,42,42,40,101,210,133,210,32,110,6,169,0, 756 8,41,192,10,42,42,40,101,210,133,210,32,110,6,169,0,
757 141,8,210,160,3,140,15,210,160,8,153,0,210,136,16,250, 757 141,8,210,160,3,140,15,210,160,8,153,0,210,136,16,250,
758 173,5,8,96,162,0,142,39,3,138,168,177,209,201,254,176, 758 173,5,8,96,162,0,142,39,3,138,168,177,209,201,254,176,
759 45,168,177,205,157,128,2,177,207,157,132,2,169,0,157,136, 759 45,168,177,205,157,128,2,177,207,157,132,2,169,0,157,136,
760 2,169,1,157,140,2,169,128,157,180,2,232,224,4,208,217, 760 2,169,1,157,140,2,169,128,157,180,2,232,224,4,208,217,
761 165,209,24,105,4,133,209,144,27,230,210,76,190,6,240,4, 761 165,209,24,105,4,133,209,144,27,230,210,76,190,6,240,4,
762 169,0,240,223,160,2,177,209,170,200,177,209,133,210,134,209, 762 169,0,240,223,160,2,177,209,170,200,177,209,133,210,134,209,
763 162,0,240,181,173,36,3,141,22,7,162,255,232,222,140,2, 763 162,0,240,181,173,36,3,141,22,7,162,255,232,222,140,2,
764 208,69,189,128,2,133,211,189,132,2,133,212,188,136,2,254, 764 208,69,189,128,2,133,211,189,132,2,133,212,188,136,2,254,
765 136,2,177,211,133,217,41,63,201,61,240,17,176,56,157,144, 765 136,2,177,211,133,217,41,63,201,61,240,17,176,56,157,144,
766 2,157,16,3,200,177,211,74,41,126,157,180,2,169,1,157, 766 2,157,16,3,200,177,211,74,41,126,157,180,2,169,1,157,
767 140,2,188,136,2,254,136,2,177,211,74,102,217,74,102,217, 767 140,2,188,136,2,254,136,2,177,211,74,102,217,74,102,217,
768 165,217,41,240,157,148,2,224,3,208,177,169,255,141,36,3, 768 165,217,41,240,157,148,2,224,3,208,177,169,255,141,36,3,
769 141,37,3,76,101,7,201,63,240,27,165,217,41,192,240,9, 769 141,37,3,76,101,7,201,63,240,27,165,217,41,192,240,9,
770 10,42,42,157,140,2,76,17,7,200,177,211,157,140,2,254, 770 10,42,42,157,140,2,76,17,7,200,177,211,157,140,2,254,
771 136,2,76,17,7,165,217,48,12,200,177,211,141,22,7,254, 771 136,2,76,17,7,165,217,48,12,200,177,211,141,22,7,254,
772 136,2,76,214,6,201,255,240,9,200,177,211,157,136,2,76, 772 136,2,76,214,6,201,255,240,9,200,177,211,157,136,2,76,
773 214,6,76,110,6,76,33,8,202,48,250,188,180,2,48,248, 773 214,6,76,110,6,76,33,8,202,48,250,188,180,2,48,248,
774 177,203,157,184,2,133,215,200,177,203,157,188,2,133,216,169, 774 177,203,157,184,2,133,215,200,177,203,157,188,2,133,216,169,
775 1,157,20,3,168,177,215,157,4,3,200,177,215,157,196,2, 775 1,157,20,3,168,177,215,157,4,3,200,177,215,157,196,2,
776 200,177,215,157,200,2,200,177,215,157,240,2,41,63,157,8, 776 200,177,215,157,200,2,200,177,215,157,240,2,41,63,157,8,
777 3,177,215,41,64,157,244,2,200,177,215,157,32,3,200,177, 777 3,177,215,41,64,157,244,2,200,177,215,157,32,3,200,177,
778 215,157,208,2,200,177,215,157,216,2,200,177,215,157,220,2, 778 215,157,208,2,200,177,215,157,216,2,200,177,215,157,220,2,
779 200,177,215,168,185,160,3,157,224,2,157,228,2,185,161,3, 779 200,177,215,168,185,160,3,157,224,2,157,228,2,185,161,3,
780 157,232,2,160,10,177,215,157,236,2,169,128,157,212,2,157, 780 157,232,2,160,10,177,215,157,236,2,169,128,157,212,2,157,
781 180,2,10,157,204,2,157,156,2,168,177,215,157,0,3,105, 781 180,2,10,157,204,2,157,156,2,168,177,215,157,0,3,105,
782 0,157,192,2,169,12,157,252,2,168,177,215,157,248,2,76, 782 0,157,192,2,169,12,157,252,2,168,177,215,157,248,2,76,
783 98,7,32,43,11,206,38,3,208,29,169,255,141,38,3,206, 783 98,7,32,43,11,206,38,3,208,29,169,255,141,38,3,206,
784 37,3,208,19,238,39,3,173,39,3,201,255,240,3,76,190, 784 37,3,208,19,238,39,3,173,39,3,201,255,240,3,76,190,
785 6,76,110,6,76,95,10,169,4,133,214,162,3,189,188,2, 785 6,76,110,6,76,95,10,169,4,133,214,162,3,189,188,2,
786 240,242,133,212,189,184,2,133,211,188,192,2,177,211,133,217, 786 240,242,133,212,189,184,2,133,211,188,192,2,177,211,133,217,
787 200,177,211,133,218,200,177,211,133,219,200,152,221,196,2,144, 787 200,177,211,133,218,200,177,211,133,219,200,152,221,196,2,144,
788 10,240,8,169,128,157,204,2,189,200,2,157,192,2,165,217, 788 10,240,8,169,128,157,204,2,189,200,2,157,192,2,165,217,
789 41,15,29,148,2,168,185,0,5,133,220,165,218,41,14,168, 789 41,15,29,148,2,168,185,0,5,133,220,165,218,41,14,168,
790 185,144,3,133,213,165,220,25,145,3,157,28,3,189,220,2, 790 185,144,3,133,213,165,220,25,145,3,157,28,3,189,220,2,
791 240,40,201,1,208,33,189,156,2,24,125,236,2,24,188,224, 791 240,40,201,1,208,33,189,156,2,24,125,236,2,24,188,224,
792 2,121,165,3,157,156,2,200,152,221,232,2,208,3,189,228, 792 2,121,165,3,157,156,2,200,152,221,232,2,208,3,189,228,
793 2,157,224,2,76,164,8,222,220,2,188,0,3,192,13,144, 793 2,157,224,2,76,164,8,222,220,2,188,0,3,192,13,144,
794 60,189,8,3,16,49,152,221,252,2,208,8,189,4,3,157, 794 60,189,8,3,16,49,152,221,252,2,208,8,189,4,3,157,
795 252,2,208,3,254,252,2,189,184,2,133,215,189,188,2,133, 795 252,2,208,3,254,252,2,189,184,2,133,215,189,188,2,133,
796 216,188,252,2,177,215,188,244,2,240,4,24,125,248,2,157, 796 216,188,252,2,177,215,188,244,2,240,4,24,125,248,2,157,
797 248,2,189,240,2,41,63,56,233,1,157,8,3,189,204,2, 797 248,2,189,240,2,41,63,56,233,1,157,8,3,189,204,2,
798 16,31,189,148,2,240,26,221,216,2,240,21,144,19,168,189, 798 16,31,189,148,2,240,26,221,216,2,240,21,144,19,168,189,
799 212,2,24,125,208,2,157,212,2,144,6,152,233,16,157,148, 799 212,2,24,125,208,2,157,212,2,144,6,152,233,16,157,148,
800 2,169,0,133,221,165,218,157,12,3,41,112,74,74,141,28, 800 2,169,0,133,221,165,218,157,12,3,41,112,74,74,141,28,
801 9,144,254,76,210,9,234,76,60,9,234,76,65,9,234,76, 801 9,144,254,76,210,9,234,76,60,9,234,76,65,9,234,76,
802 75,9,234,76,87,9,234,76,102,9,234,76,169,9,234,76, 802 75,9,234,76,87,9,234,76,102,9,234,76,169,9,234,76,
803 184,9,165,219,76,21,10,165,219,133,221,189,144,2,76,216, 803 184,9,165,219,76,21,10,165,219,133,221,189,144,2,76,216,
804 9,189,144,2,24,101,219,157,144,2,76,216,9,189,156,2, 804 9,189,144,2,24,101,219,157,144,2,76,216,9,189,156,2,
805 24,101,219,157,156,2,189,144,2,76,216,9,189,240,2,16, 805 24,101,219,157,156,2,189,144,2,76,216,9,189,240,2,16,
806 12,188,144,2,177,213,24,125,248,2,76,135,9,189,144,2, 806 12,188,144,2,177,213,24,125,248,2,76,135,9,189,144,2,
807 24,125,248,2,201,61,144,2,169,63,168,177,213,157,160,2, 807 24,125,248,2,201,61,144,2,169,63,168,177,213,157,160,2,
808 164,219,208,3,157,164,2,152,74,74,74,74,157,168,2,157, 808 164,219,208,3,157,164,2,152,74,74,74,74,157,168,2,157,
809 172,2,165,219,41,15,157,176,2,189,144,2,76,216,9,165, 809 172,2,165,219,41,15,157,176,2,189,144,2,76,216,9,165,
810 219,24,125,20,3,157,20,3,189,144,2,76,216,9,165,219, 810 219,24,125,20,3,157,20,3,189,144,2,76,216,9,165,219,
811 201,128,240,6,157,144,2,76,216,9,189,28,3,9,240,157, 811 201,128,240,6,157,144,2,76,216,9,189,28,3,9,240,157,
812 28,3,189,144,2,76,216,9,189,144,2,24,101,219,188,240, 812 28,3,189,144,2,76,216,9,189,144,2,24,101,219,188,240,
813 2,48,31,24,125,248,2,201,61,144,7,169,0,157,28,3, 813 2,48,31,24,125,248,2,201,61,144,7,169,0,157,28,3,
814 169,63,157,16,3,168,177,213,24,125,156,2,24,101,221,76, 814 169,63,157,16,3,168,177,213,24,125,156,2,24,101,221,76,
815 21,10,201,61,144,7,169,0,157,28,3,169,63,168,189,156, 815 21,10,201,61,144,7,169,0,157,28,3,169,63,168,189,156,
816 2,24,125,248,2,24,113,213,24,101,221,157,24,3,189,172, 816 2,24,125,248,2,24,113,213,24,101,221,157,24,3,189,172,
817 2,240,50,222,172,2,208,45,189,168,2,157,172,2,189,164, 817 2,240,50,222,172,2,208,45,189,168,2,157,172,2,189,164,
818 2,221,160,2,240,31,176,13,125,176,2,176,18,221,160,2, 818 2,221,160,2,240,31,176,13,125,176,2,176,18,221,160,2,
819 176,13,76,76,10,253,176,2,144,5,221,160,2,176,3,189, 819 176,13,76,76,10,253,176,2,144,5,221,160,2,176,3,189,
820 160,2,157,164,2,165,218,41,1,240,10,189,164,2,24,125, 820 160,2,157,164,2,165,218,41,1,240,10,189,164,2,24,125,
821 156,2,157,24,3,202,48,3,76,39,8,173,32,3,13,33, 821 156,2,157,24,3,202,48,3,76,39,8,173,32,3,13,33,
822 3,13,34,3,13,35,3,170,142,44,11,173,12,3,16,33, 822 3,13,34,3,13,35,3,170,142,44,11,173,12,3,16,33,
823 173,28,3,41,15,240,26,173,24,3,24,109,20,3,141,26, 823 173,28,3,41,15,240,26,173,24,3,24,109,20,3,141,26,
824 3,173,30,3,41,16,208,5,169,0,141,30,3,138,9,4, 824 3,173,30,3,41,16,208,5,169,0,141,30,3,138,9,4,
825 170,173,13,3,16,33,173,29,3,41,15,240,26,173,25,3, 825 170,173,13,3,16,33,173,29,3,41,15,240,26,173,25,3,
826 24,109,21,3,141,27,3,173,31,3,41,16,208,5,169,0, 826 24,109,21,3,141,27,3,173,31,3,41,16,208,5,169,0,
827 141,31,3,138,9,2,170,236,44,11,208,94,173,13,3,41, 827 141,31,3,138,9,2,170,236,44,11,208,94,173,13,3,41,
828 14,201,6,208,38,173,29,3,41,15,240,31,172,17,3,185, 828 14,201,6,208,38,173,29,3,41,15,240,31,172,17,3,185,
829 192,3,141,24,3,185,192,4,141,25,3,173,28,3,41,16, 829 192,3,141,24,3,185,192,4,141,25,3,173,28,3,41,16,
830 208,5,169,0,141,28,3,138,9,80,170,173,15,3,41,14, 830 208,5,169,0,141,28,3,138,9,80,170,173,15,3,41,14,
831 201,6,208,38,173,31,3,41,15,240,31,172,19,3,185,192, 831 201,6,208,38,173,31,3,41,15,240,31,172,19,3,185,192,
832 3,141,26,3,185,192,4,141,27,3,173,30,3,41,16,208, 832 3,141,26,3,185,192,4,141,27,3,173,30,3,41,16,208,
833 5,169,0,141,30,3,138,9,40,170,142,44,11,173,38,3, 833 5,169,0,141,30,3,138,9,40,170,142,44,11,173,38,3,
834 96,160,255,173,24,3,174,28,3,141,0,210,142,1,210,173, 834 96,160,255,173,24,3,174,28,3,141,0,210,142,1,210,173,
835 25,3,174,29,3,141,2,210,142,3,210,173,26,3,174,30, 835 25,3,174,29,3,141,2,210,142,3,210,173,26,3,174,30,
836 3,141,4,210,142,5,210,173,27,3,174,31,3,141,6,210, 836 3,141,4,210,142,5,210,173,27,3,174,31,3,141,6,210,
837 142,7,210,140,8,210,96 837 142,7,210,140,8,210,96
838END_CONST_ARRAY; 838END_CONST_ARRAY;
839CONST_ARRAY(byte, rmt8_obx) 839CONST_ARRAY(byte, rmt8_obx)
840 255,255,144,3,108,12,128,0,128,32,128,64,0,192,128,128, 840 255,255,144,3,108,12,128,0,128,32,128,64,0,192,128,128,
841 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, 841 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1,
842 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, 842 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1,
843 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, 843 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106,
844 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, 844 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82,
845 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, 845 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78,
846 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, 846 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127,
847 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, 847 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230,
848 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, 848 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92,
849 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, 849 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35,
850 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, 850 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13,
851 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, 851 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153,
852 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, 852 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60,
853 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, 853 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23,
854 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 854 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
855 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, 855 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144,
856 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, 856 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57,
857 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, 857 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22,
858 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, 858 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,
859 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, 859 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8,
860 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, 860 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3,
861 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, 861 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,
862 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 862 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
863 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 863 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
864 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 864 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
865 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, 865 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,
866 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, 866 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2,
867 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, 867 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2,
868 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, 868 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3,
869 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, 869 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4,
870 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, 870 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4,
871 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, 871 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5,
872 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, 872 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5,
873 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, 873 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6,
874 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, 874 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7,
875 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, 875 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7,
876 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, 876 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8,
877 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, 877 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8,
878 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, 878 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,
879 10,11,12,13,14,15,76,15,6,76,9,8,76,46,8,76, 879 10,11,12,13,14,15,76,15,6,76,9,8,76,46,8,76,
880 92,6,76,2,12,134,211,132,212,72,160,0,152,153,0,2, 880 92,6,76,2,12,134,211,132,212,72,160,0,152,153,0,2,
881 153,76,2,200,208,247,160,4,177,211,141,34,8,200,177,211, 881 153,76,2,200,208,247,160,4,177,211,141,34,8,200,177,211,
882 141,72,3,200,177,211,141,18,8,141,74,3,160,8,177,211, 882 141,72,3,200,177,211,141,18,8,141,74,3,160,8,177,211,
883 153,195,0,200,192,16,208,246,104,72,10,10,10,24,101,209, 883 153,195,0,200,192,16,208,246,104,72,10,10,10,24,101,209,
884 133,209,104,8,41,224,10,42,42,42,40,101,210,133,210,32, 884 133,209,104,8,41,224,10,42,42,42,40,101,210,133,210,32,
885 123,6,169,0,141,8,210,141,24,210,160,3,140,15,210,140, 885 123,6,169,0,141,8,210,141,24,210,160,3,140,15,210,140,
886 31,210,160,8,153,0,210,153,16,210,136,16,247,173,18,8, 886 31,210,160,8,153,0,210,153,16,210,136,16,247,173,18,8,
887 96,162,0,142,75,3,138,168,177,209,201,254,176,45,168,177, 887 96,162,0,142,75,3,138,168,177,209,201,254,176,45,168,177,
888 205,157,0,2,177,207,157,8,2,169,0,157,16,2,169,1, 888 205,157,0,2,177,207,157,8,2,169,0,157,16,2,169,1,
889 157,24,2,169,128,157,104,2,232,224,8,208,217,165,209,24, 889 157,24,2,169,128,157,104,2,232,224,8,208,217,165,209,24,
890 105,8,133,209,144,27,230,210,76,203,6,240,4,169,0,240, 890 105,8,133,209,144,27,230,210,76,203,6,240,4,169,0,240,
891 223,160,2,177,209,170,200,177,209,133,210,134,209,162,0,240, 891 223,160,2,177,209,170,200,177,209,133,210,134,209,162,0,240,
892 181,173,72,3,141,35,7,162,255,232,222,24,2,208,69,189, 892 181,173,72,3,141,35,7,162,255,232,222,24,2,208,69,189,
893 0,2,133,211,189,8,2,133,212,188,16,2,254,16,2,177, 893 0,2,133,211,189,8,2,133,212,188,16,2,254,16,2,177,
894 211,133,217,41,63,201,61,240,17,176,56,157,32,2,157,32, 894 211,133,217,41,63,201,61,240,17,176,56,157,32,2,157,32,
895 3,200,177,211,74,41,126,157,104,2,169,1,157,24,2,188, 895 3,200,177,211,74,41,126,157,104,2,169,1,157,24,2,188,
896 16,2,254,16,2,177,211,74,102,217,74,102,217,165,217,41, 896 16,2,254,16,2,177,211,74,102,217,74,102,217,165,217,41,
897 240,157,40,2,224,7,208,177,169,255,141,72,3,141,73,3, 897 240,157,40,2,224,7,208,177,169,255,141,72,3,141,73,3,
898 76,114,7,201,63,240,27,165,217,41,192,240,9,10,42,42, 898 76,114,7,201,63,240,27,165,217,41,192,240,9,10,42,42,
899 157,24,2,76,30,7,200,177,211,157,24,2,254,16,2,76, 899 157,24,2,76,30,7,200,177,211,157,24,2,254,16,2,76,
900 30,7,165,217,48,12,200,177,211,141,35,7,254,16,2,76, 900 30,7,165,217,48,12,200,177,211,141,35,7,254,16,2,76,
901 227,6,201,255,240,9,200,177,211,157,16,2,76,227,6,76, 901 227,6,201,255,240,9,200,177,211,157,16,2,76,227,6,76,
902 123,6,76,46,8,202,48,250,188,104,2,48,248,177,203,157, 902 123,6,76,46,8,202,48,250,188,104,2,48,248,177,203,157,
903 112,2,133,215,200,177,203,157,120,2,133,216,169,1,157,40, 903 112,2,133,215,200,177,203,157,120,2,133,216,169,1,157,40,
904 3,168,177,215,157,8,3,200,177,215,157,136,2,200,177,215, 904 3,168,177,215,157,8,3,200,177,215,157,136,2,200,177,215,
905 157,144,2,200,177,215,157,224,2,41,63,157,16,3,177,215, 905 157,144,2,200,177,215,157,224,2,41,63,157,16,3,177,215,
906 41,64,157,232,2,200,177,215,157,64,3,200,177,215,157,160, 906 41,64,157,232,2,200,177,215,157,64,3,200,177,215,157,160,
907 2,200,177,215,157,176,2,200,177,215,157,184,2,200,177,215, 907 2,200,177,215,157,176,2,200,177,215,157,184,2,200,177,215,
908 168,185,160,3,157,192,2,157,200,2,185,161,3,157,208,2, 908 168,185,160,3,157,192,2,157,200,2,185,161,3,157,208,2,
909 160,10,177,215,157,216,2,169,128,157,168,2,157,104,2,10, 909 160,10,177,215,157,216,2,169,128,157,168,2,157,104,2,10,
910 157,152,2,157,56,2,168,177,215,157,0,3,105,0,157,128, 910 157,152,2,157,56,2,168,177,215,157,0,3,105,0,157,128,
911 2,169,12,157,248,2,168,177,215,157,240,2,76,111,7,32, 911 2,169,12,157,248,2,168,177,215,157,240,2,76,111,7,32,
912 2,12,206,74,3,208,29,169,255,141,74,3,206,73,3,208, 912 2,12,206,74,3,208,29,169,255,141,74,3,206,73,3,208,
913 19,238,75,3,173,75,3,201,255,240,3,76,203,6,76,123, 913 19,238,75,3,173,75,3,201,255,240,3,76,203,6,76,123,
914 6,76,116,10,169,4,133,214,162,7,189,120,2,240,242,133, 914 6,76,116,10,169,4,133,214,162,7,189,120,2,240,242,133,
915 212,189,112,2,133,211,188,128,2,177,211,133,217,200,177,211, 915 212,189,112,2,133,211,188,128,2,177,211,133,217,200,177,211,
916 133,218,200,177,211,133,219,200,152,221,136,2,144,10,240,8, 916 133,218,200,177,211,133,219,200,152,221,136,2,144,10,240,8,
917 169,128,157,152,2,189,144,2,157,128,2,165,217,224,4,144, 917 169,128,157,152,2,189,144,2,157,128,2,165,217,224,4,144,
918 4,74,74,74,74,41,15,29,40,2,168,185,0,5,133,220, 918 4,74,74,74,74,41,15,29,40,2,168,185,0,5,133,220,
919 165,218,41,14,168,185,144,3,133,213,165,220,25,145,3,157, 919 165,218,41,14,168,185,144,3,133,213,165,220,25,145,3,157,
920 56,3,189,184,2,240,40,201,1,208,33,189,56,2,24,125, 920 56,3,189,184,2,240,40,201,1,208,33,189,56,2,24,125,
921 216,2,24,188,192,2,121,165,3,157,56,2,200,152,221,208, 921 216,2,24,188,192,2,121,165,3,157,56,2,200,152,221,208,
922 2,208,3,189,200,2,157,192,2,76,185,8,222,184,2,188, 922 2,208,3,189,200,2,157,192,2,76,185,8,222,184,2,188,
923 0,3,192,13,144,60,189,16,3,16,49,152,221,248,2,208, 923 0,3,192,13,144,60,189,16,3,16,49,152,221,248,2,208,
924 8,189,8,3,157,248,2,208,3,254,248,2,189,112,2,133, 924 8,189,8,3,157,248,2,208,3,254,248,2,189,112,2,133,
925 215,189,120,2,133,216,188,248,2,177,215,188,232,2,240,4, 925 215,189,120,2,133,216,188,248,2,177,215,188,232,2,240,4,
926 24,125,240,2,157,240,2,189,224,2,41,63,56,233,1,157, 926 24,125,240,2,157,240,2,189,224,2,41,63,56,233,1,157,
927 16,3,189,152,2,16,31,189,40,2,240,26,221,176,2,240, 927 16,3,189,152,2,16,31,189,40,2,240,26,221,176,2,240,
928 21,144,19,168,189,168,2,24,125,160,2,157,168,2,144,6, 928 21,144,19,168,189,168,2,24,125,160,2,157,168,2,144,6,
929 152,233,16,157,40,2,169,0,133,221,165,218,157,24,3,41, 929 152,233,16,157,40,2,169,0,133,221,165,218,157,24,3,41,
930 112,74,74,141,49,9,144,254,76,231,9,234,76,81,9,234, 930 112,74,74,141,49,9,144,254,76,231,9,234,76,81,9,234,
931 76,86,9,234,76,96,9,234,76,108,9,234,76,123,9,234, 931 76,86,9,234,76,96,9,234,76,108,9,234,76,123,9,234,
932 76,190,9,234,76,205,9,165,219,76,42,10,165,219,133,221, 932 76,190,9,234,76,205,9,165,219,76,42,10,165,219,133,221,
933 189,32,2,76,237,9,189,32,2,24,101,219,157,32,2,76, 933 189,32,2,76,237,9,189,32,2,24,101,219,157,32,2,76,
934 237,9,189,56,2,24,101,219,157,56,2,189,32,2,76,237, 934 237,9,189,56,2,24,101,219,157,56,2,189,32,2,76,237,
935 9,189,224,2,16,12,188,32,2,177,213,24,125,240,2,76, 935 9,189,224,2,16,12,188,32,2,177,213,24,125,240,2,76,
936 156,9,189,32,2,24,125,240,2,201,61,144,2,169,63,168, 936 156,9,189,32,2,24,125,240,2,201,61,144,2,169,63,168,
937 177,213,157,64,2,164,219,208,3,157,72,2,152,74,74,74, 937 177,213,157,64,2,164,219,208,3,157,72,2,152,74,74,74,
938 74,157,80,2,157,88,2,165,219,41,15,157,96,2,189,32, 938 74,157,80,2,157,88,2,165,219,41,15,157,96,2,189,32,
939 2,76,237,9,165,219,24,125,40,3,157,40,3,189,32,2, 939 2,76,237,9,165,219,24,125,40,3,157,40,3,189,32,2,
940 76,237,9,165,219,201,128,240,6,157,32,2,76,237,9,189, 940 76,237,9,165,219,201,128,240,6,157,32,2,76,237,9,189,
941 56,3,9,240,157,56,3,189,32,2,76,237,9,189,32,2, 941 56,3,9,240,157,56,3,189,32,2,76,237,9,189,32,2,
942 24,101,219,188,224,2,48,31,24,125,240,2,201,61,144,7, 942 24,101,219,188,224,2,48,31,24,125,240,2,201,61,144,7,
943 169,0,157,56,3,169,63,157,32,3,168,177,213,24,125,56, 943 169,0,157,56,3,169,63,157,32,3,168,177,213,24,125,56,
944 2,24,101,221,76,42,10,201,61,144,7,169,0,157,56,3, 944 2,24,101,221,76,42,10,201,61,144,7,169,0,157,56,3,
945 169,63,168,189,56,2,24,125,240,2,24,113,213,24,101,221, 945 169,63,168,189,56,2,24,125,240,2,24,113,213,24,101,221,
946 157,48,3,189,88,2,240,50,222,88,2,208,45,189,80,2, 946 157,48,3,189,88,2,240,50,222,88,2,208,45,189,80,2,
947 157,88,2,189,72,2,221,64,2,240,31,176,13,125,96,2, 947 157,88,2,189,72,2,221,64,2,240,31,176,13,125,96,2,
948 176,18,221,64,2,176,13,76,97,10,253,96,2,144,5,221, 948 176,18,221,64,2,176,13,76,97,10,253,96,2,144,5,221,
949 64,2,176,3,189,64,2,157,72,2,165,218,41,1,240,10, 949 64,2,176,3,189,64,2,157,72,2,165,218,41,1,240,10,
950 189,72,2,24,125,56,2,157,48,3,202,48,3,76,52,8, 950 189,72,2,24,125,56,2,157,48,3,202,48,3,76,52,8,
951 173,64,3,13,65,3,13,66,3,13,67,3,170,142,101,12, 951 173,64,3,13,65,3,13,66,3,13,67,3,170,142,101,12,
952 173,24,3,16,33,173,56,3,41,15,240,26,173,48,3,24, 952 173,24,3,16,33,173,56,3,41,15,240,26,173,48,3,24,
953 109,40,3,141,50,3,173,58,3,41,16,208,5,169,0,141, 953 109,40,3,141,50,3,173,58,3,41,16,208,5,169,0,141,
954 58,3,138,9,4,170,173,25,3,16,33,173,57,3,41,15, 954 58,3,138,9,4,170,173,25,3,16,33,173,57,3,41,15,
955 240,26,173,49,3,24,109,41,3,141,51,3,173,59,3,41, 955 240,26,173,49,3,24,109,41,3,141,51,3,173,59,3,41,
956 16,208,5,169,0,141,59,3,138,9,2,170,236,101,12,208, 956 16,208,5,169,0,141,59,3,138,9,2,170,236,101,12,208,
957 94,173,25,3,41,14,201,6,208,38,173,57,3,41,15,240, 957 94,173,25,3,41,14,201,6,208,38,173,57,3,41,15,240,
958 31,172,33,3,185,192,3,141,48,3,185,192,4,141,49,3, 958 31,172,33,3,185,192,3,141,48,3,185,192,4,141,49,3,
959 173,56,3,41,16,208,5,169,0,141,56,3,138,9,80,170, 959 173,56,3,41,16,208,5,169,0,141,56,3,138,9,80,170,
960 173,27,3,41,14,201,6,208,38,173,59,3,41,15,240,31, 960 173,27,3,41,14,201,6,208,38,173,59,3,41,15,240,31,
961 172,35,3,185,192,3,141,50,3,185,192,4,141,51,3,173, 961 172,35,3,185,192,3,141,50,3,185,192,4,141,51,3,173,
962 58,3,41,16,208,5,169,0,141,58,3,138,9,40,170,142, 962 58,3,41,16,208,5,169,0,141,58,3,138,9,40,170,142,
963 101,12,173,68,3,13,69,3,13,70,3,13,71,3,170,142, 963 101,12,173,68,3,13,69,3,13,70,3,13,71,3,170,142,
964 3,12,173,28,3,16,33,173,60,3,41,15,240,26,173,52, 964 3,12,173,28,3,16,33,173,60,3,41,15,240,26,173,52,
965 3,24,109,44,3,141,54,3,173,62,3,41,16,208,5,169, 965 3,24,109,44,3,141,54,3,173,62,3,41,16,208,5,169,
966 0,141,62,3,138,9,4,170,173,29,3,16,33,173,61,3, 966 0,141,62,3,138,9,4,170,173,29,3,16,33,173,61,3,
967 41,15,240,26,173,53,3,24,109,45,3,141,55,3,173,63, 967 41,15,240,26,173,53,3,24,109,45,3,141,55,3,173,63,
968 3,41,16,208,5,169,0,141,63,3,138,9,2,170,236,3, 968 3,41,16,208,5,169,0,141,63,3,138,9,2,170,236,3,
969 12,208,94,173,29,3,41,14,201,6,208,38,173,61,3,41, 969 12,208,94,173,29,3,41,14,201,6,208,38,173,61,3,41,
970 15,240,31,172,37,3,185,192,3,141,52,3,185,192,4,141, 970 15,240,31,172,37,3,185,192,3,141,52,3,185,192,4,141,
971 53,3,173,60,3,41,16,208,5,169,0,141,60,3,138,9, 971 53,3,173,60,3,41,16,208,5,169,0,141,60,3,138,9,
972 80,170,173,31,3,41,14,201,6,208,38,173,63,3,41,15, 972 80,170,173,31,3,41,14,201,6,208,38,173,63,3,41,15,
973 240,31,172,39,3,185,192,3,141,54,3,185,192,4,141,55, 973 240,31,172,39,3,185,192,3,141,54,3,185,192,4,141,55,
974 3,173,62,3,41,16,208,5,169,0,141,62,3,138,9,40, 974 3,173,62,3,41,16,208,5,169,0,141,62,3,138,9,40,
975 170,142,3,12,173,74,3,96,160,255,173,52,3,174,48,3, 975 170,142,3,12,173,74,3,96,160,255,173,52,3,174,48,3,
976 141,16,210,142,0,210,173,60,3,174,56,3,141,17,210,142, 976 141,16,210,142,0,210,173,60,3,174,56,3,141,17,210,142,
977 1,210,173,53,3,174,49,3,141,18,210,142,2,210,173,61, 977 1,210,173,53,3,174,49,3,141,18,210,142,2,210,173,61,
978 3,174,57,3,141,19,210,142,3,210,173,54,3,174,50,3, 978 3,174,57,3,141,19,210,142,3,210,173,54,3,174,50,3,
979 141,20,210,142,4,210,173,62,3,174,58,3,141,21,210,142, 979 141,20,210,142,4,210,173,62,3,174,58,3,141,21,210,142,
980 5,210,173,55,3,174,51,3,141,22,210,142,6,210,173,63, 980 5,210,173,55,3,174,51,3,141,22,210,142,6,210,173,63,
981 3,174,59,3,141,23,210,142,7,210,169,255,140,24,210,141, 981 3,174,59,3,141,23,210,142,7,210,169,255,140,24,210,141,
982 8,210,96 982 8,210,96
983END_CONST_ARRAY; 983END_CONST_ARRAY;
984CONST_ARRAY(byte, tmc_obx) 984CONST_ARRAY(byte, tmc_obx)
985 255,255,0,5,104,15,76,206,13,76,208,8,76,239,9,15, 985 255,255,0,5,104,15,76,206,13,76,208,8,76,239,9,15,
986 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 986 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
987 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 987 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
988 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 988 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
989 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 989 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
990 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1, 990 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,
991 1,1,0,0,0,0,1,1,1,1,1,1,1,1,2,2, 991 1,1,0,0,0,0,1,1,1,1,1,1,1,1,2,2,
992 2,2,0,0,0,1,1,1,1,1,2,2,2,2,2,3, 992 2,2,0,0,0,1,1,1,1,1,2,2,2,2,2,3,
993 3,3,0,0,1,1,1,1,2,2,2,2,3,3,3,3, 993 3,3,0,0,1,1,1,1,2,2,2,2,3,3,3,3,
994 4,4,0,0,1,1,1,2,2,2,3,3,3,4,4,4, 994 4,4,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
995 5,5,0,0,1,1,2,2,2,3,3,4,4,4,5,5, 995 5,5,0,0,1,1,2,2,2,3,3,4,4,4,5,5,
996 6,6,0,0,1,1,2,2,3,3,4,4,5,5,6,6, 996 6,6,0,0,1,1,2,2,3,3,4,4,5,5,6,6,
997 7,7,0,1,1,2,2,3,3,4,4,5,5,6,6,7, 997 7,7,0,1,1,2,2,3,3,4,4,5,5,6,6,7,
998 7,8,0,1,1,2,2,3,4,4,5,5,6,7,7,8, 998 7,8,0,1,1,2,2,3,4,4,5,5,6,7,7,8,
999 8,9,0,1,1,2,3,3,4,5,5,6,7,7,8,9, 999 8,9,0,1,1,2,3,3,4,5,5,6,7,7,8,9,
1000 9,10,0,1,1,2,3,4,4,5,6,7,7,8,9,10, 1000 9,10,0,1,1,2,3,4,4,5,6,7,7,8,9,10,
1001 10,11,0,1,2,2,3,4,5,6,6,7,8,9,10,10, 1001 10,11,0,1,2,2,3,4,5,6,6,7,8,9,10,10,
1002 11,12,0,1,2,3,3,4,5,6,7,8,9,10,10,11, 1002 11,12,0,1,2,3,3,4,5,6,7,8,9,10,10,11,
1003 12,13,0,1,2,3,4,5,6,7,7,8,9,10,11,12, 1003 12,13,0,1,2,3,4,5,6,7,7,8,9,10,11,12,
1004 13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13, 1004 13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13,
1005 14,15,0,241,228,215,203,192,181,170,161,152,143,135,127,120, 1005 14,15,0,241,228,215,203,192,181,170,161,152,143,135,127,120,
1006 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, 1006 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47,
1007 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, 1007 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18,
1008 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 1008 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
1009 1,0,0,242,230,218,206,191,182,170,161,152,143,137,128,122, 1009 1,0,0,242,230,218,206,191,182,170,161,152,143,137,128,122,
1010 113,107,101,95,92,86,80,77,71,68,62,60,56,53,50,47, 1010 113,107,101,95,92,86,80,77,71,68,62,60,56,53,50,47,
1011 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, 1011 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18,
1012 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 1012 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
1013 1,0,0,255,241,228,216,202,192,181,171,162,153,142,135,127, 1013 1,0,0,255,241,228,216,202,192,181,171,162,153,142,135,127,
1014 121,115,112,102,97,90,85,82,75,72,67,63,60,57,55,51, 1014 121,115,112,102,97,90,85,82,75,72,67,63,60,57,55,51,
1015 48,45,42,40,37,36,33,31,30,28,27,25,23,22,21,19, 1015 48,45,42,40,37,36,33,31,30,28,27,25,23,22,21,19,
1016 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3, 1016 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,
1017 2,1,0,243,230,217,204,193,181,173,162,153,144,136,128,121, 1017 2,1,0,243,230,217,204,193,181,173,162,153,144,136,128,121,
1018 114,108,102,96,91,85,81,76,72,68,64,60,57,53,50,47, 1018 114,108,102,96,91,85,81,76,72,68,64,60,57,53,50,47,
1019 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, 1019 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18,
1020 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 1020 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
1021 1,0,0,242,51,150,226,56,140,0,106,232,106,239,128,8, 1021 1,0,0,242,51,150,226,56,140,0,106,232,106,239,128,8,
1022 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, 1022 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200,
1023 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, 1023 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21,
1024 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, 1024 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106,
1025 100,94,0,13,13,12,11,11,10,10,9,8,8,7,7,7, 1025 100,94,0,13,13,12,11,11,10,10,9,8,8,7,7,7,
1026 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, 1026 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2,
1027 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, 1027 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,
1028 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1028 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1029 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1029 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1030 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1030 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1031 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1031 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1032 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1032 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1033 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1033 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1034 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1034 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1035 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1035 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1036 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1036 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1037 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1037 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1038 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1038 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1039 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1039 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1040 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1040 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1041 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1041 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1042 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1042 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1043 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1043 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1044 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, 1044 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,
1045 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, 1045 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16,
1046 0,8,0,16,0,8,173,183,8,240,94,173,182,8,201,64, 1046 0,8,0,16,0,8,173,183,8,240,94,173,182,8,201,64,
1047 144,90,206,181,8,240,3,76,239,9,162,7,169,0,157,196, 1047 144,90,206,181,8,240,3,76,239,9,162,7,169,0,157,196,
1048 7,157,204,7,202,16,247,141,182,8,170,160,15,177,254,16, 1048 7,157,204,7,202,16,247,141,182,8,170,160,15,177,254,16,
1049 32,136,177,254,16,3,76,95,14,134,252,10,10,38,252,10, 1049 32,136,177,254,16,3,76,95,14,134,252,10,10,38,252,10,
1050 38,252,10,38,252,105,0,133,254,165,252,105,0,133,255,144, 1050 38,252,10,38,252,105,0,133,254,165,252,105,0,133,255,144,
1051 218,157,212,7,136,177,254,157,220,7,232,136,16,207,24,165, 1051 218,157,212,7,136,177,254,157,220,7,232,136,16,207,24,165,
1052 254,105,16,133,254,144,2,230,255,76,239,9,206,181,8,16, 1052 254,105,16,133,254,144,2,230,255,76,239,9,206,181,8,16,
1053 248,238,182,8,173,180,8,141,181,8,162,7,222,204,7,48, 1053 248,238,182,8,173,180,8,141,181,8,162,7,222,204,7,48,
1054 3,76,233,9,188,212,7,185,255,255,133,252,185,255,255,133, 1054 3,76,233,9,188,212,7,185,255,255,133,252,185,255,255,133,
1055 253,188,196,7,177,252,208,6,32,109,13,76,230,9,201,64, 1055 253,188,196,7,177,252,208,6,32,109,13,76,230,9,201,64,
1056 176,18,125,220,7,157,228,7,32,109,13,188,42,5,32,188, 1056 176,18,125,220,7,157,228,7,32,109,13,188,42,5,32,188,
1057 14,76,230,9,208,34,200,254,196,7,177,252,16,7,133,251, 1057 14,76,230,9,208,34,200,254,196,7,177,252,16,7,133,251,
1058 32,109,13,165,251,41,127,208,7,169,64,141,182,8,208,76, 1058 32,109,13,165,251,41,127,208,7,169,64,141,182,8,208,76,
1059 141,180,8,141,181,8,208,68,201,128,176,43,41,63,125,220, 1059 141,180,8,141,181,8,208,68,201,128,176,43,41,63,125,220,
1060 7,157,228,7,200,254,196,7,177,252,41,127,208,7,169,64, 1060 7,157,228,7,200,254,196,7,177,252,41,127,208,7,169,64,
1061 141,182,8,208,6,141,180,8,141,181,8,32,109,13,188,42, 1061 141,182,8,208,6,141,180,8,141,181,8,32,109,13,188,42,
1062 5,32,188,14,76,230,9,201,192,176,12,41,63,157,42,5, 1062 5,32,188,14,76,230,9,201,192,176,12,41,63,157,42,5,
1063 200,254,196,7,76,94,9,41,63,157,204,7,254,196,7,202, 1063 200,254,196,7,76,94,9,41,63,157,204,7,254,196,7,202,
1064 48,3,76,70,9,162,7,189,188,7,240,33,32,46,11,189, 1064 48,3,76,70,9,162,7,189,188,7,240,33,32,46,11,189,
1065 50,5,61,192,8,240,22,160,71,177,252,24,125,34,5,157, 1065 50,5,61,192,8,240,22,160,71,177,252,24,125,34,5,157,
1066 36,5,168,185,60,6,56,125,100,8,157,246,7,202,16,215, 1066 36,5,168,185,60,6,56,125,100,8,157,246,7,202,16,215,
1067 14,9,5,14,9,5,14,9,5,14,9,5,232,134,252,134, 1067 14,9,5,14,9,5,14,9,5,14,9,5,232,134,252,134,
1068 253,162,7,138,168,185,252,7,208,12,188,184,8,185,4,8, 1068 253,162,7,138,168,185,252,7,208,12,188,184,8,185,4,8,
1069 208,4,138,168,169,0,133,250,152,157,26,5,185,244,7,157, 1069 208,4,138,168,169,0,133,250,152,157,26,5,185,244,7,157,
1070 18,5,185,50,5,133,251,5,253,133,253,165,251,61,192,8, 1070 18,5,185,50,5,133,251,5,253,133,253,165,251,61,192,8,
1071 240,6,185,246,7,157,20,5,165,251,61,200,8,240,18,185, 1071 240,6,185,246,7,157,20,5,165,251,61,200,8,240,18,185,
1072 34,5,41,63,168,200,132,252,185,123,7,157,18,5,76,137, 1072 34,5,41,63,168,200,132,252,185,123,7,157,18,5,76,137,
1073 10,164,252,240,10,185,59,7,157,18,5,169,0,133,252,165, 1073 10,164,252,240,10,185,59,7,157,18,5,169,0,133,252,165,
1074 250,13,9,5,168,185,60,5,188,26,5,25,236,7,157,10, 1074 250,13,9,5,168,185,60,5,188,26,5,25,236,7,157,10,
1075 5,224,4,208,9,165,253,141,59,5,169,0,133,253,202,16, 1075 5,224,4,208,9,165,253,141,59,5,169,0,133,253,202,16,
1076 130,78,9,5,78,9,5,78,9,5,78,9,5,165,253,162, 1076 130,78,9,5,78,9,5,78,9,5,78,9,5,165,253,162,
1077 3,142,31,210,142,15,210,174,22,5,172,18,5,142,16,210, 1077 3,142,31,210,142,15,210,174,22,5,172,18,5,142,16,210,
1078 140,0,210,174,14,5,172,10,5,142,17,210,140,1,210,174, 1078 140,0,210,174,14,5,172,10,5,142,17,210,140,1,210,174,
1079 23,5,172,19,5,142,18,210,140,2,210,174,15,5,172,11, 1079 23,5,172,19,5,142,18,210,140,2,210,174,15,5,172,11,
1080 5,142,19,210,140,3,210,174,24,5,172,20,5,142,20,210, 1080 5,142,19,210,140,3,210,174,24,5,172,20,5,142,20,210,
1081 140,4,210,174,16,5,172,12,5,142,21,210,140,5,210,174, 1081 140,4,210,174,16,5,172,12,5,142,21,210,140,5,210,174,
1082 25,5,172,21,5,142,22,210,140,6,210,174,17,5,172,13, 1082 25,5,172,21,5,142,22,210,140,6,210,174,17,5,172,13,
1083 5,142,23,210,140,7,210,141,58,5,174,59,5,142,24,210, 1083 5,142,23,210,140,7,210,141,58,5,174,59,5,142,24,210,
1084 141,8,210,96,189,28,8,133,252,189,36,8,133,253,188,44, 1084 141,8,210,96,189,28,8,133,252,189,36,8,133,253,188,44,
1085 8,192,63,240,123,254,44,8,254,44,8,254,44,8,177,252, 1085 8,192,63,240,123,254,44,8,254,44,8,254,44,8,177,252,
1086 41,240,157,236,7,177,252,41,15,56,253,12,8,16,2,169, 1086 41,240,157,236,7,177,252,41,15,56,253,12,8,16,2,169,
1087 0,157,252,7,200,177,252,41,15,56,253,20,8,16,2,169, 1087 0,157,252,7,200,177,252,41,15,56,253,20,8,16,2,169,
1088 0,157,4,8,177,252,41,240,240,116,16,11,160,73,177,252, 1088 0,157,4,8,177,252,41,240,240,116,16,11,160,73,177,252,
1089 188,44,8,136,136,16,2,169,0,157,50,5,177,252,41,112, 1089 188,44,8,136,136,16,2,169,0,157,50,5,177,252,41,112,
1090 240,99,74,74,141,154,11,169,0,157,100,8,200,177,252,144, 1090 240,99,74,74,141,154,11,169,0,157,100,8,200,177,252,144,
1091 254,234,234,234,234,76,56,13,234,76,53,13,234,76,60,13, 1091 254,234,234,234,234,76,56,13,234,76,53,13,234,76,60,13,
1092 234,76,74,13,234,76,84,13,234,76,95,13,234,76,81,13, 1092 234,76,74,13,234,76,84,13,234,76,95,13,234,76,81,13,
1093 189,52,8,240,18,222,68,8,208,13,157,68,8,189,252,7, 1093 189,52,8,240,18,222,68,8,208,13,157,68,8,189,252,7,
1094 41,15,240,3,222,252,7,189,60,8,240,18,222,76,8,208, 1094 41,15,240,3,222,252,7,189,60,8,240,18,222,76,8,208,
1095 13,157,76,8,189,4,8,41,15,240,3,222,4,8,160,72, 1095 13,157,76,8,189,4,8,41,15,240,3,222,4,8,160,72,
1096 177,252,157,50,5,189,148,8,24,105,63,168,177,252,125,228, 1096 177,252,157,50,5,189,148,8,24,105,63,168,177,252,125,228,
1097 7,157,34,5,168,185,60,6,157,244,7,222,164,8,16,51, 1097 7,157,34,5,168,185,60,6,157,244,7,222,164,8,16,51,
1098 189,156,8,157,164,8,189,172,8,240,24,24,125,148,8,157, 1098 189,156,8,157,164,8,189,172,8,240,24,24,125,148,8,157,
1099 148,8,240,7,221,140,8,208,26,169,254,24,105,1,157,172, 1099 148,8,240,7,221,140,8,208,26,169,254,24,105,1,157,172,
1100 8,208,16,254,148,8,189,140,8,221,148,8,176,5,169,0, 1100 8,208,16,254,148,8,189,140,8,221,148,8,176,5,169,0,
1101 157,148,8,189,116,8,240,4,222,116,8,96,189,108,8,133, 1101 157,148,8,189,116,8,240,4,222,116,8,96,189,108,8,133,
1102 250,189,92,8,133,251,32,105,12,222,132,8,16,16,165,250, 1102 250,189,92,8,133,251,32,105,12,222,132,8,16,16,165,250,
1103 157,108,8,165,251,157,92,8,189,124,8,157,132,8,96,189, 1103 157,108,8,165,251,157,92,8,189,124,8,157,132,8,96,189,
1104 84,8,141,112,12,16,254,76,167,12,234,76,144,12,234,76, 1104 84,8,141,112,12,16,254,76,167,12,234,76,144,12,234,76,
1105 174,12,234,76,180,12,234,76,190,12,234,76,210,12,234,76, 1105 174,12,234,76,180,12,234,76,190,12,234,76,210,12,234,76,
1106 226,12,234,76,244,12,165,250,230,250,41,3,74,144,15,208, 1106 226,12,234,76,244,12,165,250,230,250,41,3,74,144,15,208,
1107 71,165,251,157,100,8,24,125,244,7,157,244,7,96,169,0, 1107 71,165,251,157,100,8,24,125,244,7,157,244,7,96,169,0,
1108 157,100,8,96,32,29,13,76,157,12,32,29,13,24,125,34, 1108 157,100,8,96,32,29,13,76,157,12,32,29,13,24,125,34,
1109 5,76,84,13,165,250,157,100,8,24,125,244,7,157,244,7, 1109 5,76,84,13,165,250,157,100,8,24,125,244,7,157,244,7,
1110 165,250,24,101,251,133,250,96,189,34,5,56,229,250,157,34, 1110 165,250,24,101,251,133,250,96,189,34,5,56,229,250,157,34,
1111 5,168,185,60,6,76,199,12,189,244,7,56,229,251,157,244, 1111 5,168,185,60,6,76,199,12,189,244,7,56,229,251,157,244,
1112 7,56,169,0,229,251,157,100,8,96,189,132,8,208,174,165, 1112 7,56,169,0,229,251,157,100,8,96,189,132,8,208,174,165,
1113 251,16,16,189,4,8,240,165,189,252,7,201,15,240,158,254, 1113 251,16,16,189,4,8,240,165,189,252,7,201,15,240,158,254,
1114 252,7,96,189,252,7,240,149,189,4,8,201,15,240,142,254, 1114 252,7,96,189,252,7,240,149,189,4,8,201,15,240,142,254,
1115 4,8,96,164,250,165,251,48,2,200,200,136,152,133,250,197, 1115 4,8,96,164,250,165,251,48,2,200,200,136,152,133,250,197,
1116 251,208,6,165,251,73,255,133,251,152,96,125,244,7,157,244, 1116 251,208,6,165,251,73,255,133,251,152,96,125,244,7,157,244,
1117 7,96,188,228,7,121,60,6,157,244,7,152,157,34,5,96, 1117 7,96,188,228,7,121,60,6,157,244,7,152,157,34,5,96,
1118 45,10,210,157,244,7,96,125,228,7,157,34,5,168,185,60, 1118 45,10,210,157,244,7,96,125,228,7,157,34,5,168,185,60,
1119 6,157,244,7,96,157,34,5,168,189,244,7,121,60,6,157, 1119 6,157,244,7,96,157,34,5,168,189,244,7,121,60,6,157,
1120 244,7,96,200,254,196,7,177,252,74,74,74,74,157,12,8, 1120 244,7,96,200,254,196,7,177,252,74,74,74,74,157,12,8,
1121 177,252,41,15,157,20,8,96,32,95,14,160,15,169,0,133, 1121 177,252,41,15,157,20,8,96,32,95,14,160,15,169,0,133,
1122 254,169,0,133,255,138,240,46,177,254,16,1,202,24,165,254, 1122 254,169,0,133,255,138,240,46,177,254,16,1,202,24,165,254,
1123 105,16,133,254,144,239,230,255,176,235,32,95,14,169,0,133, 1123 105,16,133,254,144,239,230,255,176,235,32,95,14,169,0,133,
1124 252,138,10,10,38,252,10,38,252,10,38,252,105,0,133,254, 1124 252,138,10,10,38,252,10,38,252,10,38,252,105,0,133,254,
1125 165,252,105,0,133,255,169,64,141,182,8,169,1,141,181,8, 1125 165,252,105,0,133,255,169,64,141,182,8,169,1,141,181,8,
1126 141,183,8,96,201,16,144,176,201,32,144,206,201,48,176,3, 1126 141,183,8,96,201,16,144,176,201,32,144,206,201,48,176,3,
1127 76,174,14,201,64,176,9,138,41,15,240,3,141,180,8,96, 1127 76,174,14,201,64,176,9,138,41,15,240,3,141,180,8,96,
1128 201,80,144,113,201,96,176,6,169,0,141,183,8,96,201,112, 1128 201,80,144,113,201,96,176,6,169,0,141,183,8,96,201,112,
1129 144,248,169,1,141,181,8,169,64,141,182,8,132,252,134,253, 1129 144,248,169,1,141,181,8,169,64,141,182,8,132,252,134,253,
1130 160,30,177,252,141,180,8,165,252,24,105,32,141,194,14,144, 1130 160,30,177,252,141,180,8,165,252,24,105,32,141,194,14,144,
1131 1,232,142,195,14,24,105,64,141,202,14,144,1,232,142,203, 1131 1,232,142,195,14,24,105,64,141,202,14,144,1,232,142,203,
1132 14,24,105,64,141,82,9,144,1,232,142,83,9,24,105,128, 1132 14,24,105,64,141,82,9,144,1,232,142,83,9,24,105,128,
1133 141,87,9,144,1,232,142,88,9,24,105,128,133,254,141,16, 1133 141,87,9,144,1,232,142,88,9,24,105,128,133,254,141,16,
1134 9,141,136,13,141,183,13,144,1,232,134,255,142,22,9,142, 1134 9,141,136,13,141,183,13,144,1,232,134,255,142,22,9,142,
1135 140,13,142,189,13,160,7,169,0,141,183,8,153,0,210,153, 1135 140,13,142,189,13,160,7,169,0,141,183,8,153,0,210,153,
1136 16,210,153,10,5,153,252,7,153,4,8,153,50,5,153,188, 1136 16,210,153,10,5,153,252,7,153,4,8,153,50,5,153,188,
1137 7,136,16,232,141,8,210,141,24,210,141,58,5,141,59,5, 1137 7,136,16,232,141,8,210,141,24,210,141,58,5,141,59,5,
1138 96,157,252,7,157,4,8,157,50,5,189,228,7,157,34,5, 1138 96,157,252,7,157,4,8,157,50,5,189,228,7,157,34,5,
1139 96,152,73,240,74,74,74,74,157,12,8,152,41,15,73,15, 1139 96,152,73,240,74,74,74,74,157,12,8,152,41,15,73,15,
1140 157,20,8,96,41,7,133,252,138,166,252,41,63,240,226,157, 1140 157,20,8,96,41,7,133,252,138,166,252,41,63,240,226,157,
1141 228,7,169,0,157,188,7,185,255,255,157,28,8,133,252,185, 1141 228,7,169,0,157,188,7,185,255,255,157,28,8,133,252,185,
1142 255,255,157,36,8,133,253,5,252,240,182,160,74,177,252,157, 1142 255,255,157,36,8,133,253,5,252,240,182,160,74,177,252,157,
1143 52,8,157,68,8,200,177,252,157,60,8,157,76,8,200,177, 1143 52,8,157,68,8,200,177,252,157,60,8,157,76,8,200,177,
1144 252,41,112,74,74,157,84,8,177,252,41,15,157,92,8,177, 1144 252,41,112,74,74,157,84,8,177,252,41,15,157,92,8,177,
1145 252,16,11,189,92,8,73,255,24,105,1,157,92,8,200,177, 1145 252,16,11,189,92,8,73,255,24,105,1,157,92,8,200,177,
1146 252,157,116,8,200,177,252,41,63,157,124,8,157,132,8,200, 1146 252,157,116,8,200,177,252,41,63,157,124,8,157,132,8,200,
1147 177,252,41,128,240,2,169,1,157,172,8,177,252,41,112,74, 1147 177,252,41,128,240,2,169,1,157,172,8,177,252,41,112,74,
1148 74,74,74,157,140,8,208,3,157,172,8,177,252,41,15,157, 1148 74,74,74,157,140,8,208,3,157,172,8,177,252,41,15,157,
1149 156,8,157,164,8,136,177,252,41,192,24,125,228,7,157,228, 1149 156,8,157,164,8,136,177,252,41,192,24,125,228,7,157,228,
1150 7,157,34,5,168,185,60,6,157,244,7,169,0,157,44,8, 1150 7,157,34,5,168,185,60,6,157,244,7,169,0,157,44,8,
1151 157,100,8,157,108,8,157,148,8,169,1,157,188,7,96 1151 157,100,8,157,108,8,157,148,8,169,1,157,188,7,96
1152END_CONST_ARRAY; 1152END_CONST_ARRAY;
1153CONST_ARRAY(byte, tm2_obx) 1153CONST_ARRAY(byte, tm2_obx)
1154 255,255,0,2,107,16,0,0,0,0,0,0,0,0,0,0, 1154 255,255,0,2,107,16,0,0,0,0,0,0,0,0,0,0,
1155 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 1155 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1156 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, 1156 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,
1157 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, 1157 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2,
1158 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, 1158 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2,
1159 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, 1159 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3,
1160 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, 1160 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4,
1161 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, 1161 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4,
1162 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, 1162 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5,
1163 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, 1163 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5,
1164 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, 1164 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6,
1165 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, 1165 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7,
1166 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, 1166 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7,
1167 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, 1167 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8,
1168 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, 1168 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8,
1169 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, 1169 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,
1170 10,11,12,13,14,15,0,241,228,215,203,192,181,170,161,152, 1170 10,11,12,13,14,15,0,241,228,215,203,192,181,170,161,152,
1171 143,135,127,120,114,107,101,95,90,85,80,75,71,67,63,60, 1171 143,135,127,120,114,107,101,95,90,85,80,75,71,67,63,60,
1172 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, 1172 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23,
1173 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 1173 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
1174 5,4,3,2,1,0,0,242,233,218,206,191,182,170,161,152, 1174 5,4,3,2,1,0,0,242,233,218,206,191,182,170,161,152,
1175 143,137,128,122,113,107,101,95,92,86,80,77,71,68,62,60, 1175 143,137,128,122,113,107,101,95,92,86,80,77,71,68,62,60,
1176 56,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, 1176 56,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,
1177 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 1177 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
1178 5,4,3,2,1,0,0,255,241,228,216,202,192,181,171,162, 1178 5,4,3,2,1,0,0,255,241,228,216,202,192,181,171,162,
1179 153,142,135,127,121,115,112,102,97,90,85,82,75,72,67,63, 1179 153,142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,
1180 60,57,55,51,48,45,42,40,37,36,33,31,30,28,27,25, 1180 60,57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,
1181 23,22,21,19,18,17,16,15,14,13,12,11,10,9,8,7, 1181 23,22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,
1182 6,5,4,3,2,1,0,243,230,217,204,193,181,173,162,153, 1182 6,5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,
1183 144,136,128,121,114,108,102,96,91,85,81,76,72,68,64,60, 1183 144,136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,
1184 57,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, 1184 57,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,
1185 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 1185 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
1186 5,4,3,2,1,0,226,56,140,0,106,232,106,239,128,8, 1186 5,4,3,2,1,0,226,56,140,0,106,232,106,239,128,8,
1187 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, 1187 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200,
1188 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, 1188 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21,
1189 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, 1189 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106,
1190 100,94,87,82,50,10,0,242,51,150,226,56,140,0,106,232, 1190 100,94,87,82,50,10,0,242,51,150,226,56,140,0,106,232,
1191 106,239,128,8,174,70,230,149,65,246,176,110,48,246,187,132, 1191 106,239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,
1192 82,34,244,200,160,122,85,52,20,245,216,189,164,141,119,96, 1192 82,34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,
1193 78,56,39,21,6,247,232,219,207,195,184,172,162,154,144,136, 1193 78,56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,
1194 127,120,112,106,100,94,11,11,10,10,9,8,8,7,7,7, 1194 127,120,112,106,100,94,11,11,10,10,9,8,8,7,7,7,
1195 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, 1195 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2,
1196 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, 1196 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,
1197 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1197 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1198 0,0,0,0,0,0,0,13,13,12,11,11,10,10,9,8, 1198 0,0,0,0,0,0,0,13,13,12,11,11,10,10,9,8,
1199 8,7,7,7,6,6,5,5,5,4,4,4,4,3,3,3, 1199 8,7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,
1200 3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1, 1200 3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,
1201 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0, 1201 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
1202 0,0,0,0,0,0,76,228,13,76,227,6,76,159,8,1, 1202 0,0,0,0,0,0,76,228,13,76,227,6,76,159,8,1,
1203 16,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1203 16,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1204 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1204 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1205 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1205 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1206 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1206 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1207 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1207 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1208 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1208 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1209 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1209 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1210 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1210 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1211 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1211 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1212 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1212 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1213 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1213 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1215 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1215 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1216 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1216 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1217 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1217 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1218 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1218 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1219 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1219 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1220 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1220 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1221 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1221 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1222 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1222 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1223 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1223 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1224 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1224 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1225 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1225 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1226 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1226 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1227 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, 1227 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,
1228 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, 1228 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16,
1229 0,8,0,16,0,8,133,211,129,169,133,211,129,169,136,177, 1229 0,8,0,16,0,8,133,211,129,169,133,211,129,169,136,177,
1230 250,141,23,5,162,0,134,252,10,38,252,10,38,252,10,38, 1230 250,141,23,5,162,0,134,252,10,38,252,10,38,252,10,38,
1231 252,10,38,252,109,23,5,144,2,230,252,24,105,0,133,250, 1231 252,10,38,252,109,23,5,144,2,230,252,24,105,0,133,250,
1232 165,252,105,0,133,251,76,7,7,32,181,9,173,22,5,240, 1232 165,252,105,0,133,251,76,7,7,32,181,9,173,22,5,240,
1233 5,206,28,5,48,3,76,162,8,206,29,5,208,82,162,0, 1233 5,206,28,5,48,3,76,162,8,206,29,5,208,82,162,0,
1234 238,23,5,173,25,5,133,250,173,26,5,133,251,160,16,177, 1234 238,23,5,173,25,5,133,250,173,26,5,133,251,160,16,177,
1235 250,48,171,208,3,76,44,15,141,29,5,136,177,250,136,132, 1235 250,48,171,208,3,76,44,15,141,29,5,136,177,250,136,132,
1236 252,168,185,255,255,157,80,5,185,255,255,157,88,5,169,0, 1236 252,168,185,255,255,157,80,5,185,255,255,157,88,5,169,0,
1237 157,112,5,157,96,5,164,252,177,250,157,104,5,232,136,16, 1237 157,112,5,157,96,5,164,252,177,250,157,104,5,232,136,16,
1238 219,169,17,24,101,250,141,25,5,169,0,101,251,141,26,5, 1238 219,169,17,24,101,250,141,25,5,169,0,101,251,141,26,5,
1239 173,27,5,141,28,5,162,7,222,112,5,48,6,202,16,248, 1239 173,27,5,141,28,5,162,7,222,112,5,48,6,202,16,248,
1240 76,162,8,189,80,5,133,250,189,88,5,133,251,188,96,5, 1240 76,162,8,189,80,5,133,250,189,88,5,133,251,188,96,5,
1241 177,250,208,28,200,177,250,157,208,5,41,240,157,216,5,177, 1241 177,250,208,28,200,177,250,157,208,5,41,240,157,216,5,177,
1242 250,10,10,10,10,157,224,5,200,152,157,96,5,76,87,7, 1242 250,10,10,10,10,157,224,5,200,152,157,96,5,76,87,7,
1243 201,64,176,79,125,104,5,157,152,5,200,177,250,16,37,41, 1243 201,64,176,79,125,104,5,157,152,5,200,177,250,16,37,41,
1244 127,133,252,200,177,250,157,208,5,41,240,157,216,5,177,250, 1244 127,133,252,200,177,250,157,208,5,41,240,157,216,5,177,250,
1245 10,10,10,10,157,224,5,200,152,157,96,5,164,252,32,156, 1245 10,10,10,10,157,224,5,200,152,157,96,5,164,252,32,156,
1246 15,76,87,7,168,254,96,5,254,96,5,189,208,5,41,240, 1246 15,76,87,7,168,254,96,5,254,96,5,189,208,5,41,240,
1247 157,216,5,189,208,5,10,10,10,10,157,224,5,32,156,15, 1247 157,216,5,189,208,5,10,10,10,10,157,224,5,32,156,15,
1248 76,87,7,201,128,176,37,41,63,24,125,104,5,157,152,5, 1248 76,87,7,201,128,176,37,41,63,24,125,104,5,157,152,5,
1249 200,177,250,157,208,5,41,240,157,216,5,177,250,10,10,10, 1249 200,177,250,157,208,5,41,240,157,216,5,177,250,10,10,10,
1250 10,157,224,5,200,152,157,96,5,76,87,7,208,14,200,177, 1250 10,157,224,5,200,152,157,96,5,76,87,7,208,14,200,177,
1251 250,157,112,5,200,152,157,96,5,76,87,7,201,192,176,15, 1251 250,157,112,5,200,152,157,96,5,76,87,7,201,192,176,15,
1252 41,63,24,125,104,5,157,152,5,254,96,5,76,87,7,201, 1252 41,63,24,125,104,5,157,152,5,254,96,5,76,87,7,201,
1253 208,176,15,200,254,96,5,41,15,141,27,5,141,28,5,76, 1253 208,176,15,200,254,96,5,41,15,141,27,5,141,28,5,76,
1254 106,7,201,224,176,22,177,250,133,252,200,177,250,133,253,200, 1254 106,7,201,224,176,22,177,250,133,252,200,177,250,133,253,200,
1255 152,157,96,5,165,252,32,14,14,76,87,7,201,240,176,46, 1255 152,157,96,5,165,252,32,14,14,76,87,7,201,240,176,46,
1256 177,250,133,252,200,177,250,133,253,165,252,32,14,14,188,96, 1256 177,250,133,252,200,177,250,133,253,165,252,32,14,14,188,96,
1257 5,200,200,177,250,157,208,5,41,240,157,216,5,177,250,10, 1257 5,200,200,177,250,157,208,5,41,240,157,216,5,177,250,10,
1258 10,10,10,157,224,5,200,152,157,96,5,76,87,7,201,255, 1258 10,10,10,157,224,5,200,152,157,96,5,76,87,7,201,255,
1259 176,11,233,239,157,112,5,254,96,5,76,87,7,169,64,157, 1259 176,11,233,239,157,112,5,254,96,5,76,87,7,169,64,157,
1260 112,5,76,87,7,32,181,9,162,7,189,120,5,240,115,76, 1260 112,5,76,87,7,32,181,9,162,7,189,120,5,240,115,76,
1261 217,10,189,14,5,240,14,169,0,157,32,5,157,40,5,202, 1261 217,10,189,14,5,240,14,169,0,157,32,5,157,40,5,202,
1262 16,232,76,31,9,164,253,185,0,3,24,101,252,157,56,5, 1262 16,232,76,31,9,164,253,185,0,3,24,101,252,157,56,5,
1263 152,157,160,5,189,176,5,61,168,6,240,40,165,253,41,127, 1263 152,157,160,5,189,176,5,61,168,6,240,40,165,253,41,127,
1264 168,185,0,4,24,101,252,157,55,5,185,128,4,105,0,157, 1264 168,185,0,4,24,101,252,157,55,5,185,128,4,105,0,157,
1265 56,5,169,0,157,31,5,188,152,6,153,39,5,202,202,16, 1265 56,5,169,0,157,31,5,188,152,6,153,39,5,202,202,16,
1266 169,76,31,9,189,176,5,61,160,6,240,22,189,104,6,24, 1266 169,76,31,9,189,176,5,61,160,6,240,22,189,104,6,24,
1267 101,253,157,162,5,168,185,0,3,24,101,252,56,101,254,157, 1267 101,253,157,162,5,168,185,0,3,24,101,252,56,101,254,157,
1268 58,5,202,16,133,232,134,252,162,3,173,9,5,240,6,41, 1268 58,5,202,16,133,232,134,252,162,3,173,9,5,240,6,41,
1269 64,208,60,162,7,138,168,185,32,5,208,12,188,152,6,185, 1269 64,208,60,162,7,138,168,185,32,5,208,12,188,152,6,185,
1270 40,5,208,4,138,168,169,0,25,168,5,157,48,5,185,56, 1270 40,5,208,4,138,168,169,0,25,168,5,157,48,5,185,56,
1271 5,157,72,5,185,160,5,157,64,5,185,176,5,5,252,133, 1271 5,157,72,5,185,160,5,157,64,5,185,176,5,5,252,133,
1272 252,224,4,208,3,141,31,5,202,16,202,141,30,5,96,189, 1272 252,224,4,208,3,141,31,5,202,16,202,141,30,5,96,189,
1273 32,5,29,168,5,157,48,5,189,44,5,29,172,5,157,52, 1273 32,5,29,168,5,157,48,5,189,44,5,29,172,5,157,52,
1274 5,189,56,5,157,72,5,189,60,5,157,76,5,189,160,5, 1274 5,189,56,5,157,72,5,189,60,5,157,76,5,189,160,5,
1275 157,64,5,189,164,5,157,68,5,202,16,211,173,176,5,13, 1275 157,64,5,189,164,5,157,68,5,202,16,211,173,176,5,13,
1276 177,5,13,178,5,13,179,5,141,30,5,173,180,5,13,181, 1276 177,5,13,178,5,13,179,5,141,30,5,173,180,5,13,181,
1277 5,13,182,5,13,183,5,141,31,5,96,173,9,5,208,3, 1277 5,13,182,5,13,183,5,141,31,5,96,173,9,5,208,3,
1278 76,144,10,48,3,76,72,10,173,13,5,170,74,74,41,1, 1278 76,144,10,48,3,76,72,10,173,13,5,170,74,74,41,1,
1279 168,185,30,5,141,56,210,138,41,4,168,185,56,5,141,48, 1279 168,185,30,5,141,56,210,138,41,4,168,185,56,5,141,48,
1280 210,189,32,5,141,49,210,185,57,5,141,50,210,189,33,5, 1280 210,189,32,5,141,49,210,185,57,5,141,50,210,189,33,5,
1281 141,51,210,185,58,5,141,52,210,189,34,5,141,53,210,185, 1281 141,51,210,185,58,5,141,52,210,189,34,5,141,53,210,185,
1282 59,5,141,54,210,189,35,5,141,55,210,173,12,5,170,74, 1282 59,5,141,54,210,189,35,5,141,55,210,173,12,5,170,74,
1283 74,41,1,168,185,30,5,141,40,210,138,41,4,168,185,56, 1283 74,41,1,168,185,30,5,141,40,210,138,41,4,168,185,56,
1284 5,141,32,210,189,32,5,141,33,210,185,57,5,141,34,210, 1284 5,141,32,210,189,32,5,141,33,210,185,57,5,141,34,210,
1285 189,33,5,141,35,210,185,58,5,141,36,210,189,34,5,141, 1285 189,33,5,141,35,210,185,58,5,141,36,210,189,34,5,141,
1286 37,210,185,59,5,141,38,210,189,35,5,141,39,210,173,11, 1286 37,210,185,59,5,141,38,210,189,35,5,141,39,210,173,11,
1287 5,170,74,74,41,1,168,185,30,5,141,24,210,138,172,9, 1287 5,170,74,74,41,1,168,185,30,5,141,24,210,138,172,9,
1288 5,16,2,41,4,168,185,56,5,141,16,210,189,32,5,141, 1288 5,16,2,41,4,168,185,56,5,141,16,210,189,32,5,141,
1289 17,210,185,57,5,141,18,210,189,33,5,141,19,210,185,58, 1289 17,210,185,57,5,141,18,210,189,33,5,141,19,210,185,58,
1290 5,141,20,210,189,34,5,141,21,210,185,59,5,141,22,210, 1290 5,141,20,210,189,34,5,141,21,210,185,59,5,141,22,210,
1291 189,35,5,141,23,210,173,10,5,170,74,74,41,1,168,185, 1291 189,35,5,141,23,210,173,10,5,170,74,74,41,1,168,185,
1292 30,5,141,8,210,138,172,9,5,16,2,41,4,168,185,56, 1292 30,5,141,8,210,138,172,9,5,16,2,41,4,168,185,56,
1293 5,141,0,210,189,32,5,141,1,210,185,57,5,141,2,210, 1293 5,141,0,210,189,32,5,141,1,210,185,57,5,141,2,210,
1294 189,33,5,141,3,210,185,58,5,141,4,210,189,34,5,141, 1294 189,33,5,141,3,210,185,58,5,141,4,210,189,34,5,141,
1295 5,210,185,59,5,141,6,210,189,35,5,141,7,210,96,189, 1295 5,210,185,59,5,141,6,210,189,35,5,141,7,210,96,189,
1296 128,5,133,250,189,136,5,133,251,189,128,6,133,252,189,136, 1296 128,5,133,250,189,136,5,133,251,189,128,6,133,252,189,136,
1297 6,133,253,189,144,6,133,254,189,184,5,221,192,5,144,12, 1297 6,133,253,189,144,6,133,254,189,184,5,221,192,5,144,12,
1298 157,8,6,189,200,5,157,184,5,76,11,11,189,8,6,240, 1298 157,8,6,189,200,5,157,184,5,76,11,11,189,8,6,240,
1299 48,189,232,5,240,19,222,248,5,208,14,157,248,5,189,216, 1299 48,189,232,5,240,19,222,248,5,208,14,157,248,5,189,216,
1300 5,240,6,56,233,16,157,216,5,189,240,5,240,19,222,0, 1300 5,240,6,56,233,16,157,216,5,189,240,5,240,19,222,0,
1301 6,208,14,157,0,6,189,224,5,240,6,56,233,16,157,224, 1301 6,208,14,157,0,6,189,224,5,240,6,56,233,16,157,224,
1302 5,188,72,6,177,250,24,125,152,5,24,101,253,133,253,222, 1302 5,188,72,6,177,250,24,125,152,5,24,101,253,133,253,222,
1303 88,6,16,57,189,80,6,157,88,6,189,96,6,240,30,24, 1303 88,6,16,57,189,80,6,157,88,6,189,96,6,240,30,24,
1304 125,72,6,157,72,6,240,13,221,64,6,144,32,169,255,157, 1304 125,72,6,157,72,6,240,13,221,64,6,144,32,169,255,157,
1305 96,6,76,135,11,169,1,157,96,6,76,135,11,254,72,6, 1305 96,6,76,135,11,169,1,157,96,6,76,135,11,254,72,6,
1306 189,64,6,221,72,6,176,5,169,0,157,72,6,169,19,24, 1306 189,64,6,221,72,6,176,5,169,0,157,72,6,169,19,24,
1307 101,250,133,250,144,2,230,251,188,184,5,177,250,41,240,157, 1307 101,250,133,250,144,2,230,251,188,184,5,177,250,41,240,157,
1308 168,5,177,250,41,15,29,216,5,168,185,0,2,5,255,168, 1308 168,5,177,250,41,15,29,216,5,168,185,0,2,5,255,168,
1309 185,0,2,157,32,5,188,184,5,200,177,250,41,15,29,224, 1309 185,0,2,157,32,5,188,184,5,200,177,250,41,15,29,224,
1310 5,168,185,0,2,5,255,168,185,0,2,157,40,5,189,40, 1310 5,168,185,0,2,5,255,168,185,0,2,157,40,5,189,40,
1311 6,208,39,189,16,6,141,212,11,16,254,76,209,12,234,76, 1311 6,208,39,189,16,6,141,212,11,16,254,76,209,12,234,76,
1312 108,12,234,76,167,12,234,76,212,12,234,76,1,13,234,76, 1312 108,12,234,76,167,12,234,76,212,12,234,76,1,13,234,76,
1313 33,13,234,76,65,13,234,76,73,13,222,40,6,188,184,5, 1313 33,13,234,76,65,13,234,76,73,13,222,40,6,188,184,5,
1314 200,177,250,41,112,74,74,74,141,34,12,177,250,48,6,189, 1314 200,177,250,41,112,74,74,74,141,34,12,177,250,48,6,189,
1315 112,6,76,18,12,189,120,6,61,176,6,157,176,5,200,200, 1315 112,6,76,18,12,189,120,6,61,176,6,157,176,5,200,200,
1316 152,157,184,5,136,177,250,144,254,144,22,144,12,144,34,144, 1316 152,157,184,5,136,177,250,144,254,144,22,144,12,144,34,144,
1317 24,144,46,144,36,144,50,144,52,125,128,6,157,128,6,177, 1317 24,144,46,144,36,144,50,144,52,125,128,6,157,128,6,177,
1318 250,24,101,252,133,252,76,172,8,125,136,6,157,136,6,177, 1318 250,24,101,252,133,252,76,172,8,125,136,6,157,136,6,177,
1319 250,24,101,253,133,253,76,172,8,125,144,6,157,144,6,177, 1319 250,24,101,253,133,253,76,172,8,125,144,6,157,144,6,177,
1320 250,24,101,254,133,254,76,172,8,133,252,169,0,133,253,76, 1320 250,24,101,254,133,254,76,172,8,133,252,169,0,133,253,76,
1321 172,8,189,32,6,41,3,74,144,10,208,25,189,24,6,24, 1321 172,8,189,32,6,41,3,74,144,10,208,25,189,24,6,24,
1322 101,252,133,252,222,56,6,16,78,254,32,6,189,48,6,157, 1322 101,252,133,252,222,56,6,16,78,254,32,6,189,48,6,157,
1323 56,6,76,247,11,165,252,253,24,6,133,252,222,56,6,16, 1323 56,6,76,247,11,165,252,253,24,6,133,252,222,56,6,16,
1324 54,254,32,6,189,48,6,157,56,6,76,247,11,188,32,6, 1324 54,254,32,6,189,48,6,157,56,6,76,247,11,188,32,6,
1325 189,24,6,48,2,200,200,136,152,24,101,252,133,252,222,56, 1325 189,24,6,48,2,200,200,136,152,24,101,252,133,252,222,56,
1326 6,16,20,152,157,32,6,221,24,6,208,5,73,255,157,24, 1326 6,16,20,152,157,32,6,221,24,6,208,5,73,255,157,24,
1327 6,189,48,6,157,56,6,76,247,11,188,32,6,189,24,6, 1327 6,189,48,6,157,56,6,76,247,11,188,32,6,189,24,6,
1328 48,2,200,200,136,152,24,101,253,133,253,222,56,6,16,231, 1328 48,2,200,200,136,152,24,101,253,133,253,222,56,6,16,231,
1329 152,157,32,6,221,24,6,208,216,73,255,157,24,6,189,48, 1329 152,157,32,6,221,24,6,208,216,73,255,157,24,6,189,48,
1330 6,157,56,6,76,247,11,189,32,6,24,101,252,133,252,222, 1330 6,157,56,6,76,247,11,189,32,6,24,101,252,133,252,222,
1331 56,6,16,195,189,24,6,24,125,32,6,157,32,6,189,48, 1331 56,6,16,195,189,24,6,24,125,32,6,157,32,6,189,48,
1332 6,157,56,6,76,247,11,165,253,56,253,32,6,133,253,222, 1332 6,157,56,6,76,247,11,165,253,56,253,32,6,133,253,222,
1333 56,6,16,163,189,24,6,24,125,32,6,157,32,6,189,48, 1333 56,6,16,163,189,24,6,24,125,32,6,157,32,6,189,48,
1334 6,157,56,6,76,247,11,189,24,6,24,101,252,133,252,76, 1334 6,157,56,6,76,247,11,189,24,6,24,101,252,133,252,76,
1335 247,11,160,16,169,0,133,250,169,0,133,251,169,0,141,23, 1335 247,11,160,16,169,0,133,250,169,0,133,251,169,0,141,23,
1336 5,138,240,63,177,250,240,2,16,1,202,169,17,24,101,250, 1336 5,138,240,63,177,250,240,2,16,1,202,169,17,24,101,250,
1337 133,250,144,2,230,251,238,23,5,208,230,162,0,169,0,133, 1337 133,250,144,2,230,251,238,23,5,208,230,162,0,169,0,133,
1338 252,138,141,23,5,10,38,252,10,38,252,10,38,252,10,38, 1338 252,138,141,23,5,10,38,252,10,38,252,10,38,252,10,38,
1339 252,109,23,5,144,2,230,252,24,105,0,133,250,165,252,105, 1339 252,109,23,5,144,2,230,252,24,105,0,133,250,165,252,105,
1340 0,133,251,32,44,15,165,250,141,25,5,165,251,141,26,5, 1340 0,133,251,32,44,15,165,250,141,25,5,165,251,141,26,5,
1341 162,7,169,255,157,208,5,169,240,157,216,5,157,224,5,202, 1341 162,7,169,255,157,208,5,169,240,157,216,5,157,224,5,202,
1342 16,240,169,3,141,15,210,141,31,210,141,47,210,141,63,210, 1342 16,240,169,3,141,15,210,141,31,210,141,47,210,141,63,210,
1343 206,23,5,232,142,28,5,232,142,29,5,142,22,5,96,138, 1343 206,23,5,232,142,28,5,232,142,29,5,142,22,5,96,138,
1344 41,15,141,27,5,96,142,22,5,96,201,16,176,3,76,76, 1344 41,15,141,27,5,96,142,22,5,96,201,16,176,3,76,76,
1345 13,201,32,144,136,201,48,176,3,76,133,15,201,64,144,223, 1345 13,201,32,144,136,201,48,176,3,76,133,15,201,64,144,223,
1346 201,80,176,3,76,44,15,201,96,144,219,201,112,144,3,76, 1346 201,80,176,3,76,44,15,201,96,144,219,201,112,144,3,76,
1347 180,14,132,253,41,15,10,141,23,14,165,253,144,254,144,30, 1347 180,14,132,253,41,15,10,141,23,14,165,253,144,254,144,30,
1348 144,56,144,89,144,96,144,26,144,28,144,30,144,32,144,34, 1348 144,56,144,89,144,96,144,26,144,28,144,30,144,32,144,34,
1349 144,36,144,13,144,11,144,9,144,7,144,5,144,3,141,24, 1349 144,36,144,13,144,11,144,9,144,7,144,5,144,3,141,24,
1350 5,96,157,104,6,96,157,112,6,96,157,120,6,96,157,144, 1350 5,96,157,104,6,96,157,112,6,96,157,120,6,96,157,144,
1351 6,96,157,128,6,96,157,136,6,96,41,112,74,74,157,16, 1351 6,96,157,128,6,96,157,136,6,96,41,112,74,74,157,16,
1352 6,41,48,208,3,157,32,6,165,253,48,6,41,15,157,24, 1352 6,41,48,208,3,157,32,6,165,253,48,6,41,15,157,24,
1353 6,96,41,15,73,255,24,105,1,157,24,6,96,41,63,157, 1353 6,96,41,15,73,255,24,105,1,157,24,6,96,41,63,157,
1354 48,6,157,56,6,96,41,128,10,42,157,96,6,165,253,41, 1354 48,6,157,56,6,96,41,128,10,42,157,96,6,165,253,41,
1355 112,74,74,74,74,157,64,6,208,3,157,96,6,165,253,41, 1355 112,74,74,74,74,157,64,6,208,3,157,96,6,165,253,41,
1356 15,157,80,6,157,88,6,189,72,6,221,64,6,144,143,189, 1356 15,157,80,6,157,88,6,189,72,6,221,64,6,144,143,189,
1357 64,6,240,2,233,1,157,72,6,96,132,250,134,251,160,25, 1357 64,6,240,2,233,1,157,72,6,96,132,250,134,251,160,25,
1358 177,250,200,141,9,5,177,250,200,141,10,5,177,250,200,141, 1358 177,250,200,141,9,5,177,250,200,141,10,5,177,250,200,141,
1359 11,5,177,250,200,141,12,5,177,250,200,141,13,5,177,250, 1359 11,5,177,250,200,141,12,5,177,250,200,141,13,5,177,250,
1360 141,27,5,165,250,73,128,48,1,232,141,172,15,142,173,15, 1360 141,27,5,165,250,73,128,48,1,232,141,172,15,142,173,15,
1361 73,128,48,1,232,141,29,7,142,30,7,232,141,35,7,142, 1361 73,128,48,1,232,141,29,7,142,30,7,232,141,35,7,142,
1362 36,7,232,141,162,15,142,163,15,73,128,48,1,232,141,25, 1362 36,7,232,141,162,15,142,163,15,73,128,48,1,232,141,25,
1363 5,141,215,6,141,79,13,141,148,13,142,26,5,142,221,6, 1363 5,141,215,6,141,79,13,141,148,13,142,26,5,142,221,6,
1364 142,83,13,142,154,13,169,240,133,255,169,0,141,22,5,141, 1364 142,83,13,142,154,13,169,240,133,255,169,0,141,22,5,141,
1365 24,5,162,7,169,0,141,22,5,157,120,5,157,176,5,157, 1365 24,5,162,7,169,0,141,22,5,157,120,5,157,176,5,157,
1366 32,5,157,40,5,157,48,5,157,48,210,157,32,210,157,16, 1366 32,5,157,40,5,157,48,5,157,48,210,157,32,210,157,16,
1367 210,157,0,210,202,16,226,141,24,210,141,8,210,141,56,210, 1367 210,157,0,210,202,16,226,141,24,210,141,8,210,141,56,210,
1368 141,40,210,141,30,5,141,31,5,96,157,32,5,157,40,5, 1368 141,40,210,141,30,5,141,31,5,96,157,32,5,157,40,5,
1369 157,48,5,157,176,5,96,152,157,208,5,41,240,157,216,5, 1369 157,48,5,157,176,5,96,152,157,208,5,41,240,157,216,5,
1370 189,208,5,10,10,10,10,157,224,5,96,41,7,133,250,138, 1370 189,208,5,10,10,10,10,157,224,5,96,41,7,133,250,138,
1371 166,250,41,63,240,225,157,152,5,152,48,238,189,208,5,32, 1371 166,250,41,63,240,225,157,152,5,152,48,238,189,208,5,32,
1372 117,15,169,0,157,120,5,185,255,255,240,190,157,136,5,133, 1372 117,15,169,0,157,120,5,185,255,255,240,190,157,136,5,133,
1373 251,185,255,255,157,128,5,133,250,152,157,144,5,160,8,177, 1373 251,185,255,255,157,128,5,133,250,152,157,144,5,160,8,177,
1374 250,200,157,192,5,177,250,200,157,200,5,177,250,200,157,104, 1374 250,200,157,192,5,177,250,200,157,200,5,177,250,200,157,104,
1375 6,177,250,200,157,112,6,177,250,200,157,120,6,177,250,200, 1375 6,177,250,200,157,112,6,177,250,200,157,120,6,177,250,200,
1376 157,232,5,157,248,5,177,250,200,157,240,5,157,0,6,177, 1376 157,232,5,157,248,5,177,250,200,157,240,5,157,0,6,177,
1377 250,41,112,74,74,157,16,6,177,250,200,48,8,41,15,157, 1377 250,41,112,74,74,157,16,6,177,250,200,48,8,41,15,157,
1378 24,6,76,9,16,41,15,73,255,24,105,1,157,24,6,177, 1378 24,6,76,9,16,41,15,73,255,24,105,1,157,24,6,177,
1379 250,200,157,40,6,177,250,200,41,63,157,48,6,157,56,6, 1379 250,200,157,40,6,177,250,200,41,63,157,48,6,157,56,6,
1380 177,250,41,128,10,42,157,96,6,177,250,41,112,74,74,74, 1380 177,250,41,128,10,42,157,96,6,177,250,41,112,74,74,74,
1381 74,157,64,6,208,3,157,96,6,177,250,136,41,15,157,80, 1381 74,157,64,6,208,3,157,96,6,177,250,136,41,15,157,80,
1382 6,157,88,6,177,250,41,192,29,152,5,157,152,5,168,185, 1382 6,157,88,6,177,250,41,192,29,152,5,157,152,5,168,185,
1383 0,3,157,56,5,169,0,157,184,5,157,32,6,157,8,6, 1383 0,3,157,56,5,169,0,157,184,5,157,32,6,157,8,6,
1384 157,72,6,157,128,6,157,136,6,157,144,6,169,1,157,120, 1384 157,72,6,157,128,6,157,136,6,157,144,6,169,1,157,120,
1385 5,96 1385 5,96
1386END_CONST_ARRAY; 1386END_CONST_ARRAY;
diff --git a/apps/codecs/libfaad/hcr.c b/apps/codecs/libfaad/hcr.c
index f2766c38e1..f968ea7bec 100644
--- a/apps/codecs/libfaad/hcr.c
+++ b/apps/codecs/libfaad/hcr.c
@@ -78,7 +78,7 @@ typedef struct
78{ 78{
79 uint8_t cb; 79 uint8_t cb;
80 uint8_t decoded; 80 uint8_t decoded;
81 uint16_t sp_offset; 81 uint16_t sp_offset;
82 bits_t bits; 82 bits_t bits;
83} codeword_t; 83} codeword_t;
84 84
diff --git a/apps/codecs/libfaad/huffman.c b/apps/codecs/libfaad/huffman.c
index 8b9e27b553..c142ad7ac7 100644
--- a/apps/codecs/libfaad/huffman.c
+++ b/apps/codecs/libfaad/huffman.c
@@ -124,7 +124,7 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
124{ 124{
125 uint8_t neg, i; 125 uint8_t neg, i;
126 int16_t j; 126 int16_t j;
127 int16_t off; 127 int16_t off;
128 128
129 if (sp < 0) 129 if (sp < 0)
130 { 130 {
@@ -500,14 +500,14 @@ int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp)
500 break; 500 break;
501 } 501 }
502 502
503 /* decode sign bits */ 503 /* decode sign bits */
504 if (unsigned_cb[cb]) 504 if (unsigned_cb[cb])
505 { 505 {
506 for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++) 506 for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++)
507 { 507 {
508 if(sp[i]) 508 if(sp[i])
509 { 509 {
510 uint8_t b; 510 uint8_t b;
511 if ( get1bit_hcr(ld, &b) ) return -1; 511 if ( get1bit_hcr(ld, &b) ) return -1;
512 if (b != 0) { 512 if (b != 0) {
513 sp[i] = -sp[i]; 513 sp[i] = -sp[i];
diff --git a/apps/codecs/libfaad/sbr_dct.c b/apps/codecs/libfaad/sbr_dct.c
index dbfbb8945c..c916a82a61 100644
--- a/apps/codecs/libfaad/sbr_dct.c
+++ b/apps/codecs/libfaad/sbr_dct.c
@@ -1489,7 +1489,7 @@ static void fft_dif(real_t * Real, real_t * Imag)
1489 // First 2 stages of 32 point FFT decimation in frequency 1489 // First 2 stages of 32 point FFT decimation in frequency
1490 // 4*16*2=64*2=128 multiplications 1490 // 4*16*2=64*2=128 multiplications
1491 // 6*16*2=96*2=192 additions 1491 // 6*16*2=96*2=192 additions
1492 // Stage 1 of 32 point FFT decimation in frequency 1492 // Stage 1 of 32 point FFT decimation in frequency
1493 for (i = 0; i < 16; i++) 1493 for (i = 0; i < 16; i++)
1494 { 1494 {
1495 point1_real = Real[i]; 1495 point1_real = Real[i];
@@ -1519,7 +1519,7 @@ static void fft_dif(real_t * Real, real_t * Imag)
1519 w_real = w_array_real[w_index]; 1519 w_real = w_array_real[w_index];
1520 w_imag = w_array_imag[w_index]; 1520 w_imag = w_array_imag[w_index];
1521 1521
1522 i = j; 1522 i = j;
1523 point1_real = Real[i]; 1523 point1_real = Real[i];
1524 point1_imag = Imag[i]; 1524 point1_imag = Imag[i];
1525 i2 = i+8; 1525 i2 = i+8;
@@ -1818,9 +1818,9 @@ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t *
1818 // 3*32=96 additions 1818 // 3*32=96 additions
1819 for (i = 0; i < 32; i++) 1819 for (i = 0; i < 32; i++)
1820 { 1820 {
1821 real_t x_re, x_im, tmp; 1821 real_t x_re, x_im, tmp;
1822 x_re = in_real[i]; 1822 x_re = in_real[i];
1823 x_im = in_imag[i]; 1823 x_im = in_imag[i];
1824 tmp = MUL_C(x_re + x_im, dct4_64_tab[i]); 1824 tmp = MUL_C(x_re + x_im, dct4_64_tab[i]);
1825 in_real[i] = MUL_C(x_im, dct4_64_tab[i + 64]) + tmp; 1825 in_real[i] = MUL_C(x_im, dct4_64_tab[i + 64]) + tmp;
1826 in_imag[i] = MUL_C(x_re, dct4_64_tab[i + 32]) + tmp; 1826 in_imag[i] = MUL_C(x_re, dct4_64_tab[i + 32]) + tmp;
@@ -1834,10 +1834,10 @@ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t *
1834 // 3*31+2=95 additions 1834 // 3*31+2=95 additions
1835 for (i = 0; i < 16; i++) 1835 for (i = 0; i < 16; i++)
1836 { 1836 {
1837 real_t x_re, x_im, tmp; 1837 real_t x_re, x_im, tmp;
1838 i_rev = bit_rev_tab[i]; 1838 i_rev = bit_rev_tab[i];
1839 x_re = in_real[i_rev]; 1839 x_re = in_real[i_rev];
1840 x_im = in_imag[i_rev]; 1840 x_im = in_imag[i_rev];
1841 1841
1842 tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]); 1842 tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]);
1843 out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp; 1843 out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp;
@@ -1848,10 +1848,10 @@ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t *
1848 out_real[16] = MUL_C(in_real[1] + in_imag[1], dct4_64_tab[16 + 3*32]); 1848 out_real[16] = MUL_C(in_real[1] + in_imag[1], dct4_64_tab[16 + 3*32]);
1849 for (i = 17; i < 32; i++) 1849 for (i = 17; i < 32; i++)
1850 { 1850 {
1851 real_t x_re, x_im, tmp; 1851 real_t x_re, x_im, tmp;
1852 i_rev = bit_rev_tab[i]; 1852 i_rev = bit_rev_tab[i];
1853 x_re = in_real[i_rev]; 1853 x_re = in_real[i_rev];
1854 x_im = in_imag[i_rev]; 1854 x_im = in_imag[i_rev];
1855 tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]); 1855 tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]);
1856 out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp; 1856 out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp;
1857 out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp; 1857 out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp;
diff --git a/apps/codecs/libfaad/sbr_dec.c b/apps/codecs/libfaad/sbr_dec.c
index c18ea454d5..97f1d9b647 100644
--- a/apps/codecs/libfaad/sbr_dec.c
+++ b/apps/codecs/libfaad/sbr_dec.c
@@ -50,7 +50,7 @@ static void sbr_save_matrix(sbr_info *sbr, uint8_t ch);
50sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, 50sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
51 uint32_t sample_rate, uint8_t downSampledSBR 51 uint32_t sample_rate, uint8_t downSampledSBR
52#ifdef DRM 52#ifdef DRM
53 , uint8_t IsDRM 53 , uint8_t IsDRM
54#endif 54#endif
55 ) 55 )
56{ 56{
diff --git a/apps/codecs/libfaad/sbr_hfadj.c b/apps/codecs/libfaad/sbr_hfadj.c
index 374d16f443..453180d544 100644
--- a/apps/codecs/libfaad/sbr_hfadj.c
+++ b/apps/codecs/libfaad/sbr_hfadj.c
@@ -1561,7 +1561,7 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj,
1561#ifndef SBR_LOW_POWER 1561#ifndef SBR_LOW_POWER
1562 if (h_SL != 0) 1562 if (h_SL != 0)
1563 { 1563 {
1564 uint8_t ri = sbr->GQ_ringbuf_index[ch]; 1564 uint8_t ri = sbr->GQ_ringbuf_index[ch];
1565 for (n = 0; n <= 4; n++) 1565 for (n = 0; n <= 4; n++)
1566 { 1566 {
1567 real_t curr_h_smooth = h_smooth[n]; 1567 real_t curr_h_smooth = h_smooth[n];
diff --git a/apps/codecs/libfaad/sbr_hfgen.c b/apps/codecs/libfaad/sbr_hfgen.c
index f77bbd052f..63a2fce855 100644
--- a/apps/codecs/libfaad/sbr_hfgen.c
+++ b/apps/codecs/libfaad/sbr_hfgen.c
@@ -128,20 +128,20 @@ void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
128 a1_i = MUL_C(IM(alpha_1[p]), bw2); 128 a1_i = MUL_C(IM(alpha_1[p]), bw2);
129#endif 129#endif
130 130
131 temp2_r = QMF_RE(Xlow[first - 2 + offset][p]); 131 temp2_r = QMF_RE(Xlow[first - 2 + offset][p]);
132 temp3_r = QMF_RE(Xlow[first - 1 + offset][p]); 132 temp3_r = QMF_RE(Xlow[first - 1 + offset][p]);
133#ifndef SBR_LOW_POWER 133#ifndef SBR_LOW_POWER
134 temp2_i = QMF_IM(Xlow[first - 2 + offset][p]); 134 temp2_i = QMF_IM(Xlow[first - 2 + offset][p]);
135 temp3_i = QMF_IM(Xlow[first - 1 + offset][p]); 135 temp3_i = QMF_IM(Xlow[first - 1 + offset][p]);
136#endif 136#endif
137 for (l = first; l < last; l++) 137 for (l = first; l < last; l++)
138 { 138 {
139 temp1_r = temp2_r; 139 temp1_r = temp2_r;
140 temp2_r = temp3_r; 140 temp2_r = temp3_r;
141 temp3_r = QMF_RE(Xlow[l + offset][p]); 141 temp3_r = QMF_RE(Xlow[l + offset][p]);
142#ifndef SBR_LOW_POWER 142#ifndef SBR_LOW_POWER
143 temp1_i = temp2_i; 143 temp1_i = temp2_i;
144 temp2_i = temp3_i; 144 temp2_i = temp3_i;
145 temp3_i = QMF_IM(Xlow[l + offset][p]); 145 temp3_i = QMF_IM(Xlow[l + offset][p]);
146#endif 146#endif
147 147
@@ -303,10 +303,10 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
303 303
304 for (j = offset; j < len + offset; j++) 304 for (j = offset; j < len + offset; j++)
305 { 305 {
306 temp1_r = temp2_r; // temp1_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp; 306 temp1_r = temp2_r; // temp1_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
307 temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp; 307 temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
308 temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp; 308 temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
309 temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp; 309 temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
310 temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp; 310 temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp;
311 temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp; 311 temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp;
312 r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i); 312 r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i);
@@ -352,10 +352,10 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
352 352
353 for (j = offset; j < len + offset; j++) 353 for (j = offset; j < len + offset; j++)
354 { 354 {
355 temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd]; 355 temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd];
356 temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd]; 356 temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
357 temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd]; 357 temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
358 temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd]; 358 temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
359 temp3_r = QMF_RE(buffer[j][bd]); 359 temp3_r = QMF_RE(buffer[j][bd]);
360 temp3_i = QMF_IM(buffer[j][bd]); 360 temp3_i = QMF_IM(buffer[j][bd]);
361 r01r += temp3_r * temp2_r + temp3_i * temp2_i; 361 r01r += temp3_r * temp2_r + temp3_i * temp2_i;
diff --git a/apps/codecs/libfaad/sbr_qmf.c b/apps/codecs/libfaad/sbr_qmf.c
index 540332bdcb..5486cd283d 100644
--- a/apps/codecs/libfaad/sbr_qmf.c
+++ b/apps/codecs/libfaad/sbr_qmf.c
@@ -42,12 +42,12 @@ qmfa_info *qmfa_init(uint8_t channels)
42{ 42{
43 qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info)); 43 qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info));
44 44
45 /* x is implemented as double ringbuffer */ 45 /* x is implemented as double ringbuffer */
46 qmfa->x = (real_t*)faad_malloc(2 * channels * 10 * sizeof(real_t)); 46 qmfa->x = (real_t*)faad_malloc(2 * channels * 10 * sizeof(real_t));
47 memset(qmfa->x, 0, 2 * channels * 10 * sizeof(real_t)); 47 memset(qmfa->x, 0, 2 * channels * 10 * sizeof(real_t));
48 48
49 /* ringbuffer index */ 49 /* ringbuffer index */
50 qmfa->x_index = 0; 50 qmfa->x_index = 0;
51 51
52 qmfa->channels = channels; 52 qmfa->channels = channels;
53 53
@@ -81,7 +81,7 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
81 int16_t n; 81 int16_t n;
82 82
83 /* shift input buffer x */ 83 /* shift input buffer x */
84 /* input buffer is not shifted anymore, x is implemented as double ringbuffer */ 84 /* input buffer is not shifted anymore, x is implemented as double ringbuffer */
85 //memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t)); 85 //memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t));
86 86
87 /* add new samples to input buffer x */ 87 /* add new samples to input buffer x */
@@ -104,10 +104,10 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
104 MUL_F(qmfa->x[qmfa->x_index + n + 256], qmf_c[2*(n + 256)]); 104 MUL_F(qmfa->x[qmfa->x_index + n + 256], qmf_c[2*(n + 256)]);
105 } 105 }
106 106
107 /* update ringbuffer index */ 107 /* update ringbuffer index */
108 qmfa->x_index -= 32; 108 qmfa->x_index -= 32;
109 if (qmfa->x_index < 0) 109 if (qmfa->x_index < 0)
110 qmfa->x_index = (320-32); 110 qmfa->x_index = (320-32);
111 111
112 /* calculate 32 subband samples by introducing X */ 112 /* calculate 32 subband samples by introducing X */
113#ifdef SBR_LOW_POWER 113#ifdef SBR_LOW_POWER
@@ -224,7 +224,7 @@ qmfs_info *qmfs_init(uint8_t channels)
224{ 224{
225 qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info)); 225 qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info));
226 226
227 /* v is a double ringbuffer */ 227 /* v is a double ringbuffer */
228 qmfs->v = (real_t*)faad_malloc(2 * channels * 20 * sizeof(real_t)); 228 qmfs->v = (real_t*)faad_malloc(2 * channels * 20 * sizeof(real_t));
229 memset(qmfs->v, 0, 2 * channels * 20 * sizeof(real_t)); 229 memset(qmfs->v, 0, 2 * channels * 20 * sizeof(real_t));
230 230
@@ -483,8 +483,8 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6
483 for (l = 0; l < sbr->numTimeSlotsRate; l++) 483 for (l = 0; l < sbr->numTimeSlotsRate; l++)
484 { 484 {
485 /* shift buffer v */ 485 /* shift buffer v */
486 /* buffer is not shifted, we use double ringbuffer */ 486 /* buffer is not shifted, we use double ringbuffer */
487 //memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t)); 487 //memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t));
488 488
489 /* calculate 128 samples */ 489 /* calculate 128 samples */
490#ifndef FIXED_POINT 490#ifndef FIXED_POINT
diff --git a/apps/codecs/libfaad/sbr_syntax.c b/apps/codecs/libfaad/sbr_syntax.c
index 267e954a2e..eff26e9f46 100644
--- a/apps/codecs/libfaad/sbr_syntax.c
+++ b/apps/codecs/libfaad/sbr_syntax.c
@@ -337,16 +337,16 @@ static uint8_t sbr_data(bitfile *ld, sbr_info *sbr)
337 switch (sbr->id_aac) 337 switch (sbr->id_aac)
338 { 338 {
339 case ID_SCE: 339 case ID_SCE:
340 if ((result = sbr_single_channel_element(ld, sbr)) > 0) 340 if ((result = sbr_single_channel_element(ld, sbr)) > 0)
341 return result; 341 return result;
342 break; 342 break;
343 case ID_CPE: 343 case ID_CPE:
344 if ((result = sbr_channel_pair_element(ld, sbr)) > 0) 344 if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
345 return result; 345 return result;
346 break; 346 break;
347 } 347 }
348 348
349 return 0; 349 return 0;
350} 350}
351 351
352/* table 5 */ 352/* table 5 */
diff --git a/apps/codecs/libffmpegFLAC/bitstream.h b/apps/codecs/libffmpegFLAC/bitstream.h
index 19f2b6e01c..9a8c548d95 100644
--- a/apps/codecs/libffmpegFLAC/bitstream.h
+++ b/apps/codecs/libffmpegFLAC/bitstream.h
@@ -100,7 +100,7 @@ typedef struct RL_VLC_ELEM {
100# ifdef __GNUC__ 100# ifdef __GNUC__
101static inline uint32_t unaligned32(const void *v) { 101static inline uint32_t unaligned32(const void *v) {
102 struct Unaligned { 102 struct Unaligned {
103 uint32_t i; 103 uint32_t i;
104 } __attribute__((packed)); 104 } __attribute__((packed));
105 105
106 return ((const struct Unaligned *) v)->i; 106 return ((const struct Unaligned *) v)->i;
@@ -165,10 +165,10 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
165static inline int unaligned32_be(const void *v) 165static inline int unaligned32_be(const void *v)
166{ 166{
167#ifdef CONFIG_ALIGN 167#ifdef CONFIG_ALIGN
168 const uint8_t *p=v; 168 const uint8_t *p=v;
169 return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); 169 return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]);
170#else 170#else
171 return betoh32( unaligned32(v)); //original 171 return betoh32( unaligned32(v)); //original
172#endif 172#endif
173} 173}
174 174
diff --git a/apps/codecs/libffmpegFLAC/golomb.h b/apps/codecs/libffmpegFLAC/golomb.h
index 4f99671338..197b78ee1c 100644
--- a/apps/codecs/libffmpegFLAC/golomb.h
+++ b/apps/codecs/libffmpegFLAC/golomb.h
@@ -93,7 +93,7 @@ static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int es
93#define get_ur_golomb_shorten(gb, k) get_ur_golomb_jpegls(gb, k, INT_MAX, 0) 93#define get_ur_golomb_shorten(gb, k) get_ur_golomb_jpegls(gb, k, INT_MAX, 0)
94/* 94/*
95static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){ 95static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){
96 return get_ur_golomb_jpegls(gb, k, INT_MAX, 0); 96 return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
97} 97}
98*/ 98*/
99 99
diff --git a/apps/codecs/libffmpegFLAC/main.c b/apps/codecs/libffmpegFLAC/main.c
index 058c581aea..5d232a8896 100644
--- a/apps/codecs/libffmpegFLAC/main.c
+++ b/apps/codecs/libffmpegFLAC/main.c
@@ -221,7 +221,7 @@ static bool flac_init(int fd, FLACContext* fc)
221 offset_lo=betoh32(*(p++)); 221 offset_lo=betoh32(*(p++));
222 222
223 if ((seekpoint_hi != 0xffffffff) && (seekpoint_lo != 0xffffffff)) { 223 if ((seekpoint_hi != 0xffffffff) && (seekpoint_lo != 0xffffffff)) {
224 fprintf(stderr,"Seekpoint: %u, Offset=%u\n",seekpoint_lo,offset_lo); 224 fprintf(stderr,"Seekpoint: %u, Offset=%u\n",seekpoint_lo,offset_lo);
225 } 225 }
226 } 226 }
227 lseek(fd, blocklength, SEEK_CUR); 227 lseek(fd, blocklength, SEEK_CUR);
diff --git a/apps/codecs/libmad/bit.c b/apps/codecs/libmad/bit.c
index f132347c25..f3cca84b2b 100644
--- a/apps/codecs/libmad/bit.c
+++ b/apps/codecs/libmad/bit.c
@@ -87,8 +87,8 @@ unsigned short const crc_table[256] = {
87#endif 87#endif
88 88
89/* 89/*
90 * NAME: bit->init() 90 * NAME: bit->init()
91 * DESCRIPTION: initialize bit pointer struct 91 * DESCRIPTION: initialize bit pointer struct
92 */ 92 */
93void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) 93void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
94{ 94{
@@ -97,11 +97,11 @@ void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
97} 97}
98 98
99/* 99/*
100 * NAME: bit->length() 100 * NAME: bit->length()
101 * DESCRIPTION: return number of bits between start and end points 101 * DESCRIPTION: return number of bits between start and end points
102 */ 102 */
103unsigned int mad_bit_length(struct mad_bitptr const *begin, 103unsigned int mad_bit_length(struct mad_bitptr const *begin,
104 struct mad_bitptr const *end) 104 struct mad_bitptr const *end)
105{ 105{
106 return end->readbit - begin->readbit; 106 return end->readbit - begin->readbit;
107} 107}
@@ -111,8 +111,8 @@ unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr)
111 return 8 - (bitptr->readbit & 7); 111 return 8 - (bitptr->readbit & 7);
112} 112}
113/* 113/*
114 * NAME: bit->nextbyte() 114 * NAME: bit->nextbyte()
115 * DESCRIPTION: return pointer to next unprocessed byte 115 * DESCRIPTION: return pointer to next unprocessed byte
116 */ 116 */
117unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr) 117unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
118{ 118{
@@ -120,8 +120,8 @@ unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
120} 120}
121 121
122/* 122/*
123 * NAME: bit->skip() 123 * NAME: bit->skip()
124 * DESCRIPTION: advance bit pointer 124 * DESCRIPTION: advance bit pointer
125 */ 125 */
126void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len) 126void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
127{ 127{
@@ -129,8 +129,8 @@ void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
129} 129}
130 130
131/* 131/*
132 * NAME: bit->read() 132 * NAME: bit->read()
133 * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value 133 * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
134 */ 134 */
135 135
136uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR; 136uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR;
@@ -154,11 +154,11 @@ uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
154 154
155# if 0 155# if 0
156/* 156/*
157 * NAME: bit->write() 157 * NAME: bit->write()
158 * DESCRIPTION: write an arbitrary number of bits 158 * DESCRIPTION: write an arbitrary number of bits
159 */ 159 */
160void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, 160void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
161 uint32_t value) 161 uint32_t value)
162{ 162{
163 unsigned char *ptr; 163 unsigned char *ptr;
164 164
@@ -169,11 +169,11 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
169# endif 169# endif
170 170
171/* 171/*
172 * NAME: bit->crc() 172 * NAME: bit->crc()
173 * DESCRIPTION: compute CRC-check word 173 * DESCRIPTION: compute CRC-check word
174 */ 174 */
175unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, 175unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
176 unsigned short init) 176 unsigned short init)
177{ 177{
178 register unsigned int crc; 178 register unsigned int crc;
179 179
@@ -190,11 +190,11 @@ unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
190 190
191 switch (len / 8) { 191 switch (len / 8) {
192 case 3: crc = (crc << 8) ^ 192 case 3: crc = (crc << 8) ^
193 crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; 193 crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
194 case 2: crc = (crc << 8) ^ 194 case 2: crc = (crc << 8) ^
195 crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; 195 crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
196 case 1: crc = (crc << 8) ^ 196 case 1: crc = (crc << 8) ^
197 crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; 197 crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
198 198
199 len %= 8; 199 len %= 8;
200 200
diff --git a/apps/codecs/libmad/bit.h b/apps/codecs/libmad/bit.h
index 615cabee89..ad13373eee 100644
--- a/apps/codecs/libmad/bit.h
+++ b/apps/codecs/libmad/bit.h
@@ -29,10 +29,10 @@ struct mad_bitptr {
29 29
30void mad_bit_init(struct mad_bitptr *, unsigned char const *); 30void mad_bit_init(struct mad_bitptr *, unsigned char const *);
31 31
32# define mad_bit_finish(bitptr) /* nothing */ 32# define mad_bit_finish(bitptr) /* nothing */
33 33
34unsigned int mad_bit_length(struct mad_bitptr const *, 34unsigned int mad_bit_length(struct mad_bitptr const *,
35 struct mad_bitptr const *); 35 struct mad_bitptr const *);
36 36
37unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr); 37unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr);
38unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); 38unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
diff --git a/apps/codecs/libmad/decoder.c b/apps/codecs/libmad/decoder.c
index fcbabce923..dfa45aaa34 100644
--- a/apps/codecs/libmad/decoder.c
+++ b/apps/codecs/libmad/decoder.c
@@ -51,25 +51,25 @@
51# include "decoder.h" 51# include "decoder.h"
52 52
53/* 53/*
54 * NAME: decoder->init() 54 * NAME: decoder->init()
55 * DESCRIPTION: initialize a decoder object with callback routines 55 * DESCRIPTION: initialize a decoder object with callback routines
56 */ 56 */
57void mad_decoder_init(struct mad_decoder *decoder, void *data, 57void mad_decoder_init(struct mad_decoder *decoder, void *data,
58 enum mad_flow (*input_func)(void *, 58 enum mad_flow (*input_func)(void *,
59 struct mad_stream *), 59 struct mad_stream *),
60 enum mad_flow (*header_func)(void *, 60 enum mad_flow (*header_func)(void *,
61 struct mad_header const *), 61 struct mad_header const *),
62 enum mad_flow (*filter_func)(void *, 62 enum mad_flow (*filter_func)(void *,
63 struct mad_stream const *, 63 struct mad_stream const *,
64 struct mad_frame *), 64 struct mad_frame *),
65 enum mad_flow (*output_func)(void *, 65 enum mad_flow (*output_func)(void *,
66 struct mad_header const *, 66 struct mad_header const *,
67 struct mad_pcm *), 67 struct mad_pcm *),
68 enum mad_flow (*error_func)(void *, 68 enum mad_flow (*error_func)(void *,
69 struct mad_stream *, 69 struct mad_stream *,
70 struct mad_frame *), 70 struct mad_frame *),
71 enum mad_flow (*message_func)(void *, 71 enum mad_flow (*message_func)(void *,
72 void *, unsigned int *)) 72 void *, unsigned int *))
73{ 73{
74 decoder->mode = -1; 74 decoder->mode = -1;
75 75
@@ -237,9 +237,9 @@ enum mad_flow receive(int fd, void **message, unsigned int *size)
237 237
238 if (*size > 0) { 238 if (*size > 0) {
239 if (*message == 0) { 239 if (*message == 0) {
240 *message = malloc(*size); 240 *message = malloc(*size);
241 if (*message == 0) 241 if (*message == 0)
242 return MAD_FLOW_BREAK; 242 return MAD_FLOW_BREAK;
243 } 243 }
244 244
245 result = receive_io_blocking(fd, *message, *size); 245 result = receive_io_blocking(fd, *message, *size);
@@ -278,8 +278,8 @@ enum mad_flow check_message(struct mad_decoder *decoder)
278 result = decoder->message_func(decoder->cb_data, message, &size); 278 result = decoder->message_func(decoder->cb_data, message, &size);
279 279
280 if (result == MAD_FLOW_IGNORE || 280 if (result == MAD_FLOW_IGNORE ||
281 result == MAD_FLOW_BREAK) 281 result == MAD_FLOW_BREAK)
282 size = 0; 282 size = 0;
283 } 283 }
284 284
285 if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE) 285 if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE)
@@ -295,7 +295,7 @@ enum mad_flow check_message(struct mad_decoder *decoder)
295 295
296static 296static
297enum mad_flow error_default(void *data, struct mad_stream *stream, 297enum mad_flow error_default(void *data, struct mad_stream *stream,
298 struct mad_frame *frame) 298 struct mad_frame *frame)
299{ 299{
300 int *bad_last_frame = data; 300 int *bad_last_frame = data;
301 301
@@ -361,92 +361,92 @@ int run_sync(struct mad_decoder *decoder)
361 while (1) { 361 while (1) {
362# if defined(USE_ASYNC) 362# if defined(USE_ASYNC)
363 if (decoder->mode == MAD_DECODER_MODE_ASYNC) { 363 if (decoder->mode == MAD_DECODER_MODE_ASYNC) {
364 switch (check_message(decoder)) { 364 switch (check_message(decoder)) {
365 case MAD_FLOW_IGNORE: 365 case MAD_FLOW_IGNORE:
366 case MAD_FLOW_CONTINUE: 366 case MAD_FLOW_CONTINUE:
367 break; 367 break;
368 case MAD_FLOW_BREAK: 368 case MAD_FLOW_BREAK:
369 goto fail; 369 goto fail;
370 case MAD_FLOW_STOP: 370 case MAD_FLOW_STOP:
371 goto done; 371 goto done;
372 } 372 }
373 } 373 }
374# endif 374# endif
375 375
376 if (decoder->header_func) { 376 if (decoder->header_func) {
377 if (mad_header_decode(&frame->header, stream) == -1) { 377 if (mad_header_decode(&frame->header, stream) == -1) {
378 if (!MAD_RECOVERABLE(stream->error)) 378 if (!MAD_RECOVERABLE(stream->error))
379 break; 379 break;
380 380
381 switch (error_func(error_data, stream, frame)) { 381 switch (error_func(error_data, stream, frame)) {
382 case MAD_FLOW_STOP: 382 case MAD_FLOW_STOP:
383 goto done; 383 goto done;
384 case MAD_FLOW_BREAK: 384 case MAD_FLOW_BREAK:
385 goto fail; 385 goto fail;
386 case MAD_FLOW_IGNORE: 386 case MAD_FLOW_IGNORE:
387 case MAD_FLOW_CONTINUE: 387 case MAD_FLOW_CONTINUE:
388 default: 388 default:
389 continue; 389 continue;
390 } 390 }
391 } 391 }
392 392
393 switch (decoder->header_func(decoder->cb_data, &frame->header)) { 393 switch (decoder->header_func(decoder->cb_data, &frame->header)) {
394 case MAD_FLOW_STOP: 394 case MAD_FLOW_STOP:
395 goto done; 395 goto done;
396 case MAD_FLOW_BREAK: 396 case MAD_FLOW_BREAK:
397 goto fail; 397 goto fail;
398 case MAD_FLOW_IGNORE: 398 case MAD_FLOW_IGNORE:
399 continue; 399 continue;
400 case MAD_FLOW_CONTINUE: 400 case MAD_FLOW_CONTINUE:
401 break; 401 break;
402 } 402 }
403 } 403 }
404 404
405 if (mad_frame_decode(frame, stream) == -1) { 405 if (mad_frame_decode(frame, stream) == -1) {
406 if (!MAD_RECOVERABLE(stream->error)) 406 if (!MAD_RECOVERABLE(stream->error))
407 break; 407 break;
408 408
409 switch (error_func(error_data, stream, frame)) { 409 switch (error_func(error_data, stream, frame)) {
410 case MAD_FLOW_STOP: 410 case MAD_FLOW_STOP:
411 goto done; 411 goto done;
412 case MAD_FLOW_BREAK: 412 case MAD_FLOW_BREAK:
413 goto fail; 413 goto fail;
414 case MAD_FLOW_IGNORE: 414 case MAD_FLOW_IGNORE:
415 break; 415 break;
416 case MAD_FLOW_CONTINUE: 416 case MAD_FLOW_CONTINUE:
417 default: 417 default:
418 continue; 418 continue;
419 } 419 }
420 } 420 }
421 else 421 else
422 bad_last_frame = 0; 422 bad_last_frame = 0;
423 423
424 if (decoder->filter_func) { 424 if (decoder->filter_func) {
425 switch (decoder->filter_func(decoder->cb_data, stream, frame)) { 425 switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
426 case MAD_FLOW_STOP: 426 case MAD_FLOW_STOP:
427 goto done; 427 goto done;
428 case MAD_FLOW_BREAK: 428 case MAD_FLOW_BREAK:
429 goto fail; 429 goto fail;
430 case MAD_FLOW_IGNORE: 430 case MAD_FLOW_IGNORE:
431 continue; 431 continue;
432 case MAD_FLOW_CONTINUE: 432 case MAD_FLOW_CONTINUE:
433 break; 433 break;
434 } 434 }
435 } 435 }
436 436
437 mad_synth_frame(synth, frame); 437 mad_synth_frame(synth, frame);
438 438
439 if (decoder->output_func) { 439 if (decoder->output_func) {
440 switch (decoder->output_func(decoder->cb_data, 440 switch (decoder->output_func(decoder->cb_data,
441 &frame->header, &synth->pcm)) { 441 &frame->header, &synth->pcm)) {
442 case MAD_FLOW_STOP: 442 case MAD_FLOW_STOP:
443 goto done; 443 goto done;
444 case MAD_FLOW_BREAK: 444 case MAD_FLOW_BREAK:
445 goto fail; 445 goto fail;
446 case MAD_FLOW_IGNORE: 446 case MAD_FLOW_IGNORE:
447 case MAD_FLOW_CONTINUE: 447 case MAD_FLOW_CONTINUE:
448 break; 448 break;
449 } 449 }
450 } 450 }
451 } 451 }
452 } 452 }
@@ -528,8 +528,8 @@ int run_async(struct mad_decoder *decoder)
528# endif 528# endif
529 529
530/* 530/*
531 * NAME: decoder->run() 531 * NAME: decoder->run()
532 * DESCRIPTION: run the decoder thread either synchronously or asynchronously 532 * DESCRIPTION: run the decoder thread either synchronously or asynchronously
533 */ 533 */
534int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) 534int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
535{ 535{
@@ -564,11 +564,11 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
564} 564}
565 565
566/* 566/*
567 * NAME: decoder->message() 567 * NAME: decoder->message()
568 * DESCRIPTION: send a message to and receive a reply from the decoder process 568 * DESCRIPTION: send a message to and receive a reply from the decoder process
569 */ 569 */
570int mad_decoder_message(struct mad_decoder *decoder, 570int mad_decoder_message(struct mad_decoder *decoder,
571 void *message, unsigned int *len) 571 void *message, unsigned int *len)
572{ 572{
573# if defined(USE_ASYNC) 573# if defined(USE_ASYNC)
574 if (decoder->mode != MAD_DECODER_MODE_ASYNC || 574 if (decoder->mode != MAD_DECODER_MODE_ASYNC ||
diff --git a/apps/codecs/libmad/decoder.h b/apps/codecs/libmad/decoder.h
index 714e72c602..1f022154f2 100644
--- a/apps/codecs/libmad/decoder.h
+++ b/apps/codecs/libmad/decoder.h
@@ -32,10 +32,10 @@ enum mad_decoder_mode {
32}; 32};
33 33
34enum mad_flow { 34enum mad_flow {
35 MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ 35 MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
36 MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ 36 MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
37 MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ 37 MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
38 MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ 38 MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
39}; 39};
40 40
41struct mad_decoder { 41struct mad_decoder {
@@ -60,26 +60,26 @@ struct mad_decoder {
60 enum mad_flow (*input_func)(void *, struct mad_stream *); 60 enum mad_flow (*input_func)(void *, struct mad_stream *);
61 enum mad_flow (*header_func)(void *, struct mad_header const *); 61 enum mad_flow (*header_func)(void *, struct mad_header const *);
62 enum mad_flow (*filter_func)(void *, 62 enum mad_flow (*filter_func)(void *,
63 struct mad_stream const *, struct mad_frame *); 63 struct mad_stream const *, struct mad_frame *);
64 enum mad_flow (*output_func)(void *, 64 enum mad_flow (*output_func)(void *,
65 struct mad_header const *, struct mad_pcm *); 65 struct mad_header const *, struct mad_pcm *);
66 enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); 66 enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
67 enum mad_flow (*message_func)(void *, void *, unsigned int *); 67 enum mad_flow (*message_func)(void *, void *, unsigned int *);
68}; 68};
69 69
70void mad_decoder_init(struct mad_decoder *, void *, 70void mad_decoder_init(struct mad_decoder *, void *,
71 enum mad_flow (*)(void *, struct mad_stream *), 71 enum mad_flow (*)(void *, struct mad_stream *),
72 enum mad_flow (*)(void *, struct mad_header const *), 72 enum mad_flow (*)(void *, struct mad_header const *),
73 enum mad_flow (*)(void *, 73 enum mad_flow (*)(void *,
74 struct mad_stream const *, 74 struct mad_stream const *,
75 struct mad_frame *), 75 struct mad_frame *),
76 enum mad_flow (*)(void *, 76 enum mad_flow (*)(void *,
77 struct mad_header const *, 77 struct mad_header const *,
78 struct mad_pcm *), 78 struct mad_pcm *),
79 enum mad_flow (*)(void *, 79 enum mad_flow (*)(void *,
80 struct mad_stream *, 80 struct mad_stream *,
81 struct mad_frame *), 81 struct mad_frame *),
82 enum mad_flow (*)(void *, void *, unsigned int *)); 82 enum mad_flow (*)(void *, void *, unsigned int *));
83int mad_decoder_finish(struct mad_decoder *); 83int mad_decoder_finish(struct mad_decoder *);
84 84
85# define mad_decoder_options(decoder, opts) \ 85# define mad_decoder_options(decoder, opts) \
diff --git a/apps/codecs/libmad/fixed.c b/apps/codecs/libmad/fixed.c
index d30f7a1219..f2f0a3ce4a 100644
--- a/apps/codecs/libmad/fixed.c
+++ b/apps/codecs/libmad/fixed.c
@@ -28,8 +28,8 @@
28# include "fixed.h" 28# include "fixed.h"
29 29
30/* 30/*
31 * NAME: fixed->abs() 31 * NAME: fixed->abs()
32 * DESCRIPTION: return absolute value of a fixed-point number 32 * DESCRIPTION: return absolute value of a fixed-point number
33 */ 33 */
34mad_fixed_t mad_f_abs(mad_fixed_t x) 34mad_fixed_t mad_f_abs(mad_fixed_t x)
35{ 35{
@@ -37,8 +37,8 @@ mad_fixed_t mad_f_abs(mad_fixed_t x)
37} 37}
38 38
39/* 39/*
40 * NAME: fixed->div() 40 * NAME: fixed->div()
41 * DESCRIPTION: perform division using fixed-point math 41 * DESCRIPTION: perform division using fixed-point math
42 */ 42 */
43mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y) 43mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y)
44{ 44{
diff --git a/apps/codecs/libmad/fixed.h b/apps/codecs/libmad/fixed.h
index 7e580c4e8f..84bb5954e3 100644
--- a/apps/codecs/libmad/fixed.h
+++ b/apps/codecs/libmad/fixed.h
@@ -64,50 +64,50 @@ typedef mad_fixed_t mad_sample_t;
64 * supported, and must be done with care. 64 * supported, and must be done with care.
65 */ 65 */
66 66
67# define MAD_F_FRACBITS 28 67# define MAD_F_FRACBITS 28
68 68
69# if MAD_F_FRACBITS == 28 69# if MAD_F_FRACBITS == 28
70# define MAD_F(x) ((mad_fixed_t) (x##L)) 70# define MAD_F(x) ((mad_fixed_t) (x##L))
71# else 71# else
72# if MAD_F_FRACBITS < 28 72# if MAD_F_FRACBITS < 28
73# warning "MAD_F_FRACBITS < 28" 73# warning "MAD_F_FRACBITS < 28"
74# define MAD_F(x) ((mad_fixed_t) \ 74# define MAD_F(x) ((mad_fixed_t) \
75 (((x##L) + \ 75 (((x##L) + \
76 (1L << (28 - MAD_F_FRACBITS - 1))) >> \ 76 (1L << (28 - MAD_F_FRACBITS - 1))) >> \
77 (28 - MAD_F_FRACBITS))) 77 (28 - MAD_F_FRACBITS)))
78# elif MAD_F_FRACBITS > 28 78# elif MAD_F_FRACBITS > 28
79# error "MAD_F_FRACBITS > 28 not currently supported" 79# error "MAD_F_FRACBITS > 28 not currently supported"
80# define MAD_F(x) ((mad_fixed_t) \ 80# define MAD_F(x) ((mad_fixed_t) \
81 ((x##L) << (MAD_F_FRACBITS - 28))) 81 ((x##L) << (MAD_F_FRACBITS - 28)))
82# endif 82# endif
83# endif 83# endif
84 84
85# define MAD_F_MIN ((mad_fixed_t) -0x80000000L) 85# define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
86# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) 86# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
87 87
88# define MAD_F_ONE MAD_F(0x10000000) 88# define MAD_F_ONE MAD_F(0x10000000)
89 89
90# define mad_f_tofixed(x) ((mad_fixed_t) \ 90# define mad_f_tofixed(x) ((mad_fixed_t) \
91 ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) 91 ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
92# define mad_f_todouble(x) ((double) \ 92# define mad_f_todouble(x) ((double) \
93 ((x) / (double) (1L << MAD_F_FRACBITS))) 93 ((x) / (double) (1L << MAD_F_FRACBITS)))
94 94
95# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) 95# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
96# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) 96# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
97 /* (x should be positive) */ 97 /* (x should be positive) */
98 98
99# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS) 99# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
100 100
101# define mad_f_add(x, y) ((x) + (y)) 101# define mad_f_add(x, y) ((x) + (y))
102# define mad_f_sub(x, y) ((x) - (y)) 102# define mad_f_sub(x, y) ((x) - (y))
103 103
104# if defined(FPM_FLOAT) 104# if defined(FPM_FLOAT)
105# error "FPM_FLOAT not yet supported" 105# error "FPM_FLOAT not yet supported"
106 106
107# undef MAD_F 107# undef MAD_F
108# define MAD_F(x) mad_f_todouble(x) 108# define MAD_F(x) mad_f_todouble(x)
109 109
110# define mad_f_mul(x, y) ((x) * (y)) 110# define mad_f_mul(x, y) ((x) * (y))
111# define mad_f_scale64 111# define mad_f_scale64
112 112
113# undef ASO_ZEROCHECK 113# undef ASO_ZEROCHECK
@@ -154,7 +154,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
154} 154}
155# pragma warning(pop) 155# pragma warning(pop)
156 156
157# define mad_f_mul mad_f_mul_inline 157# define mad_f_mul mad_f_mul_inline
158# define mad_f_scale64 158# define mad_f_scale64
159# else 159# else
160/* 160/*
@@ -163,9 +163,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
163 */ 163 */
164# define MAD_F_MLX(hi, lo, x, y) \ 164# define MAD_F_MLX(hi, lo, x, y) \
165 asm ("imull %3" \ 165 asm ("imull %3" \
166 : "=a" (lo), "=d" (hi) \ 166 : "=a" (lo), "=d" (hi) \
167 : "%a" (x), "rm" (y) \ 167 : "%a" (x), "rm" (y) \
168 : "cc") 168 : "cc")
169 169
170# if defined(OPT_ACCURACY) 170# if defined(OPT_ACCURACY)
171/* 171/*
@@ -176,10 +176,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
176 mad_fixed64lo_t __lo; \ 176 mad_fixed64lo_t __lo; \
177 MAD_F_MLX(__hi, __lo, (x), (y)); \ 177 MAD_F_MLX(__hi, __lo, (x), (y)); \
178 asm ("addl %2,%0\n\t" \ 178 asm ("addl %2,%0\n\t" \
179 "adcl %3,%1" \ 179 "adcl %3,%1" \
180 : "=rm" (lo), "=rm" (hi) \ 180 : "=rm" (lo), "=rm" (hi) \
181 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ 181 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
182 : "cc"); \ 182 : "cc"); \
183 }) 183 })
184# endif /* OPT_ACCURACY */ 184# endif /* OPT_ACCURACY */
185 185
@@ -192,15 +192,15 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
192 mad_fixed64lo_t __lo_; \ 192 mad_fixed64lo_t __lo_; \
193 mad_fixed_t __result; \ 193 mad_fixed_t __result; \
194 asm ("addl %4,%2\n\t" \ 194 asm ("addl %4,%2\n\t" \
195 "adcl %5,%3" \ 195 "adcl %5,%3" \
196 : "=rm" (__lo_), "=rm" (__hi_) \ 196 : "=rm" (__lo_), "=rm" (__hi_) \
197 : "0" (lo), "1" (hi), \ 197 : "0" (lo), "1" (hi), \
198 "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ 198 "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
199 : "cc"); \ 199 : "cc"); \
200 asm ("shrdl %3,%2,%1" \ 200 asm ("shrdl %3,%2,%1" \
201 : "=rm" (__result) \ 201 : "=rm" (__result) \
202 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ 202 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
203 : "cc"); \ 203 : "cc"); \
204 __result; \ 204 __result; \
205 }) 205 })
206# elif defined(OPT_INTEL) 206# elif defined(OPT_INTEL)
@@ -210,21 +210,21 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
210# define mad_f_scale64(hi, lo) \ 210# define mad_f_scale64(hi, lo) \
211 ({ mad_fixed_t __result; \ 211 ({ mad_fixed_t __result; \
212 asm ("shrl %3,%1\n\t" \ 212 asm ("shrl %3,%1\n\t" \
213 "shll %4,%2\n\t" \ 213 "shll %4,%2\n\t" \
214 "orl %2,%1" \ 214 "orl %2,%1" \
215 : "=rm" (__result) \ 215 : "=rm" (__result) \
216 : "0" (lo), "r" (hi), \ 216 : "0" (lo), "r" (hi), \
217 "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ 217 "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
218 : "cc"); \ 218 : "cc"); \
219 __result; \ 219 __result; \
220 }) 220 })
221# else 221# else
222# define mad_f_scale64(hi, lo) \ 222# define mad_f_scale64(hi, lo) \
223 ({ mad_fixed_t __result; \ 223 ({ mad_fixed_t __result; \
224 asm ("shrdl %3,%2,%1" \ 224 asm ("shrdl %3,%2,%1" \
225 : "=rm" (__result) \ 225 : "=rm" (__result) \
226 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ 226 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
227 : "cc"); \ 227 : "cc"); \
228 __result; \ 228 __result; \
229 }) 229 })
230# endif /* OPT_ACCURACY */ 230# endif /* OPT_ACCURACY */
@@ -249,42 +249,42 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
249 ({ mad_fixed64hi_t __hi; \ 249 ({ mad_fixed64hi_t __hi; \
250 mad_fixed64lo_t __lo; \ 250 mad_fixed64lo_t __lo; \
251 mad_fixed_t __result; \ 251 mad_fixed_t __result; \
252 asm ("smull %0, %1, %3, %4\n\t" \ 252 asm ("smull %0, %1, %3, %4\n\t" \
253 "movs %0, %0, lsr %5\n\t" \ 253 "movs %0, %0, lsr %5\n\t" \
254 "adc %2, %0, %1, lsl %6" \ 254 "adc %2, %0, %1, lsl %6" \
255 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ 255 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
256 : "%r" (x), "r" (y), \ 256 : "%r" (x), "r" (y), \
257 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ 257 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
258 : "cc"); \ 258 : "cc"); \
259 __result; \ 259 __result; \
260 }) 260 })
261# endif 261# endif
262 262
263# define MAD_F_MLX(hi, lo, x, y) \ 263# define MAD_F_MLX(hi, lo, x, y) \
264 asm ("smull %0, %1, %2, %3" \ 264 asm ("smull %0, %1, %2, %3" \
265 : "=&r" (lo), "=&r" (hi) \ 265 : "=&r" (lo), "=&r" (hi) \
266 : "%r" (x), "r" (y)) 266 : "%r" (x), "r" (y))
267 267
268# define MAD_F_MLA(hi, lo, x, y) \ 268# define MAD_F_MLA(hi, lo, x, y) \
269 asm ("smlal %0, %1, %2, %3" \ 269 asm ("smlal %0, %1, %2, %3" \
270 : "+r" (lo), "+r" (hi) \ 270 : "+r" (lo), "+r" (hi) \
271 : "%r" (x), "r" (y)) 271 : "%r" (x), "r" (y))
272 272
273# define MAD_F_MLN(hi, lo) \ 273# define MAD_F_MLN(hi, lo) \
274 asm ("rsbs %0, %2, #0\n\t" \ 274 asm ("rsbs %0, %2, #0\n\t" \
275 "rsc %1, %3, #0" \ 275 "rsc %1, %3, #0" \
276 : "=r" (lo), "=r" (hi) \ 276 : "=r" (lo), "=r" (hi) \
277 : "0" (lo), "1" (hi) \ 277 : "0" (lo), "1" (hi) \
278 : "cc") 278 : "cc")
279 279
280# define mad_f_scale64(hi, lo) \ 280# define mad_f_scale64(hi, lo) \
281 ({ mad_fixed_t __result; \ 281 ({ mad_fixed_t __result; \
282 asm ("movs %0, %1, lsr %3\n\t" \ 282 asm ("movs %0, %1, lsr %3\n\t" \
283 "adc %0, %0, %2, lsl %4" \ 283 "adc %0, %0, %2, lsl %4" \
284 : "=&r" (__result) \ 284 : "=&r" (__result) \
285 : "r" (lo), "r" (hi), \ 285 : "r" (lo), "r" (hi), \
286 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ 286 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
287 : "cc"); \ 287 : "cc"); \
288 __result; \ 288 __result; \
289 }) 289 })
290 290
@@ -299,28 +299,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
299 * significant bit depends on OPT_ACCURACY via mad_f_scale64(). 299 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
300 */ 300 */
301# define MAD_F_MLX(hi, lo, x, y) \ 301# define MAD_F_MLX(hi, lo, x, y) \
302 asm ("mult %2,%3" \ 302 asm ("mult %2,%3" \
303 : "=l" (lo), "=h" (hi) \ 303 : "=l" (lo), "=h" (hi) \
304 : "%r" (x), "r" (y)) 304 : "%r" (x), "r" (y))
305 305
306# if defined(HAVE_MADD_ASM) 306# if defined(HAVE_MADD_ASM)
307# define MAD_F_MLA(hi, lo, x, y) \ 307# define MAD_F_MLA(hi, lo, x, y) \
308 asm ("madd %2,%3" \ 308 asm ("madd %2,%3" \
309 : "+l" (lo), "+h" (hi) \ 309 : "+l" (lo), "+h" (hi) \
310 : "%r" (x), "r" (y)) 310 : "%r" (x), "r" (y))
311# elif defined(HAVE_MADD16_ASM) 311# elif defined(HAVE_MADD16_ASM)
312/* 312/*
313 * This loses significant accuracy due to the 16-bit integer limit in the 313 * This loses significant accuracy due to the 16-bit integer limit in the
314 * multiply/accumulate instruction. 314 * multiply/accumulate instruction.
315 */ 315 */
316# define MAD_F_ML0(hi, lo, x, y) \ 316# define MAD_F_ML0(hi, lo, x, y) \
317 asm ("mult %2,%3" \ 317 asm ("mult %2,%3" \
318 : "=l" (lo), "=h" (hi) \ 318 : "=l" (lo), "=h" (hi) \
319 : "%r" ((x) >> 12), "r" ((y) >> 16)) 319 : "%r" ((x) >> 12), "r" ((y) >> 16))
320# define MAD_F_MLA(hi, lo, x, y) \ 320# define MAD_F_MLA(hi, lo, x, y) \
321 asm ("madd16 %2,%3" \ 321 asm ("madd16 %2,%3" \
322 : "+l" (lo), "+h" (hi) \ 322 : "+l" (lo), "+h" (hi) \
323 : "%r" ((x) >> 12), "r" ((y) >> 16)) 323 : "%r" ((x) >> 12), "r" ((y) >> 16))
324# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) 324# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo))
325# endif 325# endif
326 326
@@ -340,9 +340,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
340 */ 340 */
341# define MAD_F_MLX(hi, lo, x, y) \ 341# define MAD_F_MLX(hi, lo, x, y) \
342 asm ("smul %2, %3, %0\n\t" \ 342 asm ("smul %2, %3, %0\n\t" \
343 "rd %%y, %1" \ 343 "rd %%y, %1" \
344 : "=r" (lo), "=r" (hi) \ 344 : "=r" (lo), "=r" (hi) \
345 : "%r" (x), "rI" (y)) 345 : "%r" (x), "rI" (y))
346 346
347/* --- PowerPC ------------------------------------------------------------- */ 347/* --- PowerPC ------------------------------------------------------------- */
348 348
@@ -355,11 +355,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
355# define MAD_F_MLX(hi, lo, x, y) \ 355# define MAD_F_MLX(hi, lo, x, y) \
356 do { \ 356 do { \
357 asm ("mullw %0,%1,%2" \ 357 asm ("mullw %0,%1,%2" \
358 : "=r" (lo) \ 358 : "=r" (lo) \
359 : "%r" (x), "r" (y)); \ 359 : "%r" (x), "r" (y)); \
360 asm ("mulhw %0,%1,%2" \ 360 asm ("mulhw %0,%1,%2" \
361 : "=r" (hi) \ 361 : "=r" (hi) \
362 : "%r" (x), "r" (y)); \ 362 : "%r" (x), "r" (y)); \
363 } \ 363 } \
364 while (0) 364 while (0)
365 365
@@ -372,11 +372,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
372 mad_fixed64lo_t __lo; \ 372 mad_fixed64lo_t __lo; \
373 MAD_F_MLX(__hi, __lo, (x), (y)); \ 373 MAD_F_MLX(__hi, __lo, (x), (y)); \
374 asm ("addc %0,%2,%3\n\t" \ 374 asm ("addc %0,%2,%3\n\t" \
375 "adde %1,%4,%5" \ 375 "adde %1,%4,%5" \
376 : "=r" (lo), "=r" (hi) \ 376 : "=r" (lo), "=r" (hi) \
377 : "%r" (lo), "r" (__lo), \ 377 : "%r" (lo), "r" (__lo), \
378 "%r" (hi), "r" (__hi) \ 378 "%r" (hi), "r" (__hi) \
379 : "xer"); \ 379 : "xer"); \
380 }) 380 })
381# endif 381# endif
382 382
@@ -387,28 +387,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
387# define mad_f_scale64(hi, lo) \ 387# define mad_f_scale64(hi, lo) \
388 ({ mad_fixed_t __result, __round; \ 388 ({ mad_fixed_t __result, __round; \
389 asm ("rotrwi %0,%1,%2" \ 389 asm ("rotrwi %0,%1,%2" \
390 : "=r" (__result) \ 390 : "=r" (__result) \
391 : "r" (lo), "i" (MAD_F_SCALEBITS)); \ 391 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
392 asm ("extrwi %0,%1,1,0" \ 392 asm ("extrwi %0,%1,1,0" \
393 : "=r" (__round) \ 393 : "=r" (__round) \
394 : "r" (__result)); \ 394 : "r" (__result)); \
395 asm ("insrwi %0,%1,%2,0" \ 395 asm ("insrwi %0,%1,%2,0" \
396 : "+r" (__result) \ 396 : "+r" (__result) \
397 : "r" (hi), "i" (MAD_F_SCALEBITS)); \ 397 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
398 asm ("add %0,%1,%2" \ 398 asm ("add %0,%1,%2" \
399 : "=r" (__result) \ 399 : "=r" (__result) \
400 : "%r" (__result), "r" (__round)); \ 400 : "%r" (__result), "r" (__round)); \
401 __result; \ 401 __result; \
402 }) 402 })
403# else 403# else
404# define mad_f_scale64(hi, lo) \ 404# define mad_f_scale64(hi, lo) \
405 ({ mad_fixed_t __result; \ 405 ({ mad_fixed_t __result; \
406 asm ("rotrwi %0,%1,%2" \ 406 asm ("rotrwi %0,%1,%2" \
407 : "=r" (__result) \ 407 : "=r" (__result) \
408 : "r" (lo), "i" (MAD_F_SCALEBITS)); \ 408 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
409 asm ("insrwi %0,%1,%2,0" \ 409 asm ("insrwi %0,%1,%2,0" \
410 : "+r" (__result) \ 410 : "+r" (__result) \
411 : "r" (hi), "i" (MAD_F_SCALEBITS)); \ 411 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
412 __result; \ 412 __result; \
413 }) 413 })
414# endif 414# endif
@@ -452,10 +452,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
452 * Pre-rounding is required to stay within the limits of compliance. 452 * Pre-rounding is required to stay within the limits of compliance.
453 */ 453 */
454# if defined(OPT_SPEED) 454# if defined(OPT_SPEED)
455# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16)) 455# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
456# else 456# else
457# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \ 457# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
458 (((y) + (1L << 15)) >> 16)) 458 (((y) + (1L << 15)) >> 16))
459# endif 459# endif
460 460
461/* ------------------------------------------------------------------------- */ 461/* ------------------------------------------------------------------------- */
@@ -476,22 +476,22 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
476# endif 476# endif
477 477
478# if !defined(MAD_F_MLA) 478# if !defined(MAD_F_MLA)
479# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) 479# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
480# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) 480# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
481# define MAD_F_MLN(hi, lo) ((lo) = -(lo)) 481# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
482# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) 482# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
483# endif 483# endif
484 484
485# if !defined(MAD_F_ML0) 485# if !defined(MAD_F_ML0)
486# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y)) 486# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
487# endif 487# endif
488 488
489# if !defined(MAD_F_MLN) 489# if !defined(MAD_F_MLN)
490# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) 490# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
491# endif 491# endif
492 492
493# if !defined(MAD_F_MLZ) 493# if !defined(MAD_F_MLZ)
494# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) 494# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
495# endif 495# endif
496 496
497# if !defined(mad_f_scale64) 497# if !defined(mad_f_scale64)
@@ -499,7 +499,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
499# define mad_f_scale64(hi, lo) \ 499# define mad_f_scale64(hi, lo) \
500 ((((mad_fixed_t) \ 500 ((((mad_fixed_t) \
501 (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ 501 (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \
502 ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) 502 ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
503# else 503# else
504# define mad_f_scale64(hi, lo) \ 504# define mad_f_scale64(hi, lo) \
505 ((mad_fixed_t) \ 505 ((mad_fixed_t) \
diff --git a/apps/codecs/libmad/frame.c b/apps/codecs/libmad/frame.c
index 3fb971d3e1..85c2a201f7 100644
--- a/apps/codecs/libmad/frame.c
+++ b/apps/codecs/libmad/frame.c
@@ -61,8 +61,8 @@ int (*const decoder_table[3])(struct mad_stream *, struct mad_frame *) = {
61}; 61};
62 62
63/* 63/*
64 * NAME: header->init() 64 * NAME: header->init()
65 * DESCRIPTION: initialize header struct 65 * DESCRIPTION: initialize header struct
66 */ 66 */
67void mad_header_init(struct mad_header *header) 67void mad_header_init(struct mad_header *header)
68{ 68{
@@ -84,8 +84,8 @@ void mad_header_init(struct mad_header *header)
84} 84}
85 85
86/* 86/*
87 * NAME: frame->init() 87 * NAME: frame->init()
88 * DESCRIPTION: initialize frame struct 88 * DESCRIPTION: initialize frame struct
89 */ 89 */
90void mad_frame_init(struct mad_frame *frame) 90void mad_frame_init(struct mad_frame *frame)
91{ 91{
@@ -98,8 +98,8 @@ void mad_frame_init(struct mad_frame *frame)
98} 98}
99 99
100/* 100/*
101 * NAME: frame->finish() 101 * NAME: frame->finish()
102 * DESCRIPTION: deallocate any dynamic memory associated with frame 102 * DESCRIPTION: deallocate any dynamic memory associated with frame
103 */ 103 */
104void mad_frame_finish(struct mad_frame *frame) 104void mad_frame_finish(struct mad_frame *frame)
105{ 105{
@@ -112,8 +112,8 @@ void mad_frame_finish(struct mad_frame *frame)
112} 112}
113 113
114/* 114/*
115 * NAME: decode_header() 115 * NAME: decode_header()
116 * DESCRIPTION: read header data and following CRC word 116 * DESCRIPTION: read header data and following CRC word
117 */ 117 */
118static 118static
119int decode_header(struct mad_header *header, struct mad_stream *stream) 119int decode_header(struct mad_header *header, struct mad_stream *stream)
@@ -231,8 +231,8 @@ int decode_header(struct mad_header *header, struct mad_stream *stream)
231} 231}
232 232
233/* 233/*
234 * NAME: free_bitrate() 234 * NAME: free_bitrate()
235 * DESCRIPTION: attempt to discover the bitstream's free bitrate 235 * DESCRIPTION: attempt to discover the bitstream's free bitrate
236 */ 236 */
237static 237static
238int free_bitrate(struct mad_stream *stream, struct mad_header const *header) 238int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
@@ -246,7 +246,7 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
246 246
247 pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; 247 pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0;
248 slots_per_frame = (header->layer == MAD_LAYER_III && 248 slots_per_frame = (header->layer == MAD_LAYER_III &&
249 (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; 249 (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
250 250
251 while (mad_stream_sync(stream) == 0) { 251 while (mad_stream_sync(stream) == 0) {
252 struct mad_stream peek_stream; 252 struct mad_stream peek_stream;
@@ -256,8 +256,8 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
256 peek_header = *header; 256 peek_header = *header;
257 257
258 if (decode_header(&peek_header, &peek_stream) == 0 && 258 if (decode_header(&peek_header, &peek_stream) == 0 &&
259 peek_header.layer == header->layer && 259 peek_header.layer == header->layer &&
260 peek_header.samplerate == header->samplerate) { 260 peek_header.samplerate == header->samplerate) {
261 unsigned int N; 261 unsigned int N;
262 262
263 ptr = mad_bit_nextbyte(&stream->ptr); 263 ptr = mad_bit_nextbyte(&stream->ptr);
@@ -265,16 +265,16 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
265 N = ptr - stream->this_frame; 265 N = ptr - stream->this_frame;
266 266
267 if (header->layer == MAD_LAYER_I) { 267 if (header->layer == MAD_LAYER_I) {
268 rate = (unsigned long) header->samplerate * 268 rate = (unsigned long) header->samplerate *
269 (N - 4 * pad_slot + 4) / 48 / 1000; 269 (N - 4 * pad_slot + 4) / 48 / 1000;
270 } 270 }
271 else { 271 else {
272 rate = (unsigned long) header->samplerate * 272 rate = (unsigned long) header->samplerate *
273 (N - pad_slot + 1) / slots_per_frame / 1000; 273 (N - pad_slot + 1) / slots_per_frame / 1000;
274 } 274 }
275 275
276 if (rate >= 8) 276 if (rate >= 8)
277 break; 277 break;
278 } 278 }
279 279
280 mad_bit_skip(&stream->ptr, 8); 280 mad_bit_skip(&stream->ptr, 8);
@@ -293,8 +293,8 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
293} 293}
294 294
295/* 295/*
296 * NAME: header->decode() 296 * NAME: header->decode()
297 * DESCRIPTION: read the next frame header from the stream 297 * DESCRIPTION: read the next frame header from the stream
298 */ 298 */
299int mad_header_decode(struct mad_header *header, struct mad_stream *stream) 299int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
300{ 300{
@@ -351,7 +351,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
351 351
352 if (mad_stream_sync(stream) == -1) { 352 if (mad_stream_sync(stream) == -1) {
353 if (end - stream->next_frame >= MAD_BUFFER_GUARD) 353 if (end - stream->next_frame >= MAD_BUFFER_GUARD)
354 stream->next_frame = end - MAD_BUFFER_GUARD; 354 stream->next_frame = end - MAD_BUFFER_GUARD;
355 355
356 stream->error = MAD_ERROR_BUFLEN; 356 stream->error = MAD_ERROR_BUFLEN;
357 goto fail; 357 goto fail;
@@ -371,13 +371,13 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
371 371
372 /* calculate frame duration */ 372 /* calculate frame duration */
373 mad_timer_set(&header->duration, 0, 373 mad_timer_set(&header->duration, 0,
374 32 * MAD_NSBSAMPLES(header), header->samplerate); 374 32 * MAD_NSBSAMPLES(header), header->samplerate);
375 375
376 /* calculate free bit rate */ 376 /* calculate free bit rate */
377 if (header->bitrate == 0) { 377 if (header->bitrate == 0) {
378 if ((stream->freerate == 0 || !stream->sync || 378 if ((stream->freerate == 0 || !stream->sync ||
379 (header->layer == MAD_LAYER_III && stream->freerate > 640000)) && 379 (header->layer == MAD_LAYER_III && stream->freerate > 640000)) &&
380 free_bitrate(stream, header) == -1) 380 free_bitrate(stream, header) == -1)
381 goto fail; 381 goto fail;
382 382
383 header->bitrate = stream->freerate; 383 header->bitrate = stream->freerate;
@@ -393,7 +393,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
393 unsigned int slots_per_frame; 393 unsigned int slots_per_frame;
394 394
395 slots_per_frame = (header->layer == MAD_LAYER_III && 395 slots_per_frame = (header->layer == MAD_LAYER_III &&
396 (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; 396 (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
397 397
398 N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot; 398 N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot;
399 } 399 }
@@ -431,8 +431,8 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
431} 431}
432 432
433/* 433/*
434 * NAME: frame->decode() 434 * NAME: frame->decode()
435 * DESCRIPTION: decode a single frame from a bitstream 435 * DESCRIPTION: decode a single frame from a bitstream
436 */ 436 */
437int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream) 437int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
438{ 438{
@@ -479,8 +479,8 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
479} 479}
480 480
481/* 481/*
482 * NAME: frame->mute() 482 * NAME: frame->mute()
483 * DESCRIPTION: zero all subband values so the frame becomes silent 483 * DESCRIPTION: zero all subband values so the frame becomes silent
484 */ 484 */
485void mad_frame_mute(struct mad_frame *frame) 485void mad_frame_mute(struct mad_frame *frame)
486{ 486{
@@ -496,8 +496,8 @@ void mad_frame_mute(struct mad_frame *frame)
496 if (frame->overlap) { 496 if (frame->overlap) {
497 for (s = 0; s < 18; ++s) { 497 for (s = 0; s < 18; ++s) {
498 for (sb = 0; sb < 32; ++sb) { 498 for (sb = 0; sb < 32; ++sb) {
499 (*frame->overlap)[0][sb][s] = 499 (*frame->overlap)[0][sb][s] =
500 (*frame->overlap)[1][sb][s] = 0; 500 (*frame->overlap)[1][sb][s] = 0;
501 } 501 }
502 } 502 }
503 } 503 }
diff --git a/apps/codecs/libmad/frame.h b/apps/codecs/libmad/frame.h
index d2d6dca3ef..4d23107d76 100644
--- a/apps/codecs/libmad/frame.h
+++ b/apps/codecs/libmad/frame.h
@@ -27,41 +27,41 @@
27# include "stream.h" 27# include "stream.h"
28 28
29enum mad_layer { 29enum mad_layer {
30 MAD_LAYER_I = 1, /* Layer I */ 30 MAD_LAYER_I = 1, /* Layer I */
31 MAD_LAYER_II = 2, /* Layer II */ 31 MAD_LAYER_II = 2, /* Layer II */
32 MAD_LAYER_III = 3 /* Layer III */ 32 MAD_LAYER_III = 3 /* Layer III */
33}; 33};
34 34
35enum mad_mode { 35enum mad_mode {
36 MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ 36 MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
37 MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ 37 MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
38 MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ 38 MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
39 MAD_MODE_STEREO = 3 /* normal LR stereo */ 39 MAD_MODE_STEREO = 3 /* normal LR stereo */
40}; 40};
41 41
42enum mad_emphasis { 42enum mad_emphasis {
43 MAD_EMPHASIS_NONE = 0, /* no emphasis */ 43 MAD_EMPHASIS_NONE = 0, /* no emphasis */
44 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ 44 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
45 MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ 45 MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
46 MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ 46 MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
47}; 47};
48 48
49struct mad_header { 49struct mad_header {
50 enum mad_layer layer; /* audio layer (1, 2, or 3) */ 50 enum mad_layer layer; /* audio layer (1, 2, or 3) */
51 enum mad_mode mode; /* channel mode (see above) */ 51 enum mad_mode mode; /* channel mode (see above) */
52 int mode_extension; /* additional mode info */ 52 int mode_extension; /* additional mode info */
53 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ 53 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
54 54
55 unsigned long bitrate; /* stream bitrate (bps) */ 55 unsigned long bitrate; /* stream bitrate (bps) */
56 unsigned int samplerate; /* sampling frequency (Hz) */ 56 unsigned int samplerate; /* sampling frequency (Hz) */
57 57
58 unsigned short crc_check; /* frame CRC accumulator */ 58 unsigned short crc_check; /* frame CRC accumulator */
59 unsigned short crc_target; /* final target CRC checksum */ 59 unsigned short crc_target; /* final target CRC checksum */
60 60
61 int flags; /* flags (see below) */ 61 int flags; /* flags (see below) */
62 int private_bits; /* private bits (see below) */ 62 int private_bits; /* private bits (see below) */
63 63
64 mad_timer_t duration; /* audio playing time of frame */ 64 mad_timer_t duration; /* audio playing time of frame */
65}; 65};
66 66
67struct mad_frame { 67struct mad_frame {
@@ -76,33 +76,33 @@ struct mad_frame {
76 mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ 76 mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
77}; 77};
78 78
79# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) 79# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
80# define MAD_NSBSAMPLES(header) \ 80# define MAD_NSBSAMPLES(header) \
81 ((header)->layer == MAD_LAYER_I ? 12 : \ 81 ((header)->layer == MAD_LAYER_I ? 12 : \
82 (((header)->layer == MAD_LAYER_III && \ 82 (((header)->layer == MAD_LAYER_III && \
83 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) 83 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
84 84
85enum { 85enum {
86 MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ 86 MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
87 MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ 87 MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
88 88
89 MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ 89 MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
90 MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ 90 MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
91 MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ 91 MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
92 MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ 92 MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
93 93
94 MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ 94 MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
95 MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ 95 MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
96 MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ 96 MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
97 97
98 MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ 98 MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
99 MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ 99 MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
100 MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ 100 MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
101}; 101};
102 102
103enum { 103enum {
104 MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ 104 MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
105 MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ 105 MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
106}; 106};
107 107
108void mad_header_init(struct mad_header *); 108void mad_header_init(struct mad_header *);
diff --git a/apps/codecs/libmad/global.h b/apps/codecs/libmad/global.h
index 22e8546fa6..96bd3eb71e 100644
--- a/apps/codecs/libmad/global.h
+++ b/apps/codecs/libmad/global.h
@@ -64,9 +64,9 @@
64 64
65# if !defined(HAVE_ASSERT_H) 65# if !defined(HAVE_ASSERT_H)
66# if defined(NDEBUG) 66# if defined(NDEBUG)
67# define assert(x) /* nothing */ 67# define assert(x) /* nothing */
68# else 68# else
69# define assert(x) do { if (!(x)) abort(); } while (0) 69# define assert(x) do { if (!(x)) abort(); } while (0)
70# endif 70# endif
71# endif 71# endif
72 72
diff --git a/apps/codecs/libmad/huffman.c b/apps/codecs/libmad/huffman.c
index 43216d3680..db788e71b4 100644
--- a/apps/codecs/libmad/huffman.c
+++ b/apps/codecs/libmad/huffman.c
@@ -36,15 +36,15 @@
36 36
37# if defined(__GNUC__) || \ 37# if defined(__GNUC__) || \
38 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) 38 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
39# define PTR(offs, bits) { .ptr = { 0, bits, offs } } 39# define PTR(offs, bits) { .ptr = { 0, bits, offs } }
40# define V(v, w, x, y, hlen) { .value = { 1, hlen, v, w, x, y } } 40# define V(v, w, x, y, hlen) { .value = { 1, hlen, v, w, x, y } }
41# else 41# else
42# define PTR(offs, bits) { { 0, bits, offs } } 42# define PTR(offs, bits) { { 0, bits, offs } }
43# if defined(WORDS_BIGENDIAN) 43# if defined(WORDS_BIGENDIAN)
44# define V(v, w, x, y, hlen) { { 1, hlen, (v << 11) | (w << 10) | \ 44# define V(v, w, x, y, hlen) { { 1, hlen, (v << 11) | (w << 10) | \
45 (x << 9) | (y << 8) } } 45 (x << 9) | (y << 8) } }
46# else 46# else
47# define V(v, w, x, y, hlen) { { 1, hlen, (v << 0) | (w << 1) | \ 47# define V(v, w, x, y, hlen) { { 1, hlen, (v << 0) | (w << 1) | \
48 (x << 2) | (y << 3) } } 48 (x << 2) | (y << 3) } }
49# endif 49# endif
50# endif 50# endif
@@ -69,23 +69,23 @@ union huffquad const hufftabA[] ICONST_ATTR_MPA_HUFFMAN = {
69 /* 1111 */ V(0, 0, 0, 0, 1), 69 /* 1111 */ V(0, 0, 0, 0, 1),
70 70
71 /* 0000 ... */ 71 /* 0000 ... */
72 /* 00 */ V(1, 0, 1, 1, 2), /* 16 */ 72 /* 00 */ V(1, 0, 1, 1, 2), /* 16 */
73 /* 01 */ V(1, 1, 1, 1, 2), 73 /* 01 */ V(1, 1, 1, 1, 2),
74 /* 10 */ V(1, 1, 0, 1, 2), 74 /* 10 */ V(1, 1, 0, 1, 2),
75 /* 11 */ V(1, 1, 1, 0, 2), 75 /* 11 */ V(1, 1, 1, 0, 2),
76 76
77 /* 0001 ... */ 77 /* 0001 ... */
78 /* 00 */ V(0, 1, 1, 1, 2), /* 20 */ 78 /* 00 */ V(0, 1, 1, 1, 2), /* 20 */
79 /* 01 */ V(0, 1, 0, 1, 2), 79 /* 01 */ V(0, 1, 0, 1, 2),
80 /* 10 */ V(1, 0, 0, 1, 1), 80 /* 10 */ V(1, 0, 0, 1, 1),
81 /* 11 */ V(1, 0, 0, 1, 1), 81 /* 11 */ V(1, 0, 0, 1, 1),
82 82
83 /* 0010 ... */ 83 /* 0010 ... */
84 /* 0 */ V(0, 1, 1, 0, 1), /* 24 */ 84 /* 0 */ V(0, 1, 1, 0, 1), /* 24 */
85 /* 1 */ V(0, 0, 1, 1, 1), 85 /* 1 */ V(0, 0, 1, 1, 1),
86 86
87 /* 0011 ... */ 87 /* 0011 ... */
88 /* 0 */ V(1, 0, 1, 0, 1), /* 26 */ 88 /* 0 */ V(1, 0, 1, 0, 1), /* 26 */
89 /* 1 */ V(1, 1, 0, 0, 1) 89 /* 1 */ V(1, 1, 0, 0, 1)
90}; 90};
91 91
@@ -114,14 +114,14 @@ union huffquad const hufftabB[] ICONST_ATTR_MPA_HUFFMAN = {
114 114
115# if defined(__GNUC__) || \ 115# if defined(__GNUC__) || \
116 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) 116 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
117# define PTR(offs, bits) { .ptr = { 0, bits, offs } } 117# define PTR(offs, bits) { .ptr = { 0, bits, offs } }
118# define V(x, y, hlen) { .value = { 1, hlen, x, y } } 118# define V(x, y, hlen) { .value = { 1, hlen, x, y } }
119# else 119# else
120# define PTR(offs, bits) { { 0, bits, offs } } 120# define PTR(offs, bits) { { 0, bits, offs } }
121# if defined(WORDS_BIGENDIAN) 121# if defined(WORDS_BIGENDIAN)
122# define V(x, y, hlen) { { 1, hlen, (x << 8) | (y << 4) } } 122# define V(x, y, hlen) { { 1, hlen, (x << 8) | (y << 4) } }
123# else 123# else
124# define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } } 124# define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } }
125# endif 125# endif
126# endif 126# endif
127 127
@@ -154,7 +154,7 @@ union huffpair const hufftab2[] ICONST_ATTR_MPA_HUFFMAN = {
154 /* 111 */ V(0, 0, 1), 154 /* 111 */ V(0, 0, 1),
155 155
156 /* 000 ... */ 156 /* 000 ... */
157 /* 000 */ V(2, 2, 3), /* 8 */ 157 /* 000 */ V(2, 2, 3), /* 8 */
158 /* 001 */ V(0, 2, 3), 158 /* 001 */ V(0, 2, 3),
159 /* 010 */ V(1, 2, 2), 159 /* 010 */ V(1, 2, 2),
160 /* 011 */ V(1, 2, 2), 160 /* 011 */ V(1, 2, 2),
@@ -176,7 +176,7 @@ union huffpair const hufftab3[] ICONST_ATTR_MPA_HUFFMAN = {
176 /* 111 */ V(0, 0, 2), 176 /* 111 */ V(0, 0, 2),
177 177
178 /* 000 ... */ 178 /* 000 ... */
179 /* 000 */ V(2, 2, 3), /* 8 */ 179 /* 000 */ V(2, 2, 3), /* 8 */
180 /* 001 */ V(0, 2, 3), 180 /* 001 */ V(0, 2, 3),
181 /* 010 */ V(1, 2, 2), 181 /* 010 */ V(1, 2, 2),
182 /* 011 */ V(1, 2, 2), 182 /* 011 */ V(1, 2, 2),
@@ -198,7 +198,7 @@ union huffpair const hufftab5[] ICONST_ATTR_MPA_HUFFMAN = {
198 /* 111 */ V(0, 0, 1), 198 /* 111 */ V(0, 0, 1),
199 199
200 /* 000 ... */ 200 /* 000 ... */
201 /* 0000 */ PTR(24, 1), /* 8 */ 201 /* 0000 */ PTR(24, 1), /* 8 */
202 /* 0001 */ V(3, 2, 4), 202 /* 0001 */ V(3, 2, 4),
203 /* 0010 */ V(3, 1, 3), 203 /* 0010 */ V(3, 1, 3),
204 /* 0011 */ V(3, 1, 3), 204 /* 0011 */ V(3, 1, 3),
@@ -216,7 +216,7 @@ union huffpair const hufftab5[] ICONST_ATTR_MPA_HUFFMAN = {
216 /* 1111 */ V(2, 0, 3), 216 /* 1111 */ V(2, 0, 3),
217 217
218 /* 000 0000 ... */ 218 /* 000 0000 ... */
219 /* 0 */ V(3, 3, 1), /* 24 */ 219 /* 0 */ V(3, 3, 1), /* 24 */
220 /* 1 */ V(2, 3, 1) 220 /* 1 */ V(2, 3, 1)
221}; 221};
222 222
@@ -240,7 +240,7 @@ union huffpair const hufftab6[] ICONST_ATTR_MPA_HUFFMAN = {
240 /* 1111 */ V(0, 0, 3), 240 /* 1111 */ V(0, 0, 3),
241 241
242 /* 0000 ... */ 242 /* 0000 ... */
243 /* 000 */ V(3, 3, 3), /* 16 */ 243 /* 000 */ V(3, 3, 3), /* 16 */
244 /* 001 */ V(0, 3, 3), 244 /* 001 */ V(0, 3, 3),
245 /* 010 */ V(2, 3, 2), 245 /* 010 */ V(2, 3, 2),
246 /* 011 */ V(2, 3, 2), 246 /* 011 */ V(2, 3, 2),
@@ -250,11 +250,11 @@ union huffpair const hufftab6[] ICONST_ATTR_MPA_HUFFMAN = {
250 /* 111 */ V(3, 0, 2), 250 /* 111 */ V(3, 0, 2),
251 251
252 /* 0001 ... */ 252 /* 0001 ... */
253 /* 0 */ V(1, 3, 1), /* 24 */ 253 /* 0 */ V(1, 3, 1), /* 24 */
254 /* 1 */ V(3, 1, 1), 254 /* 1 */ V(3, 1, 1),
255 255
256 /* 0010 ... */ 256 /* 0010 ... */
257 /* 0 */ V(2, 2, 1), /* 26 */ 257 /* 0 */ V(2, 2, 1), /* 26 */
258 /* 1 */ V(0, 2, 1) 258 /* 1 */ V(0, 2, 1)
259}; 259};
260 260
@@ -278,7 +278,7 @@ union huffpair const hufftab7[] ICONST_ATTR_MPA_HUFFMAN = {
278 /* 1111 */ V(0, 0, 1), 278 /* 1111 */ V(0, 0, 1),
279 279
280 /* 0000 ... */ 280 /* 0000 ... */
281 /* 0000 */ PTR(52, 2), /* 16 */ 281 /* 0000 */ PTR(52, 2), /* 16 */
282 /* 0001 */ PTR(56, 1), 282 /* 0001 */ PTR(56, 1),
283 /* 0010 */ PTR(58, 1), 283 /* 0010 */ PTR(58, 1),
284 /* 0011 */ V(1, 5, 4), 284 /* 0011 */ V(1, 5, 4),
@@ -296,7 +296,7 @@ union huffpair const hufftab7[] ICONST_ATTR_MPA_HUFFMAN = {
296 /* 1111 */ V(4, 0, 3), 296 /* 1111 */ V(4, 0, 3),
297 297
298 /* 0001 ... */ 298 /* 0001 ... */
299 /* 0000 */ V(0, 4, 4), /* 32 */ 299 /* 0000 */ V(0, 4, 4), /* 32 */
300 /* 0001 */ V(2, 3, 4), 300 /* 0001 */ V(2, 3, 4),
301 /* 0010 */ V(3, 2, 4), 301 /* 0010 */ V(3, 2, 4),
302 /* 0011 */ V(0, 3, 4), 302 /* 0011 */ V(0, 3, 4),
@@ -314,31 +314,31 @@ union huffpair const hufftab7[] ICONST_ATTR_MPA_HUFFMAN = {
314 /* 1111 */ V(1, 2, 2), 314 /* 1111 */ V(1, 2, 2),
315 315
316 /* 0010 ... */ 316 /* 0010 ... */
317 /* 00 */ V(2, 1, 1), /* 48 */ 317 /* 00 */ V(2, 1, 1), /* 48 */
318 /* 01 */ V(2, 1, 1), 318 /* 01 */ V(2, 1, 1),
319 /* 10 */ V(0, 2, 2), 319 /* 10 */ V(0, 2, 2),
320 /* 11 */ V(2, 0, 2), 320 /* 11 */ V(2, 0, 2),
321 321
322 /* 0000 0000 ... */ 322 /* 0000 0000 ... */
323 /* 00 */ V(5, 5, 2), /* 52 */ 323 /* 00 */ V(5, 5, 2), /* 52 */
324 /* 01 */ V(4, 5, 2), 324 /* 01 */ V(4, 5, 2),
325 /* 10 */ V(5, 4, 2), 325 /* 10 */ V(5, 4, 2),
326 /* 11 */ V(5, 3, 2), 326 /* 11 */ V(5, 3, 2),
327 327
328 /* 0000 0001 ... */ 328 /* 0000 0001 ... */
329 /* 0 */ V(3, 5, 1), /* 56 */ 329 /* 0 */ V(3, 5, 1), /* 56 */
330 /* 1 */ V(4, 4, 1), 330 /* 1 */ V(4, 4, 1),
331 331
332 /* 0000 0010 ... */ 332 /* 0000 0010 ... */
333 /* 0 */ V(2, 5, 1), /* 58 */ 333 /* 0 */ V(2, 5, 1), /* 58 */
334 /* 1 */ V(5, 2, 1), 334 /* 1 */ V(5, 2, 1),
335 335
336 /* 0000 0101 ... */ 336 /* 0000 0101 ... */
337 /* 0 */ V(0, 5, 1), /* 60 */ 337 /* 0 */ V(0, 5, 1), /* 60 */
338 /* 1 */ V(3, 4, 1), 338 /* 1 */ V(3, 4, 1),
339 339
340 /* 0000 0111 ... */ 340 /* 0000 0111 ... */
341 /* 0 */ V(4, 3, 1), /* 62 */ 341 /* 0 */ V(4, 3, 1), /* 62 */
342 /* 1 */ V(3, 3, 1) 342 /* 1 */ V(3, 3, 1)
343}; 343};
344 344
@@ -365,7 +365,7 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
365 /* 1111 */ V(0, 0, 2), 365 /* 1111 */ V(0, 0, 2),
366 366
367 /* 0000 ... */ 367 /* 0000 ... */
368 /* 0000 */ PTR(36, 3), /* 16 */ 368 /* 0000 */ PTR(36, 3), /* 16 */
369 /* 0001 */ PTR(44, 2), 369 /* 0001 */ PTR(44, 2),
370 /* 0010 */ PTR(48, 1), 370 /* 0010 */ PTR(48, 1),
371 /* 0011 */ V(1, 5, 4), 371 /* 0011 */ V(1, 5, 4),
@@ -383,13 +383,13 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
383 /* 1111 */ V(3, 2, 4), 383 /* 1111 */ V(3, 2, 4),
384 384
385 /* 0001 ... */ 385 /* 0001 ... */
386 /* 00 */ PTR(54, 2), /* 32 */ 386 /* 00 */ PTR(54, 2), /* 32 */
387 /* 01 */ V(2, 2, 2), 387 /* 01 */ V(2, 2, 2),
388 /* 10 */ V(0, 2, 2), 388 /* 10 */ V(0, 2, 2),
389 /* 11 */ V(2, 0, 2), 389 /* 11 */ V(2, 0, 2),
390 390
391 /* 0000 0000 ... */ 391 /* 0000 0000 ... */
392 /* 000 */ V(5, 5, 3), /* 36 */ 392 /* 000 */ V(5, 5, 3), /* 36 */
393 /* 001 */ V(5, 4, 3), 393 /* 001 */ V(5, 4, 3),
394 /* 010 */ V(4, 5, 2), 394 /* 010 */ V(4, 5, 2),
395 /* 011 */ V(4, 5, 2), 395 /* 011 */ V(4, 5, 2),
@@ -399,25 +399,25 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
399 /* 111 */ V(5, 3, 1), 399 /* 111 */ V(5, 3, 1),
400 400
401 /* 0000 0001 ... */ 401 /* 0000 0001 ... */
402 /* 00 */ V(3, 5, 2), /* 44 */ 402 /* 00 */ V(3, 5, 2), /* 44 */
403 /* 01 */ V(4, 4, 2), 403 /* 01 */ V(4, 4, 2),
404 /* 10 */ V(2, 5, 1), 404 /* 10 */ V(2, 5, 1),
405 /* 11 */ V(2, 5, 1), 405 /* 11 */ V(2, 5, 1),
406 406
407 /* 0000 0010 ... */ 407 /* 0000 0010 ... */
408 /* 0 */ V(5, 2, 1), /* 48 */ 408 /* 0 */ V(5, 2, 1), /* 48 */
409 /* 1 */ V(0, 5, 1), 409 /* 1 */ V(0, 5, 1),
410 410
411 /* 0000 0101 ... */ 411 /* 0000 0101 ... */
412 /* 0 */ V(3, 4, 1), /* 50 */ 412 /* 0 */ V(3, 4, 1), /* 50 */
413 /* 1 */ V(4, 3, 1), 413 /* 1 */ V(4, 3, 1),
414 414
415 /* 0000 0110 ... */ 415 /* 0000 0110 ... */
416 /* 0 */ V(5, 0, 1), /* 52 */ 416 /* 0 */ V(5, 0, 1), /* 52 */
417 /* 1 */ V(3, 3, 1), 417 /* 1 */ V(3, 3, 1),
418 418
419 /* 0001 00 ... */ 419 /* 0001 00 ... */
420 /* 00 */ V(1, 3, 2), /* 54 */ 420 /* 00 */ V(1, 3, 2), /* 54 */
421 /* 01 */ V(3, 1, 2), 421 /* 01 */ V(3, 1, 2),
422 /* 10 */ V(0, 3, 2), 422 /* 10 */ V(0, 3, 2),
423 /* 11 */ V(3, 0, 2), 423 /* 11 */ V(3, 0, 2),
@@ -443,7 +443,7 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
443 /* 1111 */ V(0, 0, 2), 443 /* 1111 */ V(0, 0, 2),
444 444
445 /* 0000 ... */ 445 /* 0000 ... */
446 /* 0000 */ PTR(48, 3), /* 16 */ 446 /* 0000 */ PTR(48, 3), /* 16 */
447 /* 0001 */ PTR(56, 2), 447 /* 0001 */ PTR(56, 2),
448 /* 0010 */ PTR(60, 1), 448 /* 0010 */ PTR(60, 1),
449 /* 0011 */ V(1, 5, 4), 449 /* 0011 */ V(1, 5, 4),
@@ -461,7 +461,7 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
461 /* 1111 */ V(3, 2, 4), 461 /* 1111 */ V(3, 2, 4),
462 462
463 /* 0001 ... */ 463 /* 0001 ... */
464 /* 0000 */ V(1, 3, 4), /* 32 */ 464 /* 0000 */ V(1, 3, 4), /* 32 */
465 /* 0001 */ V(3, 1, 4), 465 /* 0001 */ V(3, 1, 4),
466 /* 0010 */ V(0, 3, 4), 466 /* 0010 */ V(0, 3, 4),
467 /* 0011 */ V(3, 0, 4), 467 /* 0011 */ V(3, 0, 4),
@@ -479,7 +479,7 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
479 /* 1111 */ V(2, 0, 2), 479 /* 1111 */ V(2, 0, 2),
480 480
481 /* 0000 0000 ... */ 481 /* 0000 0000 ... */
482 /* 000 */ V(5, 5, 3), /* 48 */ 482 /* 000 */ V(5, 5, 3), /* 48 */
483 /* 001 */ V(5, 4, 3), 483 /* 001 */ V(5, 4, 3),
484 /* 010 */ V(4, 5, 2), 484 /* 010 */ V(4, 5, 2),
485 /* 011 */ V(4, 5, 2), 485 /* 011 */ V(4, 5, 2),
@@ -489,21 +489,21 @@ union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = {
489 /* 111 */ V(5, 3, 1), 489 /* 111 */ V(5, 3, 1),
490 490
491 /* 0000 0001 ... */ 491 /* 0000 0001 ... */
492 /* 00 */ V(3, 5, 2), /* 56 */ 492 /* 00 */ V(3, 5, 2), /* 56 */
493 /* 01 */ V(4, 4, 2), 493 /* 01 */ V(4, 4, 2),
494 /* 10 */ V(2, 5, 1), 494 /* 10 */ V(2, 5, 1),
495 /* 11 */ V(2, 5, 1), 495 /* 11 */ V(2, 5, 1),
496 496
497 /* 0000 0010 ... */ 497 /* 0000 0010 ... */
498 /* 0 */ V(5, 2, 1), /* 60 */ 498 /* 0 */ V(5, 2, 1), /* 60 */
499 /* 1 */ V(0, 5, 1), 499 /* 1 */ V(0, 5, 1),
500 500
501 /* 0000 0101 ... */ 501 /* 0000 0101 ... */
502 /* 0 */ V(3, 4, 1), /* 62 */ 502 /* 0 */ V(3, 4, 1), /* 62 */
503 /* 1 */ V(4, 3, 1), 503 /* 1 */ V(4, 3, 1),
504 504
505 /* 0000 0110 ... */ 505 /* 0000 0110 ... */
506 /* 0 */ V(5, 0, 1), /* 64 */ 506 /* 0 */ V(5, 0, 1), /* 64 */
507 /* 1 */ V(3, 3, 1) 507 /* 1 */ V(3, 3, 1)
508}; 508};
509# endif 509# endif
@@ -528,7 +528,7 @@ union huffpair const hufftab9[] ICONST_ATTR_MPA_HUFFMAN = {
528 /* 1111 */ V(0, 0, 3), 528 /* 1111 */ V(0, 0, 3),
529 529
530 /* 0000 ... */ 530 /* 0000 ... */
531 /* 0000 */ PTR(50, 1), /* 16 */ 531 /* 0000 */ PTR(50, 1), /* 16 */
532 /* 0001 */ V(3, 5, 4), 532 /* 0001 */ V(3, 5, 4),
533 /* 0010 */ V(5, 3, 4), 533 /* 0010 */ V(5, 3, 4),
534 /* 0011 */ PTR(52, 1), 534 /* 0011 */ PTR(52, 1),
@@ -546,7 +546,7 @@ union huffpair const hufftab9[] ICONST_ATTR_MPA_HUFFMAN = {
546 /* 1111 */ V(0, 4, 4), 546 /* 1111 */ V(0, 4, 4),
547 547
548 /* 0001 ... */ 548 /* 0001 ... */
549 /* 000 */ V(2, 4, 3), /* 32 */ 549 /* 000 */ V(2, 4, 3), /* 32 */
550 /* 001 */ V(4, 2, 3), 550 /* 001 */ V(4, 2, 3),
551 /* 010 */ V(3, 3, 3), 551 /* 010 */ V(3, 3, 3),
552 /* 011 */ V(4, 0, 3), 552 /* 011 */ V(4, 0, 3),
@@ -556,27 +556,27 @@ union huffpair const hufftab9[] ICONST_ATTR_MPA_HUFFMAN = {
556 /* 111 */ V(4, 1, 2), 556 /* 111 */ V(4, 1, 2),
557 557
558 /* 0010 ... */ 558 /* 0010 ... */
559 /* 00 */ V(2, 3, 2), /* 40 */ 559 /* 00 */ V(2, 3, 2), /* 40 */
560 /* 01 */ V(3, 2, 2), 560 /* 01 */ V(3, 2, 2),
561 /* 10 */ V(1, 3, 1), 561 /* 10 */ V(1, 3, 1),
562 /* 11 */ V(1, 3, 1), 562 /* 11 */ V(1, 3, 1),
563 563
564 /* 0011 ... */ 564 /* 0011 ... */
565 /* 00 */ V(3, 1, 1), /* 44 */ 565 /* 00 */ V(3, 1, 1), /* 44 */
566 /* 01 */ V(3, 1, 1), 566 /* 01 */ V(3, 1, 1),
567 /* 10 */ V(0, 3, 2), 567 /* 10 */ V(0, 3, 2),
568 /* 11 */ V(3, 0, 2), 568 /* 11 */ V(3, 0, 2),
569 569
570 /* 0100 ... */ 570 /* 0100 ... */
571 /* 0 */ V(2, 2, 1), /* 48 */ 571 /* 0 */ V(2, 2, 1), /* 48 */
572 /* 1 */ V(0, 2, 1), 572 /* 1 */ V(0, 2, 1),
573 573
574 /* 0000 0000 ... */ 574 /* 0000 0000 ... */
575 /* 0 */ V(5, 5, 1), /* 50 */ 575 /* 0 */ V(5, 5, 1), /* 50 */
576 /* 1 */ V(4, 5, 1), 576 /* 1 */ V(4, 5, 1),
577 577
578 /* 0000 0011 ... */ 578 /* 0000 0011 ... */
579 /* 0 */ V(5, 4, 1), /* 52 */ 579 /* 0 */ V(5, 4, 1), /* 52 */
580 /* 1 */ V(0, 5, 1) 580 /* 1 */ V(0, 5, 1)
581}; 581};
582 582
@@ -600,7 +600,7 @@ union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = {
600 /* 1111 */ V(0, 0, 1), 600 /* 1111 */ V(0, 0, 1),
601 601
602 /* 0000 ... */ 602 /* 0000 ... */
603 /* 0000 */ PTR(52, 3), /* 16 */ 603 /* 0000 */ PTR(52, 3), /* 16 */
604 /* 0001 */ PTR(60, 2), 604 /* 0001 */ PTR(60, 2),
605 /* 0010 */ PTR(64, 3), 605 /* 0010 */ PTR(64, 3),
606 /* 0011 */ PTR(72, 1), 606 /* 0011 */ PTR(72, 1),
@@ -618,7 +618,7 @@ union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = {
618 /* 1111 */ PTR(96, 1), 618 /* 1111 */ PTR(96, 1),
619 619
620 /* 0001 ... */ 620 /* 0001 ... */
621 /* 0000 */ PTR(98, 1), /* 32 */ 621 /* 0000 */ PTR(98, 1), /* 32 */
622 /* 0001 */ PTR(100, 1), 622 /* 0001 */ PTR(100, 1),
623 /* 0010 */ V(1, 4, 4), 623 /* 0010 */ V(1, 4, 4),
624 /* 0011 */ V(4, 1, 4), 624 /* 0011 */ V(4, 1, 4),
@@ -636,13 +636,13 @@ union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = {
636 /* 1111 */ V(2, 2, 3), 636 /* 1111 */ V(2, 2, 3),
637 637
638 /* 0010 ... */ 638 /* 0010 ... */
639 /* 00 */ V(1, 2, 2), /* 48 */ 639 /* 00 */ V(1, 2, 2), /* 48 */
640 /* 01 */ V(2, 1, 2), 640 /* 01 */ V(2, 1, 2),
641 /* 10 */ V(0, 2, 2), 641 /* 10 */ V(0, 2, 2),
642 /* 11 */ V(2, 0, 2), 642 /* 11 */ V(2, 0, 2),
643 643
644 /* 0000 0000 ... */ 644 /* 0000 0000 ... */
645 /* 000 */ V(7, 7, 3), /* 52 */ 645 /* 000 */ V(7, 7, 3), /* 52 */
646 /* 001 */ V(6, 7, 3), 646 /* 001 */ V(6, 7, 3),
647 /* 010 */ V(7, 6, 3), 647 /* 010 */ V(7, 6, 3),
648 /* 011 */ V(5, 7, 3), 648 /* 011 */ V(5, 7, 3),
@@ -652,13 +652,13 @@ union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = {
652 /* 111 */ V(4, 7, 2), 652 /* 111 */ V(4, 7, 2),
653 653
654 /* 0000 0001 ... */ 654 /* 0000 0001 ... */
655 /* 00 */ V(7, 4, 2), /* 60 */ 655 /* 00 */ V(7, 4, 2), /* 60 */
656 /* 01 */ V(5, 6, 2), 656 /* 01 */ V(5, 6, 2),
657 /* 10 */ V(6, 5, 2), 657 /* 10 */ V(6, 5, 2),
658 /* 11 */ V(3, 7, 2), 658 /* 11 */ V(3, 7, 2),
659 659
660 /* 0000 0010 ... */ 660 /* 0000 0010 ... */
661 /* 000 */ V(7, 3, 2), /* 64 */ 661 /* 000 */ V(7, 3, 2), /* 64 */
662 /* 001 */ V(7, 3, 2), 662 /* 001 */ V(7, 3, 2),
663 /* 010 */ V(4, 6, 2), 663 /* 010 */ V(4, 6, 2),
664 /* 011 */ V(4, 6, 2), 664 /* 011 */ V(4, 6, 2),
@@ -668,53 +668,53 @@ union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = {
668 /* 111 */ V(6, 3, 2), 668 /* 111 */ V(6, 3, 2),
669 669
670 /* 0000 0011 ... */ 670 /* 0000 0011 ... */
671 /* 0 */ V(2, 7, 1), /* 72 */ 671 /* 0 */ V(2, 7, 1), /* 72 */
672 /* 1 */ V(7, 2, 1), 672 /* 1 */ V(7, 2, 1),
673 673
674 /* 0000 0100 ... */ 674 /* 0000 0100 ... */
675 /* 00 */ V(6, 4, 2), /* 74 */ 675 /* 00 */ V(6, 4, 2), /* 74 */
676 /* 01 */ V(0, 7, 2), 676 /* 01 */ V(0, 7, 2),
677 /* 10 */ V(7, 0, 1), 677 /* 10 */ V(7, 0, 1),
678 /* 11 */ V(7, 0, 1), 678 /* 11 */ V(7, 0, 1),
679 679
680 /* 0000 0101 ... */ 680 /* 0000 0101 ... */
681 /* 00 */ V(6, 2, 1), /* 78 */ 681 /* 00 */ V(6, 2, 1), /* 78 */
682 /* 01 */ V(6, 2, 1), 682 /* 01 */ V(6, 2, 1),
683 /* 10 */ V(4, 5, 2), 683 /* 10 */ V(4, 5, 2),
684 /* 11 */ V(3, 5, 2), 684 /* 11 */ V(3, 5, 2),
685 685
686 /* 0000 0110 ... */ 686 /* 0000 0110 ... */
687 /* 00 */ V(0, 6, 1), /* 82 */ 687 /* 00 */ V(0, 6, 1), /* 82 */
688 /* 01 */ V(0, 6, 1), 688 /* 01 */ V(0, 6, 1),
689 /* 10 */ V(5, 3, 2), 689 /* 10 */ V(5, 3, 2),
690 /* 11 */ V(4, 4, 2), 690 /* 11 */ V(4, 4, 2),
691 691
692 /* 0000 1001 ... */ 692 /* 0000 1001 ... */
693 /* 0 */ V(3, 6, 1), /* 86 */ 693 /* 0 */ V(3, 6, 1), /* 86 */
694 /* 1 */ V(2, 6, 1), 694 /* 1 */ V(2, 6, 1),
695 695
696 /* 0000 1010 ... */ 696 /* 0000 1010 ... */
697 /* 00 */ V(2, 5, 2), /* 88 */ 697 /* 00 */ V(2, 5, 2), /* 88 */
698 /* 01 */ V(5, 2, 2), 698 /* 01 */ V(5, 2, 2),
699 /* 10 */ V(1, 5, 1), 699 /* 10 */ V(1, 5, 1),
700 /* 11 */ V(1, 5, 1), 700 /* 11 */ V(1, 5, 1),
701 701
702 /* 0000 1011 ... */ 702 /* 0000 1011 ... */
703 /* 00 */ V(5, 1, 1), /* 92 */ 703 /* 00 */ V(5, 1, 1), /* 92 */
704 /* 01 */ V(5, 1, 1), 704 /* 01 */ V(5, 1, 1),
705 /* 10 */ V(3, 4, 2), 705 /* 10 */ V(3, 4, 2),
706 /* 11 */ V(4, 3, 2), 706 /* 11 */ V(4, 3, 2),
707 707
708 /* 0000 1111 ... */ 708 /* 0000 1111 ... */
709 /* 0 */ V(0, 5, 1), /* 96 */ 709 /* 0 */ V(0, 5, 1), /* 96 */
710 /* 1 */ V(5, 0, 1), 710 /* 1 */ V(5, 0, 1),
711 711
712 /* 0001 0000 ... */ 712 /* 0001 0000 ... */
713 /* 0 */ V(2, 4, 1), /* 98 */ 713 /* 0 */ V(2, 4, 1), /* 98 */
714 /* 1 */ V(4, 2, 1), 714 /* 1 */ V(4, 2, 1),
715 715
716 /* 0001 0001 ... */ 716 /* 0001 0001 ... */
717 /* 0 */ V(3, 3, 1), /* 100 */ 717 /* 0 */ V(3, 3, 1), /* 100 */
718 /* 1 */ V(0, 4, 1) 718 /* 1 */ V(0, 4, 1)
719}; 719};
720 720
@@ -738,7 +738,7 @@ union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = {
738 /* 1111 */ V(0, 0, 2), 738 /* 1111 */ V(0, 0, 2),
739 739
740 /* 0000 ... */ 740 /* 0000 ... */
741 /* 0000 */ PTR(74, 2), /* 16 */ 741 /* 0000 */ PTR(74, 2), /* 16 */
742 /* 0001 */ PTR(78, 3), 742 /* 0001 */ PTR(78, 3),
743 /* 0010 */ PTR(86, 2), 743 /* 0010 */ PTR(86, 2),
744 /* 0011 */ PTR(90, 1), 744 /* 0011 */ PTR(90, 1),
@@ -756,7 +756,7 @@ union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = {
756 /* 1111 */ PTR(98, 1), 756 /* 1111 */ PTR(98, 1),
757 757
758 /* 0001 ... */ 758 /* 0001 ... */
759 /* 0000 */ PTR(100, 1), /* 32 */ 759 /* 0000 */ PTR(100, 1), /* 32 */
760 /* 0001 */ V(1, 5, 4), 760 /* 0001 */ V(1, 5, 4),
761 /* 0010 */ V(6, 2, 3), 761 /* 0010 */ V(6, 2, 3),
762 /* 0011 */ V(6, 2, 3), 762 /* 0011 */ V(6, 2, 3),
@@ -774,7 +774,7 @@ union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = {
774 /* 1111 */ V(4, 2, 4), 774 /* 1111 */ V(4, 2, 4),
775 775
776 /* 0010 ... */ 776 /* 0010 ... */
777 /* 0000 */ V(1, 4, 4), /* 48 */ 777 /* 0000 */ V(1, 4, 4), /* 48 */
778 /* 0001 */ V(4, 1, 4), 778 /* 0001 */ V(4, 1, 4),
779 /* 0010 */ V(0, 4, 4), 779 /* 0010 */ V(0, 4, 4),
780 /* 0011 */ V(4, 0, 4), 780 /* 0011 */ V(4, 0, 4),
@@ -792,7 +792,7 @@ union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = {
792 /* 1111 */ V(3, 1, 2), 792 /* 1111 */ V(3, 1, 2),
793 793
794 /* 0011 ... */ 794 /* 0011 ... */
795 /* 000 */ V(0, 3, 3), /* 64 */ 795 /* 000 */ V(0, 3, 3), /* 64 */
796 /* 001 */ V(3, 0, 3), 796 /* 001 */ V(3, 0, 3),
797 /* 010 */ V(2, 2, 2), 797 /* 010 */ V(2, 2, 2),
798 /* 011 */ V(2, 2, 2), 798 /* 011 */ V(2, 2, 2),
@@ -802,17 +802,17 @@ union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = {
802 /* 111 */ V(2, 1, 1), 802 /* 111 */ V(2, 1, 1),
803 803
804 /* 0101 ... */ 804 /* 0101 ... */
805 /* 0 */ V(0, 2, 1), /* 72 */ 805 /* 0 */ V(0, 2, 1), /* 72 */
806 /* 1 */ V(2, 0, 1), 806 /* 1 */ V(2, 0, 1),
807 807
808 /* 0000 0000 ... */ 808 /* 0000 0000 ... */
809 /* 00 */ V(7, 7, 2), /* 74 */ 809 /* 00 */ V(7, 7, 2), /* 74 */
810 /* 01 */ V(6, 7, 2), 810 /* 01 */ V(6, 7, 2),
811 /* 10 */ V(7, 6, 2), 811 /* 10 */ V(7, 6, 2),
812 /* 11 */ V(7, 5, 2), 812 /* 11 */ V(7, 5, 2),
813 813
814 /* 0000 0001 ... */ 814 /* 0000 0001 ... */
815 /* 000 */ V(6, 6, 2), /* 78 */ 815 /* 000 */ V(6, 6, 2), /* 78 */
816 /* 001 */ V(6, 6, 2), 816 /* 001 */ V(6, 6, 2),
817 /* 010 */ V(4, 7, 2), 817 /* 010 */ V(4, 7, 2),
818 /* 011 */ V(4, 7, 2), 818 /* 011 */ V(4, 7, 2),
@@ -822,35 +822,35 @@ union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = {
822 /* 111 */ V(5, 5, 3), 822 /* 111 */ V(5, 5, 3),
823 823
824 /* 0000 0010 ... */ 824 /* 0000 0010 ... */
825 /* 00 */ V(5, 6, 2), /* 86 */ 825 /* 00 */ V(5, 6, 2), /* 86 */
826 /* 01 */ V(6, 5, 2), 826 /* 01 */ V(6, 5, 2),
827 /* 10 */ V(3, 7, 1), 827 /* 10 */ V(3, 7, 1),
828 /* 11 */ V(3, 7, 1), 828 /* 11 */ V(3, 7, 1),
829 829
830 /* 0000 0011 ... */ 830 /* 0000 0011 ... */
831 /* 0 */ V(7, 3, 1), /* 90 */ 831 /* 0 */ V(7, 3, 1), /* 90 */
832 /* 1 */ V(4, 6, 1), 832 /* 1 */ V(4, 6, 1),
833 833
834 /* 0000 0100 ... */ 834 /* 0000 0100 ... */
835 /* 00 */ V(4, 5, 2), /* 92 */ 835 /* 00 */ V(4, 5, 2), /* 92 */
836 /* 01 */ V(5, 4, 2), 836 /* 01 */ V(5, 4, 2),
837 /* 10 */ V(3, 5, 2), 837 /* 10 */ V(3, 5, 2),
838 /* 11 */ V(5, 3, 2), 838 /* 11 */ V(5, 3, 2),
839 839
840 /* 0000 0111 ... */ 840 /* 0000 0111 ... */
841 /* 0 */ V(6, 4, 1), /* 96 */ 841 /* 0 */ V(6, 4, 1), /* 96 */
842 /* 1 */ V(0, 7, 1), 842 /* 1 */ V(0, 7, 1),
843 843
844 /* 0000 1111 ... */ 844 /* 0000 1111 ... */
845 /* 0 */ V(4, 4, 1), /* 98 */ 845 /* 0 */ V(4, 4, 1), /* 98 */
846 /* 1 */ V(2, 5, 1), 846 /* 1 */ V(2, 5, 1),
847 847
848 /* 0001 0000 ... */ 848 /* 0001 0000 ... */
849 /* 0 */ V(5, 2, 1), /* 100 */ 849 /* 0 */ V(5, 2, 1), /* 100 */
850 /* 1 */ V(0, 5, 1), 850 /* 1 */ V(0, 5, 1),
851 851
852 /* 0001 1101 ... */ 852 /* 0001 1101 ... */
853 /* 0 */ V(4, 3, 1), /* 102 */ 853 /* 0 */ V(4, 3, 1), /* 102 */
854 /* 1 */ V(3, 3, 1) 854 /* 1 */ V(3, 3, 1)
855}; 855};
856 856
@@ -874,7 +874,7 @@ union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = {
874 /* 1111 */ V(1, 0, 3), 874 /* 1111 */ V(1, 0, 3),
875 875
876 /* 0000 ... */ 876 /* 0000 ... */
877 /* 0000 */ PTR(80, 2), /* 16 */ 877 /* 0000 */ PTR(80, 2), /* 16 */
878 /* 0001 */ PTR(84, 1), 878 /* 0001 */ PTR(84, 1),
879 /* 0010 */ PTR(86, 1), 879 /* 0010 */ PTR(86, 1),
880 /* 0011 */ PTR(88, 1), 880 /* 0011 */ PTR(88, 1),
@@ -892,7 +892,7 @@ union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = {
892 /* 1111 */ V(6, 3, 4), 892 /* 1111 */ V(6, 3, 4),
893 893
894 /* 0001 ... */ 894 /* 0001 ... */
895 /* 0000 */ V(4, 5, 4), /* 32 */ 895 /* 0000 */ V(4, 5, 4), /* 32 */
896 /* 0001 */ V(5, 4, 4), 896 /* 0001 */ V(5, 4, 4),
897 /* 0010 */ V(4, 4, 4), 897 /* 0010 */ V(4, 4, 4),
898 /* 0011 */ PTR(94, 1), 898 /* 0011 */ PTR(94, 1),
@@ -910,7 +910,7 @@ union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = {
910 /* 1111 */ V(5, 2, 4), 910 /* 1111 */ V(5, 2, 4),
911 911
912 /* 0010 ... */ 912 /* 0010 ... */
913 /* 0000 */ V(1, 5, 3), /* 48 */ 913 /* 0000 */ V(1, 5, 3), /* 48 */
914 /* 0001 */ V(1, 5, 3), 914 /* 0001 */ V(1, 5, 3),
915 /* 0010 */ V(5, 1, 3), 915 /* 0010 */ V(5, 1, 3),
916 /* 0011 */ V(5, 1, 3), 916 /* 0011 */ V(5, 1, 3),
@@ -928,13 +928,13 @@ union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = {
928 /* 1111 */ V(1, 4, 3), 928 /* 1111 */ V(1, 4, 3),
929 929
930 /* 0011 ... */ 930 /* 0011 ... */
931 /* 00 */ V(3, 3, 2), /* 64 */ 931 /* 00 */ V(3, 3, 2), /* 64 */
932 /* 01 */ V(4, 1, 2), 932 /* 01 */ V(4, 1, 2),
933 /* 10 */ V(2, 3, 2), 933 /* 10 */ V(2, 3, 2),
934 /* 11 */ V(3, 2, 2), 934 /* 11 */ V(3, 2, 2),
935 935
936 /* 0100 ... */ 936 /* 0100 ... */
937 /* 000 */ V(4, 0, 3), /* 68 */ 937 /* 000 */ V(4, 0, 3), /* 68 */
938 /* 001 */ V(0, 3, 3), 938 /* 001 */ V(0, 3, 3),
939 /* 010 */ V(3, 0, 2), 939 /* 010 */ V(3, 0, 2),
940 /* 011 */ V(3, 0, 2), 940 /* 011 */ V(3, 0, 2),
@@ -944,41 +944,41 @@ union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = {
944 /* 111 */ V(1, 3, 1), 944 /* 111 */ V(1, 3, 1),
945 945
946 /* 0101 ... */ 946 /* 0101 ... */
947 /* 0 */ V(3, 1, 1), /* 76 */ 947 /* 0 */ V(3, 1, 1), /* 76 */
948 /* 1 */ V(2, 2, 1), 948 /* 1 */ V(2, 2, 1),
949 949
950 /* 1000 ... */ 950 /* 1000 ... */
951 /* 0 */ V(0, 2, 1), /* 78 */ 951 /* 0 */ V(0, 2, 1), /* 78 */
952 /* 1 */ V(2, 0, 1), 952 /* 1 */ V(2, 0, 1),
953 953
954 /* 0000 0000 ... */ 954 /* 0000 0000 ... */
955 /* 00 */ V(7, 7, 2), /* 80 */ 955 /* 00 */ V(7, 7, 2), /* 80 */
956 /* 01 */ V(6, 7, 2), 956 /* 01 */ V(6, 7, 2),
957 /* 10 */ V(7, 6, 1), 957 /* 10 */ V(7, 6, 1),
958 /* 11 */ V(7, 6, 1), 958 /* 11 */ V(7, 6, 1),
959 959
960 /* 0000 0001 ... */ 960 /* 0000 0001 ... */
961 /* 0 */ V(5, 7, 1), /* 84 */ 961 /* 0 */ V(5, 7, 1), /* 84 */
962 /* 1 */ V(7, 5, 1), 962 /* 1 */ V(7, 5, 1),
963 963
964 /* 0000 0010 ... */ 964 /* 0000 0010 ... */
965 /* 0 */ V(6, 6, 1), /* 86 */ 965 /* 0 */ V(6, 6, 1), /* 86 */
966 /* 1 */ V(4, 7, 1), 966 /* 1 */ V(4, 7, 1),
967 967
968 /* 0000 0011 ... */ 968 /* 0000 0011 ... */
969 /* 0 */ V(7, 4, 1), /* 88 */ 969 /* 0 */ V(7, 4, 1), /* 88 */
970 /* 1 */ V(6, 5, 1), 970 /* 1 */ V(6, 5, 1),
971 971
972 /* 0000 0110 ... */ 972 /* 0000 0110 ... */
973 /* 0 */ V(7, 3, 1), /* 90 */ 973 /* 0 */ V(7, 3, 1), /* 90 */
974 /* 1 */ V(5, 5, 1), 974 /* 1 */ V(5, 5, 1),
975 975
976 /* 0000 1101 ... */ 976 /* 0000 1101 ... */
977 /* 0 */ V(0, 7, 1), /* 92 */ 977 /* 0 */ V(0, 7, 1), /* 92 */
978 /* 1 */ V(7, 0, 1), 978 /* 1 */ V(7, 0, 1),
979 979
980 /* 0001 0011 ... */ 980 /* 0001 0011 ... */
981 /* 0 */ V(0, 6, 1), /* 94 */ 981 /* 0 */ V(0, 6, 1), /* 94 */
982 /* 1 */ V(0, 5, 1) 982 /* 1 */ V(0, 5, 1)
983}; 983};
984 984
@@ -1002,7 +1002,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1002 /* 1111 */ V(0, 0, 1), 1002 /* 1111 */ V(0, 0, 1),
1003 1003
1004 /* 0000 ... */ 1004 /* 0000 ... */
1005 /* 0000 */ PTR(68, 4), /* 16 */ 1005 /* 0000 */ PTR(68, 4), /* 16 */
1006 /* 0001 */ PTR(84, 4), 1006 /* 0001 */ PTR(84, 4),
1007 /* 0010 */ PTR(100, 4), 1007 /* 0010 */ PTR(100, 4),
1008 /* 0011 */ PTR(116, 4), 1008 /* 0011 */ PTR(116, 4),
@@ -1020,7 +1020,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1020 /* 1111 */ PTR(226, 1), 1020 /* 1111 */ PTR(226, 1),
1021 1021
1022 /* 0001 ... */ 1022 /* 0001 ... */
1023 /* 0000 */ PTR(228, 2), /* 32 */ 1023 /* 0000 */ PTR(228, 2), /* 32 */
1024 /* 0001 */ PTR(232, 2), 1024 /* 0001 */ PTR(232, 2),
1025 /* 0010 */ PTR(236, 2), 1025 /* 0010 */ PTR(236, 2),
1026 /* 0011 */ PTR(240, 2), 1026 /* 0011 */ PTR(240, 2),
@@ -1038,7 +1038,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1038 /* 1111 */ V(1, 4, 4), 1038 /* 1111 */ V(1, 4, 4),
1039 1039
1040 /* 0010 ... */ 1040 /* 0010 ... */
1041 /* 0000 */ V(4, 1, 3), /* 48 */ 1041 /* 0000 */ V(4, 1, 3), /* 48 */
1042 /* 0001 */ V(4, 1, 3), 1042 /* 0001 */ V(4, 1, 3),
1043 /* 0010 */ V(0, 4, 4), 1043 /* 0010 */ V(0, 4, 4),
1044 /* 0011 */ V(4, 0, 4), 1044 /* 0011 */ V(4, 0, 4),
@@ -1056,13 +1056,13 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1056 /* 1111 */ V(2, 2, 3), 1056 /* 1111 */ V(2, 2, 3),
1057 1057
1058 /* 0011 ... */ 1058 /* 0011 ... */
1059 /* 00 */ V(1, 2, 2), /* 64 */ 1059 /* 00 */ V(1, 2, 2), /* 64 */
1060 /* 01 */ V(2, 1, 2), 1060 /* 01 */ V(2, 1, 2),
1061 /* 10 */ V(0, 2, 2), 1061 /* 10 */ V(0, 2, 2),
1062 /* 11 */ V(2, 0, 2), 1062 /* 11 */ V(2, 0, 2),
1063 1063
1064 /* 0000 0000 ... */ 1064 /* 0000 0000 ... */
1065 /* 0000 */ PTR(262, 4), /* 68 */ 1065 /* 0000 */ PTR(262, 4), /* 68 */
1066 /* 0001 */ PTR(278, 4), 1066 /* 0001 */ PTR(278, 4),
1067 /* 0010 */ PTR(294, 4), 1067 /* 0010 */ PTR(294, 4),
1068 /* 0011 */ PTR(310, 3), 1068 /* 0011 */ PTR(310, 3),
@@ -1080,7 +1080,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1080 /* 1111 */ V(15, 1, 4), 1080 /* 1111 */ V(15, 1, 4),
1081 1081
1082 /* 0000 0001 ... */ 1082 /* 0000 0001 ... */
1083 /* 0000 */ V(15, 0, 4), /* 84 */ 1083 /* 0000 */ V(15, 0, 4), /* 84 */
1084 /* 0001 */ PTR(360, 1), 1084 /* 0001 */ PTR(360, 1),
1085 /* 0010 */ PTR(362, 1), 1085 /* 0010 */ PTR(362, 1),
1086 /* 0011 */ PTR(364, 1), 1086 /* 0011 */ PTR(364, 1),
@@ -1098,7 +1098,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1098 /* 1111 */ V(3, 13, 4), 1098 /* 1111 */ V(3, 13, 4),
1099 1099
1100 /* 0000 0010 ... */ 1100 /* 0000 0010 ... */
1101 /* 0000 */ PTR(380, 1), /* 100 */ 1101 /* 0000 */ PTR(380, 1), /* 100 */
1102 /* 0001 */ V(2, 13, 4), 1102 /* 0001 */ V(2, 13, 4),
1103 /* 0010 */ V(13, 2, 4), 1103 /* 0010 */ V(13, 2, 4),
1104 /* 0011 */ V(1, 13, 4), 1104 /* 0011 */ V(1, 13, 4),
@@ -1116,7 +1116,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1116 /* 1111 */ V(10, 8, 4), 1116 /* 1111 */ V(10, 8, 4),
1117 1117
1118 /* 0000 0011 ... */ 1118 /* 0000 0011 ... */
1119 /* 0000 */ V(4, 12, 4), /* 116 */ 1119 /* 0000 */ V(4, 12, 4), /* 116 */
1120 /* 0001 */ V(12, 4, 4), 1120 /* 0001 */ V(12, 4, 4),
1121 /* 0010 */ V(6, 11, 4), 1121 /* 0010 */ V(6, 11, 4),
1122 /* 0011 */ V(11, 6, 4), 1122 /* 0011 */ V(11, 6, 4),
@@ -1134,7 +1134,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1134 /* 1111 */ V(1, 12, 3), 1134 /* 1111 */ V(1, 12, 3),
1135 1135
1136 /* 0000 0100 ... */ 1136 /* 0000 0100 ... */
1137 /* 0000 */ V(12, 1, 3), /* 132 */ 1137 /* 0000 */ V(12, 1, 3), /* 132 */
1138 /* 0001 */ V(12, 1, 3), 1138 /* 0001 */ V(12, 1, 3),
1139 /* 0010 */ V(9, 8, 4), 1139 /* 0010 */ V(9, 8, 4),
1140 /* 0011 */ V(0, 12, 4), 1140 /* 0011 */ V(0, 12, 4),
@@ -1152,7 +1152,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1152 /* 1111 */ V(5, 10, 4), 1152 /* 1111 */ V(5, 10, 4),
1153 1153
1154 /* 0000 0101 ... */ 1154 /* 0000 0101 ... */
1155 /* 0000 */ V(2, 11, 3), /* 148 */ 1155 /* 0000 */ V(2, 11, 3), /* 148 */
1156 /* 0001 */ V(2, 11, 3), 1156 /* 0001 */ V(2, 11, 3),
1157 /* 0010 */ V(10, 5, 4), 1157 /* 0010 */ V(10, 5, 4),
1158 /* 0011 */ V(6, 9, 4), 1158 /* 0011 */ V(6, 9, 4),
@@ -1170,7 +1170,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1170 /* 1111 */ V(11, 2, 2), 1170 /* 1111 */ V(11, 2, 2),
1171 1171
1172 /* 0000 0110 ... */ 1172 /* 0000 0110 ... */
1173 /* 000 */ V(1, 11, 2), /* 164 */ 1173 /* 000 */ V(1, 11, 2), /* 164 */
1174 /* 001 */ V(1, 11, 2), 1174 /* 001 */ V(1, 11, 2),
1175 /* 010 */ V(11, 1, 2), 1175 /* 010 */ V(11, 1, 2),
1176 /* 011 */ V(11, 1, 2), 1176 /* 011 */ V(11, 1, 2),
@@ -1180,7 +1180,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1180 /* 111 */ V(4, 10, 3), 1180 /* 111 */ V(4, 10, 3),
1181 1181
1182 /* 0000 0111 ... */ 1182 /* 0000 0111 ... */
1183 /* 000 */ V(3, 10, 3), /* 172 */ 1183 /* 000 */ V(3, 10, 3), /* 172 */
1184 /* 001 */ V(10, 3, 3), 1184 /* 001 */ V(10, 3, 3),
1185 /* 010 */ V(5, 9, 3), 1185 /* 010 */ V(5, 9, 3),
1186 /* 011 */ V(9, 5, 3), 1186 /* 011 */ V(9, 5, 3),
@@ -1190,7 +1190,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1190 /* 111 */ V(10, 2, 2), 1190 /* 111 */ V(10, 2, 2),
1191 1191
1192 /* 0000 1000 ... */ 1192 /* 0000 1000 ... */
1193 /* 000 */ V(1, 10, 2), /* 180 */ 1193 /* 000 */ V(1, 10, 2), /* 180 */
1194 /* 001 */ V(1, 10, 2), 1194 /* 001 */ V(1, 10, 2),
1195 /* 010 */ V(10, 1, 2), 1195 /* 010 */ V(10, 1, 2),
1196 /* 011 */ V(10, 1, 2), 1196 /* 011 */ V(10, 1, 2),
@@ -1200,7 +1200,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1200 /* 111 */ V(10, 0, 2), 1200 /* 111 */ V(10, 0, 2),
1201 1201
1202 /* 0000 1001 ... */ 1202 /* 0000 1001 ... */
1203 /* 000 */ V(8, 6, 3), /* 188 */ 1203 /* 000 */ V(8, 6, 3), /* 188 */
1204 /* 001 */ V(4, 9, 3), 1204 /* 001 */ V(4, 9, 3),
1205 /* 010 */ V(9, 3, 2), 1205 /* 010 */ V(9, 3, 2),
1206 /* 011 */ V(9, 3, 2), 1206 /* 011 */ V(9, 3, 2),
@@ -1210,7 +1210,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1210 /* 111 */ V(6, 7, 3), 1210 /* 111 */ V(6, 7, 3),
1211 1211
1212 /* 0000 1010 ... */ 1212 /* 0000 1010 ... */
1213 /* 000 */ V(2, 9, 2), /* 196 */ 1213 /* 000 */ V(2, 9, 2), /* 196 */
1214 /* 001 */ V(2, 9, 2), 1214 /* 001 */ V(2, 9, 2),
1215 /* 010 */ V(9, 2, 2), 1215 /* 010 */ V(9, 2, 2),
1216 /* 011 */ V(9, 2, 2), 1216 /* 011 */ V(9, 2, 2),
@@ -1220,7 +1220,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1220 /* 111 */ V(3, 8, 2), 1220 /* 111 */ V(3, 8, 2),
1221 1221
1222 /* 0000 1011 ... */ 1222 /* 0000 1011 ... */
1223 /* 000 */ V(8, 3, 2), /* 204 */ 1223 /* 000 */ V(8, 3, 2), /* 204 */
1224 /* 001 */ V(8, 3, 2), 1224 /* 001 */ V(8, 3, 2),
1225 /* 010 */ V(6, 6, 3), 1225 /* 010 */ V(6, 6, 3),
1226 /* 011 */ V(4, 7, 3), 1226 /* 011 */ V(4, 7, 3),
@@ -1230,17 +1230,17 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1230 /* 111 */ V(7, 3, 3), 1230 /* 111 */ V(7, 3, 3),
1231 1231
1232 /* 0000 1100 ... */ 1232 /* 0000 1100 ... */
1233 /* 0 */ V(1, 9, 1), /* 212 */ 1233 /* 0 */ V(1, 9, 1), /* 212 */
1234 /* 1 */ V(9, 1, 1), 1234 /* 1 */ V(9, 1, 1),
1235 1235
1236 /* 0000 1101 ... */ 1236 /* 0000 1101 ... */
1237 /* 00 */ V(0, 9, 2), /* 214 */ 1237 /* 00 */ V(0, 9, 2), /* 214 */
1238 /* 01 */ V(9, 0, 2), 1238 /* 01 */ V(9, 0, 2),
1239 /* 10 */ V(4, 8, 2), 1239 /* 10 */ V(4, 8, 2),
1240 /* 11 */ V(8, 4, 2), 1240 /* 11 */ V(8, 4, 2),
1241 1241
1242 /* 0000 1110 ... */ 1242 /* 0000 1110 ... */
1243 /* 000 */ V(7, 2, 2), /* 218 */ 1243 /* 000 */ V(7, 2, 2), /* 218 */
1244 /* 001 */ V(7, 2, 2), 1244 /* 001 */ V(7, 2, 2),
1245 /* 010 */ V(4, 6, 3), 1245 /* 010 */ V(4, 6, 3),
1246 /* 011 */ V(6, 4, 3), 1246 /* 011 */ V(6, 4, 3),
@@ -1250,69 +1250,69 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1250 /* 111 */ V(2, 8, 1), 1250 /* 111 */ V(2, 8, 1),
1251 1251
1252 /* 0000 1111 ... */ 1252 /* 0000 1111 ... */
1253 /* 0 */ V(8, 2, 1), /* 226 */ 1253 /* 0 */ V(8, 2, 1), /* 226 */
1254 /* 1 */ V(1, 8, 1), 1254 /* 1 */ V(1, 8, 1),
1255 1255
1256 /* 0001 0000 ... */ 1256 /* 0001 0000 ... */
1257 /* 00 */ V(3, 7, 2), /* 228 */ 1257 /* 00 */ V(3, 7, 2), /* 228 */
1258 /* 01 */ V(2, 7, 2), 1258 /* 01 */ V(2, 7, 2),
1259 /* 10 */ V(1, 7, 1), 1259 /* 10 */ V(1, 7, 1),
1260 /* 11 */ V(1, 7, 1), 1260 /* 11 */ V(1, 7, 1),
1261 1261
1262 /* 0001 0001 ... */ 1262 /* 0001 0001 ... */
1263 /* 00 */ V(7, 1, 1), /* 232 */ 1263 /* 00 */ V(7, 1, 1), /* 232 */
1264 /* 01 */ V(7, 1, 1), 1264 /* 01 */ V(7, 1, 1),
1265 /* 10 */ V(5, 5, 2), 1265 /* 10 */ V(5, 5, 2),
1266 /* 11 */ V(0, 7, 2), 1266 /* 11 */ V(0, 7, 2),
1267 1267
1268 /* 0001 0010 ... */ 1268 /* 0001 0010 ... */
1269 /* 00 */ V(7, 0, 2), /* 236 */ 1269 /* 00 */ V(7, 0, 2), /* 236 */
1270 /* 01 */ V(3, 6, 2), 1270 /* 01 */ V(3, 6, 2),
1271 /* 10 */ V(6, 3, 2), 1271 /* 10 */ V(6, 3, 2),
1272 /* 11 */ V(4, 5, 2), 1272 /* 11 */ V(4, 5, 2),
1273 1273
1274 /* 0001 0011 ... */ 1274 /* 0001 0011 ... */
1275 /* 00 */ V(5, 4, 2), /* 240 */ 1275 /* 00 */ V(5, 4, 2), /* 240 */
1276 /* 01 */ V(2, 6, 2), 1276 /* 01 */ V(2, 6, 2),
1277 /* 10 */ V(6, 2, 2), 1277 /* 10 */ V(6, 2, 2),
1278 /* 11 */ V(3, 5, 2), 1278 /* 11 */ V(3, 5, 2),
1279 1279
1280 /* 0001 0101 ... */ 1280 /* 0001 0101 ... */
1281 /* 0 */ V(0, 8, 1), /* 244 */ 1281 /* 0 */ V(0, 8, 1), /* 244 */
1282 /* 1 */ V(8, 0, 1), 1282 /* 1 */ V(8, 0, 1),
1283 1283
1284 /* 0001 0110 ... */ 1284 /* 0001 0110 ... */
1285 /* 0 */ V(1, 6, 1), /* 246 */ 1285 /* 0 */ V(1, 6, 1), /* 246 */
1286 /* 1 */ V(6, 1, 1), 1286 /* 1 */ V(6, 1, 1),
1287 1287
1288 /* 0001 0111 ... */ 1288 /* 0001 0111 ... */
1289 /* 0 */ V(0, 6, 1), /* 248 */ 1289 /* 0 */ V(0, 6, 1), /* 248 */
1290 /* 1 */ V(6, 0, 1), 1290 /* 1 */ V(6, 0, 1),
1291 1291
1292 /* 0001 1000 ... */ 1292 /* 0001 1000 ... */
1293 /* 00 */ V(5, 3, 2), /* 250 */ 1293 /* 00 */ V(5, 3, 2), /* 250 */
1294 /* 01 */ V(4, 4, 2), 1294 /* 01 */ V(4, 4, 2),
1295 /* 10 */ V(2, 5, 1), 1295 /* 10 */ V(2, 5, 1),
1296 /* 11 */ V(2, 5, 1), 1296 /* 11 */ V(2, 5, 1),
1297 1297
1298 /* 0001 1001 ... */ 1298 /* 0001 1001 ... */
1299 /* 0 */ V(5, 2, 1), /* 254 */ 1299 /* 0 */ V(5, 2, 1), /* 254 */
1300 /* 1 */ V(0, 5, 1), 1300 /* 1 */ V(0, 5, 1),
1301 1301
1302 /* 0001 1100 ... */ 1302 /* 0001 1100 ... */
1303 /* 0 */ V(3, 4, 1), /* 256 */ 1303 /* 0 */ V(3, 4, 1), /* 256 */
1304 /* 1 */ V(4, 3, 1), 1304 /* 1 */ V(4, 3, 1),
1305 1305
1306 /* 0001 1101 ... */ 1306 /* 0001 1101 ... */
1307 /* 0 */ V(5, 0, 1), /* 258 */ 1307 /* 0 */ V(5, 0, 1), /* 258 */
1308 /* 1 */ V(2, 4, 1), 1308 /* 1 */ V(2, 4, 1),
1309 1309
1310 /* 0001 1110 ... */ 1310 /* 0001 1110 ... */
1311 /* 0 */ V(4, 2, 1), /* 260 */ 1311 /* 0 */ V(4, 2, 1), /* 260 */
1312 /* 1 */ V(3, 3, 1), 1312 /* 1 */ V(3, 3, 1),
1313 1313
1314 /* 0000 0000 0000 ... */ 1314 /* 0000 0000 0000 ... */
1315 /* 0000 */ PTR(388, 3), /* 262 */ 1315 /* 0000 */ PTR(388, 3), /* 262 */
1316 /* 0001 */ V(15, 15, 4), 1316 /* 0001 */ V(15, 15, 4),
1317 /* 0010 */ V(14, 15, 4), 1317 /* 0010 */ V(14, 15, 4),
1318 /* 0011 */ V(13, 15, 4), 1318 /* 0011 */ V(13, 15, 4),
@@ -1330,7 +1330,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1330 /* 1111 */ V(13, 13, 3), 1330 /* 1111 */ V(13, 13, 3),
1331 1331
1332 /* 0000 0000 0001 ... */ 1332 /* 0000 0000 0001 ... */
1333 /* 0000 */ V(15, 10, 4), /* 278 */ 1333 /* 0000 */ V(15, 10, 4), /* 278 */
1334 /* 0001 */ V(12, 13, 4), 1334 /* 0001 */ V(12, 13, 4),
1335 /* 0010 */ V(11, 14, 3), 1335 /* 0010 */ V(11, 14, 3),
1336 /* 0011 */ V(11, 14, 3), 1336 /* 0011 */ V(11, 14, 3),
@@ -1348,7 +1348,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1348 /* 1111 */ V(13, 11, 3), 1348 /* 1111 */ V(13, 11, 3),
1349 1349
1350 /* 0000 0000 0010 ... */ 1350 /* 0000 0000 0010 ... */
1351 /* 0000 */ V(8, 15, 3), /* 294 */ 1351 /* 0000 */ V(8, 15, 3), /* 294 */
1352 /* 0001 */ V(8, 15, 3), 1352 /* 0001 */ V(8, 15, 3),
1353 /* 0010 */ V(15, 8, 3), 1353 /* 0010 */ V(15, 8, 3),
1354 /* 0011 */ V(15, 8, 3), 1354 /* 0011 */ V(15, 8, 3),
@@ -1366,7 +1366,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1366 /* 1111 */ V(15, 7, 2), 1366 /* 1111 */ V(15, 7, 2),
1367 1367
1368 /* 0000 0000 0011 ... */ 1368 /* 0000 0000 0011 ... */
1369 /* 000 */ V(13, 10, 2), /* 310 */ 1369 /* 000 */ V(13, 10, 2), /* 310 */
1370 /* 001 */ V(13, 10, 2), 1370 /* 001 */ V(13, 10, 2),
1371 /* 010 */ V(10, 13, 3), 1371 /* 010 */ V(10, 13, 3),
1372 /* 011 */ V(11, 12, 3), 1372 /* 011 */ V(11, 12, 3),
@@ -1376,19 +1376,19 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1376 /* 111 */ V(6, 15, 2), 1376 /* 111 */ V(6, 15, 2),
1377 1377
1378 /* 0000 0000 0100 ... */ 1378 /* 0000 0000 0100 ... */
1379 /* 00 */ V(14, 8, 2), /* 318 */ 1379 /* 00 */ V(14, 8, 2), /* 318 */
1380 /* 01 */ V(5, 15, 2), 1380 /* 01 */ V(5, 15, 2),
1381 /* 10 */ V(9, 13, 2), 1381 /* 10 */ V(9, 13, 2),
1382 /* 11 */ V(13, 9, 2), 1382 /* 11 */ V(13, 9, 2),
1383 1383
1384 /* 0000 0000 0101 ... */ 1384 /* 0000 0000 0101 ... */
1385 /* 00 */ V(15, 5, 2), /* 322 */ 1385 /* 00 */ V(15, 5, 2), /* 322 */
1386 /* 01 */ V(14, 7, 2), 1386 /* 01 */ V(14, 7, 2),
1387 /* 10 */ V(10, 12, 2), 1387 /* 10 */ V(10, 12, 2),
1388 /* 11 */ V(11, 11, 2), 1388 /* 11 */ V(11, 11, 2),
1389 1389
1390 /* 0000 0000 0110 ... */ 1390 /* 0000 0000 0110 ... */
1391 /* 000 */ V(4, 15, 2), /* 326 */ 1391 /* 000 */ V(4, 15, 2), /* 326 */
1392 /* 001 */ V(4, 15, 2), 1392 /* 001 */ V(4, 15, 2),
1393 /* 010 */ V(15, 4, 2), 1393 /* 010 */ V(15, 4, 2),
1394 /* 011 */ V(15, 4, 2), 1394 /* 011 */ V(15, 4, 2),
@@ -1398,103 +1398,103 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1398 /* 111 */ V(15, 3, 2), 1398 /* 111 */ V(15, 3, 2),
1399 1399
1400 /* 0000 0000 0111 ... */ 1400 /* 0000 0000 0111 ... */
1401 /* 00 */ V(3, 15, 1), /* 334 */ 1401 /* 00 */ V(3, 15, 1), /* 334 */
1402 /* 01 */ V(3, 15, 1), 1402 /* 01 */ V(3, 15, 1),
1403 /* 10 */ V(8, 13, 2), 1403 /* 10 */ V(8, 13, 2),
1404 /* 11 */ V(13, 8, 2), 1404 /* 11 */ V(13, 8, 2),
1405 1405
1406 /* 0000 0000 1000 ... */ 1406 /* 0000 0000 1000 ... */
1407 /* 0 */ V(2, 15, 1), /* 338 */ 1407 /* 0 */ V(2, 15, 1), /* 338 */
1408 /* 1 */ V(15, 2, 1), 1408 /* 1 */ V(15, 2, 1),
1409 1409
1410 /* 0000 0000 1001 ... */ 1410 /* 0000 0000 1001 ... */
1411 /* 00 */ V(6, 14, 2), /* 340 */ 1411 /* 00 */ V(6, 14, 2), /* 340 */
1412 /* 01 */ V(9, 12, 2), 1412 /* 01 */ V(9, 12, 2),
1413 /* 10 */ V(0, 15, 1), 1413 /* 10 */ V(0, 15, 1),
1414 /* 11 */ V(0, 15, 1), 1414 /* 11 */ V(0, 15, 1),
1415 1415
1416 /* 0000 0000 1010 ... */ 1416 /* 0000 0000 1010 ... */
1417 /* 00 */ V(12, 9, 2), /* 344 */ 1417 /* 00 */ V(12, 9, 2), /* 344 */
1418 /* 01 */ V(5, 14, 2), 1418 /* 01 */ V(5, 14, 2),
1419 /* 10 */ V(10, 11, 1), 1419 /* 10 */ V(10, 11, 1),
1420 /* 11 */ V(10, 11, 1), 1420 /* 11 */ V(10, 11, 1),
1421 1421
1422 /* 0000 0000 1011 ... */ 1422 /* 0000 0000 1011 ... */
1423 /* 00 */ V(7, 13, 2), /* 348 */ 1423 /* 00 */ V(7, 13, 2), /* 348 */
1424 /* 01 */ V(13, 7, 2), 1424 /* 01 */ V(13, 7, 2),
1425 /* 10 */ V(4, 14, 1), 1425 /* 10 */ V(4, 14, 1),
1426 /* 11 */ V(4, 14, 1), 1426 /* 11 */ V(4, 14, 1),
1427 1427
1428 /* 0000 0000 1100 ... */ 1428 /* 0000 0000 1100 ... */
1429 /* 00 */ V(12, 8, 2), /* 352 */ 1429 /* 00 */ V(12, 8, 2), /* 352 */
1430 /* 01 */ V(13, 6, 2), 1430 /* 01 */ V(13, 6, 2),
1431 /* 10 */ V(3, 14, 1), 1431 /* 10 */ V(3, 14, 1),
1432 /* 11 */ V(3, 14, 1), 1432 /* 11 */ V(3, 14, 1),
1433 1433
1434 /* 0000 0000 1101 ... */ 1434 /* 0000 0000 1101 ... */
1435 /* 00 */ V(11, 9, 1), /* 356 */ 1435 /* 00 */ V(11, 9, 1), /* 356 */
1436 /* 01 */ V(11, 9, 1), 1436 /* 01 */ V(11, 9, 1),
1437 /* 10 */ V(9, 11, 2), 1437 /* 10 */ V(9, 11, 2),
1438 /* 11 */ V(10, 10, 2), 1438 /* 11 */ V(10, 10, 2),
1439 1439
1440 /* 0000 0001 0001 ... */ 1440 /* 0000 0001 0001 ... */
1441 /* 0 */ V(11, 10, 1), /* 360 */ 1441 /* 0 */ V(11, 10, 1), /* 360 */
1442 /* 1 */ V(14, 5, 1), 1442 /* 1 */ V(14, 5, 1),
1443 1443
1444 /* 0000 0001 0010 ... */ 1444 /* 0000 0001 0010 ... */
1445 /* 0 */ V(14, 4, 1), /* 362 */ 1445 /* 0 */ V(14, 4, 1), /* 362 */
1446 /* 1 */ V(8, 12, 1), 1446 /* 1 */ V(8, 12, 1),
1447 1447
1448 /* 0000 0001 0011 ... */ 1448 /* 0000 0001 0011 ... */
1449 /* 0 */ V(6, 13, 1), /* 364 */ 1449 /* 0 */ V(6, 13, 1), /* 364 */
1450 /* 1 */ V(14, 3, 1), 1450 /* 1 */ V(14, 3, 1),
1451 1451
1452 /* 0000 0001 0101 ... */ 1452 /* 0000 0001 0101 ... */
1453 /* 0 */ V(2, 14, 1), /* 366 */ 1453 /* 0 */ V(2, 14, 1), /* 366 */
1454 /* 1 */ V(0, 14, 1), 1454 /* 1 */ V(0, 14, 1),
1455 1455
1456 /* 0000 0001 1000 ... */ 1456 /* 0000 0001 1000 ... */
1457 /* 0 */ V(14, 0, 1), /* 368 */ 1457 /* 0 */ V(14, 0, 1), /* 368 */
1458 /* 1 */ V(5, 13, 1), 1458 /* 1 */ V(5, 13, 1),
1459 1459
1460 /* 0000 0001 1001 ... */ 1460 /* 0000 0001 1001 ... */
1461 /* 0 */ V(13, 5, 1), /* 370 */ 1461 /* 0 */ V(13, 5, 1), /* 370 */
1462 /* 1 */ V(7, 12, 1), 1462 /* 1 */ V(7, 12, 1),
1463 1463
1464 /* 0000 0001 1010 ... */ 1464 /* 0000 0001 1010 ... */
1465 /* 0 */ V(12, 7, 1), /* 372 */ 1465 /* 0 */ V(12, 7, 1), /* 372 */
1466 /* 1 */ V(4, 13, 1), 1466 /* 1 */ V(4, 13, 1),
1467 1467
1468 /* 0000 0001 1011 ... */ 1468 /* 0000 0001 1011 ... */
1469 /* 0 */ V(8, 11, 1), /* 374 */ 1469 /* 0 */ V(8, 11, 1), /* 374 */
1470 /* 1 */ V(11, 8, 1), 1470 /* 1 */ V(11, 8, 1),
1471 1471
1472 /* 0000 0001 1100 ... */ 1472 /* 0000 0001 1100 ... */
1473 /* 0 */ V(13, 4, 1), /* 376 */ 1473 /* 0 */ V(13, 4, 1), /* 376 */
1474 /* 1 */ V(9, 10, 1), 1474 /* 1 */ V(9, 10, 1),
1475 1475
1476 /* 0000 0001 1101 ... */ 1476 /* 0000 0001 1101 ... */
1477 /* 0 */ V(10, 9, 1), /* 378 */ 1477 /* 0 */ V(10, 9, 1), /* 378 */
1478 /* 1 */ V(6, 12, 1), 1478 /* 1 */ V(6, 12, 1),
1479 1479
1480 /* 0000 0010 0000 ... */ 1480 /* 0000 0010 0000 ... */
1481 /* 0 */ V(13, 3, 1), /* 380 */ 1481 /* 0 */ V(13, 3, 1), /* 380 */
1482 /* 1 */ V(7, 11, 1), 1482 /* 1 */ V(7, 11, 1),
1483 1483
1484 /* 0000 0010 0101 ... */ 1484 /* 0000 0010 0101 ... */
1485 /* 0 */ V(5, 12, 1), /* 382 */ 1485 /* 0 */ V(5, 12, 1), /* 382 */
1486 /* 1 */ V(12, 5, 1), 1486 /* 1 */ V(12, 5, 1),
1487 1487
1488 /* 0000 0010 0110 ... */ 1488 /* 0000 0010 0110 ... */
1489 /* 0 */ V(9, 9, 1), /* 384 */ 1489 /* 0 */ V(9, 9, 1), /* 384 */
1490 /* 1 */ V(7, 10, 1), 1490 /* 1 */ V(7, 10, 1),
1491 1491
1492 /* 0000 0010 1000 ... */ 1492 /* 0000 0010 1000 ... */
1493 /* 0 */ V(10, 7, 1), /* 386 */ 1493 /* 0 */ V(10, 7, 1), /* 386 */
1494 /* 1 */ V(9, 7, 1), 1494 /* 1 */ V(9, 7, 1),
1495 1495
1496 /* 0000 0000 0000 0000 ... */ 1496 /* 0000 0000 0000 0000 ... */
1497 /* 000 */ V(15, 14, 3), /* 388 */ 1497 /* 000 */ V(15, 14, 3), /* 388 */
1498 /* 001 */ V(15, 12, 3), 1498 /* 001 */ V(15, 12, 3),
1499 /* 010 */ V(15, 13, 2), 1499 /* 010 */ V(15, 13, 2),
1500 /* 011 */ V(15, 13, 2), 1500 /* 011 */ V(15, 13, 2),
@@ -1504,7 +1504,7 @@ union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = {
1504 /* 111 */ V(14, 13, 1), 1504 /* 111 */ V(14, 13, 1),
1505 1505
1506 /* 0000 0000 0000 1011 ... */ 1506 /* 0000 0000 0000 1011 ... */
1507 /* 0 */ V(10, 15, 1), /* 396 */ 1507 /* 0 */ V(10, 15, 1), /* 396 */
1508 /* 1 */ V(14, 9, 1) 1508 /* 1 */ V(14, 9, 1)
1509}; 1509};
1510 1510
@@ -1528,7 +1528,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1528 /* 1111 */ V(0, 0, 3), 1528 /* 1111 */ V(0, 0, 3),
1529 1529
1530 /* 0000 ... */ 1530 /* 0000 ... */
1531 /* 0000 */ PTR(120, 4), /* 16 */ 1531 /* 0000 */ PTR(120, 4), /* 16 */
1532 /* 0001 */ PTR(136, 4), 1532 /* 0001 */ PTR(136, 4),
1533 /* 0010 */ PTR(152, 4), 1533 /* 0010 */ PTR(152, 4),
1534 /* 0011 */ PTR(168, 4), 1534 /* 0011 */ PTR(168, 4),
@@ -1546,7 +1546,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1546 /* 1111 */ PTR(284, 2), 1546 /* 1111 */ PTR(284, 2),
1547 1547
1548 /* 0001 ... */ 1548 /* 0001 ... */
1549 /* 0000 */ PTR(288, 2), /* 32 */ 1549 /* 0000 */ PTR(288, 2), /* 32 */
1550 /* 0001 */ PTR(292, 2), 1550 /* 0001 */ PTR(292, 2),
1551 /* 0010 */ PTR(296, 2), 1551 /* 0010 */ PTR(296, 2),
1552 /* 0011 */ PTR(300, 2), 1552 /* 0011 */ PTR(300, 2),
@@ -1564,7 +1564,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1564 /* 1111 */ PTR(338, 1), 1564 /* 1111 */ PTR(338, 1),
1565 1565
1566 /* 0010 ... */ 1566 /* 0010 ... */
1567 /* 0000 */ PTR(340, 1), /* 48 */ 1567 /* 0000 */ PTR(340, 1), /* 48 */
1568 /* 0001 */ PTR(342, 1), 1568 /* 0001 */ PTR(342, 1),
1569 /* 0010 */ V(9, 1, 4), 1569 /* 0010 */ V(9, 1, 4),
1570 /* 0011 */ PTR(344, 1), 1570 /* 0011 */ PTR(344, 1),
@@ -1582,7 +1582,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1582 /* 1111 */ PTR(360, 1), 1582 /* 1111 */ PTR(360, 1),
1583 1583
1584 /* 0011 ... */ 1584 /* 0011 ... */
1585 /* 0000 */ V(2, 7, 4), /* 64 */ 1585 /* 0000 */ V(2, 7, 4), /* 64 */
1586 /* 0001 */ V(7, 2, 4), 1586 /* 0001 */ V(7, 2, 4),
1587 /* 0010 */ V(6, 4, 4), 1587 /* 0010 */ V(6, 4, 4),
1588 /* 0011 */ V(1, 7, 4), 1588 /* 0011 */ V(1, 7, 4),
@@ -1600,7 +1600,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1600 /* 1111 */ V(3, 5, 4), 1600 /* 1111 */ V(3, 5, 4),
1601 1601
1602 /* 0100 ... */ 1602 /* 0100 ... */
1603 /* 0000 */ V(6, 1, 3), /* 80 */ 1603 /* 0000 */ V(6, 1, 3), /* 80 */
1604 /* 0001 */ V(6, 1, 3), 1604 /* 0001 */ V(6, 1, 3),
1605 /* 0010 */ V(5, 3, 4), 1605 /* 0010 */ V(5, 3, 4),
1606 /* 0011 */ V(4, 4, 4), 1606 /* 0011 */ V(4, 4, 4),
@@ -1618,7 +1618,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1618 /* 1111 */ V(3, 4, 3), 1618 /* 1111 */ V(3, 4, 3),
1619 1619
1620 /* 0101 ... */ 1620 /* 0101 ... */
1621 /* 000 */ V(4, 3, 3), /* 96 */ 1621 /* 000 */ V(4, 3, 3), /* 96 */
1622 /* 001 */ V(2, 4, 3), 1622 /* 001 */ V(2, 4, 3),
1623 /* 010 */ V(4, 2, 3), 1623 /* 010 */ V(4, 2, 3),
1624 /* 011 */ V(3, 3, 3), 1624 /* 011 */ V(3, 3, 3),
@@ -1628,7 +1628,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1628 /* 111 */ V(0, 4, 3), 1628 /* 111 */ V(0, 4, 3),
1629 1629
1630 /* 0110 ... */ 1630 /* 0110 ... */
1631 /* 000 */ V(2, 3, 2), /* 104 */ 1631 /* 000 */ V(2, 3, 2), /* 104 */
1632 /* 001 */ V(2, 3, 2), 1632 /* 001 */ V(2, 3, 2),
1633 /* 010 */ V(3, 2, 2), 1633 /* 010 */ V(3, 2, 2),
1634 /* 011 */ V(3, 2, 2), 1634 /* 011 */ V(3, 2, 2),
@@ -1638,21 +1638,21 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1638 /* 111 */ V(1, 3, 2), 1638 /* 111 */ V(1, 3, 2),
1639 1639
1640 /* 0111 ... */ 1640 /* 0111 ... */
1641 /* 00 */ V(3, 1, 2), /* 112 */ 1641 /* 00 */ V(3, 1, 2), /* 112 */
1642 /* 01 */ V(3, 0, 2), 1642 /* 01 */ V(3, 0, 2),
1643 /* 10 */ V(2, 2, 1), 1643 /* 10 */ V(2, 2, 1),
1644 /* 11 */ V(2, 2, 1), 1644 /* 11 */ V(2, 2, 1),
1645 1645
1646 /* 1000 ... */ 1646 /* 1000 ... */
1647 /* 0 */ V(1, 2, 1), /* 116 */ 1647 /* 0 */ V(1, 2, 1), /* 116 */
1648 /* 1 */ V(2, 1, 1), 1648 /* 1 */ V(2, 1, 1),
1649 1649
1650 /* 1001 ... */ 1650 /* 1001 ... */
1651 /* 0 */ V(0, 2, 1), /* 118 */ 1651 /* 0 */ V(0, 2, 1), /* 118 */
1652 /* 1 */ V(2, 0, 1), 1652 /* 1 */ V(2, 0, 1),
1653 1653
1654 /* 0000 0000 ... */ 1654 /* 0000 0000 ... */
1655 /* 0000 */ PTR(366, 1), /* 120 */ 1655 /* 0000 */ PTR(366, 1), /* 120 */
1656 /* 0001 */ PTR(368, 1), 1656 /* 0001 */ PTR(368, 1),
1657 /* 0010 */ V(14, 14, 4), 1657 /* 0010 */ V(14, 14, 4),
1658 /* 0011 */ PTR(370, 1), 1658 /* 0011 */ PTR(370, 1),
@@ -1670,7 +1670,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1670 /* 1111 */ V(9, 15, 4), 1670 /* 1111 */ V(9, 15, 4),
1671 1671
1672 /* 0000 0001 ... */ 1672 /* 0000 0001 ... */
1673 /* 0000 */ V(15, 9, 4), /* 136 */ 1673 /* 0000 */ V(15, 9, 4), /* 136 */
1674 /* 0001 */ V(14, 10, 4), 1674 /* 0001 */ V(14, 10, 4),
1675 /* 0010 */ V(11, 13, 4), 1675 /* 0010 */ V(11, 13, 4),
1676 /* 0011 */ V(13, 11, 4), 1676 /* 0011 */ V(13, 11, 4),
@@ -1688,7 +1688,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1688 /* 1111 */ PTR(378, 1), 1688 /* 1111 */ PTR(378, 1),
1689 1689
1690 /* 0000 0010 ... */ 1690 /* 0000 0010 ... */
1691 /* 0000 */ V(12, 11, 3), /* 152 */ 1691 /* 0000 */ V(12, 11, 3), /* 152 */
1692 /* 0001 */ V(12, 11, 3), 1692 /* 0001 */ V(12, 11, 3),
1693 /* 0010 */ V(15, 6, 3), 1693 /* 0010 */ V(15, 6, 3),
1694 /* 0011 */ V(15, 6, 3), 1694 /* 0011 */ V(15, 6, 3),
@@ -1706,7 +1706,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1706 /* 1111 */ V(10, 12, 3), 1706 /* 1111 */ V(10, 12, 3),
1707 1707
1708 /* 0000 0011 ... */ 1708 /* 0000 0011 ... */
1709 /* 0000 */ V(12, 10, 3), /* 168 */ 1709 /* 0000 */ V(12, 10, 3), /* 168 */
1710 /* 0001 */ V(12, 10, 3), 1710 /* 0001 */ V(12, 10, 3),
1711 /* 0010 */ V(11, 11, 3), 1711 /* 0010 */ V(11, 11, 3),
1712 /* 0011 */ V(11, 11, 3), 1712 /* 0011 */ V(11, 11, 3),
@@ -1724,7 +1724,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1724 /* 1111 */ V(13, 8, 3), 1724 /* 1111 */ V(13, 8, 3),
1725 1725
1726 /* 0000 0100 ... */ 1726 /* 0000 0100 ... */
1727 /* 0000 */ V(14, 6, 3), /* 184 */ 1727 /* 0000 */ V(14, 6, 3), /* 184 */
1728 /* 0001 */ V(14, 6, 3), 1728 /* 0001 */ V(14, 6, 3),
1729 /* 0010 */ V(2, 15, 3), 1729 /* 0010 */ V(2, 15, 3),
1730 /* 0011 */ V(2, 15, 3), 1730 /* 0011 */ V(2, 15, 3),
@@ -1742,7 +1742,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1742 /* 1111 */ V(12, 9, 3), 1742 /* 1111 */ V(12, 9, 3),
1743 1743
1744 /* 0000 0101 ... */ 1744 /* 0000 0101 ... */
1745 /* 000 */ V(5, 14, 3), /* 200 */ 1745 /* 000 */ V(5, 14, 3), /* 200 */
1746 /* 001 */ V(10, 11, 3), 1746 /* 001 */ V(10, 11, 3),
1747 /* 010 */ V(11, 10, 3), 1747 /* 010 */ V(11, 10, 3),
1748 /* 011 */ V(14, 5, 3), 1748 /* 011 */ V(14, 5, 3),
@@ -1752,7 +1752,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1752 /* 111 */ V(14, 4, 3), 1752 /* 111 */ V(14, 4, 3),
1753 1753
1754 /* 0000 0110 ... */ 1754 /* 0000 0110 ... */
1755 /* 000 */ V(8, 12, 3), /* 208 */ 1755 /* 000 */ V(8, 12, 3), /* 208 */
1756 /* 001 */ V(12, 8, 3), 1756 /* 001 */ V(12, 8, 3),
1757 /* 010 */ V(3, 14, 3), 1757 /* 010 */ V(3, 14, 3),
1758 /* 011 */ V(6, 13, 3), 1758 /* 011 */ V(6, 13, 3),
@@ -1762,7 +1762,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1762 /* 111 */ V(11, 9, 3), 1762 /* 111 */ V(11, 9, 3),
1763 1763
1764 /* 0000 0111 ... */ 1764 /* 0000 0111 ... */
1765 /* 0000 */ V(2, 14, 3), /* 216 */ 1765 /* 0000 */ V(2, 14, 3), /* 216 */
1766 /* 0001 */ V(2, 14, 3), 1766 /* 0001 */ V(2, 14, 3),
1767 /* 0010 */ V(10, 10, 3), 1767 /* 0010 */ V(10, 10, 3),
1768 /* 0011 */ V(10, 10, 3), 1768 /* 0011 */ V(10, 10, 3),
@@ -1780,7 +1780,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1780 /* 1111 */ V(13, 5, 3), 1780 /* 1111 */ V(13, 5, 3),
1781 1781
1782 /* 0000 1000 ... */ 1782 /* 0000 1000 ... */
1783 /* 000 */ V(7, 12, 3), /* 232 */ 1783 /* 000 */ V(7, 12, 3), /* 232 */
1784 /* 001 */ V(12, 7, 3), 1784 /* 001 */ V(12, 7, 3),
1785 /* 010 */ V(4, 13, 3), 1785 /* 010 */ V(4, 13, 3),
1786 /* 011 */ V(8, 11, 3), 1786 /* 011 */ V(8, 11, 3),
@@ -1790,7 +1790,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1790 /* 111 */ V(9, 10, 3), 1790 /* 111 */ V(9, 10, 3),
1791 1791
1792 /* 0000 1001 ... */ 1792 /* 0000 1001 ... */
1793 /* 000 */ V(10, 9, 3), /* 240 */ 1793 /* 000 */ V(10, 9, 3), /* 240 */
1794 /* 001 */ V(6, 12, 3), 1794 /* 001 */ V(6, 12, 3),
1795 /* 010 */ V(12, 6, 3), 1795 /* 010 */ V(12, 6, 3),
1796 /* 011 */ V(3, 13, 3), 1796 /* 011 */ V(3, 13, 3),
@@ -1800,7 +1800,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1800 /* 111 */ V(13, 2, 2), 1800 /* 111 */ V(13, 2, 2),
1801 1801
1802 /* 0000 1010 ... */ 1802 /* 0000 1010 ... */
1803 /* 000 */ V(2, 13, 3), /* 248 */ 1803 /* 000 */ V(2, 13, 3), /* 248 */
1804 /* 001 */ V(0, 13, 3), 1804 /* 001 */ V(0, 13, 3),
1805 /* 010 */ V(1, 13, 2), 1805 /* 010 */ V(1, 13, 2),
1806 /* 011 */ V(1, 13, 2), 1806 /* 011 */ V(1, 13, 2),
@@ -1810,7 +1810,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1810 /* 111 */ V(11, 7, 2), 1810 /* 111 */ V(11, 7, 2),
1811 1811
1812 /* 0000 1011 ... */ 1812 /* 0000 1011 ... */
1813 /* 000 */ V(13, 1, 2), /* 256 */ 1813 /* 000 */ V(13, 1, 2), /* 256 */
1814 /* 001 */ V(13, 1, 2), 1814 /* 001 */ V(13, 1, 2),
1815 /* 010 */ V(5, 12, 3), 1815 /* 010 */ V(5, 12, 3),
1816 /* 011 */ V(13, 0, 3), 1816 /* 011 */ V(13, 0, 3),
@@ -1820,13 +1820,13 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1820 /* 111 */ V(8, 10, 2), 1820 /* 111 */ V(8, 10, 2),
1821 1821
1822 /* 0000 1100 ... */ 1822 /* 0000 1100 ... */
1823 /* 00 */ V(10, 8, 2), /* 264 */ 1823 /* 00 */ V(10, 8, 2), /* 264 */
1824 /* 01 */ V(4, 12, 2), 1824 /* 01 */ V(4, 12, 2),
1825 /* 10 */ V(12, 4, 2), 1825 /* 10 */ V(12, 4, 2),
1826 /* 11 */ V(6, 11, 2), 1826 /* 11 */ V(6, 11, 2),
1827 1827
1828 /* 0000 1101 ... */ 1828 /* 0000 1101 ... */
1829 /* 000 */ V(11, 6, 2), /* 268 */ 1829 /* 000 */ V(11, 6, 2), /* 268 */
1830 /* 001 */ V(11, 6, 2), 1830 /* 001 */ V(11, 6, 2),
1831 /* 010 */ V(9, 9, 3), 1831 /* 010 */ V(9, 9, 3),
1832 /* 011 */ V(0, 12, 3), 1832 /* 011 */ V(0, 12, 3),
@@ -1836,7 +1836,7 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1836 /* 111 */ V(12, 3, 2), 1836 /* 111 */ V(12, 3, 2),
1837 1837
1838 /* 0000 1110 ... */ 1838 /* 0000 1110 ... */
1839 /* 000 */ V(7, 10, 2), /* 276 */ 1839 /* 000 */ V(7, 10, 2), /* 276 */
1840 /* 001 */ V(7, 10, 2), 1840 /* 001 */ V(7, 10, 2),
1841 /* 010 */ V(10, 7, 2), 1841 /* 010 */ V(10, 7, 2),
1842 /* 011 */ V(10, 7, 2), 1842 /* 011 */ V(10, 7, 2),
@@ -1846,173 +1846,173 @@ union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = {
1846 /* 111 */ V(0, 11, 3), 1846 /* 111 */ V(0, 11, 3),
1847 1847
1848 /* 0000 1111 ... */ 1848 /* 0000 1111 ... */
1849 /* 00 */ V(12, 2, 1), /* 284 */ 1849 /* 00 */ V(12, 2, 1), /* 284 */
1850 /* 01 */ V(12, 2, 1), 1850 /* 01 */ V(12, 2, 1),
1851 /* 10 */ V(2, 12, 2), 1851 /* 10 */ V(2, 12, 2),
1852 /* 11 */ V(5, 11, 2), 1852 /* 11 */ V(5, 11, 2),
1853 1853
1854 /* 0001 0000 ... */ 1854 /* 0001 0000 ... */
1855 /* 00 */ V(11, 5, 2), /* 288 */ 1855 /* 00 */ V(11, 5, 2), /* 288 */
1856 /* 01 */ V(1, 12, 2), 1856 /* 01 */ V(1, 12, 2),
1857 /* 10 */ V(8, 9, 2), 1857 /* 10 */ V(8, 9, 2),
1858 /* 11 */ V(9, 8, 2), 1858 /* 11 */ V(9, 8, 2),
1859 1859
1860 /* 0001 0001 ... */ 1860 /* 0001 0001 ... */
1861 /* 00 */ V(12, 1, 2), /* 292 */ 1861 /* 00 */ V(12, 1, 2), /* 292 */
1862 /* 01 */ V(4, 11, 2), 1862 /* 01 */ V(4, 11, 2),
1863 /* 10 */ V(11, 4, 2), 1863 /* 10 */ V(11, 4, 2),
1864 /* 11 */ V(6, 10, 2), 1864 /* 11 */ V(6, 10, 2),
1865 1865
1866 /* 0001 0010 ... */ 1866 /* 0001 0010 ... */
1867 /* 00 */ V(3, 11, 2), /* 296 */ 1867 /* 00 */ V(3, 11, 2), /* 296 */
1868 /* 01 */ V(7, 9, 2), 1868 /* 01 */ V(7, 9, 2),
1869 /* 10 */ V(11, 3, 1), 1869 /* 10 */ V(11, 3, 1),
1870 /* 11 */ V(11, 3, 1), 1870 /* 11 */ V(11, 3, 1),
1871 1871
1872 /* 0001 0011 ... */ 1872 /* 0001 0011 ... */
1873 /* 00 */ V(9, 7, 2), /* 300 */ 1873 /* 00 */ V(9, 7, 2), /* 300 */
1874 /* 01 */ V(8, 8, 2), 1874 /* 01 */ V(8, 8, 2),
1875 /* 10 */ V(2, 11, 2), 1875 /* 10 */ V(2, 11, 2),
1876 /* 11 */ V(5, 10, 2), 1876 /* 11 */ V(5, 10, 2),
1877 1877
1878 /* 0001 0100 ... */ 1878 /* 0001 0100 ... */
1879 /* 00 */ V(11, 2, 1), /* 304 */ 1879 /* 00 */ V(11, 2, 1), /* 304 */
1880 /* 01 */ V(11, 2, 1), 1880 /* 01 */ V(11, 2, 1),
1881 /* 10 */ V(10, 5, 2), 1881 /* 10 */ V(10, 5, 2),
1882 /* 11 */ V(1, 11, 2), 1882 /* 11 */ V(1, 11, 2),
1883 1883
1884 /* 0001 0101 ... */ 1884 /* 0001 0101 ... */
1885 /* 00 */ V(11, 1, 1), /* 308 */ 1885 /* 00 */ V(11, 1, 1), /* 308 */
1886 /* 01 */ V(11, 1, 1), 1886 /* 01 */ V(11, 1, 1),
1887 /* 10 */ V(11, 0, 2), 1887 /* 10 */ V(11, 0, 2),
1888 /* 11 */ V(6, 9, 2), 1888 /* 11 */ V(6, 9, 2),
1889 1889
1890 /* 0001 0110 ... */ 1890 /* 0001 0110 ... */
1891 /* 00 */ V(9, 6, 2), /* 312 */ 1891 /* 00 */ V(9, 6, 2), /* 312 */
1892 /* 01 */ V(4, 10, 2), 1892 /* 01 */ V(4, 10, 2),
1893 /* 10 */ V(10, 4, 2), 1893 /* 10 */ V(10, 4, 2),
1894 /* 11 */ V(7, 8, 2), 1894 /* 11 */ V(7, 8, 2),
1895 1895
1896 /* 0001 0111 ... */ 1896 /* 0001 0111 ... */
1897 /* 00 */ V(8, 7, 2), /* 316 */ 1897 /* 00 */ V(8, 7, 2), /* 316 */
1898 /* 01 */ V(3, 10, 2), 1898 /* 01 */ V(3, 10, 2),
1899 /* 10 */ V(10, 3, 1), 1899 /* 10 */ V(10, 3, 1),
1900 /* 11 */ V(10, 3, 1), 1900 /* 11 */ V(10, 3, 1),
1901 1901
1902 /* 0001 1000 ... */ 1902 /* 0001 1000 ... */
1903 /* 0 */ V(5, 9, 1), /* 320 */ 1903 /* 0 */ V(5, 9, 1), /* 320 */
1904 /* 1 */ V(9, 5, 1), 1904 /* 1 */ V(9, 5, 1),
1905 1905
1906 /* 0001 1001 ... */ 1906 /* 0001 1001 ... */
1907 /* 0 */ V(2, 10, 1), /* 322 */ 1907 /* 0 */ V(2, 10, 1), /* 322 */
1908 /* 1 */ V(10, 2, 1), 1908 /* 1 */ V(10, 2, 1),
1909 1909
1910 /* 0001 1010 ... */ 1910 /* 0001 1010 ... */
1911 /* 0 */ V(1, 10, 1), /* 324 */ 1911 /* 0 */ V(1, 10, 1), /* 324 */
1912 /* 1 */ V(10, 1, 1), 1912 /* 1 */ V(10, 1, 1),
1913 1913
1914 /* 0001 1011 ... */ 1914 /* 0001 1011 ... */
1915 /* 00 */ V(0, 10, 2), /* 326 */ 1915 /* 00 */ V(0, 10, 2), /* 326 */
1916 /* 01 */ V(10, 0, 2), 1916 /* 01 */ V(10, 0, 2),
1917 /* 10 */ V(6, 8, 1), 1917 /* 10 */ V(6, 8, 1),
1918 /* 11 */ V(6, 8, 1), 1918 /* 11 */ V(6, 8, 1),
1919 1919
1920 /* 0001 1100 ... */ 1920 /* 0001 1100 ... */
1921 /* 0 */ V(8, 6, 1), /* 330 */ 1921 /* 0 */ V(8, 6, 1), /* 330 */
1922 /* 1 */ V(4, 9, 1), 1922 /* 1 */ V(4, 9, 1),
1923 1923
1924 /* 0001 1101 ... */ 1924 /* 0001 1101 ... */
1925 /* 0 */ V(9, 4, 1), /* 332 */ 1925 /* 0 */ V(9, 4, 1), /* 332 */
1926 /* 1 */ V(3, 9, 1), 1926 /* 1 */ V(3, 9, 1),
1927 1927
1928 /* 0001 1110 ... */ 1928 /* 0001 1110 ... */
1929 /* 00 */ V(9, 3, 1), /* 334 */ 1929 /* 00 */ V(9, 3, 1), /* 334 */
1930 /* 01 */ V(9, 3, 1), 1930 /* 01 */ V(9, 3, 1),
1931 /* 10 */ V(7, 7, 2), 1931 /* 10 */ V(7, 7, 2),
1932 /* 11 */ V(0, 9, 2), 1932 /* 11 */ V(0, 9, 2),
1933 1933
1934 /* 0001 1111 ... */ 1934 /* 0001 1111 ... */
1935 /* 0 */ V(5, 8, 1), /* 338 */ 1935 /* 0 */ V(5, 8, 1), /* 338 */
1936 /* 1 */ V(8, 5, 1), 1936 /* 1 */ V(8, 5, 1),
1937 1937
1938 /* 0010 0000 ... */ 1938 /* 0010 0000 ... */
1939 /* 0 */ V(2, 9, 1), /* 340 */ 1939 /* 0 */ V(2, 9, 1), /* 340 */
1940 /* 1 */ V(6, 7, 1), 1940 /* 1 */ V(6, 7, 1),
1941 1941
1942 /* 0010 0001 ... */ 1942 /* 0010 0001 ... */
1943 /* 0 */ V(7, 6, 1), /* 342 */ 1943 /* 0 */ V(7, 6, 1), /* 342 */
1944 /* 1 */ V(9, 2, 1), 1944 /* 1 */ V(9, 2, 1),
1945 1945
1946 /* 0010 0011 ... */ 1946 /* 0010 0011 ... */
1947 /* 0 */ V(1, 9, 1), /* 344 */ 1947 /* 0 */ V(1, 9, 1), /* 344 */
1948 /* 1 */ V(9, 0, 1), 1948 /* 1 */ V(9, 0, 1),
1949 1949
1950 /* 0010 0100 ... */ 1950 /* 0010 0100 ... */
1951 /* 0 */ V(4, 8, 1), /* 346 */ 1951 /* 0 */ V(4, 8, 1), /* 346 */
1952 /* 1 */ V(8, 4, 1), 1952 /* 1 */ V(8, 4, 1),
1953 1953
1954 /* 0010 0101 ... */ 1954 /* 0010 0101 ... */
1955 /* 0 */ V(5, 7, 1), /* 348 */ 1955 /* 0 */ V(5, 7, 1), /* 348 */
1956 /* 1 */ V(7, 5, 1), 1956 /* 1 */ V(7, 5, 1),
1957 1957
1958 /* 0010 0110 ... */ 1958 /* 0010 0110 ... */
1959 /* 0 */ V(3, 8, 1), /* 350 */ 1959 /* 0 */ V(3, 8, 1), /* 350 */
1960 /* 1 */ V(8, 3, 1), 1960 /* 1 */ V(8, 3, 1),
1961 1961
1962 /* 0010 0111 ... */ 1962 /* 0010 0111 ... */
1963 /* 0 */ V(6, 6, 1), /* 352 */ 1963 /* 0 */ V(6, 6, 1), /* 352 */
1964 /* 1 */ V(4, 7, 1), 1964 /* 1 */ V(4, 7, 1),
1965 1965
1966 /* 0010 1100 ... */ 1966 /* 0010 1100 ... */
1967 /* 0 */ V(7, 4, 1), /* 354 */ 1967 /* 0 */ V(7, 4, 1), /* 354 */
1968 /* 1 */ V(0, 8, 1), 1968 /* 1 */ V(0, 8, 1),
1969 1969
1970 /* 0010 1101 ... */ 1970 /* 0010 1101 ... */
1971 /* 0 */ V(8, 0, 1), /* 356 */ 1971 /* 0 */ V(8, 0, 1), /* 356 */
1972 /* 1 */ V(5, 6, 1), 1972 /* 1 */ V(5, 6, 1),
1973 1973
1974 /* 0010 1110 ... */ 1974 /* 0010 1110 ... */
1975 /* 0 */ V(6, 5, 1), /* 358 */ 1975 /* 0 */ V(6, 5, 1), /* 358 */
1976 /* 1 */ V(3, 7, 1), 1976 /* 1 */ V(3, 7, 1),
1977 1977
1978 /* 0010 1111 ... */ 1978 /* 0010 1111 ... */
1979 /* 0 */ V(7, 3, 1), /* 360 */ 1979 /* 0 */ V(7, 3, 1), /* 360 */
1980 /* 1 */ V(4, 6, 1), 1980 /* 1 */ V(4, 6, 1),
1981 1981
1982 /* 0011 0110 ... */ 1982 /* 0011 0110 ... */
1983 /* 0 */ V(0, 7, 1), /* 362 */ 1983 /* 0 */ V(0, 7, 1), /* 362 */
1984 /* 1 */ V(7, 0, 1), 1984 /* 1 */ V(7, 0, 1),
1985 1985
1986 /* 0011 1110 ... */ 1986 /* 0011 1110 ... */
1987 /* 0 */ V(0, 6, 1), /* 364 */ 1987 /* 0 */ V(0, 6, 1), /* 364 */
1988 /* 1 */ V(6, 0, 1), 1988 /* 1 */ V(6, 0, 1),
1989 1989
1990 /* 0000 0000 0000 ... */ 1990 /* 0000 0000 0000 ... */
1991 /* 0 */ V(15, 15, 1), /* 366 */ 1991 /* 0 */ V(15, 15, 1), /* 366 */
1992 /* 1 */ V(14, 15, 1), 1992 /* 1 */ V(14, 15, 1),
1993 1993
1994 /* 0000 0000 0001 ... */ 1994 /* 0000 0000 0001 ... */
1995 /* 0 */ V(15, 14, 1), /* 368 */ 1995 /* 0 */ V(15, 14, 1), /* 368 */
1996 /* 1 */ V(13, 15, 1), 1996 /* 1 */ V(13, 15, 1),
1997 1997
1998 /* 0000 0000 0011 ... */ 1998 /* 0000 0000 0011 ... */
1999 /* 0 */ V(15, 13, 1), /* 370 */ 1999 /* 0 */ V(15, 13, 1), /* 370 */
2000 /* 1 */ V(12, 15, 1), 2000 /* 1 */ V(12, 15, 1),
2001 2001
2002 /* 0000 0000 0100 ... */ 2002 /* 0000 0000 0100 ... */
2003 /* 0 */ V(15, 12, 1), /* 372 */ 2003 /* 0 */ V(15, 12, 1), /* 372 */
2004 /* 1 */ V(13, 14, 1), 2004 /* 1 */ V(13, 14, 1),
2005 2005
2006 /* 0000 0000 0101 ... */ 2006 /* 0000 0000 0101 ... */
2007 /* 0 */ V(14, 13, 1), /* 374 */ 2007 /* 0 */ V(14, 13, 1), /* 374 */
2008 /* 1 */ V(11, 15, 1), 2008 /* 1 */ V(11, 15, 1),
2009 2009
2010 /* 0000 0000 0111 ... */ 2010 /* 0000 0000 0111 ... */
2011 /* 0 */ V(12, 14, 1), /* 376 */ 2011 /* 0 */ V(12, 14, 1), /* 376 */
2012 /* 1 */ V(14, 12, 1), 2012 /* 1 */ V(14, 12, 1),
2013 2013
2014 /* 0000 0001 1111 ... */ 2014 /* 0000 0001 1111 ... */
2015 /* 0 */ V(10, 14, 1), /* 378 */ 2015 /* 0 */ V(10, 14, 1), /* 378 */
2016 /* 1 */ V(0, 15, 1) 2016 /* 1 */ V(0, 15, 1)
2017}; 2017};
2018 2018
@@ -2036,7 +2036,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2036 /* 1111 */ V(0, 0, 1), 2036 /* 1111 */ V(0, 0, 1),
2037 2037
2038 /* 0000 ... */ 2038 /* 0000 ... */
2039 /* 0000 */ PTR(68, 3), /* 16 */ 2039 /* 0000 */ PTR(68, 3), /* 16 */
2040 /* 0001 */ PTR(76, 3), 2040 /* 0001 */ PTR(76, 3),
2041 /* 0010 */ PTR(84, 2), 2041 /* 0010 */ PTR(84, 2),
2042 /* 0011 */ V(15, 15, 4), 2042 /* 0011 */ V(15, 15, 4),
@@ -2054,7 +2054,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2054 /* 1111 */ PTR(176, 4), 2054 /* 1111 */ PTR(176, 4),
2055 2055
2056 /* 0001 ... */ 2056 /* 0001 ... */
2057 /* 0000 */ PTR(192, 4), /* 32 */ 2057 /* 0000 */ PTR(192, 4), /* 32 */
2058 /* 0001 */ PTR(208, 3), 2058 /* 0001 */ PTR(208, 3),
2059 /* 0010 */ PTR(216, 3), 2059 /* 0010 */ PTR(216, 3),
2060 /* 0011 */ PTR(224, 3), 2060 /* 0011 */ PTR(224, 3),
@@ -2072,7 +2072,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2072 /* 1111 */ PTR(284, 1), 2072 /* 1111 */ PTR(284, 1),
2073 2073
2074 /* 0010 ... */ 2074 /* 0010 ... */
2075 /* 0000 */ PTR(286, 1), /* 48 */ 2075 /* 0000 */ PTR(286, 1), /* 48 */
2076 /* 0001 */ PTR(288, 1), 2076 /* 0001 */ PTR(288, 1),
2077 /* 0010 */ PTR(290, 1), 2077 /* 0010 */ PTR(290, 1),
2078 /* 0011 */ V(1, 4, 4), 2078 /* 0011 */ V(1, 4, 4),
@@ -2090,13 +2090,13 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2090 /* 1111 */ V(2, 2, 3), 2090 /* 1111 */ V(2, 2, 3),
2091 2091
2092 /* 0011 ... */ 2092 /* 0011 ... */
2093 /* 00 */ V(1, 2, 2), /* 64 */ 2093 /* 00 */ V(1, 2, 2), /* 64 */
2094 /* 01 */ V(2, 1, 2), 2094 /* 01 */ V(2, 1, 2),
2095 /* 10 */ V(0, 2, 2), 2095 /* 10 */ V(0, 2, 2),
2096 /* 11 */ V(2, 0, 2), 2096 /* 11 */ V(2, 0, 2),
2097 2097
2098 /* 0000 0000 ... */ 2098 /* 0000 0000 ... */
2099 /* 000 */ V(14, 15, 3), /* 68 */ 2099 /* 000 */ V(14, 15, 3), /* 68 */
2100 /* 001 */ V(15, 14, 3), 2100 /* 001 */ V(15, 14, 3),
2101 /* 010 */ V(13, 15, 3), 2101 /* 010 */ V(13, 15, 3),
2102 /* 011 */ V(15, 13, 3), 2102 /* 011 */ V(15, 13, 3),
@@ -2106,7 +2106,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2106 /* 111 */ V(15, 11, 3), 2106 /* 111 */ V(15, 11, 3),
2107 2107
2108 /* 0000 0001 ... */ 2108 /* 0000 0001 ... */
2109 /* 000 */ V(10, 15, 2), /* 76 */ 2109 /* 000 */ V(10, 15, 2), /* 76 */
2110 /* 001 */ V(10, 15, 2), 2110 /* 001 */ V(10, 15, 2),
2111 /* 010 */ V(15, 10, 3), 2111 /* 010 */ V(15, 10, 3),
2112 /* 011 */ V(9, 15, 3), 2112 /* 011 */ V(9, 15, 3),
@@ -2116,23 +2116,23 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2116 /* 111 */ V(8, 15, 2), 2116 /* 111 */ V(8, 15, 2),
2117 2117
2118 /* 0000 0010 ... */ 2118 /* 0000 0010 ... */
2119 /* 00 */ V(7, 15, 2), /* 84 */ 2119 /* 00 */ V(7, 15, 2), /* 84 */
2120 /* 01 */ V(15, 7, 2), 2120 /* 01 */ V(15, 7, 2),
2121 /* 10 */ V(6, 15, 2), 2121 /* 10 */ V(6, 15, 2),
2122 /* 11 */ V(15, 6, 2), 2122 /* 11 */ V(15, 6, 2),
2123 2123
2124 /* 0000 0100 ... */ 2124 /* 0000 0100 ... */
2125 /* 00 */ V(5, 15, 2), /* 88 */ 2125 /* 00 */ V(5, 15, 2), /* 88 */
2126 /* 01 */ V(15, 5, 2), 2126 /* 01 */ V(15, 5, 2),
2127 /* 10 */ V(4, 15, 1), 2127 /* 10 */ V(4, 15, 1),
2128 /* 11 */ V(4, 15, 1), 2128 /* 11 */ V(4, 15, 1),
2129 2129
2130 /* 0000 0101 ... */ 2130 /* 0000 0101 ... */
2131 /* 0 */ V(15, 4, 1), /* 92 */ 2131 /* 0 */ V(15, 4, 1), /* 92 */
2132 /* 1 */ V(15, 3, 1), 2132 /* 1 */ V(15, 3, 1),
2133 2133
2134 /* 0000 0110 ... */ 2134 /* 0000 0110 ... */
2135 /* 0000 */ V(15, 0, 1), /* 94 */ 2135 /* 0000 */ V(15, 0, 1), /* 94 */
2136 /* 0001 */ V(15, 0, 1), 2136 /* 0001 */ V(15, 0, 1),
2137 /* 0010 */ V(15, 0, 1), 2137 /* 0010 */ V(15, 0, 1),
2138 /* 0011 */ V(15, 0, 1), 2138 /* 0011 */ V(15, 0, 1),
@@ -2150,11 +2150,11 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2150 /* 1111 */ PTR(326, 3), 2150 /* 1111 */ PTR(326, 3),
2151 2151
2152 /* 0000 1000 ... */ 2152 /* 0000 1000 ... */
2153 /* 0 */ V(2, 15, 1), /* 110 */ 2153 /* 0 */ V(2, 15, 1), /* 110 */
2154 /* 1 */ V(0, 15, 1), 2154 /* 1 */ V(0, 15, 1),
2155 2155
2156 /* 0000 1011 ... */ 2156 /* 0000 1011 ... */
2157 /* 0000 */ PTR(334, 2), /* 112 */ 2157 /* 0000 */ PTR(334, 2), /* 112 */
2158 /* 0001 */ PTR(338, 2), 2158 /* 0001 */ PTR(338, 2),
2159 /* 0010 */ PTR(342, 2), 2159 /* 0010 */ PTR(342, 2),
2160 /* 0011 */ PTR(346, 1), 2160 /* 0011 */ PTR(346, 1),
@@ -2172,7 +2172,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2172 /* 1111 */ PTR(380, 1), 2172 /* 1111 */ PTR(380, 1),
2173 2173
2174 /* 0000 1100 ... */ 2174 /* 0000 1100 ... */
2175 /* 0000 */ PTR(382, 1), /* 128 */ 2175 /* 0000 */ PTR(382, 1), /* 128 */
2176 /* 0001 */ PTR(384, 1), 2176 /* 0001 */ PTR(384, 1),
2177 /* 0010 */ PTR(386, 1), 2177 /* 0010 */ PTR(386, 1),
2178 /* 0011 */ V(0, 13, 4), 2178 /* 0011 */ V(0, 13, 4),
@@ -2190,7 +2190,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2190 /* 1111 */ V(1, 14, 4), 2190 /* 1111 */ V(1, 14, 4),
2191 2191
2192 /* 0000 1101 ... */ 2192 /* 0000 1101 ... */
2193 /* 0000 */ V(13, 3, 4), /* 144 */ 2193 /* 0000 */ V(13, 3, 4), /* 144 */
2194 /* 0001 */ V(2, 13, 4), 2194 /* 0001 */ V(2, 13, 4),
2195 /* 0010 */ V(13, 2, 4), 2195 /* 0010 */ V(13, 2, 4),
2196 /* 0011 */ V(13, 1, 4), 2196 /* 0011 */ V(13, 1, 4),
@@ -2208,7 +2208,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2208 /* 1111 */ V(11, 5, 4), 2208 /* 1111 */ V(11, 5, 4),
2209 2209
2210 /* 0000 1110 ... */ 2210 /* 0000 1110 ... */
2211 /* 0000 */ V(12, 1, 4), /* 160 */ 2211 /* 0000 */ V(12, 1, 4), /* 160 */
2212 /* 0001 */ V(0, 12, 4), 2212 /* 0001 */ V(0, 12, 4),
2213 /* 0010 */ V(4, 11, 4), 2213 /* 0010 */ V(4, 11, 4),
2214 /* 0011 */ V(11, 4, 4), 2214 /* 0011 */ V(11, 4, 4),
@@ -2226,7 +2226,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2226 /* 1111 */ V(1, 11, 3), 2226 /* 1111 */ V(1, 11, 3),
2227 2227
2228 /* 0000 1111 ... */ 2228 /* 0000 1111 ... */
2229 /* 0000 */ V(11, 1, 3), /* 176 */ 2229 /* 0000 */ V(11, 1, 3), /* 176 */
2230 /* 0001 */ V(11, 1, 3), 2230 /* 0001 */ V(11, 1, 3),
2231 /* 0010 */ V(0, 11, 4), 2231 /* 0010 */ V(0, 11, 4),
2232 /* 0011 */ V(11, 0, 4), 2232 /* 0011 */ V(11, 0, 4),
@@ -2244,7 +2244,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2244 /* 1111 */ V(2, 10, 3), 2244 /* 1111 */ V(2, 10, 3),
2245 2245
2246 /* 0001 0000 ... */ 2246 /* 0001 0000 ... */
2247 /* 0000 */ V(9, 5, 4), /* 192 */ 2247 /* 0000 */ V(9, 5, 4), /* 192 */
2248 /* 0001 */ V(6, 8, 4), 2248 /* 0001 */ V(6, 8, 4),
2249 /* 0010 */ V(10, 1, 3), 2249 /* 0010 */ V(10, 1, 3),
2250 /* 0011 */ V(10, 1, 3), 2250 /* 0011 */ V(10, 1, 3),
@@ -2262,7 +2262,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2262 /* 1111 */ V(10, 2, 2), 2262 /* 1111 */ V(10, 2, 2),
2263 2263
2264 /* 0001 0001 ... */ 2264 /* 0001 0001 ... */
2265 /* 000 */ V(1, 10, 2), /* 208 */ 2265 /* 000 */ V(1, 10, 2), /* 208 */
2266 /* 001 */ V(1, 10, 2), 2266 /* 001 */ V(1, 10, 2),
2267 /* 010 */ V(0, 10, 3), 2267 /* 010 */ V(0, 10, 3),
2268 /* 011 */ V(10, 0, 3), 2268 /* 011 */ V(10, 0, 3),
@@ -2272,7 +2272,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2272 /* 111 */ V(8, 5, 3), 2272 /* 111 */ V(8, 5, 3),
2273 2273
2274 /* 0001 0010 ... */ 2274 /* 0001 0010 ... */
2275 /* 000 */ V(2, 9, 2), /* 216 */ 2275 /* 000 */ V(2, 9, 2), /* 216 */
2276 /* 001 */ V(2, 9, 2), 2276 /* 001 */ V(2, 9, 2),
2277 /* 010 */ V(9, 2, 2), 2277 /* 010 */ V(9, 2, 2),
2278 /* 011 */ V(9, 2, 2), 2278 /* 011 */ V(9, 2, 2),
@@ -2282,7 +2282,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2282 /* 111 */ V(1, 9, 2), 2282 /* 111 */ V(1, 9, 2),
2283 2283
2284 /* 0001 0011 ... */ 2284 /* 0001 0011 ... */
2285 /* 000 */ V(9, 1, 2), /* 224 */ 2285 /* 000 */ V(9, 1, 2), /* 224 */
2286 /* 001 */ V(9, 1, 2), 2286 /* 001 */ V(9, 1, 2),
2287 /* 010 */ V(9, 0, 3), 2287 /* 010 */ V(9, 0, 3),
2288 /* 011 */ V(4, 8, 3), 2288 /* 011 */ V(4, 8, 3),
@@ -2292,7 +2292,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2292 /* 111 */ V(8, 3, 3), 2292 /* 111 */ V(8, 3, 3),
2293 2293
2294 /* 0001 0100 ... */ 2294 /* 0001 0100 ... */
2295 /* 000 */ V(6, 6, 3), /* 232 */ 2295 /* 000 */ V(6, 6, 3), /* 232 */
2296 /* 001 */ V(2, 8, 3), 2296 /* 001 */ V(2, 8, 3),
2297 /* 010 */ V(8, 2, 2), 2297 /* 010 */ V(8, 2, 2),
2298 /* 011 */ V(8, 2, 2), 2298 /* 011 */ V(8, 2, 2),
@@ -2302,7 +2302,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2302 /* 111 */ V(1, 8, 2), 2302 /* 111 */ V(1, 8, 2),
2303 2303
2304 /* 0001 0101 ... */ 2304 /* 0001 0101 ... */
2305 /* 000 */ V(8, 1, 2), /* 240 */ 2305 /* 000 */ V(8, 1, 2), /* 240 */
2306 /* 001 */ V(8, 1, 2), 2306 /* 001 */ V(8, 1, 2),
2307 /* 010 */ V(8, 0, 2), 2307 /* 010 */ V(8, 0, 2),
2308 /* 011 */ V(8, 0, 2), 2308 /* 011 */ V(8, 0, 2),
@@ -2312,7 +2312,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2312 /* 111 */ V(3, 7, 2), 2312 /* 111 */ V(3, 7, 2),
2313 2313
2314 /* 0001 0110 ... */ 2314 /* 0001 0110 ... */
2315 /* 000 */ V(7, 3, 2), /* 248 */ 2315 /* 000 */ V(7, 3, 2), /* 248 */
2316 /* 001 */ V(7, 3, 2), 2316 /* 001 */ V(7, 3, 2),
2317 /* 010 */ V(6, 5, 3), 2317 /* 010 */ V(6, 5, 3),
2318 /* 011 */ V(4, 6, 3), 2318 /* 011 */ V(4, 6, 3),
@@ -2322,7 +2322,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2322 /* 111 */ V(7, 2, 2), 2322 /* 111 */ V(7, 2, 2),
2323 2323
2324 /* 0001 0111 ... */ 2324 /* 0001 0111 ... */
2325 /* 000 */ V(6, 4, 3), /* 256 */ 2325 /* 000 */ V(6, 4, 3), /* 256 */
2326 /* 001 */ V(5, 5, 3), 2326 /* 001 */ V(5, 5, 3),
2327 /* 010 */ V(0, 7, 2), 2327 /* 010 */ V(0, 7, 2),
2328 /* 011 */ V(0, 7, 2), 2328 /* 011 */ V(0, 7, 2),
@@ -2332,59 +2332,59 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2332 /* 111 */ V(1, 7, 1), 2332 /* 111 */ V(1, 7, 1),
2333 2333
2334 /* 0001 1000 ... */ 2334 /* 0001 1000 ... */
2335 /* 00 */ V(7, 1, 1), /* 264 */ 2335 /* 00 */ V(7, 1, 1), /* 264 */
2336 /* 01 */ V(7, 1, 1), 2336 /* 01 */ V(7, 1, 1),
2337 /* 10 */ V(7, 0, 2), 2337 /* 10 */ V(7, 0, 2),
2338 /* 11 */ V(3, 6, 2), 2338 /* 11 */ V(3, 6, 2),
2339 2339
2340 /* 0001 1001 ... */ 2340 /* 0001 1001 ... */
2341 /* 00 */ V(6, 3, 2), /* 268 */ 2341 /* 00 */ V(6, 3, 2), /* 268 */
2342 /* 01 */ V(4, 5, 2), 2342 /* 01 */ V(4, 5, 2),
2343 /* 10 */ V(5, 4, 2), 2343 /* 10 */ V(5, 4, 2),
2344 /* 11 */ V(2, 6, 2), 2344 /* 11 */ V(2, 6, 2),
2345 2345
2346 /* 0001 1010 ... */ 2346 /* 0001 1010 ... */
2347 /* 0 */ V(6, 2, 1), /* 272 */ 2347 /* 0 */ V(6, 2, 1), /* 272 */
2348 /* 1 */ V(1, 6, 1), 2348 /* 1 */ V(1, 6, 1),
2349 2349
2350 /* 0001 1011 ... */ 2350 /* 0001 1011 ... */
2351 /* 00 */ V(6, 1, 1), /* 274 */ 2351 /* 00 */ V(6, 1, 1), /* 274 */
2352 /* 01 */ V(6, 1, 1), 2352 /* 01 */ V(6, 1, 1),
2353 /* 10 */ V(0, 6, 2), 2353 /* 10 */ V(0, 6, 2),
2354 /* 11 */ V(6, 0, 2), 2354 /* 11 */ V(6, 0, 2),
2355 2355
2356 /* 0001 1100 ... */ 2356 /* 0001 1100 ... */
2357 /* 00 */ V(5, 3, 1), /* 278 */ 2357 /* 00 */ V(5, 3, 1), /* 278 */
2358 /* 01 */ V(5, 3, 1), 2358 /* 01 */ V(5, 3, 1),
2359 /* 10 */ V(3, 5, 2), 2359 /* 10 */ V(3, 5, 2),
2360 /* 11 */ V(4, 4, 2), 2360 /* 11 */ V(4, 4, 2),
2361 2361
2362 /* 0001 1101 ... */ 2362 /* 0001 1101 ... */
2363 /* 0 */ V(2, 5, 1), /* 282 */ 2363 /* 0 */ V(2, 5, 1), /* 282 */
2364 /* 1 */ V(5, 2, 1), 2364 /* 1 */ V(5, 2, 1),
2365 2365
2366 /* 0001 1111 ... */ 2366 /* 0001 1111 ... */
2367 /* 0 */ V(1, 5, 1), /* 284 */ 2367 /* 0 */ V(1, 5, 1), /* 284 */
2368 /* 1 */ V(0, 5, 1), 2368 /* 1 */ V(0, 5, 1),
2369 2369
2370 /* 0010 0000 ... */ 2370 /* 0010 0000 ... */
2371 /* 0 */ V(3, 4, 1), /* 286 */ 2371 /* 0 */ V(3, 4, 1), /* 286 */
2372 /* 1 */ V(4, 3, 1), 2372 /* 1 */ V(4, 3, 1),
2373 2373
2374 /* 0010 0001 ... */ 2374 /* 0010 0001 ... */
2375 /* 0 */ V(5, 0, 1), /* 288 */ 2375 /* 0 */ V(5, 0, 1), /* 288 */
2376 /* 1 */ V(2, 4, 1), 2376 /* 1 */ V(2, 4, 1),
2377 2377
2378 /* 0010 0010 ... */ 2378 /* 0010 0010 ... */
2379 /* 0 */ V(4, 2, 1), /* 290 */ 2379 /* 0 */ V(4, 2, 1), /* 290 */
2380 /* 1 */ V(3, 3, 1), 2380 /* 1 */ V(3, 3, 1),
2381 2381
2382 /* 0010 0101 ... */ 2382 /* 0010 0101 ... */
2383 /* 0 */ V(0, 4, 1), /* 292 */ 2383 /* 0 */ V(0, 4, 1), /* 292 */
2384 /* 1 */ V(4, 0, 1), 2384 /* 1 */ V(4, 0, 1),
2385 2385
2386 /* 0000 0110 1100 ... */ 2386 /* 0000 0110 1100 ... */
2387 /* 0000 */ V(12, 14, 4), /* 294 */ 2387 /* 0000 */ V(12, 14, 4), /* 294 */
2388 /* 0001 */ PTR(400, 1), 2388 /* 0001 */ PTR(400, 1),
2389 /* 0010 */ V(13, 14, 3), 2389 /* 0010 */ V(13, 14, 3),
2390 /* 0011 */ V(13, 14, 3), 2390 /* 0011 */ V(13, 14, 3),
@@ -2402,7 +2402,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2402 /* 1111 */ V(14, 11, 3), 2402 /* 1111 */ V(14, 11, 3),
2403 2403
2404 /* 0000 0110 1101 ... */ 2404 /* 0000 0110 1101 ... */
2405 /* 000 */ V(11, 14, 2), /* 310 */ 2405 /* 000 */ V(11, 14, 2), /* 310 */
2406 /* 001 */ V(11, 14, 2), 2406 /* 001 */ V(11, 14, 2),
2407 /* 010 */ V(12, 13, 2), 2407 /* 010 */ V(12, 13, 2),
2408 /* 011 */ V(12, 13, 2), 2408 /* 011 */ V(12, 13, 2),
@@ -2412,7 +2412,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2412 /* 111 */ V(10, 14, 2), 2412 /* 111 */ V(10, 14, 2),
2413 2413
2414 /* 0000 0110 1110 ... */ 2414 /* 0000 0110 1110 ... */
2415 /* 000 */ V(12, 12, 2), /* 318 */ 2415 /* 000 */ V(12, 12, 2), /* 318 */
2416 /* 001 */ V(12, 12, 2), 2416 /* 001 */ V(12, 12, 2),
2417 /* 010 */ V(10, 13, 3), 2417 /* 010 */ V(10, 13, 3),
2418 /* 011 */ V(13, 10, 3), 2418 /* 011 */ V(13, 10, 3),
@@ -2422,7 +2422,7 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2422 /* 111 */ V(12, 10, 2), 2422 /* 111 */ V(12, 10, 2),
2423 2423
2424 /* 0000 0110 1111 ... */ 2424 /* 0000 0110 1111 ... */
2425 /* 000 */ V(12, 9, 3), /* 326 */ 2425 /* 000 */ V(12, 9, 3), /* 326 */
2426 /* 001 */ V(7, 13, 3), 2426 /* 001 */ V(7, 13, 3),
2427 /* 010 */ V(5, 14, 2), 2427 /* 010 */ V(5, 14, 2),
2428 /* 011 */ V(5, 14, 2), 2428 /* 011 */ V(5, 14, 2),
@@ -2432,121 +2432,121 @@ union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = {
2432 /* 111 */ V(11, 13, 1), 2432 /* 111 */ V(11, 13, 1),
2433 2433
2434 /* 0000 1011 0000 ... */ 2434 /* 0000 1011 0000 ... */
2435 /* 00 */ V(9, 14, 1), /* 334 */ 2435 /* 00 */ V(9, 14, 1), /* 334 */
2436 /* 01 */ V(9, 14, 1), 2436 /* 01 */ V(9, 14, 1),
2437 /* 10 */ V(11, 12, 2), 2437 /* 10 */ V(11, 12, 2),
2438 /* 11 */ V(12, 11, 2), 2438 /* 11 */ V(12, 11, 2),
2439 2439
2440 /* 0000 1011 0001 ... */ 2440 /* 0000 1011 0001 ... */
2441 /* 00 */ V(8, 14, 2), /* 338 */ 2441 /* 00 */ V(8, 14, 2), /* 338 */
2442 /* 01 */ V(14, 8, 2), 2442 /* 01 */ V(14, 8, 2),
2443 /* 10 */ V(9, 13, 2), 2443 /* 10 */ V(9, 13, 2),
2444 /* 11 */ V(14, 7, 2), 2444 /* 11 */ V(14, 7, 2),
2445 2445
2446 /* 0000 1011 0010 ... */ 2446 /* 0000 1011 0010 ... */
2447 /* 00 */ V(11, 11, 2), /* 342 */ 2447 /* 00 */ V(11, 11, 2), /* 342 */
2448 /* 01 */ V(8, 13, 2), 2448 /* 01 */ V(8, 13, 2),
2449 /* 10 */ V(13, 8, 2), 2449 /* 10 */ V(13, 8, 2),
2450 /* 11 */ V(6, 14, 2), 2450 /* 11 */ V(6, 14, 2),
2451 2451
2452 /* 0000 1011 0011 ... */ 2452 /* 0000 1011 0011 ... */
2453 /* 0 */ V(14, 6, 1), /* 346 */ 2453 /* 0 */ V(14, 6, 1), /* 346 */
2454 /* 1 */ V(9, 12, 1), 2454 /* 1 */ V(9, 12, 1),
2455 2455
2456 /* 0000 1011 0100 ... */ 2456 /* 0000 1011 0100 ... */
2457 /* 00 */ V(10, 11, 2), /* 348 */ 2457 /* 00 */ V(10, 11, 2), /* 348 */
2458 /* 01 */ V(11, 10, 2), 2458 /* 01 */ V(11, 10, 2),
2459 /* 10 */ V(14, 5, 2), 2459 /* 10 */ V(14, 5, 2),
2460 /* 11 */ V(13, 7, 2), 2460 /* 11 */ V(13, 7, 2),
2461 2461
2462 /* 0000 1011 0101 ... */ 2462 /* 0000 1011 0101 ... */
2463 /* 00 */ V(4, 14, 1), /* 352 */ 2463 /* 00 */ V(4, 14, 1), /* 352 */
2464 /* 01 */ V(4, 14, 1), 2464 /* 01 */ V(4, 14, 1),
2465 /* 10 */ V(14, 4, 2), 2465 /* 10 */ V(14, 4, 2),
2466 /* 11 */ V(8, 12, 2), 2466 /* 11 */ V(8, 12, 2),
2467 2467
2468 /* 0000 1011 0110 ... */ 2468 /* 0000 1011 0110 ... */
2469 /* 0 */ V(12, 8, 1), /* 356 */ 2469 /* 0 */ V(12, 8, 1), /* 356 */
2470 /* 1 */ V(3, 14, 1), 2470 /* 1 */ V(3, 14, 1),
2471 2471
2472 /* 0000 1011 0111 ... */ 2472 /* 0000 1011 0111 ... */
2473 /* 00 */ V(6, 13, 1), /* 358 */ 2473 /* 00 */ V(6, 13, 1), /* 358 */
2474 /* 01 */ V(6, 13, 1), 2474 /* 01 */ V(6, 13, 1),
2475 /* 10 */ V(13, 6, 2), 2475 /* 10 */ V(13, 6, 2),
2476 /* 11 */ V(9, 11, 2), 2476 /* 11 */ V(9, 11, 2),
2477 2477
2478 /* 0000 1011 1000 ... */ 2478 /* 0000 1011 1000 ... */
2479 /* 00 */ V(11, 9, 2), /* 362 */ 2479 /* 00 */ V(11, 9, 2), /* 362 */
2480 /* 01 */ V(10, 10, 2), 2480 /* 01 */ V(10, 10, 2),
2481 /* 10 */ V(14, 1, 1), 2481 /* 10 */ V(14, 1, 1),
2482 /* 11 */ V(14, 1, 1), 2482 /* 11 */ V(14, 1, 1),
2483 2483
2484 /* 0000 1011 1001 ... */ 2484 /* 0000 1011 1001 ... */
2485 /* 00 */ V(13, 4, 1), /* 366 */ 2485 /* 00 */ V(13, 4, 1), /* 366 */
2486 /* 01 */ V(13, 4, 1), 2486 /* 01 */ V(13, 4, 1),
2487 /* 10 */ V(11, 8, 2), 2487 /* 10 */ V(11, 8, 2),
2488 /* 11 */ V(10, 9, 2), 2488 /* 11 */ V(10, 9, 2),
2489 2489
2490 /* 0000 1011 1010 ... */ 2490 /* 0000 1011 1010 ... */
2491 /* 00 */ V(7, 11, 1), /* 370 */ 2491 /* 00 */ V(7, 11, 1), /* 370 */
2492 /* 01 */ V(7, 11, 1), 2492 /* 01 */ V(7, 11, 1),
2493 /* 10 */ V(11, 7, 2), 2493 /* 10 */ V(11, 7, 2),
2494 /* 11 */ V(13, 0, 2), 2494 /* 11 */ V(13, 0, 2),
2495 2495
2496 /* 0000 1011 1100 ... */ 2496 /* 0000 1011 1100 ... */
2497 /* 0 */ V(0, 14, 1), /* 374 */ 2497 /* 0 */ V(0, 14, 1), /* 374 */
2498 /* 1 */ V(14, 0, 1), 2498 /* 1 */ V(14, 0, 1),
2499 2499
2500 /* 0000 1011 1101 ... */ 2500 /* 0000 1011 1101 ... */
2501 /* 0 */ V(5, 13, 1), /* 376 */ 2501 /* 0 */ V(5, 13, 1), /* 376 */
2502 /* 1 */ V(13, 5, 1), 2502 /* 1 */ V(13, 5, 1),
2503 2503
2504 /* 0000 1011 1110 ... */ 2504 /* 0000 1011 1110 ... */
2505 /* 0 */ V(7, 12, 1), /* 378 */ 2505 /* 0 */ V(7, 12, 1), /* 378 */
2506 /* 1 */ V(12, 7, 1), 2506 /* 1 */ V(12, 7, 1),
2507 2507
2508 /* 0000 1011 1111 ... */ 2508 /* 0000 1011 1111 ... */
2509 /* 0 */ V(4, 13, 1), /* 380 */ 2509 /* 0 */ V(4, 13, 1), /* 380 */
2510 /* 1 */ V(8, 11, 1), 2510 /* 1 */ V(8, 11, 1),
2511 2511
2512 /* 0000 1100 0000 ... */ 2512 /* 0000 1100 0000 ... */
2513 /* 0 */ V(9, 10, 1), /* 382 */ 2513 /* 0 */ V(9, 10, 1), /* 382 */
2514 /* 1 */ V(6, 12, 1), 2514 /* 1 */ V(6, 12, 1),
2515 2515
2516 /* 0000 1100 0001 ... */ 2516 /* 0000 1100 0001 ... */
2517 /* 0 */ V(12, 6, 1), /* 384 */ 2517 /* 0 */ V(12, 6, 1), /* 384 */
2518 /* 1 */ V(3, 13, 1), 2518 /* 1 */ V(3, 13, 1),
2519 2519
2520 /* 0000 1100 0010 ... */ 2520 /* 0000 1100 0010 ... */
2521 /* 0 */ V(5, 12, 1), /* 386 */ 2521 /* 0 */ V(5, 12, 1), /* 386 */
2522 /* 1 */ V(12, 5, 1), 2522 /* 1 */ V(12, 5, 1),
2523 2523
2524 /* 0000 1100 0100 ... */ 2524 /* 0000 1100 0100 ... */
2525 /* 0 */ V(8, 10, 1), /* 388 */ 2525 /* 0 */ V(8, 10, 1), /* 388 */
2526 /* 1 */ V(10, 8, 1), 2526 /* 1 */ V(10, 8, 1),
2527 2527
2528 /* 0000 1100 0101 ... */ 2528 /* 0000 1100 0101 ... */
2529 /* 0 */ V(9, 9, 1), /* 390 */ 2529 /* 0 */ V(9, 9, 1), /* 390 */
2530 /* 1 */ V(4, 12, 1), 2530 /* 1 */ V(4, 12, 1),
2531 2531
2532 /* 0000 1100 0110 ... */ 2532 /* 0000 1100 0110 ... */
2533 /* 0 */ V(11, 6, 1), /* 392 */ 2533 /* 0 */ V(11, 6, 1), /* 392 */
2534 /* 1 */ V(7, 10, 1), 2534 /* 1 */ V(7, 10, 1),
2535 2535
2536 /* 0000 1100 1000 ... */ 2536 /* 0000 1100 1000 ... */
2537 /* 0 */ V(5, 11, 1), /* 394 */ 2537 /* 0 */ V(5, 11, 1), /* 394 */
2538 /* 1 */ V(8, 9, 1), 2538 /* 1 */ V(8, 9, 1),
2539 2539
2540 /* 0000 1100 1011 ... */ 2540 /* 0000 1100 1011 ... */
2541 /* 0 */ V(9, 8, 1), /* 396 */ 2541 /* 0 */ V(9, 8, 1), /* 396 */
2542 /* 1 */ V(7, 9, 1), 2542 /* 1 */ V(7, 9, 1),
2543 2543
2544 /* 0000 1101 0101 ... */ 2544 /* 0000 1101 0101 ... */
2545 /* 0 */ V(9, 7, 1), /* 398 */ 2545 /* 0 */ V(9, 7, 1), /* 398 */
2546 /* 1 */ V(8, 8, 1), 2546 /* 1 */ V(8, 8, 1),
2547 2547
2548 /* 0000 0110 1100 0001 ... */ 2548 /* 0000 0110 1100 0001 ... */
2549 /* 0 */ V(14, 12, 1), /* 400 */ 2549 /* 0 */ V(14, 12, 1), /* 400 */
2550 /* 1 */ V(13, 13, 1) 2550 /* 1 */ V(13, 13, 1)
2551}; 2551};
2552 2552
@@ -2570,7 +2570,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2570 /* 1111 */ V(0, 0, 4), 2570 /* 1111 */ V(0, 0, 4),
2571 2571
2572 /* 0000 ... */ 2572 /* 0000 ... */
2573 /* 0000 */ V(14, 15, 4), /* 16 */ 2573 /* 0000 */ V(14, 15, 4), /* 16 */
2574 /* 0001 */ V(15, 14, 4), 2574 /* 0001 */ V(15, 14, 4),
2575 /* 0010 */ V(13, 15, 4), 2575 /* 0010 */ V(13, 15, 4),
2576 /* 0011 */ V(15, 13, 4), 2576 /* 0011 */ V(15, 13, 4),
@@ -2588,7 +2588,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2588 /* 1111 */ V(15, 8, 3), 2588 /* 1111 */ V(15, 8, 3),
2589 2589
2590 /* 0001 ... */ 2590 /* 0001 ... */
2591 /* 0000 */ V(8, 15, 4), /* 32 */ 2591 /* 0000 */ V(8, 15, 4), /* 32 */
2592 /* 0001 */ V(7, 15, 4), 2592 /* 0001 */ V(7, 15, 4),
2593 /* 0010 */ V(15, 7, 3), 2593 /* 0010 */ V(15, 7, 3),
2594 /* 0011 */ V(15, 7, 3), 2594 /* 0011 */ V(15, 7, 3),
@@ -2606,7 +2606,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2606 /* 1111 */ V(15, 4, 3), 2606 /* 1111 */ V(15, 4, 3),
2607 2607
2608 /* 0010 ... */ 2608 /* 0010 ... */
2609 /* 0000 */ V(3, 15, 3), /* 48 */ 2609 /* 0000 */ V(3, 15, 3), /* 48 */
2610 /* 0001 */ V(3, 15, 3), 2610 /* 0001 */ V(3, 15, 3),
2611 /* 0010 */ V(15, 3, 3), 2611 /* 0010 */ V(15, 3, 3),
2612 /* 0011 */ V(15, 3, 3), 2612 /* 0011 */ V(15, 3, 3),
@@ -2624,7 +2624,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2624 /* 1111 */ PTR(196, 3), 2624 /* 1111 */ PTR(196, 3),
2625 2625
2626 /* 0100 ... */ 2626 /* 0100 ... */
2627 /* 0000 */ PTR(204, 4), /* 64 */ 2627 /* 0000 */ PTR(204, 4), /* 64 */
2628 /* 0001 */ PTR(220, 3), 2628 /* 0001 */ PTR(220, 3),
2629 /* 0010 */ PTR(228, 3), 2629 /* 0010 */ PTR(228, 3),
2630 /* 0011 */ PTR(236, 3), 2630 /* 0011 */ PTR(236, 3),
@@ -2642,7 +2642,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2642 /* 1111 */ PTR(292, 2), 2642 /* 1111 */ PTR(292, 2),
2643 2643
2644 /* 0101 ... */ 2644 /* 0101 ... */
2645 /* 0000 */ PTR(296, 2), /* 80 */ 2645 /* 0000 */ PTR(296, 2), /* 80 */
2646 /* 0001 */ PTR(300, 3), 2646 /* 0001 */ PTR(300, 3),
2647 /* 0010 */ PTR(308, 2), 2647 /* 0010 */ PTR(308, 2),
2648 /* 0011 */ PTR(312, 3), 2648 /* 0011 */ PTR(312, 3),
@@ -2660,7 +2660,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2660 /* 1111 */ PTR(348, 1), 2660 /* 1111 */ PTR(348, 1),
2661 2661
2662 /* 0110 ... */ 2662 /* 0110 ... */
2663 /* 0000 */ PTR(350, 1), /* 96 */ 2663 /* 0000 */ PTR(350, 1), /* 96 */
2664 /* 0001 */ PTR(352, 1), 2664 /* 0001 */ PTR(352, 1),
2665 /* 0010 */ PTR(354, 1), 2665 /* 0010 */ PTR(354, 1),
2666 /* 0011 */ PTR(356, 1), 2666 /* 0011 */ PTR(356, 1),
@@ -2678,7 +2678,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2678 /* 1111 */ V(7, 2, 4), 2678 /* 1111 */ V(7, 2, 4),
2679 2679
2680 /* 0111 ... */ 2680 /* 0111 ... */
2681 /* 0000 */ V(4, 6, 4), /* 112 */ 2681 /* 0000 */ V(4, 6, 4), /* 112 */
2682 /* 0001 */ V(6, 4, 4), 2682 /* 0001 */ V(6, 4, 4),
2683 /* 0010 */ V(5, 5, 4), 2683 /* 0010 */ V(5, 5, 4),
2684 /* 0011 */ V(7, 1, 4), 2684 /* 0011 */ V(7, 1, 4),
@@ -2696,7 +2696,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2696 /* 1111 */ V(4, 4, 4), 2696 /* 1111 */ V(4, 4, 4),
2697 2697
2698 /* 1000 ... */ 2698 /* 1000 ... */
2699 /* 0000 */ V(2, 5, 4), /* 128 */ 2699 /* 0000 */ V(2, 5, 4), /* 128 */
2700 /* 0001 */ V(5, 2, 4), 2700 /* 0001 */ V(5, 2, 4),
2701 /* 0010 */ V(1, 5, 4), 2701 /* 0010 */ V(1, 5, 4),
2702 /* 0011 */ PTR(384, 1), 2702 /* 0011 */ PTR(384, 1),
@@ -2714,7 +2714,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2714 /* 1111 */ V(1, 4, 3), 2714 /* 1111 */ V(1, 4, 3),
2715 2715
2716 /* 1001 ... */ 2716 /* 1001 ... */
2717 /* 0000 */ V(4, 1, 3), /* 144 */ 2717 /* 0000 */ V(4, 1, 3), /* 144 */
2718 /* 0001 */ V(4, 1, 3), 2718 /* 0001 */ V(4, 1, 3),
2719 /* 0010 */ V(0, 4, 4), 2719 /* 0010 */ V(0, 4, 4),
2720 /* 0011 */ V(4, 0, 4), 2720 /* 0011 */ V(4, 0, 4),
@@ -2732,7 +2732,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2732 /* 1111 */ V(3, 1, 2), 2732 /* 1111 */ V(3, 1, 2),
2733 2733
2734 /* 1010 ... */ 2734 /* 1010 ... */
2735 /* 000 */ V(0, 3, 3), /* 160 */ 2735 /* 000 */ V(0, 3, 3), /* 160 */
2736 /* 001 */ V(3, 0, 3), 2736 /* 001 */ V(3, 0, 3),
2737 /* 010 */ V(2, 2, 2), 2737 /* 010 */ V(2, 2, 2),
2738 /* 011 */ V(2, 2, 2), 2738 /* 011 */ V(2, 2, 2),
@@ -2742,13 +2742,13 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2742 /* 111 */ V(1, 2, 1), 2742 /* 111 */ V(1, 2, 1),
2743 2743
2744 /* 1011 ... */ 2744 /* 1011 ... */
2745 /* 00 */ V(2, 1, 1), /* 168 */ 2745 /* 00 */ V(2, 1, 1), /* 168 */
2746 /* 01 */ V(2, 1, 1), 2746 /* 01 */ V(2, 1, 1),
2747 /* 10 */ V(0, 2, 2), 2747 /* 10 */ V(0, 2, 2),
2748 /* 11 */ V(2, 0, 2), 2748 /* 11 */ V(2, 0, 2),
2749 2749
2750 /* 0010 1100 ... */ 2750 /* 0010 1100 ... */
2751 /* 000 */ V(0, 15, 1), /* 172 */ 2751 /* 000 */ V(0, 15, 1), /* 172 */
2752 /* 001 */ V(0, 15, 1), 2752 /* 001 */ V(0, 15, 1),
2753 /* 010 */ V(0, 15, 1), 2753 /* 010 */ V(0, 15, 1),
2754 /* 011 */ V(0, 15, 1), 2754 /* 011 */ V(0, 15, 1),
@@ -2758,7 +2758,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2758 /* 111 */ V(12, 14, 3), 2758 /* 111 */ V(12, 14, 3),
2759 2759
2760 /* 0010 1101 ... */ 2760 /* 0010 1101 ... */
2761 /* 000 */ V(14, 12, 3), /* 180 */ 2761 /* 000 */ V(14, 12, 3), /* 180 */
2762 /* 001 */ V(13, 13, 3), 2762 /* 001 */ V(13, 13, 3),
2763 /* 010 */ V(11, 14, 3), 2763 /* 010 */ V(11, 14, 3),
2764 /* 011 */ V(14, 11, 3), 2764 /* 011 */ V(14, 11, 3),
@@ -2768,7 +2768,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2768 /* 111 */ V(14, 10, 3), 2768 /* 111 */ V(14, 10, 3),
2769 2769
2770 /* 0010 1110 ... */ 2770 /* 0010 1110 ... */
2771 /* 000 */ V(11, 13, 3), /* 188 */ 2771 /* 000 */ V(11, 13, 3), /* 188 */
2772 /* 001 */ V(13, 11, 3), 2772 /* 001 */ V(13, 11, 3),
2773 /* 010 */ V(12, 12, 3), 2773 /* 010 */ V(12, 12, 3),
2774 /* 011 */ V(9, 14, 3), 2774 /* 011 */ V(9, 14, 3),
@@ -2778,7 +2778,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2778 /* 111 */ V(11, 12, 3), 2778 /* 111 */ V(11, 12, 3),
2779 2779
2780 /* 0010 1111 ... */ 2780 /* 0010 1111 ... */
2781 /* 000 */ V(12, 11, 3), /* 196 */ 2781 /* 000 */ V(12, 11, 3), /* 196 */
2782 /* 001 */ V(8, 14, 3), 2782 /* 001 */ V(8, 14, 3),
2783 /* 010 */ V(14, 8, 3), 2783 /* 010 */ V(14, 8, 3),
2784 /* 011 */ V(9, 13, 3), 2784 /* 011 */ V(9, 13, 3),
@@ -2788,7 +2788,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2788 /* 111 */ V(10, 12, 3), 2788 /* 111 */ V(10, 12, 3),
2789 2789
2790 /* 0100 0000 ... */ 2790 /* 0100 0000 ... */
2791 /* 0000 */ V(12, 10, 3), /* 204 */ 2791 /* 0000 */ V(12, 10, 3), /* 204 */
2792 /* 0001 */ V(12, 10, 3), 2792 /* 0001 */ V(12, 10, 3),
2793 /* 0010 */ V(11, 11, 3), 2793 /* 0010 */ V(11, 11, 3),
2794 /* 0011 */ V(11, 11, 3), 2794 /* 0011 */ V(11, 11, 3),
@@ -2806,7 +2806,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2806 /* 1111 */ V(14, 6, 2), 2806 /* 1111 */ V(14, 6, 2),
2807 2807
2808 /* 0100 0001 ... */ 2808 /* 0100 0001 ... */
2809 /* 000 */ V(6, 14, 3), /* 220 */ 2809 /* 000 */ V(6, 14, 3), /* 220 */
2810 /* 001 */ V(9, 12, 3), 2810 /* 001 */ V(9, 12, 3),
2811 /* 010 */ V(12, 9, 2), 2811 /* 010 */ V(12, 9, 2),
2812 /* 011 */ V(12, 9, 2), 2812 /* 011 */ V(12, 9, 2),
@@ -2816,7 +2816,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2816 /* 111 */ V(11, 10, 2), 2816 /* 111 */ V(11, 10, 2),
2817 2817
2818 /* 0100 0010 ... */ 2818 /* 0100 0010 ... */
2819 /* 000 */ V(14, 5, 2), /* 228 */ 2819 /* 000 */ V(14, 5, 2), /* 228 */
2820 /* 001 */ V(14, 5, 2), 2820 /* 001 */ V(14, 5, 2),
2821 /* 010 */ V(10, 11, 3), 2821 /* 010 */ V(10, 11, 3),
2822 /* 011 */ V(7, 13, 3), 2822 /* 011 */ V(7, 13, 3),
@@ -2826,7 +2826,7 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2826 /* 111 */ V(14, 4, 2), 2826 /* 111 */ V(14, 4, 2),
2827 2827
2828 /* 0100 0011 ... */ 2828 /* 0100 0011 ... */
2829 /* 000 */ V(8, 12, 2), /* 236 */ 2829 /* 000 */ V(8, 12, 2), /* 236 */
2830 /* 001 */ V(8, 12, 2), 2830 /* 001 */ V(8, 12, 2),
2831 /* 010 */ V(12, 8, 2), 2831 /* 010 */ V(12, 8, 2),
2832 /* 011 */ V(12, 8, 2), 2832 /* 011 */ V(12, 8, 2),
@@ -2836,61 +2836,61 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2836 /* 111 */ V(3, 14, 2), 2836 /* 111 */ V(3, 14, 2),
2837 2837
2838 /* 0100 0100 ... */ 2838 /* 0100 0100 ... */
2839 /* 00 */ V(6, 13, 2), /* 244 */ 2839 /* 00 */ V(6, 13, 2), /* 244 */
2840 /* 01 */ V(13, 6, 2), 2840 /* 01 */ V(13, 6, 2),
2841 /* 10 */ V(14, 3, 2), 2841 /* 10 */ V(14, 3, 2),
2842 /* 11 */ V(9, 11, 2), 2842 /* 11 */ V(9, 11, 2),
2843 2843
2844 /* 0100 0101 ... */ 2844 /* 0100 0101 ... */
2845 /* 00 */ V(11, 9, 2), /* 248 */ 2845 /* 00 */ V(11, 9, 2), /* 248 */
2846 /* 01 */ V(10, 10, 2), 2846 /* 01 */ V(10, 10, 2),
2847 /* 10 */ V(14, 2, 2), 2847 /* 10 */ V(14, 2, 2),
2848 /* 11 */ V(1, 14, 2), 2848 /* 11 */ V(1, 14, 2),
2849 2849
2850 /* 0100 0110 ... */ 2850 /* 0100 0110 ... */
2851 /* 00 */ V(14, 1, 2), /* 252 */ 2851 /* 00 */ V(14, 1, 2), /* 252 */
2852 /* 01 */ V(5, 13, 2), 2852 /* 01 */ V(5, 13, 2),
2853 /* 10 */ V(13, 5, 2), 2853 /* 10 */ V(13, 5, 2),
2854 /* 11 */ V(7, 12, 2), 2854 /* 11 */ V(7, 12, 2),
2855 2855
2856 /* 0100 0111 ... */ 2856 /* 0100 0111 ... */
2857 /* 00 */ V(12, 7, 2), /* 256 */ 2857 /* 00 */ V(12, 7, 2), /* 256 */
2858 /* 01 */ V(4, 13, 2), 2858 /* 01 */ V(4, 13, 2),
2859 /* 10 */ V(8, 11, 2), 2859 /* 10 */ V(8, 11, 2),
2860 /* 11 */ V(11, 8, 2), 2860 /* 11 */ V(11, 8, 2),
2861 2861
2862 /* 0100 1000 ... */ 2862 /* 0100 1000 ... */
2863 /* 00 */ V(13, 4, 2), /* 260 */ 2863 /* 00 */ V(13, 4, 2), /* 260 */
2864 /* 01 */ V(9, 10, 2), 2864 /* 01 */ V(9, 10, 2),
2865 /* 10 */ V(10, 9, 2), 2865 /* 10 */ V(10, 9, 2),
2866 /* 11 */ V(6, 12, 2), 2866 /* 11 */ V(6, 12, 2),
2867 2867
2868 /* 0100 1001 ... */ 2868 /* 0100 1001 ... */
2869 /* 00 */ V(12, 6, 2), /* 264 */ 2869 /* 00 */ V(12, 6, 2), /* 264 */
2870 /* 01 */ V(3, 13, 2), 2870 /* 01 */ V(3, 13, 2),
2871 /* 10 */ V(13, 3, 2), 2871 /* 10 */ V(13, 3, 2),
2872 /* 11 */ V(2, 13, 2), 2872 /* 11 */ V(2, 13, 2),
2873 2873
2874 /* 0100 1010 ... */ 2874 /* 0100 1010 ... */
2875 /* 00 */ V(13, 2, 2), /* 268 */ 2875 /* 00 */ V(13, 2, 2), /* 268 */
2876 /* 01 */ V(1, 13, 2), 2876 /* 01 */ V(1, 13, 2),
2877 /* 10 */ V(7, 11, 2), 2877 /* 10 */ V(7, 11, 2),
2878 /* 11 */ V(11, 7, 2), 2878 /* 11 */ V(11, 7, 2),
2879 2879
2880 /* 0100 1011 ... */ 2880 /* 0100 1011 ... */
2881 /* 00 */ V(13, 1, 2), /* 272 */ 2881 /* 00 */ V(13, 1, 2), /* 272 */
2882 /* 01 */ V(5, 12, 2), 2882 /* 01 */ V(5, 12, 2),
2883 /* 10 */ V(12, 5, 2), 2883 /* 10 */ V(12, 5, 2),
2884 /* 11 */ V(8, 10, 2), 2884 /* 11 */ V(8, 10, 2),
2885 2885
2886 /* 0100 1100 ... */ 2886 /* 0100 1100 ... */
2887 /* 00 */ V(10, 8, 2), /* 276 */ 2887 /* 00 */ V(10, 8, 2), /* 276 */
2888 /* 01 */ V(9, 9, 2), 2888 /* 01 */ V(9, 9, 2),
2889 /* 10 */ V(4, 12, 2), 2889 /* 10 */ V(4, 12, 2),
2890 /* 11 */ V(12, 4, 2), 2890 /* 11 */ V(12, 4, 2),
2891 2891
2892 /* 0100 1101 ... */ 2892 /* 0100 1101 ... */
2893 /* 000 */ V(6, 11, 2), /* 280 */ 2893 /* 000 */ V(6, 11, 2), /* 280 */
2894 /* 001 */ V(6, 11, 2), 2894 /* 001 */ V(6, 11, 2),
2895 /* 010 */ V(11, 6, 2), 2895 /* 010 */ V(11, 6, 2),
2896 /* 011 */ V(11, 6, 2), 2896 /* 011 */ V(11, 6, 2),
@@ -2900,25 +2900,25 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2900 /* 111 */ V(3, 12, 2), 2900 /* 111 */ V(3, 12, 2),
2901 2901
2902 /* 0100 1110 ... */ 2902 /* 0100 1110 ... */
2903 /* 00 */ V(12, 3, 2), /* 288 */ 2903 /* 00 */ V(12, 3, 2), /* 288 */
2904 /* 01 */ V(7, 10, 2), 2904 /* 01 */ V(7, 10, 2),
2905 /* 10 */ V(10, 7, 2), 2905 /* 10 */ V(10, 7, 2),
2906 /* 11 */ V(2, 12, 2), 2906 /* 11 */ V(2, 12, 2),
2907 2907
2908 /* 0100 1111 ... */ 2908 /* 0100 1111 ... */
2909 /* 00 */ V(12, 2, 2), /* 292 */ 2909 /* 00 */ V(12, 2, 2), /* 292 */
2910 /* 01 */ V(5, 11, 2), 2910 /* 01 */ V(5, 11, 2),
2911 /* 10 */ V(11, 5, 2), 2911 /* 10 */ V(11, 5, 2),
2912 /* 11 */ V(1, 12, 2), 2912 /* 11 */ V(1, 12, 2),
2913 2913
2914 /* 0101 0000 ... */ 2914 /* 0101 0000 ... */
2915 /* 00 */ V(8, 9, 2), /* 296 */ 2915 /* 00 */ V(8, 9, 2), /* 296 */
2916 /* 01 */ V(9, 8, 2), 2916 /* 01 */ V(9, 8, 2),
2917 /* 10 */ V(12, 1, 2), 2917 /* 10 */ V(12, 1, 2),
2918 /* 11 */ V(4, 11, 2), 2918 /* 11 */ V(4, 11, 2),
2919 2919
2920 /* 0101 0001 ... */ 2920 /* 0101 0001 ... */
2921 /* 000 */ V(12, 0, 3), /* 300 */ 2921 /* 000 */ V(12, 0, 3), /* 300 */
2922 /* 001 */ V(0, 11, 3), 2922 /* 001 */ V(0, 11, 3),
2923 /* 010 */ V(3, 11, 2), 2923 /* 010 */ V(3, 11, 2),
2924 /* 011 */ V(3, 11, 2), 2924 /* 011 */ V(3, 11, 2),
@@ -2928,13 +2928,13 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2928 /* 111 */ V(1, 10, 2), 2928 /* 111 */ V(1, 10, 2),
2929 2929
2930 /* 0101 0010 ... */ 2930 /* 0101 0010 ... */
2931 /* 00 */ V(11, 4, 1), /* 308 */ 2931 /* 00 */ V(11, 4, 1), /* 308 */
2932 /* 01 */ V(11, 4, 1), 2932 /* 01 */ V(11, 4, 1),
2933 /* 10 */ V(6, 10, 2), 2933 /* 10 */ V(6, 10, 2),
2934 /* 11 */ V(10, 6, 2), 2934 /* 11 */ V(10, 6, 2),
2935 2935
2936 /* 0101 0011 ... */ 2936 /* 0101 0011 ... */
2937 /* 000 */ V(7, 9, 2), /* 312 */ 2937 /* 000 */ V(7, 9, 2), /* 312 */
2938 /* 001 */ V(7, 9, 2), 2938 /* 001 */ V(7, 9, 2),
2939 /* 010 */ V(9, 7, 2), 2939 /* 010 */ V(9, 7, 2),
2940 /* 011 */ V(9, 7, 2), 2940 /* 011 */ V(9, 7, 2),
@@ -2944,125 +2944,125 @@ union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = {
2944 /* 111 */ V(9, 0, 2), 2944 /* 111 */ V(9, 0, 2),
2945 2945
2946 /* 0101 0100 ... */ 2946 /* 0101 0100 ... */
2947 /* 0 */ V(11, 3, 1), /* 320 */ 2947 /* 0 */ V(11, 3, 1), /* 320 */
2948 /* 1 */ V(8, 8, 1), 2948 /* 1 */ V(8, 8, 1),
2949 2949
2950 /* 0101 0101 ... */ 2950 /* 0101 0101 ... */
2951 /* 00 */ V(2, 11, 2), /* 322 */ 2951 /* 00 */ V(2, 11, 2), /* 322 */
2952 /* 01 */ V(5, 10, 2), 2952 /* 01 */ V(5, 10, 2),
2953 /* 10 */ V(11, 2, 1), 2953 /* 10 */ V(11, 2, 1),
2954 /* 11 */ V(11, 2, 1), 2954 /* 11 */ V(11, 2, 1),
2955 2955
2956 /* 0101 0110 ... */ 2956 /* 0101 0110 ... */
2957 /* 00 */ V(10, 5, 2), /* 326 */ 2957 /* 00 */ V(10, 5, 2), /* 326 */
2958 /* 01 */ V(1, 11, 2), 2958 /* 01 */ V(1, 11, 2),
2959 /* 10 */ V(11, 1, 2), 2959 /* 10 */ V(11, 1, 2),
2960 /* 11 */ V(6, 9, 2), 2960 /* 11 */ V(6, 9, 2),
2961 2961
2962 /* 0101 0111 ... */ 2962 /* 0101 0111 ... */
2963 /* 0 */ V(9, 6, 1), /* 330 */ 2963 /* 0 */ V(9, 6, 1), /* 330 */
2964 /* 1 */ V(10, 4, 1), 2964 /* 1 */ V(10, 4, 1),
2965 2965
2966 /* 0101 1000 ... */ 2966 /* 0101 1000 ... */
2967 /* 00 */ V(4, 10, 2), /* 332 */ 2967 /* 00 */ V(4, 10, 2), /* 332 */
2968 /* 01 */ V(7, 8, 2), 2968 /* 01 */ V(7, 8, 2),
2969 /* 10 */ V(8, 7, 1), 2969 /* 10 */ V(8, 7, 1),
2970 /* 11 */ V(8, 7, 1), 2970 /* 11 */ V(8, 7, 1),
2971 2971
2972 /* 0101 1001 ... */ 2972 /* 0101 1001 ... */
2973 /* 0 */ V(3, 10, 1), /* 336 */ 2973 /* 0 */ V(3, 10, 1), /* 336 */
2974 /* 1 */ V(10, 3, 1), 2974 /* 1 */ V(10, 3, 1),
2975 2975
2976 /* 0101 1010 ... */ 2976 /* 0101 1010 ... */
2977 /* 0 */ V(5, 9, 1), /* 338 */ 2977 /* 0 */ V(5, 9, 1), /* 338 */
2978 /* 1 */ V(9, 5, 1), 2978 /* 1 */ V(9, 5, 1),
2979 2979
2980 /* 0101 1011 ... */ 2980 /* 0101 1011 ... */
2981 /* 0 */ V(2, 10, 1), /* 340 */ 2981 /* 0 */ V(2, 10, 1), /* 340 */
2982 /* 1 */ V(10, 2, 1), 2982 /* 1 */ V(10, 2, 1),
2983 2983
2984 /* 0101 1100 ... */ 2984 /* 0101 1100 ... */
2985 /* 0 */ V(10, 1, 1), /* 342 */ 2985 /* 0 */ V(10, 1, 1), /* 342 */
2986 /* 1 */ V(6, 8, 1), 2986 /* 1 */ V(6, 8, 1),
2987 2987
2988 /* 0101 1101 ... */ 2988 /* 0101 1101 ... */
2989 /* 0 */ V(8, 6, 1), /* 344 */ 2989 /* 0 */ V(8, 6, 1), /* 344 */
2990 /* 1 */ V(7, 7, 1), 2990 /* 1 */ V(7, 7, 1),
2991 2991
2992 /* 0101 1110 ... */ 2992 /* 0101 1110 ... */
2993 /* 0 */ V(4, 9, 1), /* 346 */ 2993 /* 0 */ V(4, 9, 1), /* 346 */
2994 /* 1 */ V(9, 4, 1), 2994 /* 1 */ V(9, 4, 1),
2995 2995
2996 /* 0101 1111 ... */ 2996 /* 0101 1111 ... */
2997 /* 0 */ V(3, 9, 1), /* 348 */ 2997 /* 0 */ V(3, 9, 1), /* 348 */
2998 /* 1 */ V(9, 3, 1), 2998 /* 1 */ V(9, 3, 1),
2999 2999
3000 /* 0110 0000 ... */ 3000 /* 0110 0000 ... */
3001 /* 0 */ V(5, 8, 1), /* 350 */ 3001 /* 0 */ V(5, 8, 1), /* 350 */
3002 /* 1 */ V(8, 5, 1), 3002 /* 1 */ V(8, 5, 1),
3003 3003
3004 /* 0110 0001 ... */ 3004 /* 0110 0001 ... */
3005 /* 0 */ V(2, 9, 1), /* 352 */ 3005 /* 0 */ V(2, 9, 1), /* 352 */
3006 /* 1 */ V(6, 7, 1), 3006 /* 1 */ V(6, 7, 1),
3007 3007
3008 /* 0110 0010 ... */ 3008 /* 0110 0010 ... */
3009 /* 0 */ V(7, 6, 1), /* 354 */ 3009 /* 0 */ V(7, 6, 1), /* 354 */
3010 /* 1 */ V(9, 2, 1), 3010 /* 1 */ V(9, 2, 1),
3011 3011
3012 /* 0110 0011 ... */ 3012 /* 0110 0011 ... */
3013 /* 0 */ V(1, 9, 1), /* 356 */ 3013 /* 0 */ V(1, 9, 1), /* 356 */
3014 /* 1 */ V(9, 1, 1), 3014 /* 1 */ V(9, 1, 1),
3015 3015
3016 /* 0110 0100 ... */ 3016 /* 0110 0100 ... */
3017 /* 0 */ V(4, 8, 1), /* 358 */ 3017 /* 0 */ V(4, 8, 1), /* 358 */
3018 /* 1 */ V(8, 4, 1), 3018 /* 1 */ V(8, 4, 1),
3019 3019
3020 /* 0110 0101 ... */ 3020 /* 0110 0101 ... */
3021 /* 0 */ V(5, 7, 1), /* 360 */ 3021 /* 0 */ V(5, 7, 1), /* 360 */
3022 /* 1 */ V(7, 5, 1), 3022 /* 1 */ V(7, 5, 1),
3023 3023
3024 /* 0110 0110 ... */ 3024 /* 0110 0110 ... */
3025 /* 0 */ V(3, 8, 1), /* 362 */ 3025 /* 0 */ V(3, 8, 1), /* 362 */
3026 /* 1 */ V(8, 3, 1), 3026 /* 1 */ V(8, 3, 1),
3027 3027
3028 /* 0110 0111 ... */ 3028 /* 0110 0111 ... */
3029 /* 0 */ V(6, 6, 1), /* 364 */ 3029 /* 0 */ V(6, 6, 1), /* 364 */
3030 /* 1 */ V(2, 8, 1), 3030 /* 1 */ V(2, 8, 1),
3031 3031
3032 /* 0110 1000 ... */ 3032 /* 0110 1000 ... */
3033 /* 0 */ V(8, 2, 1), /* 366 */ 3033 /* 0 */ V(8, 2, 1), /* 366 */
3034 /* 1 */ V(1, 8, 1), 3034 /* 1 */ V(1, 8, 1),
3035 3035
3036 /* 0110 1001 ... */ 3036 /* 0110 1001 ... */
3037 /* 0 */ V(4, 7, 1), /* 368 */ 3037 /* 0 */ V(4, 7, 1), /* 368 */
3038 /* 1 */ V(7, 4, 1), 3038 /* 1 */ V(7, 4, 1),
3039 3039
3040 /* 0110 1010 ... */ 3040 /* 0110 1010 ... */
3041 /* 00 */ V(8, 1, 1), /* 370 */ 3041 /* 00 */ V(8, 1, 1), /* 370 */
3042 /* 01 */ V(8, 1, 1), 3042 /* 01 */ V(8, 1, 1),
3043 /* 10 */ V(0, 8, 2), 3043 /* 10 */ V(0, 8, 2),
3044 /* 11 */ V(8, 0, 2), 3044 /* 11 */ V(8, 0, 2),
3045 3045
3046 /* 0110 1011 ... */ 3046 /* 0110 1011 ... */
3047 /* 0 */ V(5, 6, 1), /* 374 */ 3047 /* 0 */ V(5, 6, 1), /* 374 */
3048 /* 1 */ V(6, 5, 1), 3048 /* 1 */ V(6, 5, 1),
3049 3049
3050 /* 0110 1100 ... */ 3050 /* 0110 1100 ... */
3051 /* 00 */ V(1, 7, 1), /* 376 */ 3051 /* 00 */ V(1, 7, 1), /* 376 */
3052 /* 01 */ V(1, 7, 1), 3052 /* 01 */ V(1, 7, 1),
3053 /* 10 */ V(0, 7, 2), 3053 /* 10 */ V(0, 7, 2),
3054 /* 11 */ V(7, 0, 2), 3054 /* 11 */ V(7, 0, 2),
3055 3055
3056 /* 0110 1110 ... */ 3056 /* 0110 1110 ... */
3057 /* 0 */ V(3, 7, 1), /* 380 */ 3057 /* 0 */ V(3, 7, 1), /* 380 */
3058 /* 1 */ V(2, 7, 1), 3058 /* 1 */ V(2, 7, 1),
3059 3059
3060 /* 0111 1100 ... */ 3060 /* 0111 1100 ... */
3061 /* 0 */ V(0, 6, 1), /* 382 */ 3061 /* 0 */ V(0, 6, 1), /* 382 */
3062 /* 1 */ V(6, 0, 1), 3062 /* 1 */ V(6, 0, 1),
3063 3063
3064 /* 1000 0011 ... */ 3064 /* 1000 0011 ... */
3065 /* 0 */ V(0, 5, 1), /* 384 */ 3065 /* 0 */ V(0, 5, 1), /* 384 */
3066 /* 1 */ V(5, 0, 1) 3066 /* 1 */ V(5, 0, 1)
3067}; 3067};
3068 3068
diff --git a/apps/codecs/libmad/layer12.c b/apps/codecs/libmad/layer12.c
index ccac392b42..d294266e69 100644
--- a/apps/codecs/libmad/layer12.c
+++ b/apps/codecs/libmad/layer12.c
@@ -69,8 +69,8 @@ mad_fixed_t const linear_table[14] ICONST_ATTR = {
69}; 69};
70 70
71/* 71/*
72 * NAME: I_sample() 72 * NAME: I_sample()
73 * DESCRIPTION: decode one requantized Layer I sample from a bitstream 73 * DESCRIPTION: decode one requantized Layer I sample from a bitstream
74 */ 74 */
75static inline 75static inline
76mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb) 76mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb)
@@ -99,8 +99,8 @@ mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb)
99} 99}
100 100
101/* 101/*
102 * NAME: layer->I() 102 * NAME: layer->I()
103 * DESCRIPTION: decode a single Layer I frame 103 * DESCRIPTION: decode a single Layer I frame
104 */ 104 */
105int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) 105int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
106{ 106{
@@ -121,10 +121,10 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
121 if (header->flags & MAD_FLAG_PROTECTION) { 121 if (header->flags & MAD_FLAG_PROTECTION) {
122 header->crc_check = 122 header->crc_check =
123 mad_bit_crc(stream->ptr, 4 * (bound * nch + (32 - bound)), 123 mad_bit_crc(stream->ptr, 4 * (bound * nch + (32 - bound)),
124 header->crc_check); 124 header->crc_check);
125 125
126 if (header->crc_check != header->crc_target && 126 if (header->crc_check != header->crc_target &&
127 !(frame->options & MAD_OPTION_IGNORECRC)) { 127 !(frame->options & MAD_OPTION_IGNORECRC)) {
128 stream->error = MAD_ERROR_BADCRC; 128 stream->error = MAD_ERROR_BADCRC;
129 return -1; 129 return -1;
130 } 130 }
@@ -137,8 +137,8 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
137 nb = mad_bit_read(&stream->ptr, 4); 137 nb = mad_bit_read(&stream->ptr, 4);
138 138
139 if (nb == 15) { 139 if (nb == 15) {
140 stream->error = MAD_ERROR_BADBITALLOC; 140 stream->error = MAD_ERROR_BADBITALLOC;
141 return -1; 141 return -1;
142 } 142 }
143 143
144 allocation[ch][sb] = nb ? nb + 1 : 0; 144 allocation[ch][sb] = nb ? nb + 1 : 0;
@@ -162,18 +162,18 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
162 for (sb = 0; sb < 32; ++sb) { 162 for (sb = 0; sb < 32; ++sb) {
163 for (ch = 0; ch < nch; ++ch) { 163 for (ch = 0; ch < nch; ++ch) {
164 if (allocation[ch][sb]) { 164 if (allocation[ch][sb]) {
165 scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6); 165 scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
166 166
167# if defined(OPT_STRICT) 167# if defined(OPT_STRICT)
168 /* 168 /*
169 * Scalefactor index 63 does not appear in Table B.1 of 169 * Scalefactor index 63 does not appear in Table B.1 of
170 * ISO/IEC 11172-3. Nonetheless, other implementations accept it, 170 * ISO/IEC 11172-3. Nonetheless, other implementations accept it,
171 * so we only reject it if OPT_STRICT is defined. 171 * so we only reject it if OPT_STRICT is defined.
172 */ 172 */
173 if (scalefactor[ch][sb] == 63) { 173 if (scalefactor[ch][sb] == 63) {
174 stream->error = MAD_ERROR_BADSCALEFACTOR; 174 stream->error = MAD_ERROR_BADSCALEFACTOR;
175 return -1; 175 return -1;
176 } 176 }
177# endif 177# endif
178 } 178 }
179 } 179 }
@@ -184,27 +184,27 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
184 for (s = 0; s < 12; ++s) { 184 for (s = 0; s < 12; ++s) {
185 for (sb = 0; sb < bound; ++sb) { 185 for (sb = 0; sb < bound; ++sb) {
186 for (ch = 0; ch < nch; ++ch) { 186 for (ch = 0; ch < nch; ++ch) {
187 nb = allocation[ch][sb]; 187 nb = allocation[ch][sb];
188 (*frame->sbsample)[ch][s][sb] = nb ? 188 (*frame->sbsample)[ch][s][sb] = nb ?
189 mad_f_mul(I_sample(&stream->ptr, nb), 189 mad_f_mul(I_sample(&stream->ptr, nb),
190 sf_table[scalefactor[ch][sb]]) : 0; 190 sf_table[scalefactor[ch][sb]]) : 0;
191 } 191 }
192 } 192 }
193 193
194 for (sb = bound; sb < 32; ++sb) { 194 for (sb = bound; sb < 32; ++sb) {
195 if ((nb = allocation[0][sb])) { 195 if ((nb = allocation[0][sb])) {
196 mad_fixed_t sample; 196 mad_fixed_t sample;
197 197
198 sample = I_sample(&stream->ptr, nb); 198 sample = I_sample(&stream->ptr, nb);
199 199
200 for (ch = 0; ch < nch; ++ch) { 200 for (ch = 0; ch < nch; ++ch) {
201 (*frame->sbsample)[ch][s][sb] = 201 (*frame->sbsample)[ch][s][sb] =
202 mad_f_mul(sample, sf_table[scalefactor[ch][sb]]); 202 mad_f_mul(sample, sf_table[scalefactor[ch][sb]]);
203 } 203 }
204 } 204 }
205 else { 205 else {
206 for (ch = 0; ch < nch; ++ch) 206 for (ch = 0; ch < nch; ++ch)
207 (*frame->sbsample)[ch][s][sb] = 0; 207 (*frame->sbsample)[ch][s][sb] = 0;
208 } 208 }
209 } 209 }
210 } 210 }
@@ -221,18 +221,18 @@ struct {
221 unsigned char const offsets[30]; 221 unsigned char const offsets[30];
222} const sbquant_table[5] = { 222} const sbquant_table[5] = {
223 /* ISO/IEC 11172-3 Table B.2a */ 223 /* ISO/IEC 11172-3 Table B.2a */
224 { 27, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 0 */ 224 { 27, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 0 */
225 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, 225 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } },
226 /* ISO/IEC 11172-3 Table B.2b */ 226 /* ISO/IEC 11172-3 Table B.2b */
227 { 30, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 1 */ 227 { 30, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 1 */
228 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } }, 228 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } },
229 /* ISO/IEC 11172-3 Table B.2c */ 229 /* ISO/IEC 11172-3 Table B.2c */
230 { 8, { 5, 5, 2, 2, 2, 2, 2, 2 } }, /* 2 */ 230 { 8, { 5, 5, 2, 2, 2, 2, 2, 2 } }, /* 2 */
231 /* ISO/IEC 11172-3 Table B.2d */ 231 /* ISO/IEC 11172-3 Table B.2d */
232 { 12, { 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, /* 3 */ 232 { 12, { 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, /* 3 */
233 /* ISO/IEC 13818-3 Table B.1 */ 233 /* ISO/IEC 13818-3 Table B.1 */
234 { 30, { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, /* 4 */ 234 { 30, { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, /* 4 */
235 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } } 235 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }
236}; 236};
237 237
238/* bit allocation table */ 238/* bit allocation table */
@@ -275,13 +275,13 @@ struct quantclass {
275}; 275};
276 276
277/* 277/*
278 * NAME: II_samples() 278 * NAME: II_samples()
279 * DESCRIPTION: decode three requantized Layer II samples from a bitstream 279 * DESCRIPTION: decode three requantized Layer II samples from a bitstream
280 */ 280 */
281static 281static
282void II_samples(struct mad_bitptr *ptr, 282void II_samples(struct mad_bitptr *ptr,
283 struct quantclass const *quantclass, 283 struct quantclass const *quantclass,
284 mad_fixed_t output[3]) 284 mad_fixed_t output[3])
285{ 285{
286 unsigned int nb, s, sample[3]; 286 unsigned int nb, s, sample[3];
287 287
@@ -326,8 +326,8 @@ void II_samples(struct mad_bitptr *ptr,
326} 326}
327 327
328/* 328/*
329 * NAME: layer->II() 329 * NAME: layer->II()
330 * DESCRIPTION: decode a single Layer II frame 330 * DESCRIPTION: decode a single Layer II frame
331 */ 331 */
332int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) 332int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
333{ 333{
@@ -358,19 +358,19 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
358 * restriction. We enforce it if OPT_STRICT is defined. 358 * restriction. We enforce it if OPT_STRICT is defined.
359 */ 359 */
360 if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) { 360 if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) {
361 stream->error = MAD_ERROR_BADMODE; 361 stream->error = MAD_ERROR_BADMODE;
362 return -1; 362 return -1;
363 } 363 }
364# endif 364# endif
365 } 365 }
366 else { /* nch == 1 */ 366 else { /* nch == 1 */
367 if (bitrate_per_channel > 192000) { 367 if (bitrate_per_channel > 192000) {
368 /* 368 /*
369 * ISO/IEC 11172-3 does not allow single channel mode for 224, 256, 369 * ISO/IEC 11172-3 does not allow single channel mode for 224, 256,
370 * 320, or 384 kbps bitrates in Layer II. 370 * 320, or 384 kbps bitrates in Layer II.
371 */ 371 */
372 stream->error = MAD_ERROR_BADMODE; 372 stream->error = MAD_ERROR_BADMODE;
373 return -1; 373 return -1;
374 } 374 }
375 } 375 }
376 376
@@ -419,7 +419,7 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
419 for (sb = 0; sb < sblimit; ++sb) { 419 for (sb = 0; sb < sblimit; ++sb) {
420 for (ch = 0; ch < nch; ++ch) { 420 for (ch = 0; ch < nch; ++ch) {
421 if (allocation[ch][sb]) 421 if (allocation[ch][sb])
422 scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2); 422 scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
423 } 423 }
424 } 424 }
425 425
@@ -428,10 +428,10 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
428 if (header->flags & MAD_FLAG_PROTECTION) { 428 if (header->flags & MAD_FLAG_PROTECTION) {
429 header->crc_check = 429 header->crc_check =
430 mad_bit_crc(start, mad_bit_length(&start, &stream->ptr), 430 mad_bit_crc(start, mad_bit_length(&start, &stream->ptr),
431 header->crc_check); 431 header->crc_check);
432 432
433 if (header->crc_check != header->crc_target && 433 if (header->crc_check != header->crc_target &&
434 !(frame->options & MAD_OPTION_IGNORECRC)) { 434 !(frame->options & MAD_OPTION_IGNORECRC)) {
435 stream->error = MAD_ERROR_BADCRC; 435 stream->error = MAD_ERROR_BADCRC;
436 return -1; 436 return -1;
437 } 437 }
@@ -442,39 +442,39 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
442 for (sb = 0; sb < sblimit; ++sb) { 442 for (sb = 0; sb < sblimit; ++sb) {
443 for (ch = 0; ch < nch; ++ch) { 443 for (ch = 0; ch < nch; ++ch) {
444 if (allocation[ch][sb]) { 444 if (allocation[ch][sb]) {
445 scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6); 445 scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
446 446
447 switch (scfsi[ch][sb]) { 447 switch (scfsi[ch][sb]) {
448 case 2: 448 case 2:
449 scalefactor[ch][sb][2] = 449 scalefactor[ch][sb][2] =
450 scalefactor[ch][sb][1] = 450 scalefactor[ch][sb][1] =
451 scalefactor[ch][sb][0]; 451 scalefactor[ch][sb][0];
452 break; 452 break;
453 453
454 case 0: 454 case 0:
455 scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6); 455 scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
456 /* fall through */ 456 /* fall through */
457 457
458 case 1: 458 case 1:
459 case 3: 459 case 3:
460 scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6); 460 scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
461 } 461 }
462 462
463 if (scfsi[ch][sb] & 1) 463 if (scfsi[ch][sb] & 1)
464 scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1]; 464 scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1];
465 465
466# if defined(OPT_STRICT) 466# if defined(OPT_STRICT)
467 /* 467 /*
468 * Scalefactor index 63 does not appear in Table B.1 of 468 * Scalefactor index 63 does not appear in Table B.1 of
469 * ISO/IEC 11172-3. Nonetheless, other implementations accept it, 469 * ISO/IEC 11172-3. Nonetheless, other implementations accept it,
470 * so we only reject it if OPT_STRICT is defined. 470 * so we only reject it if OPT_STRICT is defined.
471 */ 471 */
472 if (scalefactor[ch][sb][0] == 63 || 472 if (scalefactor[ch][sb][0] == 63 ||
473 scalefactor[ch][sb][1] == 63 || 473 scalefactor[ch][sb][1] == 63 ||
474 scalefactor[ch][sb][2] == 63) { 474 scalefactor[ch][sb][2] == 63) {
475 stream->error = MAD_ERROR_BADSCALEFACTOR; 475 stream->error = MAD_ERROR_BADSCALEFACTOR;
476 return -1; 476 return -1;
477 } 477 }
478# endif 478# endif
479 } 479 }
480 } 480 }
@@ -485,50 +485,50 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
485 for (gr = 0; gr < 12; ++gr) { 485 for (gr = 0; gr < 12; ++gr) {
486 for (sb = 0; sb < bound; ++sb) { 486 for (sb = 0; sb < bound; ++sb) {
487 for (ch = 0; ch < nch; ++ch) { 487 for (ch = 0; ch < nch; ++ch) {
488 if ((index = allocation[ch][sb])) { 488 if ((index = allocation[ch][sb])) {
489 int off = bitalloc_table[offsets[sb]].offset; 489 int off = bitalloc_table[offsets[sb]].offset;
490 index = offset_table[off][index - 1]; 490 index = offset_table[off][index - 1];
491 491
492 II_samples(&stream->ptr, &qc_table[index], samples); 492 II_samples(&stream->ptr, &qc_table[index], samples);
493 493
494 for (s = 0; s < 3; ++s) { 494 for (s = 0; s < 3; ++s) {
495 (*frame->sbsample)[ch][3 * gr + s][sb] = 495 (*frame->sbsample)[ch][3 * gr + s][sb] =
496 mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); 496 mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]);
497 } 497 }
498 } 498 }
499 else { 499 else {
500 for (s = 0; s < 3; ++s) 500 for (s = 0; s < 3; ++s)
501 (*frame->sbsample)[ch][3 * gr + s][sb] = 0; 501 (*frame->sbsample)[ch][3 * gr + s][sb] = 0;
502 } 502 }
503 } 503 }
504 } 504 }
505 505
506 for (sb = bound; sb < sblimit; ++sb) { 506 for (sb = bound; sb < sblimit; ++sb) {
507 if ((index = allocation[0][sb])) { 507 if ((index = allocation[0][sb])) {
508 int off = bitalloc_table[offsets[sb]].offset; 508 int off = bitalloc_table[offsets[sb]].offset;
509 index = offset_table[off][index - 1]; 509 index = offset_table[off][index - 1];
510 510
511 II_samples(&stream->ptr, &qc_table[index], samples); 511 II_samples(&stream->ptr, &qc_table[index], samples);
512 512
513 for (ch = 0; ch < nch; ++ch) { 513 for (ch = 0; ch < nch; ++ch) {
514 for (s = 0; s < 3; ++s) { 514 for (s = 0; s < 3; ++s) {
515 (*frame->sbsample)[ch][3 * gr + s][sb] = 515 (*frame->sbsample)[ch][3 * gr + s][sb] =
516 mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); 516 mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]);
517 } 517 }
518 } 518 }
519 } 519 }
520 else { 520 else {
521 for (ch = 0; ch < nch; ++ch) { 521 for (ch = 0; ch < nch; ++ch) {
522 for (s = 0; s < 3; ++s) 522 for (s = 0; s < 3; ++s)
523 (*frame->sbsample)[ch][3 * gr + s][sb] = 0; 523 (*frame->sbsample)[ch][3 * gr + s][sb] = 0;
524 } 524 }
525 } 525 }
526 } 526 }
527 527
528 for (ch = 0; ch < nch; ++ch) { 528 for (ch = 0; ch < nch; ++ch) {
529 for (s = 0; s < 3; ++s) { 529 for (s = 0; s < 3; ++s) {
530 for (sb = sblimit; sb < 32; ++sb) 530 for (sb = sblimit; sb < 32; ++sb)
531 (*frame->sbsample)[ch][3 * gr + s][sb] = 0; 531 (*frame->sbsample)[ch][3 * gr + s][sb] = 0;
532 } 532 }
533 } 533 }
534 } 534 }
diff --git a/apps/codecs/libmad/layer3.c b/apps/codecs/libmad/layer3.c
index 0a53086d78..2dcdeb96d4 100644
--- a/apps/codecs/libmad/layer3.c
+++ b/apps/codecs/libmad/layer3.c
@@ -57,7 +57,7 @@
57enum { 57enum {
58 count1table_select = 0x01, 58 count1table_select = 0x01,
59 scalefac_scale = 0x02, 59 scalefac_scale = 0x02,
60 preflag = 0x04, 60 preflag = 0x04,
61 mixed_block_flag = 0x08 61 mixed_block_flag = 0x08
62}; 62};
63 63
@@ -88,7 +88,7 @@ struct sideinfo {
88 unsigned char region1_count; 88 unsigned char region1_count;
89 89
90 /* from main_data */ 90 /* from main_data */
91 unsigned char scalefac[39]; /* scalefac_l and/or scalefac_s */ 91 unsigned char scalefac[39]; /* scalefac_l and/or scalefac_s */
92 } ch[2]; 92 } ch[2];
93 } gr[2]; 93 } gr[2];
94}; 94};
@@ -502,14 +502,14 @@ mad_fixed_t const is_lsf_table[2][15] = {
502}; 502};
503 503
504/* 504/*
505 * NAME: III_sideinfo() 505 * NAME: III_sideinfo()
506 * DESCRIPTION: decode frame side information from a bitstream 506 * DESCRIPTION: decode frame side information from a bitstream
507 */ 507 */
508static 508static
509enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, 509enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch,
510 int lsf, struct sideinfo *si, 510 int lsf, struct sideinfo *si,
511 unsigned int *data_bitlen, 511 unsigned int *data_bitlen,
512 unsigned int *priv_bitlen) 512 unsigned int *priv_bitlen)
513{ 513{
514 unsigned int ngr, gr, ch, i; 514 unsigned int ngr, gr, ch, i;
515 enum mad_error result = MAD_ERROR_NONE; 515 enum mad_error result = MAD_ERROR_NONE;
@@ -542,46 +542,46 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch,
542 *data_bitlen += channel->part2_3_length; 542 *data_bitlen += channel->part2_3_length;
543 543
544 if (channel->big_values > 288 && result == 0) 544 if (channel->big_values > 288 && result == 0)
545 result = MAD_ERROR_BADBIGVALUES; 545 result = MAD_ERROR_BADBIGVALUES;
546 546
547 channel->flags = 0; 547 channel->flags = 0;
548 548
549 /* window_switching_flag */ 549 /* window_switching_flag */
550 if (mad_bit_read(ptr, 1)) { 550 if (mad_bit_read(ptr, 1)) {
551 channel->block_type = mad_bit_read(ptr, 2); 551 channel->block_type = mad_bit_read(ptr, 2);
552 552
553 if (channel->block_type == 0 && result == 0) 553 if (channel->block_type == 0 && result == 0)
554 result = MAD_ERROR_BADBLOCKTYPE; 554 result = MAD_ERROR_BADBLOCKTYPE;
555 555
556 if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0) 556 if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0)
557 result = MAD_ERROR_BADSCFSI; 557 result = MAD_ERROR_BADSCFSI;
558 558
559 channel->region0_count = 7; 559 channel->region0_count = 7;
560 channel->region1_count = 36; 560 channel->region1_count = 36;
561 561
562 if (mad_bit_read(ptr, 1)) 562 if (mad_bit_read(ptr, 1))
563 channel->flags |= mixed_block_flag; 563 channel->flags |= mixed_block_flag;
564 else if (channel->block_type == 2) 564 else if (channel->block_type == 2)
565 channel->region0_count = 8; 565 channel->region0_count = 8;
566 566
567 for (i = 0; i < 2; ++i) 567 for (i = 0; i < 2; ++i)
568 channel->table_select[i] = mad_bit_read(ptr, 5); 568 channel->table_select[i] = mad_bit_read(ptr, 5);
569 569
570# if defined(DEBUG) 570# if defined(DEBUG)
571 channel->table_select[2] = 4; /* not used */ 571 channel->table_select[2] = 4; /* not used */
572# endif 572# endif
573 573
574 for (i = 0; i < 3; ++i) 574 for (i = 0; i < 3; ++i)
575 channel->subblock_gain[i] = mad_bit_read(ptr, 3); 575 channel->subblock_gain[i] = mad_bit_read(ptr, 3);
576 } 576 }
577 else { 577 else {
578 channel->block_type = 0; 578 channel->block_type = 0;
579 579
580 for (i = 0; i < 3; ++i) 580 for (i = 0; i < 3; ++i)
581 channel->table_select[i] = mad_bit_read(ptr, 5); 581 channel->table_select[i] = mad_bit_read(ptr, 5);
582 582
583 channel->region0_count = mad_bit_read(ptr, 4); 583 channel->region0_count = mad_bit_read(ptr, 4);
584 channel->region1_count = mad_bit_read(ptr, 3); 584 channel->region1_count = mad_bit_read(ptr, 3);
585 } 585 }
586 586
587 /* [preflag,] scalefac_scale, count1table_select */ 587 /* [preflag,] scalefac_scale, count1table_select */
@@ -593,13 +593,13 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch,
593} 593}
594 594
595/* 595/*
596 * NAME: III_scalefactors_lsf() 596 * NAME: III_scalefactors_lsf()
597 * DESCRIPTION: decode channel scalefactors for LSF from a bitstream 597 * DESCRIPTION: decode channel scalefactors for LSF from a bitstream
598 */ 598 */
599static 599static
600unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, 600unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
601 struct channel *channel, 601 struct channel *channel,
602 struct channel *gr1ch, int mode_extension) 602 struct channel *gr1ch, int mode_extension)
603{ 603{
604 struct mad_bitptr start; 604 struct mad_bitptr start;
605 unsigned int scalefac_compress, index, slen[4], part, n, i; 605 unsigned int scalefac_compress, index, slen[4], part, n, i;
@@ -646,7 +646,7 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
646 n = 0; 646 n = 0;
647 for (part = 0; part < 4; ++part) { 647 for (part = 0; part < 4; ++part) {
648 for (i = 0; i < nsfb[part]; ++i) 648 for (i = 0; i < nsfb[part]; ++i)
649 channel->scalefac[n++] = mad_bit_read(ptr, slen[part]); 649 channel->scalefac[n++] = mad_bit_read(ptr, slen[part]);
650 } 650 }
651 651
652 while (n < 39) 652 while (n < 39)
@@ -691,10 +691,10 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
691 max = (1 << slen[part]) - 1; 691 max = (1 << slen[part]) - 1;
692 692
693 for (i = 0; i < nsfb[part]; ++i) { 693 for (i = 0; i < nsfb[part]; ++i) {
694 is_pos = mad_bit_read(ptr, slen[part]); 694 is_pos = mad_bit_read(ptr, slen[part]);
695 695
696 channel->scalefac[n] = is_pos; 696 channel->scalefac[n] = is_pos;
697 gr1ch->scalefac[n++] = (is_pos == max); 697 gr1ch->scalefac[n++] = (is_pos == max);
698 } 698 }
699 } 699 }
700 700
@@ -708,12 +708,12 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
708} 708}
709 709
710/* 710/*
711 * NAME: III_scalefactors() 711 * NAME: III_scalefactors()
712 * DESCRIPTION: decode channel scalefactors of one granule from a bitstream 712 * DESCRIPTION: decode channel scalefactors of one granule from a bitstream
713 */ 713 */
714static 714static
715unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, 715unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel,
716 struct channel const *gr0ch, unsigned int scfsi) 716 struct channel const *gr0ch, unsigned int scfsi)
717{ 717{
718 struct mad_bitptr start; 718 struct mad_bitptr start;
719 unsigned int slen1, slen2, sfbi; 719 unsigned int slen1, slen2, sfbi;
@@ -743,38 +743,38 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel,
743 else { /* channel->block_type != 2 */ 743 else { /* channel->block_type != 2 */
744 if (scfsi & 0x8) { 744 if (scfsi & 0x8) {
745 for (sfbi = 0; sfbi < 6; ++sfbi) 745 for (sfbi = 0; sfbi < 6; ++sfbi)
746 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; 746 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi];
747 } 747 }
748 else { 748 else {
749 for (sfbi = 0; sfbi < 6; ++sfbi) 749 for (sfbi = 0; sfbi < 6; ++sfbi)
750 channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); 750 channel->scalefac[sfbi] = mad_bit_read(ptr, slen1);
751 } 751 }
752 752
753 if (scfsi & 0x4) { 753 if (scfsi & 0x4) {
754 for (sfbi = 6; sfbi < 11; ++sfbi) 754 for (sfbi = 6; sfbi < 11; ++sfbi)
755 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; 755 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi];
756 } 756 }
757 else { 757 else {
758 for (sfbi = 6; sfbi < 11; ++sfbi) 758 for (sfbi = 6; sfbi < 11; ++sfbi)
759 channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); 759 channel->scalefac[sfbi] = mad_bit_read(ptr, slen1);
760 } 760 }
761 761
762 if (scfsi & 0x2) { 762 if (scfsi & 0x2) {
763 for (sfbi = 11; sfbi < 16; ++sfbi) 763 for (sfbi = 11; sfbi < 16; ++sfbi)
764 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; 764 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi];
765 } 765 }
766 else { 766 else {
767 for (sfbi = 11; sfbi < 16; ++sfbi) 767 for (sfbi = 11; sfbi < 16; ++sfbi)
768 channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); 768 channel->scalefac[sfbi] = mad_bit_read(ptr, slen2);
769 } 769 }
770 770
771 if (scfsi & 0x1) { 771 if (scfsi & 0x1) {
772 for (sfbi = 16; sfbi < 21; ++sfbi) 772 for (sfbi = 16; sfbi < 21; ++sfbi)
773 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; 773 channel->scalefac[sfbi] = gr0ch->scalefac[sfbi];
774 } 774 }
775 else { 775 else {
776 for (sfbi = 16; sfbi < 21; ++sfbi) 776 for (sfbi = 16; sfbi < 21; ++sfbi)
777 channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); 777 channel->scalefac[sfbi] = mad_bit_read(ptr, slen2);
778 } 778 }
779 779
780 channel->scalefac[21] = 0; 780 channel->scalefac[21] = 0;
@@ -806,12 +806,12 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel,
806 */ 806 */
807 807
808/* 808/*
809 * NAME: III_exponents() 809 * NAME: III_exponents()
810 * DESCRIPTION: calculate scalefactor exponents 810 * DESCRIPTION: calculate scalefactor exponents
811 */ 811 */
812static 812static
813void III_exponents(struct channel const *channel, 813void III_exponents(struct channel const *channel,
814 unsigned char const *sfbwidth, signed int exponents[39]) 814 unsigned char const *sfbwidth, signed int exponents[39])
815{ 815{
816 signed int gain; 816 signed int gain;
817 unsigned int scalefac_multiplier, sfbi; 817 unsigned int scalefac_multiplier, sfbi;
@@ -833,11 +833,11 @@ void III_exponents(struct channel const *channel,
833 /* long block subbands 0-1 */ 833 /* long block subbands 0-1 */
834 834
835 while (l < 36) { 835 while (l < 36) {
836 exponents[sfbi] = gain - 836 exponents[sfbi] = gain -
837 (signed int) ((channel->scalefac[sfbi] + (pretab[sfbi] & premask)) << 837 (signed int) ((channel->scalefac[sfbi] + (pretab[sfbi] & premask)) <<
838 scalefac_multiplier); 838 scalefac_multiplier);
839 839
840 l += sfbwidth[sfbi++]; 840 l += sfbwidth[sfbi++];
841 } 841 }
842 } 842 }
843 843
@@ -849,11 +849,11 @@ void III_exponents(struct channel const *channel,
849 849
850 while (l < 576) { 850 while (l < 576) {
851 exponents[sfbi + 0] = gain0 - 851 exponents[sfbi + 0] = gain0 -
852 (signed int) (channel->scalefac[sfbi + 0] << scalefac_multiplier); 852 (signed int) (channel->scalefac[sfbi + 0] << scalefac_multiplier);
853 exponents[sfbi + 1] = gain1 - 853 exponents[sfbi + 1] = gain1 -
854 (signed int) (channel->scalefac[sfbi + 1] << scalefac_multiplier); 854 (signed int) (channel->scalefac[sfbi + 1] << scalefac_multiplier);
855 exponents[sfbi + 2] = gain2 - 855 exponents[sfbi + 2] = gain2 -
856 (signed int) (channel->scalefac[sfbi + 2] << scalefac_multiplier); 856 (signed int) (channel->scalefac[sfbi + 2] << scalefac_multiplier);
857 unsigned int w = sfbwidth[sfbi]; 857 unsigned int w = sfbwidth[sfbi];
858 l += 3 * w; 858 l += 3 * w;
859 sfbi += 3; 859 sfbi += 3;
@@ -862,23 +862,23 @@ void III_exponents(struct channel const *channel,
862 else { /* channel->block_type != 2 */ 862 else { /* channel->block_type != 2 */
863 if (channel->flags & preflag) { 863 if (channel->flags & preflag) {
864 for (sfbi = 0; sfbi < 22; ++sfbi) { 864 for (sfbi = 0; sfbi < 22; ++sfbi) {
865 exponents[sfbi] = gain - 865 exponents[sfbi] = gain -
866 (signed int) ((channel->scalefac[sfbi] + pretab[sfbi]) << 866 (signed int) ((channel->scalefac[sfbi] + pretab[sfbi]) <<
867 scalefac_multiplier); 867 scalefac_multiplier);
868 } 868 }
869 } 869 }
870 else { 870 else {
871 for (sfbi = 0; sfbi < 22; ++sfbi) { 871 for (sfbi = 0; sfbi < 22; ++sfbi) {
872 exponents[sfbi] = gain - 872 exponents[sfbi] = gain -
873 (signed int) (channel->scalefac[sfbi] << scalefac_multiplier); 873 (signed int) (channel->scalefac[sfbi] << scalefac_multiplier);
874 } 874 }
875 } 875 }
876 } 876 }
877} 877}
878 878
879/* 879/*
880 * NAME: III_requantize() 880 * NAME: III_requantize()
881 * DESCRIPTION: requantize one (positive) value 881 * DESCRIPTION: requantize one (positive) value
882 */ 882 */
883static 883static
884mad_fixed_t III_requantize(unsigned int value, signed int exp) 884mad_fixed_t III_requantize(unsigned int value, signed int exp)
@@ -910,7 +910,7 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp)
910 /* overflow */ 910 /* overflow */
911# if defined(DEBUG) 911# if defined(DEBUG)
912 fprintf(stderr, "requantize overflow (%f * 2^%d)\n", 912 fprintf(stderr, "requantize overflow (%f * 2^%d)\n",
913 mad_f_todouble(requantized), exp); 913 mad_f_todouble(requantized), exp);
914# endif 914# endif
915 requantized = MAD_F_MAX; 915 requantized = MAD_F_MAX;
916 } 916 }
@@ -932,21 +932,21 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp)
932 res; \ 932 res; \
933 }) 933 })
934#else 934#else
935# define MASK(cache, sz, bits) \ 935# define MASK(cache, sz, bits) \
936 (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) 936 (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1))
937#endif 937#endif
938# define MASK1BIT(cache, sz) \ 938# define MASK1BIT(cache, sz) \
939 ((cache) & (1 << ((sz) - 1))) 939 ((cache) & (1 << ((sz) - 1)))
940 940
941/* 941/*
942 * NAME: III_huffdecode() 942 * NAME: III_huffdecode()
943 * DESCRIPTION: decode Huffman code words of one channel of one granule 943 * DESCRIPTION: decode Huffman code words of one channel of one granule
944 */ 944 */
945static 945static
946enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576], 946enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
947 struct channel *channel, 947 struct channel *channel,
948 unsigned char const *sfbwidth, 948 unsigned char const *sfbwidth,
949 unsigned int part2_length) 949 unsigned int part2_length)
950{ 950{
951 unsigned int bits; 951 unsigned int bits;
952 signed int exponents[39], exp; 952 signed int exponents[39], exp;
@@ -999,23 +999,23 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
999 else 999 else
1000 if(region == 0) 1000 if(region == 0)
1001 rcount = channel->region1_count + 1; 1001 rcount = channel->region1_count + 1;
1002 else 1002 else
1003 rcount = 0; /* all remaining */ 1003 rcount = 0; /* all remaining */
1004 1004
1005 entry = &mad_huff_pair_table[channel->table_select[++region]]; 1005 entry = &mad_huff_pair_table[channel->table_select[++region]];
1006 table = entry->table; 1006 table = entry->table;
1007 linbits = entry->linbits; 1007 linbits = entry->linbits;
1008 startbits = entry->startbits; 1008 startbits = entry->startbits;
1009 1009
1010 if(table == 0) 1010 if(table == 0)
1011 return MAD_ERROR_BADHUFFTABLE; 1011 return MAD_ERROR_BADHUFFTABLE;
1012 } 1012 }
1013 1013
1014 if(exp != *expptr) 1014 if(exp != *expptr)
1015 { 1015 {
1016 exp = *expptr; 1016 exp = *expptr;
1017 /* clear cache */ 1017 /* clear cache */
1018 memset(reqcache, 0, sizeof(reqcache)); 1018 memset(reqcache, 0, sizeof(reqcache));
1019 } 1019 }
1020 1020
1021 ++expptr; 1021 ++expptr;
@@ -1052,10 +1052,10 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1052 1052
1053 cachesz -= pair->value.hlen; 1053 cachesz -= pair->value.hlen;
1054 1054
1055 /* x (0..14) */ 1055 /* x (0..14) */
1056 value = pair->value.x; 1056 value = pair->value.x;
1057 if(value == 0) 1057 if(value == 0)
1058 xr[0] = 0; 1058 xr[0] = 0;
1059 else 1059 else
1060 { 1060 {
1061 if(value == 15) 1061 if(value == 15)
@@ -1071,24 +1071,24 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1071 cachesz += bits; 1071 cachesz += bits;
1072 } 1072 }
1073 1073
1074 requantized = III_requantize(15+MASK(bitcache, cachesz, linbits), exp); 1074 requantized = III_requantize(15+MASK(bitcache, cachesz, linbits), exp);
1075 cachesz -= linbits; 1075 cachesz -= linbits;
1076 } 1076 }
1077 else 1077 else
1078 { 1078 {
1079 if(reqcache[value]) 1079 if(reqcache[value])
1080 requantized = reqcache[value]; 1080 requantized = reqcache[value];
1081 else 1081 else
1082 requantized = reqcache[value] = III_requantize(value, exp); 1082 requantized = reqcache[value] = III_requantize(value, exp);
1083 } 1083 }
1084 1084
1085 xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; 1085 xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized;
1086 } 1086 }
1087 1087
1088 /* y (0..14) */ 1088 /* y (0..14) */
1089 value = pair->value.y; 1089 value = pair->value.y;
1090 if(value == 0) 1090 if(value == 0)
1091 xr[1] = 0; 1091 xr[1] = 0;
1092 else 1092 else
1093 { 1093 {
1094 if(value == 15) 1094 if(value == 15)
@@ -1109,12 +1109,12 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1109 } 1109 }
1110 else 1110 else
1111 { 1111 {
1112 if(reqcache[value]) 1112 if(reqcache[value])
1113 requantized = reqcache[value]; 1113 requantized = reqcache[value];
1114 else 1114 else
1115 requantized = reqcache[value] = III_requantize(value, exp); 1115 requantized = reqcache[value] = III_requantize(value, exp);
1116 } 1116 }
1117 xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; 1117 xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized;
1118 } 1118 }
1119 } 1119 }
1120 } 1120 }
@@ -1162,32 +1162,32 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1162 1162
1163 cachesz -= pair->value.hlen; 1163 cachesz -= pair->value.hlen;
1164 1164
1165 /* x (0..1) */ 1165 /* x (0..1) */
1166 value = pair->value.x; 1166 value = pair->value.x;
1167 if(value == 0) 1167 if(value == 0)
1168 xr[0] = 0; 1168 xr[0] = 0;
1169 else 1169 else
1170 { 1170 {
1171 if(reqcache[value]) 1171 if(reqcache[value])
1172 requantized = reqcache[value]; 1172 requantized = reqcache[value];
1173 else 1173 else
1174 requantized = reqcache[value] = III_requantize(value, exp); 1174 requantized = reqcache[value] = III_requantize(value, exp);
1175 1175
1176 xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; 1176 xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized;
1177 } 1177 }
1178 1178
1179 /* y (0..1) */ 1179 /* y (0..1) */
1180 value = pair->value.y; 1180 value = pair->value.y;
1181 if(value == 0) 1181 if(value == 0)
1182 xr[1] = 0; 1182 xr[1] = 0;
1183 else 1183 else
1184 { 1184 {
1185 if(reqcache[value]) 1185 if(reqcache[value])
1186 requantized = reqcache[value]; 1186 requantized = reqcache[value];
1187 else 1187 else
1188 requantized = reqcache[value] = III_requantize(value, exp); 1188 requantized = reqcache[value] = III_requantize(value, exp);
1189 1189
1190 xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; 1190 xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized;
1191 } 1191 }
1192 } 1192 }
1193 } 1193 }
@@ -1218,9 +1218,9 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1218 if(cachesz < 0) 1218 if(cachesz < 0)
1219 return MAD_ERROR_BADHUFFDATA; /* cache underrun */ 1219 return MAD_ERROR_BADHUFFDATA; /* cache underrun */
1220 1220
1221 bits = MAXLSHIFT - cachesz; 1221 bits = MAXLSHIFT - cachesz;
1222 bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); 1222 bitcache = (bitcache << bits) | mad_bit_read(&peek, bits);
1223 cachesz += bits; 1223 cachesz += bits;
1224 bits_left -= bits; 1224 bits_left -= bits;
1225 } 1225 }
1226 1226
@@ -1228,53 +1228,53 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1228 1228
1229 /* quad tables guaranteed to have at most one extra lookup */ 1229 /* quad tables guaranteed to have at most one extra lookup */
1230 if (!quad->final) { 1230 if (!quad->final) {
1231 cachesz -= 4; 1231 cachesz -= 4;
1232 1232
1233 quad = &table[quad->ptr.offset + 1233 quad = &table[quad->ptr.offset +
1234 MASK(bitcache, cachesz, quad->ptr.bits)]; 1234 MASK(bitcache, cachesz, quad->ptr.bits)];
1235 } 1235 }
1236 1236
1237 cachesz -= quad->value.hlen; 1237 cachesz -= quad->value.hlen;
1238 1238
1239 if (xr == sfbound) { 1239 if (xr == sfbound) {
1240 sfbound += *sfbwidth++; 1240 sfbound += *sfbwidth++;
1241 1241
1242 if (exp != *expptr) { 1242 if (exp != *expptr) {
1243 exp = *expptr; 1243 exp = *expptr;
1244 requantized = III_requantize(1, exp); 1244 requantized = III_requantize(1, exp);
1245 } 1245 }
1246 1246
1247 ++expptr; 1247 ++expptr;
1248 } 1248 }
1249 1249
1250 /* v (0..1) */ 1250 /* v (0..1) */
1251 xr[0] = quad->value.v ? 1251 xr[0] = quad->value.v ?
1252 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; 1252 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
1253 1253
1254 /* w (0..1) */ 1254 /* w (0..1) */
1255 xr[1] = quad->value.w ? 1255 xr[1] = quad->value.w ?
1256 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; 1256 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
1257 1257
1258 xr += 2; 1258 xr += 2;
1259 1259
1260 if (xr == sfbound) { 1260 if (xr == sfbound) {
1261 sfbound += *sfbwidth++; 1261 sfbound += *sfbwidth++;
1262 1262
1263 if (exp != *expptr) { 1263 if (exp != *expptr) {
1264 exp = *expptr; 1264 exp = *expptr;
1265 requantized = III_requantize(1, exp); 1265 requantized = III_requantize(1, exp);
1266 } 1266 }
1267 1267
1268 ++expptr; 1268 ++expptr;
1269 } 1269 }
1270 1270
1271 /* x (0..1) */ 1271 /* x (0..1) */
1272 xr[0] = quad->value.x ? 1272 xr[0] = quad->value.x ?
1273 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; 1273 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
1274 1274
1275 /* y (0..1) */ 1275 /* y (0..1) */
1276 xr[1] = quad->value.y ? 1276 xr[1] = quad->value.y ?
1277 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; 1277 (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
1278 1278
1279 xr += 2; 1279 xr += 2;
1280 } 1280 }
@@ -1282,7 +1282,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1282 if(bits_left + cachesz < 0) 1282 if(bits_left + cachesz < 0)
1283 { 1283 {
1284 /* technically the bitstream is misformatted, but apparently 1284 /* technically the bitstream is misformatted, but apparently
1285 some encoders are just a bit sloppy with stuffing bits */ 1285 some encoders are just a bit sloppy with stuffing bits */
1286 xr -= 4; 1286 xr -= 4;
1287 } 1287 }
1288 } 1288 }
@@ -1297,12 +1297,12 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576],
1297# undef MASK1BIT 1297# undef MASK1BIT
1298 1298
1299/* 1299/*
1300 * NAME: III_reorder() 1300 * NAME: III_reorder()
1301 * DESCRIPTION: reorder frequency lines of a short block into subband order 1301 * DESCRIPTION: reorder frequency lines of a short block into subband order
1302 */ 1302 */
1303static 1303static
1304void III_reorder(mad_fixed_t xr[576], struct channel const *channel, 1304void III_reorder(mad_fixed_t xr[576], struct channel const *channel,
1305 unsigned char const sfbwidth[39]) 1305 unsigned char const sfbwidth[39])
1306{ 1306{
1307 mad_fixed_t tmp[32][3][6]; 1307 mad_fixed_t tmp[32][3][6];
1308 unsigned int sb, l, f, w, sbw[3], sw[3]; 1308 unsigned int sb, l, f, w, sbw[3], sw[3];
@@ -1345,14 +1345,14 @@ void III_reorder(mad_fixed_t xr[576], struct channel const *channel,
1345} 1345}
1346 1346
1347/* 1347/*
1348 * NAME: III_stereo() 1348 * NAME: III_stereo()
1349 * DESCRIPTION: perform joint stereo processing on a granule 1349 * DESCRIPTION: perform joint stereo processing on a granule
1350 */ 1350 */
1351static 1351static
1352enum mad_error III_stereo(mad_fixed_t xr[2][576], 1352enum mad_error III_stereo(mad_fixed_t xr[2][576],
1353 struct granule const *granule, 1353 struct granule const *granule,
1354 struct mad_header *header, 1354 struct mad_header *header,
1355 unsigned char const *sfbwidth) 1355 unsigned char const *sfbwidth)
1356{ 1356{
1357 short modes[39]; 1357 short modes[39];
1358 unsigned int sfbi, l, n, i; 1358 unsigned int sfbi, l, n, i;
@@ -1385,55 +1385,55 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
1385 sfbi = l = 0; 1385 sfbi = l = 0;
1386 1386
1387 if (right_ch->flags & mixed_block_flag) { 1387 if (right_ch->flags & mixed_block_flag) {
1388 while (l < 36) { 1388 while (l < 36) {
1389 n = sfbwidth[sfbi++]; 1389 n = sfbwidth[sfbi++];
1390 1390
1391 for (i = 0; i < n; ++i) { 1391 for (i = 0; i < n; ++i) {
1392 if (right_xr[i]) { 1392 if (right_xr[i]) {
1393 lower = sfbi; 1393 lower = sfbi;
1394 break; 1394 break;
1395 } 1395 }
1396 } 1396 }
1397 1397
1398 right_xr += n; 1398 right_xr += n;
1399 l += n; 1399 l += n;
1400 } 1400 }
1401 1401
1402 start = sfbi; 1402 start = sfbi;
1403 } 1403 }
1404 1404
1405 w = 0; 1405 w = 0;
1406 while (l < 576) { 1406 while (l < 576) {
1407 n = sfbwidth[sfbi++]; 1407 n = sfbwidth[sfbi++];
1408 1408
1409 for (i = 0; i < n; ++i) { 1409 for (i = 0; i < n; ++i) {
1410 if (right_xr[i]) { 1410 if (right_xr[i]) {
1411 max = bound[w] = sfbi; 1411 max = bound[w] = sfbi;
1412 break; 1412 break;
1413 } 1413 }
1414 } 1414 }
1415 1415
1416 right_xr += n; 1416 right_xr += n;
1417 l += n; 1417 l += n;
1418 w = (w + 1) % 3; 1418 w = (w + 1) % 3;
1419 } 1419 }
1420 1420
1421 if (max) 1421 if (max)
1422 lower = start; 1422 lower = start;
1423 1423
1424 /* long blocks */ 1424 /* long blocks */
1425 1425
1426 for (i = 0; i < lower; ++i) 1426 for (i = 0; i < lower; ++i)
1427 modes[i] = header->mode_extension & ~I_STEREO; 1427 modes[i] = header->mode_extension & ~I_STEREO;
1428 1428
1429 /* short blocks */ 1429 /* short blocks */
1430 1430
1431 w = 0; 1431 w = 0;
1432 for (i = start; i < max; ++i) { 1432 for (i = start; i < max; ++i) {
1433 if (i < bound[w]) 1433 if (i < bound[w])
1434 modes[i] = header->mode_extension & ~I_STEREO; 1434 modes[i] = header->mode_extension & ~I_STEREO;
1435 1435
1436 w = (w + 1) % 3; 1436 w = (w + 1) % 3;
1437 } 1437 }
1438 } 1438 }
1439 else { /* right_ch->block_type != 2 */ 1439 else { /* right_ch->block_type != 2 */
@@ -1441,20 +1441,20 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
1441 1441
1442 bound = 0; 1442 bound = 0;
1443 for (sfbi = l = 0; l < 576; l += n) { 1443 for (sfbi = l = 0; l < 576; l += n) {
1444 n = sfbwidth[sfbi++]; 1444 n = sfbwidth[sfbi++];
1445 1445
1446 for (i = 0; i < n; ++i) { 1446 for (i = 0; i < n; ++i) {
1447 if (right_xr[i]) { 1447 if (right_xr[i]) {
1448 bound = sfbi; 1448 bound = sfbi;
1449 break; 1449 break;
1450 } 1450 }
1451 } 1451 }
1452 1452
1453 right_xr += n; 1453 right_xr += n;
1454 } 1454 }
1455 1455
1456 for (i = 0; i < bound; ++i) 1456 for (i = 0; i < bound; ++i)
1457 modes[i] = header->mode_extension & ~I_STEREO; 1457 modes[i] = header->mode_extension & ~I_STEREO;
1458 } 1458 }
1459 1459
1460 /* now do the actual processing */ 1460 /* now do the actual processing */
@@ -1467,62 +1467,62 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
1467 lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1]; 1467 lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1];
1468 1468
1469 for (sfbi = l = 0; l < 576; ++sfbi, l += n) { 1469 for (sfbi = l = 0; l < 576; ++sfbi, l += n) {
1470 n = sfbwidth[sfbi]; 1470 n = sfbwidth[sfbi];
1471 1471
1472 if (!(modes[sfbi] & I_STEREO)) 1472 if (!(modes[sfbi] & I_STEREO))
1473 continue; 1473 continue;
1474 1474
1475 if (illegal_pos[sfbi]) { 1475 if (illegal_pos[sfbi]) {
1476 modes[sfbi] &= ~I_STEREO; 1476 modes[sfbi] &= ~I_STEREO;
1477 continue; 1477 continue;
1478 } 1478 }
1479 1479
1480 is_pos = right_ch->scalefac[sfbi]; 1480 is_pos = right_ch->scalefac[sfbi];
1481 1481
1482 for (i = 0; i < n; ++i) { 1482 for (i = 0; i < n; ++i) {
1483 register mad_fixed_t left; 1483 register mad_fixed_t left;
1484 1484
1485 left = xr[0][l + i]; 1485 left = xr[0][l + i];
1486 1486
1487 if (is_pos == 0) 1487 if (is_pos == 0)
1488 xr[1][l + i] = left; 1488 xr[1][l + i] = left;
1489 else { 1489 else {
1490 register mad_fixed_t opposite; 1490 register mad_fixed_t opposite;
1491 1491
1492 opposite = mad_f_mul(left, lsf_scale[(is_pos - 1) / 2]); 1492 opposite = mad_f_mul(left, lsf_scale[(is_pos - 1) / 2]);
1493 1493
1494 if (is_pos & 1) { 1494 if (is_pos & 1) {
1495 xr[0][l + i] = opposite; 1495 xr[0][l + i] = opposite;
1496 xr[1][l + i] = left; 1496 xr[1][l + i] = left;
1497 } 1497 }
1498 else 1498 else
1499 xr[1][l + i] = opposite; 1499 xr[1][l + i] = opposite;
1500 } 1500 }
1501 } 1501 }
1502 } 1502 }
1503 } 1503 }
1504 else { /* !(header->flags & MAD_FLAG_LSF_EXT) */ 1504 else { /* !(header->flags & MAD_FLAG_LSF_EXT) */
1505 for (sfbi = l = 0; l < 576; ++sfbi, l += n) { 1505 for (sfbi = l = 0; l < 576; ++sfbi, l += n) {
1506 n = sfbwidth[sfbi]; 1506 n = sfbwidth[sfbi];
1507 1507
1508 if (!(modes[sfbi] & I_STEREO)) 1508 if (!(modes[sfbi] & I_STEREO))
1509 continue; 1509 continue;
1510 1510
1511 is_pos = right_ch->scalefac[sfbi]; 1511 is_pos = right_ch->scalefac[sfbi];
1512 1512
1513 if (is_pos >= 7) { /* illegal intensity position */ 1513 if (is_pos >= 7) { /* illegal intensity position */
1514 modes[sfbi] &= ~I_STEREO; 1514 modes[sfbi] &= ~I_STEREO;
1515 continue; 1515 continue;
1516 } 1516 }
1517 1517
1518 for (i = 0; i < n; ++i) { 1518 for (i = 0; i < n; ++i) {
1519 register mad_fixed_t left; 1519 register mad_fixed_t left;
1520 1520
1521 left = xr[0][l + i]; 1521 left = xr[0][l + i];
1522 1522
1523 xr[0][l + i] = mad_f_mul(left, is_table[ is_pos]); 1523 xr[0][l + i] = mad_f_mul(left, is_table[ is_pos]);
1524 xr[1][l + i] = mad_f_mul(left, is_table[6 - is_pos]); 1524 xr[1][l + i] = mad_f_mul(left, is_table[6 - is_pos]);
1525 } 1525 }
1526 } 1526 }
1527 } 1527 }
1528 } 1528 }
@@ -1540,16 +1540,16 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
1540 n = sfbwidth[sfbi]; 1540 n = sfbwidth[sfbi];
1541 1541
1542 if (modes[sfbi] != MS_STEREO) 1542 if (modes[sfbi] != MS_STEREO)
1543 continue; 1543 continue;
1544 1544
1545 for (i = 0; i < n; ++i) { 1545 for (i = 0; i < n; ++i) {
1546 register mad_fixed_t m, s; 1546 register mad_fixed_t m, s;
1547 1547
1548 m = xr[0][l + i]; 1548 m = xr[0][l + i];
1549 s = xr[1][l + i]; 1549 s = xr[1][l + i];
1550 1550
1551 xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */ 1551 xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */
1552 xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */ 1552 xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */
1553 } 1553 }
1554 } 1554 }
1555 } 1555 }
@@ -1561,8 +1561,8 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
1561void III_aliasreduce(mad_fixed_t xr[576], int lines); 1561void III_aliasreduce(mad_fixed_t xr[576], int lines);
1562#else 1562#else
1563/* 1563/*
1564 * NAME: III_aliasreduce() 1564 * NAME: III_aliasreduce()
1565 * DESCRIPTION: perform frequency line alias reduction 1565 * DESCRIPTION: perform frequency line alias reduction
1566 */ 1566 */
1567static 1567static
1568void III_aliasreduce(mad_fixed_t xr[576], int lines) 1568void III_aliasreduce(mad_fixed_t xr[576], int lines)
@@ -1598,15 +1598,15 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
1598 xr[-1 - i] = a; 1598 xr[-1 - i] = a;
1599 xr[ i] = b; 1599 xr[ i] = b;
1600# else 1600# else
1601 MAD_F_ML0(hi, lo, a, cs[i]); 1601 MAD_F_ML0(hi, lo, a, cs[i]);
1602 MAD_F_MLA(hi, lo, -b, ca[i]); 1602 MAD_F_MLA(hi, lo, -b, ca[i]);
1603 1603
1604 xr[-1 - i] = MAD_F_MLZ(hi, lo); 1604 xr[-1 - i] = MAD_F_MLZ(hi, lo);
1605 1605
1606 MAD_F_ML0(hi, lo, b, cs[i]); 1606 MAD_F_ML0(hi, lo, b, cs[i]);
1607 MAD_F_MLA(hi, lo, a, ca[i]); 1607 MAD_F_MLA(hi, lo, a, ca[i]);
1608 1608
1609 xr[ i] = MAD_F_MLZ(hi, lo); 1609 xr[ i] = MAD_F_MLZ(hi, lo);
1610# endif 1610# endif
1611# if defined(ASO_ZEROCHECK) 1611# if defined(ASO_ZEROCHECK)
1612 } 1612 }
@@ -1774,8 +1774,8 @@ void dctIV(mad_fixed_t const y[18], mad_fixed_t X[18])
1774} 1774}
1775 1775
1776/* 1776/*
1777 * NAME: imdct36 1777 * NAME: imdct36
1778 * DESCRIPTION: perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm 1778 * DESCRIPTION: perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm
1779 */ 1779 */
1780static inline 1780static inline
1781void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36]) 1781void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36])
@@ -1807,8 +1807,8 @@ void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36])
1807} 1807}
1808# else 1808# else
1809/* 1809/*
1810 * NAME: imdct36 1810 * NAME: imdct36
1811 * DESCRIPTION: perform X[18]->x[36] IMDCT 1811 * DESCRIPTION: perform X[18]->x[36] IMDCT
1812 */ 1812 */
1813 1813
1814# if defined(CPU_COLDFIRE) 1814# if defined(CPU_COLDFIRE)
@@ -2737,12 +2737,12 @@ void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36])
2737# endif 2737# endif
2738 2738
2739/* 2739/*
2740 * NAME: III_imdct_l() 2740 * NAME: III_imdct_l()
2741 * DESCRIPTION: perform IMDCT and windowing for long blocks 2741 * DESCRIPTION: perform IMDCT and windowing for long blocks
2742 */ 2742 */
2743static 2743static
2744void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36], 2744void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
2745 unsigned int block_type) 2745 unsigned int block_type)
2746{ 2746{
2747 unsigned int i; 2747 unsigned int i;
2748 2748
@@ -2762,10 +2762,10 @@ void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
2762 tmp2 = window_l[1]; 2762 tmp2 = window_l[1];
2763 2763
2764 for (i = 0; i < 34; i += 2) { 2764 for (i = 0; i < 34; i += 2) {
2765 z[i + 0] = mad_f_mul(z[i + 0], tmp1); 2765 z[i + 0] = mad_f_mul(z[i + 0], tmp1);
2766 tmp1 = window_l[i + 2]; 2766 tmp1 = window_l[i + 2];
2767 z[i + 1] = mad_f_mul(z[i + 1], tmp2); 2767 z[i + 1] = mad_f_mul(z[i + 1], tmp2);
2768 tmp2 = window_l[i + 3]; 2768 tmp2 = window_l[i + 3];
2769 } 2769 }
2770 2770
2771 z[34] = mad_f_mul(z[34], tmp1); 2771 z[34] = mad_f_mul(z[34], tmp1);
@@ -2779,9 +2779,9 @@ void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
2779 tmp2 = window_l[0]; 2779 tmp2 = window_l[0];
2780 2780
2781 for (i = 0; i < 35; ++i) { 2781 for (i = 0; i < 35; ++i) {
2782 z[i] = mad_f_mul(tmp1, tmp2); 2782 z[i] = mad_f_mul(tmp1, tmp2);
2783 tmp1 = z[i + 1]; 2783 tmp1 = z[i + 1];
2784 tmp2 = window_l[i + 1]; 2784 tmp2 = window_l[i + 1];
2785 } 2785 }
2786 2786
2787 z[35] = mad_f_mul(tmp1, tmp2); 2787 z[35] = mad_f_mul(tmp1, tmp2);
@@ -2824,8 +2824,8 @@ void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
2824# endif /* ASO_IMDCT */ 2824# endif /* ASO_IMDCT */
2825 2825
2826/* 2826/*
2827 * NAME: III_imdct_s() 2827 * NAME: III_imdct_s()
2828 * DESCRIPTION: perform IMDCT and windowing for short blocks 2828 * DESCRIPTION: perform IMDCT and windowing for short blocks
2829 */ 2829 */
2830 2830
2831# if defined(CPU_COLDFIRE) 2831# if defined(CPU_COLDFIRE)
@@ -2911,16 +2911,16 @@ void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36])
2911 2911
2912#ifdef CPU_ARM 2912#ifdef CPU_ARM
2913void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], 2913void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18],
2914 mad_fixed_t sample[18][32], unsigned int sb); 2914 mad_fixed_t sample[18][32], unsigned int sb);
2915#else 2915#else
2916 2916
2917/* 2917/*
2918 * NAME: III_overlap() 2918 * NAME: III_overlap()
2919 * DESCRIPTION: perform overlap-add of windowed IMDCT outputs 2919 * DESCRIPTION: perform overlap-add of windowed IMDCT outputs
2920 */ 2920 */
2921static 2921static
2922void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], 2922void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18],
2923 mad_fixed_t sample[18][32], unsigned int sb) 2923 mad_fixed_t sample[18][32], unsigned int sb)
2924{ 2924{
2925 unsigned int i; 2925 unsigned int i;
2926 2926
@@ -2964,12 +2964,12 @@ void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18],
2964#endif 2964#endif
2965 2965
2966/* 2966/*
2967 * NAME: III_overlap_z() 2967 * NAME: III_overlap_z()
2968 * DESCRIPTION: perform "overlap-add" of zero IMDCT outputs 2968 * DESCRIPTION: perform "overlap-add" of zero IMDCT outputs
2969 */ 2969 */
2970static inline 2970static inline
2971void III_overlap_z(mad_fixed_t overlap[18], 2971void III_overlap_z(mad_fixed_t overlap[18],
2972 mad_fixed_t sample[18][32], unsigned int sb) 2972 mad_fixed_t sample[18][32], unsigned int sb)
2973{ 2973{
2974 unsigned int i; 2974 unsigned int i;
2975 2975
@@ -3004,8 +3004,8 @@ void III_overlap_z(mad_fixed_t overlap[18],
3004} 3004}
3005 3005
3006/* 3006/*
3007 * NAME: III_freqinver() 3007 * NAME: III_freqinver()
3008 * DESCRIPTION: perform subband frequency inversion for odd sample lines 3008 * DESCRIPTION: perform subband frequency inversion for odd sample lines
3009 */ 3009 */
3010static 3010static
3011void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) 3011void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb)
@@ -3038,12 +3038,12 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb)
3038} 3038}
3039 3039
3040/* 3040/*
3041 * NAME: III_decode() 3041 * NAME: III_decode()
3042 * DESCRIPTION: decode frame main_data 3042 * DESCRIPTION: decode frame main_data
3043 */ 3043 */
3044static 3044static
3045enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 3045enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3046 struct sideinfo *si, unsigned int nch) 3046 struct sideinfo *si, unsigned int nch)
3047{ 3047{
3048 struct mad_header *header = &frame->header; 3048 struct mad_header *header = &frame->header;
3049 unsigned int sfreqi, ngr, gr; 3049 unsigned int sfreqi, ngr, gr;
@@ -3081,23 +3081,23 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3081 3081
3082 sfbwidth[ch] = sfbwidth_table[sfreqi].l; 3082 sfbwidth[ch] = sfbwidth_table[sfreqi].l;
3083 if (channel->block_type == 2) { 3083 if (channel->block_type == 2) {
3084 sfbwidth[ch] = (channel->flags & mixed_block_flag) ? 3084 sfbwidth[ch] = (channel->flags & mixed_block_flag) ?
3085 sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s; 3085 sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s;
3086 } 3086 }
3087 3087
3088 if (header->flags & MAD_FLAG_LSF_EXT) { 3088 if (header->flags & MAD_FLAG_LSF_EXT) {
3089 part2_length = III_scalefactors_lsf(ptr, channel, 3089 part2_length = III_scalefactors_lsf(ptr, channel,
3090 ch == 0 ? 0 : &si->gr[1].ch[1], 3090 ch == 0 ? 0 : &si->gr[1].ch[1],
3091 header->mode_extension); 3091 header->mode_extension);
3092 } 3092 }
3093 else { 3093 else {
3094 part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], 3094 part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch],
3095 gr == 0 ? 0 : si->scfsi[ch]); 3095 gr == 0 ? 0 : si->scfsi[ch]);
3096 } 3096 }
3097 3097
3098 error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length); 3098 error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length);
3099 if (error) 3099 if (error)
3100 return error; 3100 return error;
3101 } 3101 }
3102 3102
3103 /* joint stereo processing */ 3103 /* joint stereo processing */
@@ -3105,7 +3105,7 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3105 if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) { 3105 if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) {
3106 error = III_stereo(xr, granule, header, sfbwidth[0]); 3106 error = III_stereo(xr, granule, header, sfbwidth[0]);
3107 if (error) 3107 if (error)
3108 return error; 3108 return error;
3109 } 3109 }
3110 3110
3111 /* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */ 3111 /* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */
@@ -3117,46 +3117,46 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3117 mad_fixed_t output[36]; 3117 mad_fixed_t output[36];
3118 3118
3119 if (channel->block_type == 2) { 3119 if (channel->block_type == 2) {
3120 III_reorder(xr[ch], channel, sfbwidth[ch]); 3120 III_reorder(xr[ch], channel, sfbwidth[ch]);
3121 3121
3122# if !defined(OPT_STRICT) 3122# if !defined(OPT_STRICT)
3123 /* 3123 /*
3124 * According to ISO/IEC 11172-3, "Alias reduction is not applied for 3124 * According to ISO/IEC 11172-3, "Alias reduction is not applied for
3125 * granules with block_type == 2 (short block)." However, other 3125 * granules with block_type == 2 (short block)." However, other
3126 * sources suggest alias reduction should indeed be performed on the 3126 * sources suggest alias reduction should indeed be performed on the
3127 * lower two subbands of mixed blocks. Most other implementations do 3127 * lower two subbands of mixed blocks. Most other implementations do
3128 * this, so by default we will too. 3128 * this, so by default we will too.
3129 */ 3129 */
3130 if (channel->flags & mixed_block_flag) 3130 if (channel->flags & mixed_block_flag)
3131 III_aliasreduce(xr[ch], 36); 3131 III_aliasreduce(xr[ch], 36);
3132# endif 3132# endif
3133 } 3133 }
3134 else 3134 else
3135 III_aliasreduce(xr[ch], 576); 3135 III_aliasreduce(xr[ch], 576);
3136 3136
3137 l = 0; 3137 l = 0;
3138 3138
3139 /* subbands 0-1 */ 3139 /* subbands 0-1 */
3140 3140
3141 if (channel->block_type != 2 || (channel->flags & mixed_block_flag)) { 3141 if (channel->block_type != 2 || (channel->flags & mixed_block_flag)) {
3142 unsigned int block_type; 3142 unsigned int block_type;
3143 3143
3144 block_type = channel->block_type; 3144 block_type = channel->block_type;
3145 if (channel->flags & mixed_block_flag) 3145 if (channel->flags & mixed_block_flag)
3146 block_type = 0; 3146 block_type = 0;
3147 3147
3148 /* long blocks */ 3148 /* long blocks */
3149 for (sb = 0; sb < 2; ++sb, l += 18) { 3149 for (sb = 0; sb < 2; ++sb, l += 18) {
3150 III_imdct_l(&xr[ch][l], output, block_type); 3150 III_imdct_l(&xr[ch][l], output, block_type);
3151 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); 3151 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb);
3152 } 3152 }
3153 } 3153 }
3154 else { 3154 else {
3155 /* short blocks */ 3155 /* short blocks */
3156 for (sb = 0; sb < 2; ++sb, l += 18) { 3156 for (sb = 0; sb < 2; ++sb, l += 18) {
3157 III_imdct_s(&xr[ch][l], output); 3157 III_imdct_s(&xr[ch][l], output);
3158 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); 3158 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb);
3159 } 3159 }
3160 } 3160 }
3161 3161
3162 III_freqinver(sample, 1); 3162 III_freqinver(sample, 1);
@@ -3166,7 +3166,7 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3166/* 3166/*
3167 i = 576; 3167 i = 576;
3168 while (i > 36 && xr[ch][i - 1] == 0) 3168 while (i > 36 && xr[ch][i - 1] == 0)
3169 --i; 3169 --i;
3170*/ 3170*/
3171 3171
3172 { 3172 {
@@ -3181,33 +3181,33 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3181 sblimit = 32 - (576 - i) / 18; 3181 sblimit = 32 - (576 - i) / 18;
3182 3182
3183 if (channel->block_type != 2) { 3183 if (channel->block_type != 2) {
3184 /* long blocks */ 3184 /* long blocks */
3185 for (sb = 2; sb < sblimit; ++sb, l += 18) { 3185 for (sb = 2; sb < sblimit; ++sb, l += 18) {
3186 III_imdct_l(&xr[ch][l], output, channel->block_type); 3186 III_imdct_l(&xr[ch][l], output, channel->block_type);
3187 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); 3187 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb);
3188 3188
3189 if (sb & 1) 3189 if (sb & 1)
3190 III_freqinver(sample, sb); 3190 III_freqinver(sample, sb);
3191 } 3191 }
3192 } 3192 }
3193 else { 3193 else {
3194 /* short blocks */ 3194 /* short blocks */
3195 for (sb = 2; sb < sblimit; ++sb, l += 18) { 3195 for (sb = 2; sb < sblimit; ++sb, l += 18) {
3196 III_imdct_s(&xr[ch][l], output); 3196 III_imdct_s(&xr[ch][l], output);
3197 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); 3197 III_overlap(output, (*frame->overlap)[ch][sb], sample, sb);
3198 3198
3199 if (sb & 1) 3199 if (sb & 1)
3200 III_freqinver(sample, sb); 3200 III_freqinver(sample, sb);
3201 } 3201 }
3202 } 3202 }
3203 3203
3204 /* remaining (zero) subbands */ 3204 /* remaining (zero) subbands */
3205 3205
3206 for (sb = sblimit; sb < 32; ++sb) { 3206 for (sb = sblimit; sb < 32; ++sb) {
3207 III_overlap_z((*frame->overlap)[ch][sb], sample, sb); 3207 III_overlap_z((*frame->overlap)[ch][sb], sample, sb);
3208 3208
3209 if (sb & 1) 3209 if (sb & 1)
3210 III_freqinver(sample, sb); 3210 III_freqinver(sample, sb);
3211 } 3211 }
3212 } 3212 }
3213 } 3213 }
@@ -3216,8 +3216,8 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
3216} 3216}
3217 3217
3218/* 3218/*
3219 * NAME: layer->III() 3219 * NAME: layer->III()
3220 * DESCRIPTION: decode a single Layer III frame 3220 * DESCRIPTION: decode a single Layer III frame
3221 */ 3221 */
3222int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) 3222int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3223{ 3223{
@@ -3268,7 +3268,7 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3268 mad_bit_crc(stream->ptr, si_len * CHAR_BIT, header->crc_check); 3268 mad_bit_crc(stream->ptr, si_len * CHAR_BIT, header->crc_check);
3269 3269
3270 if (header->crc_check != header->crc_target && 3270 if (header->crc_check != header->crc_target &&
3271 !(frame->options & MAD_OPTION_IGNORECRC)) { 3271 !(frame->options & MAD_OPTION_IGNORECRC)) {
3272 stream->error = MAD_ERROR_BADCRC; 3272 stream->error = MAD_ERROR_BADCRC;
3273 result = -1; 3273 result = -1;
3274 } 3274 }
@@ -3277,7 +3277,7 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3277 /* decode frame side information */ 3277 /* decode frame side information */
3278 3278
3279 error = III_sideinfo(&stream->ptr, nch, header->flags & MAD_FLAG_LSF_EXT, 3279 error = III_sideinfo(&stream->ptr, nch, header->flags & MAD_FLAG_LSF_EXT,
3280 &si, &data_bitlen, &priv_bitlen); 3280 &si, &data_bitlen, &priv_bitlen);
3281 if (error && result == 0) { 3281 if (error && result == 0) {
3282 stream->error = error; 3282 stream->error = error;
3283 result = -1; 3283 result = -1;
@@ -3297,10 +3297,10 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3297 header = mad_bit_read(&peek, 32); 3297 header = mad_bit_read(&peek, 32);
3298 if ((header & 0xffe60000L) /* syncword | layer */ == 0xffe20000L) { 3298 if ((header & 0xffe60000L) /* syncword | layer */ == 0xffe20000L) {
3299 if (!(header & 0x00010000L)) /* protection_bit */ 3299 if (!(header & 0x00010000L)) /* protection_bit */
3300 mad_bit_skip(&peek, 16); /* crc_check */ 3300 mad_bit_skip(&peek, 16); /* crc_check */
3301 3301
3302 next_md_begin = 3302 next_md_begin =
3303 mad_bit_read(&peek, (header & 0x00080000L) /* ID */ ? 9 : 8); 3303 mad_bit_read(&peek, (header & 0x00080000L) /* ID */ ? 9 : 8);
3304 } 3304 }
3305 3305
3306 mad_bit_finish(&peek); 3306 mad_bit_finish(&peek);
@@ -3326,22 +3326,22 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3326 else { 3326 else {
3327 if (si.main_data_begin > stream->md_len) { 3327 if (si.main_data_begin > stream->md_len) {
3328 if (result == 0) { 3328 if (result == 0) {
3329 stream->error = MAD_ERROR_BADDATAPTR; 3329 stream->error = MAD_ERROR_BADDATAPTR;
3330 result = -1; 3330 result = -1;
3331 } 3331 }
3332 } 3332 }
3333 else { 3333 else {
3334 mad_bit_init(&ptr, 3334 mad_bit_init(&ptr,
3335 *stream->main_data + stream->md_len - si.main_data_begin); 3335 *stream->main_data + stream->md_len - si.main_data_begin);
3336 3336
3337 if (md_len > si.main_data_begin) { 3337 if (md_len > si.main_data_begin) {
3338 assert(stream->md_len + md_len - 3338 assert(stream->md_len + md_len -
3339 si.main_data_begin <= MAD_BUFFER_MDLEN); 3339 si.main_data_begin <= MAD_BUFFER_MDLEN);
3340 3340
3341 memcpy(*stream->main_data + stream->md_len, 3341 memcpy(*stream->main_data + stream->md_len,
3342 mad_bit_nextbyte(&stream->ptr), 3342 mad_bit_nextbyte(&stream->ptr),
3343 frame_used = md_len - si.main_data_begin); 3343 frame_used = md_len - si.main_data_begin);
3344 stream->md_len += frame_used; 3344 stream->md_len += frame_used;
3345 } 3345 }
3346 } 3346 }
3347 } 3347 }
@@ -3365,17 +3365,17 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3365 3365
3366# if 0 && defined(DEBUG) 3366# if 0 && defined(DEBUG)
3367 fprintf(stderr, 3367 fprintf(stderr,
3368 "main_data_begin:%u, md_len:%u, frame_free:%u, " 3368 "main_data_begin:%u, md_len:%u, frame_free:%u, "
3369 "data_bitlen:%u, anc_bitlen: %u\n", 3369 "data_bitlen:%u, anc_bitlen: %u\n",
3370 si.main_data_begin, md_len, frame_free, 3370 si.main_data_begin, md_len, frame_free,
3371 data_bitlen, stream->anc_bitlen); 3371 data_bitlen, stream->anc_bitlen);
3372# endif 3372# endif
3373 3373
3374 /* preload main_data buffer with up to 511 bytes for next frame(s) */ 3374 /* preload main_data buffer with up to 511 bytes for next frame(s) */
3375 3375
3376 if (frame_free >= next_md_begin) { 3376 if (frame_free >= next_md_begin) {
3377 memcpy(*stream->main_data, 3377 memcpy(*stream->main_data,
3378 stream->next_frame - next_md_begin, next_md_begin); 3378 stream->next_frame - next_md_begin, next_md_begin);
3379 stream->md_len = next_md_begin; 3379 stream->md_len = next_md_begin;
3380 } 3380 }
3381 else { 3381 else {
@@ -3384,19 +3384,19 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
3384 3384
3385 extra = si.main_data_begin - md_len; 3385 extra = si.main_data_begin - md_len;
3386 if (extra + frame_free > next_md_begin) 3386 if (extra + frame_free > next_md_begin)
3387 extra = next_md_begin - frame_free; 3387 extra = next_md_begin - frame_free;
3388 3388
3389 if (extra < stream->md_len) { 3389 if (extra < stream->md_len) {
3390 memmove(*stream->main_data, 3390 memmove(*stream->main_data,
3391 *stream->main_data + stream->md_len - extra, extra); 3391 *stream->main_data + stream->md_len - extra, extra);
3392 stream->md_len = extra; 3392 stream->md_len = extra;
3393 } 3393 }
3394 } 3394 }
3395 else 3395 else
3396 stream->md_len = 0; 3396 stream->md_len = 0;
3397 3397
3398 memcpy(*stream->main_data + stream->md_len, 3398 memcpy(*stream->main_data + stream->md_len,
3399 stream->next_frame - frame_free, frame_free); 3399 stream->next_frame - frame_free, frame_free);
3400 stream->md_len += frame_free; 3400 stream->md_len += frame_free;
3401 } 3401 }
3402 3402
diff --git a/apps/codecs/libmad/mad.h b/apps/codecs/libmad/mad.h
index 52a74d122c..6e75e3bf09 100644
--- a/apps/codecs/libmad/mad.h
+++ b/apps/codecs/libmad/mad.h
@@ -27,28 +27,28 @@ extern "C" {
27# endif 27# endif
28 28
29# define FPM_DEFAULT 29# define FPM_DEFAULT
30 30
31/* Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp */ 31/* Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp */
32 32
33# ifndef LIBMAD_VERSION_H 33# ifndef LIBMAD_VERSION_H
34# define LIBMAD_VERSION_H 34# define LIBMAD_VERSION_H
35 35
36# define MAD_VERSION_MAJOR 0 36# define MAD_VERSION_MAJOR 0
37# define MAD_VERSION_MINOR 15 37# define MAD_VERSION_MINOR 15
38# define MAD_VERSION_PATCH 1 38# define MAD_VERSION_PATCH 1
39# define MAD_VERSION_EXTRA " (beta)" 39# define MAD_VERSION_EXTRA " (beta)"
40 40
41# define MAD_VERSION_STRINGIZE(str) #str 41# define MAD_VERSION_STRINGIZE(str) #str
42# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) 42# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
43 43
44# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ 44# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
45 MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ 45 MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
46 MAD_VERSION_STRING(MAD_VERSION_PATCH) \ 46 MAD_VERSION_STRING(MAD_VERSION_PATCH) \
47 MAD_VERSION_EXTRA 47 MAD_VERSION_EXTRA
48 48
49# define MAD_PUBLISHYEAR "2000-2004" 49# define MAD_PUBLISHYEAR "2000-2004"
50# define MAD_AUTHOR "Underbit Technologies, Inc." 50# define MAD_AUTHOR "Underbit Technologies, Inc."
51# define MAD_EMAIL "info@underbit.com" 51# define MAD_EMAIL "info@underbit.com"
52 52
53extern char const mad_version[]; 53extern char const mad_version[];
54extern char const mad_copyright[]; 54extern char const mad_copyright[];
@@ -102,50 +102,50 @@ typedef mad_fixed_t mad_sample_t;
102 * supported, and must be done with care. 102 * supported, and must be done with care.
103 */ 103 */
104 104
105# define MAD_F_FRACBITS 28 105# define MAD_F_FRACBITS 28
106 106
107# if MAD_F_FRACBITS == 28 107# if MAD_F_FRACBITS == 28
108# define MAD_F(x) ((mad_fixed_t) (x##L)) 108# define MAD_F(x) ((mad_fixed_t) (x##L))
109# else 109# else
110# if MAD_F_FRACBITS < 28 110# if MAD_F_FRACBITS < 28
111# warning "MAD_F_FRACBITS < 28" 111# warning "MAD_F_FRACBITS < 28"
112# define MAD_F(x) ((mad_fixed_t) \ 112# define MAD_F(x) ((mad_fixed_t) \
113 (((x##L) + \ 113 (((x##L) + \
114 (1L << (28 - MAD_F_FRACBITS - 1))) >> \ 114 (1L << (28 - MAD_F_FRACBITS - 1))) >> \
115 (28 - MAD_F_FRACBITS))) 115 (28 - MAD_F_FRACBITS)))
116# elif MAD_F_FRACBITS > 28 116# elif MAD_F_FRACBITS > 28
117# error "MAD_F_FRACBITS > 28 not currently supported" 117# error "MAD_F_FRACBITS > 28 not currently supported"
118# define MAD_F(x) ((mad_fixed_t) \ 118# define MAD_F(x) ((mad_fixed_t) \
119 ((x##L) << (MAD_F_FRACBITS - 28))) 119 ((x##L) << (MAD_F_FRACBITS - 28)))
120# endif 120# endif
121# endif 121# endif
122 122
123# define MAD_F_MIN ((mad_fixed_t) -0x80000000L) 123# define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
124# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) 124# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
125 125
126# define MAD_F_ONE MAD_F(0x10000000) 126# define MAD_F_ONE MAD_F(0x10000000)
127 127
128# define mad_f_tofixed(x) ((mad_fixed_t) \ 128# define mad_f_tofixed(x) ((mad_fixed_t) \
129 ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) 129 ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
130# define mad_f_todouble(x) ((double) \ 130# define mad_f_todouble(x) ((double) \
131 ((x) / (double) (1L << MAD_F_FRACBITS))) 131 ((x) / (double) (1L << MAD_F_FRACBITS)))
132 132
133# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) 133# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
134# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) 134# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
135 /* (x should be positive) */ 135 /* (x should be positive) */
136 136
137# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS) 137# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
138 138
139# define mad_f_add(x, y) ((x) + (y)) 139# define mad_f_add(x, y) ((x) + (y))
140# define mad_f_sub(x, y) ((x) - (y)) 140# define mad_f_sub(x, y) ((x) - (y))
141 141
142# if defined(FPM_FLOAT) 142# if defined(FPM_FLOAT)
143# error "FPM_FLOAT not yet supported" 143# error "FPM_FLOAT not yet supported"
144 144
145# undef MAD_F 145# undef MAD_F
146# define MAD_F(x) mad_f_todouble(x) 146# define MAD_F(x) mad_f_todouble(x)
147 147
148# define mad_f_mul(x, y) ((x) * (y)) 148# define mad_f_mul(x, y) ((x) * (y))
149# define mad_f_scale64 149# define mad_f_scale64
150 150
151# undef ASO_ZEROCHECK 151# undef ASO_ZEROCHECK
@@ -192,7 +192,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
192} 192}
193# pragma warning(pop) 193# pragma warning(pop)
194 194
195# define mad_f_mul mad_f_mul_inline 195# define mad_f_mul mad_f_mul_inline
196# define mad_f_scale64 196# define mad_f_scale64
197# else 197# else
198/* 198/*
@@ -201,9 +201,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
201 */ 201 */
202# define MAD_F_MLX(hi, lo, x, y) \ 202# define MAD_F_MLX(hi, lo, x, y) \
203 asm ("imull %3" \ 203 asm ("imull %3" \
204 : "=a" (lo), "=d" (hi) \ 204 : "=a" (lo), "=d" (hi) \
205 : "%a" (x), "rm" (y) \ 205 : "%a" (x), "rm" (y) \
206 : "cc") 206 : "cc")
207 207
208# if defined(OPT_ACCURACY) 208# if defined(OPT_ACCURACY)
209/* 209/*
@@ -214,10 +214,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
214 mad_fixed64lo_t __lo; \ 214 mad_fixed64lo_t __lo; \
215 MAD_F_MLX(__hi, __lo, (x), (y)); \ 215 MAD_F_MLX(__hi, __lo, (x), (y)); \
216 asm ("addl %2,%0\n\t" \ 216 asm ("addl %2,%0\n\t" \
217 "adcl %3,%1" \ 217 "adcl %3,%1" \
218 : "=rm" (lo), "=rm" (hi) \ 218 : "=rm" (lo), "=rm" (hi) \
219 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ 219 : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
220 : "cc"); \ 220 : "cc"); \
221 }) 221 })
222# endif /* OPT_ACCURACY */ 222# endif /* OPT_ACCURACY */
223 223
@@ -230,15 +230,15 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
230 mad_fixed64lo_t __lo_; \ 230 mad_fixed64lo_t __lo_; \
231 mad_fixed_t __result; \ 231 mad_fixed_t __result; \
232 asm ("addl %4,%2\n\t" \ 232 asm ("addl %4,%2\n\t" \
233 "adcl %5,%3" \ 233 "adcl %5,%3" \
234 : "=rm" (__lo_), "=rm" (__hi_) \ 234 : "=rm" (__lo_), "=rm" (__hi_) \
235 : "0" (lo), "1" (hi), \ 235 : "0" (lo), "1" (hi), \
236 "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ 236 "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
237 : "cc"); \ 237 : "cc"); \
238 asm ("shrdl %3,%2,%1" \ 238 asm ("shrdl %3,%2,%1" \
239 : "=rm" (__result) \ 239 : "=rm" (__result) \
240 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ 240 : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
241 : "cc"); \ 241 : "cc"); \
242 __result; \ 242 __result; \
243 }) 243 })
244# elif defined(OPT_INTEL) 244# elif defined(OPT_INTEL)
@@ -248,21 +248,21 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
248# define mad_f_scale64(hi, lo) \ 248# define mad_f_scale64(hi, lo) \
249 ({ mad_fixed_t __result; \ 249 ({ mad_fixed_t __result; \
250 asm ("shrl %3,%1\n\t" \ 250 asm ("shrl %3,%1\n\t" \
251 "shll %4,%2\n\t" \ 251 "shll %4,%2\n\t" \
252 "orl %2,%1" \ 252 "orl %2,%1" \
253 : "=rm" (__result) \ 253 : "=rm" (__result) \
254 : "0" (lo), "r" (hi), \ 254 : "0" (lo), "r" (hi), \
255 "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ 255 "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
256 : "cc"); \ 256 : "cc"); \
257 __result; \ 257 __result; \
258 }) 258 })
259# else 259# else
260# define mad_f_scale64(hi, lo) \ 260# define mad_f_scale64(hi, lo) \
261 ({ mad_fixed_t __result; \ 261 ({ mad_fixed_t __result; \
262 asm ("shrdl %3,%2,%1" \ 262 asm ("shrdl %3,%2,%1" \
263 : "=rm" (__result) \ 263 : "=rm" (__result) \
264 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ 264 : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
265 : "cc"); \ 265 : "cc"); \
266 __result; \ 266 __result; \
267 }) 267 })
268# endif /* OPT_ACCURACY */ 268# endif /* OPT_ACCURACY */
@@ -287,42 +287,42 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
287 ({ mad_fixed64hi_t __hi; \ 287 ({ mad_fixed64hi_t __hi; \
288 mad_fixed64lo_t __lo; \ 288 mad_fixed64lo_t __lo; \
289 mad_fixed_t __result; \ 289 mad_fixed_t __result; \
290 asm ("smull %0, %1, %3, %4\n\t" \ 290 asm ("smull %0, %1, %3, %4\n\t" \
291 "movs %0, %0, lsr %5\n\t" \ 291 "movs %0, %0, lsr %5\n\t" \
292 "adc %2, %0, %1, lsl %6" \ 292 "adc %2, %0, %1, lsl %6" \
293 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ 293 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
294 : "%r" (x), "r" (y), \ 294 : "%r" (x), "r" (y), \
295 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ 295 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
296 : "cc"); \ 296 : "cc"); \
297 __result; \ 297 __result; \
298 }) 298 })
299# endif 299# endif
300 300
301# define MAD_F_MLX(hi, lo, x, y) \ 301# define MAD_F_MLX(hi, lo, x, y) \
302 asm ("smull %0, %1, %2, %3" \ 302 asm ("smull %0, %1, %2, %3" \
303 : "=&r" (lo), "=&r" (hi) \ 303 : "=&r" (lo), "=&r" (hi) \
304 : "%r" (x), "r" (y)) 304 : "%r" (x), "r" (y))
305 305
306# define MAD_F_MLA(hi, lo, x, y) \ 306# define MAD_F_MLA(hi, lo, x, y) \
307 asm ("smlal %0, %1, %2, %3" \ 307 asm ("smlal %0, %1, %2, %3" \
308 : "+r" (lo), "+r" (hi) \ 308 : "+r" (lo), "+r" (hi) \
309 : "%r" (x), "r" (y)) 309 : "%r" (x), "r" (y))
310 310
311# define MAD_F_MLN(hi, lo) \ 311# define MAD_F_MLN(hi, lo) \
312 asm ("rsbs %0, %2, #0\n\t" \ 312 asm ("rsbs %0, %2, #0\n\t" \
313 "rsc %1, %3, #0" \ 313 "rsc %1, %3, #0" \
314 : "=r" (lo), "=r" (hi) \ 314 : "=r" (lo), "=r" (hi) \
315 : "0" (lo), "1" (hi) \ 315 : "0" (lo), "1" (hi) \
316 : "cc") 316 : "cc")
317 317
318# define mad_f_scale64(hi, lo) \ 318# define mad_f_scale64(hi, lo) \
319 ({ mad_fixed_t __result; \ 319 ({ mad_fixed_t __result; \
320 asm ("movs %0, %1, lsr %3\n\t" \ 320 asm ("movs %0, %1, lsr %3\n\t" \
321 "adc %0, %0, %2, lsl %4" \ 321 "adc %0, %0, %2, lsl %4" \
322 : "=&r" (__result) \ 322 : "=&r" (__result) \
323 : "r" (lo), "r" (hi), \ 323 : "r" (lo), "r" (hi), \
324 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ 324 "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
325 : "cc"); \ 325 : "cc"); \
326 __result; \ 326 __result; \
327 }) 327 })
328 328
@@ -337,28 +337,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
337 * significant bit depends on OPT_ACCURACY via mad_f_scale64(). 337 * significant bit depends on OPT_ACCURACY via mad_f_scale64().
338 */ 338 */
339# define MAD_F_MLX(hi, lo, x, y) \ 339# define MAD_F_MLX(hi, lo, x, y) \
340 asm ("mult %2,%3" \ 340 asm ("mult %2,%3" \
341 : "=l" (lo), "=h" (hi) \ 341 : "=l" (lo), "=h" (hi) \
342 : "%r" (x), "r" (y)) 342 : "%r" (x), "r" (y))
343 343
344# if defined(HAVE_MADD_ASM) 344# if defined(HAVE_MADD_ASM)
345# define MAD_F_MLA(hi, lo, x, y) \ 345# define MAD_F_MLA(hi, lo, x, y) \
346 asm ("madd %2,%3" \ 346 asm ("madd %2,%3" \
347 : "+l" (lo), "+h" (hi) \ 347 : "+l" (lo), "+h" (hi) \
348 : "%r" (x), "r" (y)) 348 : "%r" (x), "r" (y))
349# elif defined(HAVE_MADD16_ASM) 349# elif defined(HAVE_MADD16_ASM)
350/* 350/*
351 * This loses significant accuracy due to the 16-bit integer limit in the 351 * This loses significant accuracy due to the 16-bit integer limit in the
352 * multiply/accumulate instruction. 352 * multiply/accumulate instruction.
353 */ 353 */
354# define MAD_F_ML0(hi, lo, x, y) \ 354# define MAD_F_ML0(hi, lo, x, y) \
355 asm ("mult %2,%3" \ 355 asm ("mult %2,%3" \
356 : "=l" (lo), "=h" (hi) \ 356 : "=l" (lo), "=h" (hi) \
357 : "%r" ((x) >> 12), "r" ((y) >> 16)) 357 : "%r" ((x) >> 12), "r" ((y) >> 16))
358# define MAD_F_MLA(hi, lo, x, y) \ 358# define MAD_F_MLA(hi, lo, x, y) \
359 asm ("madd16 %2,%3" \ 359 asm ("madd16 %2,%3" \
360 : "+l" (lo), "+h" (hi) \ 360 : "+l" (lo), "+h" (hi) \
361 : "%r" ((x) >> 12), "r" ((y) >> 16)) 361 : "%r" ((x) >> 12), "r" ((y) >> 16))
362# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) 362# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo))
363# endif 363# endif
364 364
@@ -378,9 +378,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
378 */ 378 */
379# define MAD_F_MLX(hi, lo, x, y) \ 379# define MAD_F_MLX(hi, lo, x, y) \
380 asm ("smul %2, %3, %0\n\t" \ 380 asm ("smul %2, %3, %0\n\t" \
381 "rd %%y, %1" \ 381 "rd %%y, %1" \
382 : "=r" (lo), "=r" (hi) \ 382 : "=r" (lo), "=r" (hi) \
383 : "%r" (x), "rI" (y)) 383 : "%r" (x), "rI" (y))
384 384
385/* --- PowerPC ------------------------------------------------------------- */ 385/* --- PowerPC ------------------------------------------------------------- */
386 386
@@ -393,11 +393,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
393# define MAD_F_MLX(hi, lo, x, y) \ 393# define MAD_F_MLX(hi, lo, x, y) \
394 do { \ 394 do { \
395 asm ("mullw %0,%1,%2" \ 395 asm ("mullw %0,%1,%2" \
396 : "=r" (lo) \ 396 : "=r" (lo) \
397 : "%r" (x), "r" (y)); \ 397 : "%r" (x), "r" (y)); \
398 asm ("mulhw %0,%1,%2" \ 398 asm ("mulhw %0,%1,%2" \
399 : "=r" (hi) \ 399 : "=r" (hi) \
400 : "%r" (x), "r" (y)); \ 400 : "%r" (x), "r" (y)); \
401 } \ 401 } \
402 while (0) 402 while (0)
403 403
@@ -410,11 +410,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
410 mad_fixed64lo_t __lo; \ 410 mad_fixed64lo_t __lo; \
411 MAD_F_MLX(__hi, __lo, (x), (y)); \ 411 MAD_F_MLX(__hi, __lo, (x), (y)); \
412 asm ("addc %0,%2,%3\n\t" \ 412 asm ("addc %0,%2,%3\n\t" \
413 "adde %1,%4,%5" \ 413 "adde %1,%4,%5" \
414 : "=r" (lo), "=r" (hi) \ 414 : "=r" (lo), "=r" (hi) \
415 : "%r" (lo), "r" (__lo), \ 415 : "%r" (lo), "r" (__lo), \
416 "%r" (hi), "r" (__hi) \ 416 "%r" (hi), "r" (__hi) \
417 : "xer"); \ 417 : "xer"); \
418 }) 418 })
419# endif 419# endif
420 420
@@ -425,28 +425,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
425# define mad_f_scale64(hi, lo) \ 425# define mad_f_scale64(hi, lo) \
426 ({ mad_fixed_t __result, __round; \ 426 ({ mad_fixed_t __result, __round; \
427 asm ("rotrwi %0,%1,%2" \ 427 asm ("rotrwi %0,%1,%2" \
428 : "=r" (__result) \ 428 : "=r" (__result) \
429 : "r" (lo), "i" (MAD_F_SCALEBITS)); \ 429 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
430 asm ("extrwi %0,%1,1,0" \ 430 asm ("extrwi %0,%1,1,0" \
431 : "=r" (__round) \ 431 : "=r" (__round) \
432 : "r" (__result)); \ 432 : "r" (__result)); \
433 asm ("insrwi %0,%1,%2,0" \ 433 asm ("insrwi %0,%1,%2,0" \
434 : "+r" (__result) \ 434 : "+r" (__result) \
435 : "r" (hi), "i" (MAD_F_SCALEBITS)); \ 435 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
436 asm ("add %0,%1,%2" \ 436 asm ("add %0,%1,%2" \
437 : "=r" (__result) \ 437 : "=r" (__result) \
438 : "%r" (__result), "r" (__round)); \ 438 : "%r" (__result), "r" (__round)); \
439 __result; \ 439 __result; \
440 }) 440 })
441# else 441# else
442# define mad_f_scale64(hi, lo) \ 442# define mad_f_scale64(hi, lo) \
443 ({ mad_fixed_t __result; \ 443 ({ mad_fixed_t __result; \
444 asm ("rotrwi %0,%1,%2" \ 444 asm ("rotrwi %0,%1,%2" \
445 : "=r" (__result) \ 445 : "=r" (__result) \
446 : "r" (lo), "i" (MAD_F_SCALEBITS)); \ 446 : "r" (lo), "i" (MAD_F_SCALEBITS)); \
447 asm ("insrwi %0,%1,%2,0" \ 447 asm ("insrwi %0,%1,%2,0" \
448 : "+r" (__result) \ 448 : "+r" (__result) \
449 : "r" (hi), "i" (MAD_F_SCALEBITS)); \ 449 : "r" (hi), "i" (MAD_F_SCALEBITS)); \
450 __result; \ 450 __result; \
451 }) 451 })
452# endif 452# endif
@@ -467,10 +467,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
467 * Pre-rounding is required to stay within the limits of compliance. 467 * Pre-rounding is required to stay within the limits of compliance.
468 */ 468 */
469# if defined(OPT_SPEED) 469# if defined(OPT_SPEED)
470# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16)) 470# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
471# else 471# else
472# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \ 472# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
473 (((y) + (1L << 15)) >> 16)) 473 (((y) + (1L << 15)) >> 16))
474# endif 474# endif
475 475
476/* ------------------------------------------------------------------------- */ 476/* ------------------------------------------------------------------------- */
@@ -491,22 +491,22 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
491# endif 491# endif
492 492
493# if !defined(MAD_F_MLA) 493# if !defined(MAD_F_MLA)
494# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) 494# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
495# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) 495# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
496# define MAD_F_MLN(hi, lo) ((lo) = -(lo)) 496# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
497# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) 497# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
498# endif 498# endif
499 499
500# if !defined(MAD_F_ML0) 500# if !defined(MAD_F_ML0)
501# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y)) 501# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
502# endif 502# endif
503 503
504# if !defined(MAD_F_MLN) 504# if !defined(MAD_F_MLN)
505# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) 505# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
506# endif 506# endif
507 507
508# if !defined(MAD_F_MLZ) 508# if !defined(MAD_F_MLZ)
509# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) 509# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
510# endif 510# endif
511 511
512# if !defined(mad_f_scale64) 512# if !defined(mad_f_scale64)
@@ -514,7 +514,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
514# define mad_f_scale64(hi, lo) \ 514# define mad_f_scale64(hi, lo) \
515 ((((mad_fixed_t) \ 515 ((((mad_fixed_t) \
516 (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ 516 (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \
517 ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) 517 ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
518# else 518# else
519# define mad_f_scale64(hi, lo) \ 519# define mad_f_scale64(hi, lo) \
520 ((mad_fixed_t) \ 520 ((mad_fixed_t) \
@@ -544,10 +544,10 @@ struct mad_bitptr {
544 544
545void mad_bit_init(struct mad_bitptr *, unsigned char const *); 545void mad_bit_init(struct mad_bitptr *, unsigned char const *);
546 546
547# define mad_bit_finish(bitptr) /* nothing */ 547# define mad_bit_finish(bitptr) /* nothing */
548 548
549unsigned int mad_bit_length(struct mad_bitptr const *, 549unsigned int mad_bit_length(struct mad_bitptr const *,
550 struct mad_bitptr const *); 550 struct mad_bitptr const *);
551 551
552# define mad_bit_bitsleft(bitptr) ((bitptr)->left) 552# define mad_bit_bitsleft(bitptr) ((bitptr)->left)
553unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); 553unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
@@ -566,67 +566,67 @@ unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
566# define LIBMAD_TIMER_H 566# define LIBMAD_TIMER_H
567 567
568typedef struct { 568typedef struct {
569 signed long seconds; /* whole seconds */ 569 signed long seconds; /* whole seconds */
570 unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */ 570 unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
571} mad_timer_t; 571} mad_timer_t;
572 572
573extern mad_timer_t const mad_timer_zero; 573extern mad_timer_t const mad_timer_zero;
574 574
575# define MAD_TIMER_RESOLUTION 352800000UL 575# define MAD_TIMER_RESOLUTION 352800000UL
576 576
577enum mad_units { 577enum mad_units {
578 MAD_UNITS_HOURS = -2, 578 MAD_UNITS_HOURS = -2,
579 MAD_UNITS_MINUTES = -1, 579 MAD_UNITS_MINUTES = -1,
580 MAD_UNITS_SECONDS = 0, 580 MAD_UNITS_SECONDS = 0,
581 581
582 /* metric units */ 582 /* metric units */
583 583
584 MAD_UNITS_DECISECONDS = 10, 584 MAD_UNITS_DECISECONDS = 10,
585 MAD_UNITS_CENTISECONDS = 100, 585 MAD_UNITS_CENTISECONDS = 100,
586 MAD_UNITS_MILLISECONDS = 1000, 586 MAD_UNITS_MILLISECONDS = 1000,
587 587
588 /* audio sample units */ 588 /* audio sample units */
589 589
590 MAD_UNITS_8000_HZ = 8000, 590 MAD_UNITS_8000_HZ = 8000,
591 MAD_UNITS_11025_HZ = 11025, 591 MAD_UNITS_11025_HZ = 11025,
592 MAD_UNITS_12000_HZ = 12000, 592 MAD_UNITS_12000_HZ = 12000,
593 593
594 MAD_UNITS_16000_HZ = 16000, 594 MAD_UNITS_16000_HZ = 16000,
595 MAD_UNITS_22050_HZ = 22050, 595 MAD_UNITS_22050_HZ = 22050,
596 MAD_UNITS_24000_HZ = 24000, 596 MAD_UNITS_24000_HZ = 24000,
597 597
598 MAD_UNITS_32000_HZ = 32000, 598 MAD_UNITS_32000_HZ = 32000,
599 MAD_UNITS_44100_HZ = 44100, 599 MAD_UNITS_44100_HZ = 44100,
600 MAD_UNITS_48000_HZ = 48000, 600 MAD_UNITS_48000_HZ = 48000,
601 601
602 /* video frame/field units */ 602 /* video frame/field units */
603 603
604 MAD_UNITS_24_FPS = 24, 604 MAD_UNITS_24_FPS = 24,
605 MAD_UNITS_25_FPS = 25, 605 MAD_UNITS_25_FPS = 25,
606 MAD_UNITS_30_FPS = 30, 606 MAD_UNITS_30_FPS = 30,
607 MAD_UNITS_48_FPS = 48, 607 MAD_UNITS_48_FPS = 48,
608 MAD_UNITS_50_FPS = 50, 608 MAD_UNITS_50_FPS = 50,
609 MAD_UNITS_60_FPS = 60, 609 MAD_UNITS_60_FPS = 60,
610 610
611 /* CD audio frames */ 611 /* CD audio frames */
612 612
613 MAD_UNITS_75_FPS = 75, 613 MAD_UNITS_75_FPS = 75,
614 614
615 /* video drop-frame units */ 615 /* video drop-frame units */
616 616
617 MAD_UNITS_23_976_FPS = -24, 617 MAD_UNITS_23_976_FPS = -24,
618 MAD_UNITS_24_975_FPS = -25, 618 MAD_UNITS_24_975_FPS = -25,
619 MAD_UNITS_29_97_FPS = -30, 619 MAD_UNITS_29_97_FPS = -30,
620 MAD_UNITS_47_952_FPS = -48, 620 MAD_UNITS_47_952_FPS = -48,
621 MAD_UNITS_49_95_FPS = -50, 621 MAD_UNITS_49_95_FPS = -50,
622 MAD_UNITS_59_94_FPS = -60 622 MAD_UNITS_59_94_FPS = -60
623}; 623};
624 624
625# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero)) 625# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
626 626
627int mad_timer_compare(mad_timer_t, mad_timer_t); 627int mad_timer_compare(mad_timer_t, mad_timer_t);
628 628
629# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero) 629# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
630 630
631void mad_timer_negate(mad_timer_t *); 631void mad_timer_negate(mad_timer_t *);
632mad_timer_t mad_timer_abs(mad_timer_t); 632mad_timer_t mad_timer_abs(mad_timer_t);
@@ -638,7 +638,7 @@ void mad_timer_multiply(mad_timer_t *, signed long);
638signed long mad_timer_count(mad_timer_t, enum mad_units); 638signed long mad_timer_count(mad_timer_t, enum mad_units);
639unsigned long mad_timer_fraction(mad_timer_t, unsigned long); 639unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
640void mad_timer_string(mad_timer_t, char *, char const *, 640void mad_timer_string(mad_timer_t, char *, char const *,
641 enum mad_units, enum mad_units, unsigned long); 641 enum mad_units, enum mad_units, unsigned long);
642 642
643# endif 643# endif
644 644
@@ -648,70 +648,70 @@ void mad_timer_string(mad_timer_t, char *, char const *,
648# define LIBMAD_STREAM_H 648# define LIBMAD_STREAM_H
649 649
650 650
651# define MAD_BUFFER_GUARD 8 651# define MAD_BUFFER_GUARD 8
652# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) 652# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
653 653
654enum mad_error { 654enum mad_error {
655 MAD_ERROR_NONE = 0x0000, /* no error */ 655 MAD_ERROR_NONE = 0x0000, /* no error */
656 656
657 MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ 657 MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
658 MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ 658 MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
659 659
660 MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ 660 MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
661 661
662 MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ 662 MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
663 MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ 663 MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */
664 MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ 664 MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */
665 MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ 665 MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
666 MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ 666 MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
667 667
668 MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ 668 MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
669 MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ 669 MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */
670 MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ 670 MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */
671 MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ 671 MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */
672 MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ 672 MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */
673 MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ 673 MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */
674 MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ 674 MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */
675 MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ 675 MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */
676 MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ 676 MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */
677 MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ 677 MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */
678 MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ 678 MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */
679 MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ 679 MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */
680 MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ 680 MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */
681}; 681};
682 682
683# define MAD_RECOVERABLE(error) ((error) & 0xff00) 683# define MAD_RECOVERABLE(error) ((error) & 0xff00)
684 684
685struct mad_stream { 685struct mad_stream {
686 unsigned char const *buffer; /* input bitstream buffer */ 686 unsigned char const *buffer; /* input bitstream buffer */
687 unsigned char const *bufend; /* end of buffer */ 687 unsigned char const *bufend; /* end of buffer */
688 unsigned long skiplen; /* bytes to skip before next frame */ 688 unsigned long skiplen; /* bytes to skip before next frame */
689 689
690 int sync; /* stream sync found */ 690 int sync; /* stream sync found */
691 unsigned long freerate; /* free bitrate (fixed) */ 691 unsigned long freerate; /* free bitrate (fixed) */
692 692
693 unsigned char const *this_frame; /* start of current frame */ 693 unsigned char const *this_frame; /* start of current frame */
694 unsigned char const *next_frame; /* start of next frame */ 694 unsigned char const *next_frame; /* start of next frame */
695 struct mad_bitptr ptr; /* current processing bit pointer */ 695 struct mad_bitptr ptr; /* current processing bit pointer */
696 696
697 struct mad_bitptr anc_ptr; /* ancillary bits pointer */ 697 struct mad_bitptr anc_ptr; /* ancillary bits pointer */
698 unsigned int anc_bitlen; /* number of ancillary bits */ 698 unsigned int anc_bitlen; /* number of ancillary bits */
699 699
700 unsigned char (*main_data)[MAD_BUFFER_MDLEN]; 700 unsigned char (*main_data)[MAD_BUFFER_MDLEN];
701 /* Layer III main_data() */ 701 /* Layer III main_data() */
702 unsigned int md_len; /* bytes in main_data */ 702 unsigned int md_len; /* bytes in main_data */
703 703
704 int options; /* decoding options (see below) */ 704 int options; /* decoding options (see below) */
705 enum mad_error error; /* error code (see above) */ 705 enum mad_error error; /* error code (see above) */
706}; 706};
707 707
708enum { 708enum {
709 MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ 709 MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
710 MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ 710 MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
711# if 0 /* not yet implemented */ 711# if 0 /* not yet implemented */
712 MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ 712 MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
713 MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ 713 MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
714 MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ 714 MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
715# endif 715# endif
716}; 716};
717 717
@@ -722,7 +722,7 @@ void mad_stream_finish(struct mad_stream *);
722 ((void) ((stream)->options = (opts))) 722 ((void) ((stream)->options = (opts)))
723 723
724void mad_stream_buffer(struct mad_stream *, 724void mad_stream_buffer(struct mad_stream *,
725 unsigned char const *, unsigned long); 725 unsigned char const *, unsigned long);
726void mad_stream_skip(struct mad_stream *, unsigned long); 726void mad_stream_skip(struct mad_stream *, unsigned long);
727 727
728int mad_stream_sync(struct mad_stream *); 728int mad_stream_sync(struct mad_stream *);
@@ -738,82 +738,82 @@ char const *mad_stream_errorstr(struct mad_stream const *);
738 738
739 739
740enum mad_layer { 740enum mad_layer {
741 MAD_LAYER_I = 1, /* Layer I */ 741 MAD_LAYER_I = 1, /* Layer I */
742 MAD_LAYER_II = 2, /* Layer II */ 742 MAD_LAYER_II = 2, /* Layer II */
743 MAD_LAYER_III = 3 /* Layer III */ 743 MAD_LAYER_III = 3 /* Layer III */
744}; 744};
745 745
746enum mad_mode { 746enum mad_mode {
747 MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ 747 MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
748 MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ 748 MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
749 MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ 749 MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
750 MAD_MODE_STEREO = 3 /* normal LR stereo */ 750 MAD_MODE_STEREO = 3 /* normal LR stereo */
751}; 751};
752 752
753enum mad_emphasis { 753enum mad_emphasis {
754 MAD_EMPHASIS_NONE = 0, /* no emphasis */ 754 MAD_EMPHASIS_NONE = 0, /* no emphasis */
755 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ 755 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
756 MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ 756 MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
757 MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ 757 MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
758}; 758};
759 759
760struct mad_header { 760struct mad_header {
761 enum mad_layer layer; /* audio layer (1, 2, or 3) */ 761 enum mad_layer layer; /* audio layer (1, 2, or 3) */
762 enum mad_mode mode; /* channel mode (see above) */ 762 enum mad_mode mode; /* channel mode (see above) */
763 int mode_extension; /* additional mode info */ 763 int mode_extension; /* additional mode info */
764 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ 764 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
765 765
766 unsigned long bitrate; /* stream bitrate (bps) */ 766 unsigned long bitrate; /* stream bitrate (bps) */
767 unsigned int samplerate; /* sampling frequency (Hz) */ 767 unsigned int samplerate; /* sampling frequency (Hz) */
768 768
769 unsigned short crc_check; /* frame CRC accumulator */ 769 unsigned short crc_check; /* frame CRC accumulator */
770 unsigned short crc_target; /* final target CRC checksum */ 770 unsigned short crc_target; /* final target CRC checksum */
771 771
772 int flags; /* flags (see below) */ 772 int flags; /* flags (see below) */
773 int private_bits; /* private bits (see below) */ 773 int private_bits; /* private bits (see below) */
774 774
775 mad_timer_t duration; /* audio playing time of frame */ 775 mad_timer_t duration; /* audio playing time of frame */
776}; 776};
777 777
778struct mad_frame { 778struct mad_frame {
779 struct mad_header header; /* MPEG audio header */ 779 struct mad_header header; /* MPEG audio header */
780 int options; /* decoding options (from stream) */ 780 int options; /* decoding options (from stream) */
781 781
782 mad_fixed_t (*sbsample)[2][36][32]; /* synthesis subband filter samples */ 782 mad_fixed_t (*sbsample)[2][36][32]; /* synthesis subband filter samples */
783 mad_fixed_t (*sbsample_prev)[2][36][32]; /* synthesis subband filter samples 783 mad_fixed_t (*sbsample_prev)[2][36][32]; /* synthesis subband filter samples
784 from previous frame only needed 784 from previous frame only needed
785 when synthesis is on cop */ 785 when synthesis is on cop */
786 786
787 mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ 787 mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
788}; 788};
789 789
790# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) 790# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
791# define MAD_NSBSAMPLES(header) \ 791# define MAD_NSBSAMPLES(header) \
792 ((header)->layer == MAD_LAYER_I ? 12 : \ 792 ((header)->layer == MAD_LAYER_I ? 12 : \
793 (((header)->layer == MAD_LAYER_III && \ 793 (((header)->layer == MAD_LAYER_III && \
794 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) 794 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
795 795
796enum { 796enum {
797 MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ 797 MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
798 MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ 798 MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
799 799
800 MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ 800 MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
801 MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ 801 MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
802 MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ 802 MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
803 MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ 803 MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
804 804
805 MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ 805 MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
806 MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ 806 MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
807 MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ 807 MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
808 808
809 MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ 809 MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
810 MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ 810 MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
811 MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ 811 MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
812}; 812};
813 813
814enum { 814enum {
815 MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ 815 MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
816 MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ 816 MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
817}; 817};
818 818
819void mad_header_init(struct mad_header *); 819void mad_header_init(struct mad_header *);
@@ -838,19 +838,19 @@ void mad_frame_mute(struct mad_frame *);
838 838
839 839
840struct mad_pcm { 840struct mad_pcm {
841 unsigned int samplerate; /* sampling frequency (Hz) */ 841 unsigned int samplerate; /* sampling frequency (Hz) */
842 unsigned short channels; /* number of channels */ 842 unsigned short channels; /* number of channels */
843 unsigned short length; /* number of samples per channel */ 843 unsigned short length; /* number of samples per channel */
844 mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ 844 mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
845}; 845};
846 846
847struct mad_synth { 847struct mad_synth {
848 mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ 848 mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
849 /* [ch][eo][peo][s][v] */ 849 /* [ch][eo][peo][s][v] */
850 850
851 unsigned int phase; /* current processing phase */ 851 unsigned int phase; /* current processing phase */
852 852
853 struct mad_pcm pcm; /* PCM output */ 853 struct mad_pcm pcm; /* PCM output */
854}; 854};
855 855
856/* single channel PCM selector */ 856/* single channel PCM selector */
@@ -892,10 +892,10 @@ enum mad_decoder_mode {
892}; 892};
893 893
894enum mad_flow { 894enum mad_flow {
895 MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ 895 MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
896 MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ 896 MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
897 MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ 897 MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
898 MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ 898 MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
899}; 899};
900 900
901struct mad_decoder { 901struct mad_decoder {
@@ -920,26 +920,26 @@ struct mad_decoder {
920 enum mad_flow (*input_func)(void *, struct mad_stream *); 920 enum mad_flow (*input_func)(void *, struct mad_stream *);
921 enum mad_flow (*header_func)(void *, struct mad_header const *); 921 enum mad_flow (*header_func)(void *, struct mad_header const *);
922 enum mad_flow (*filter_func)(void *, 922 enum mad_flow (*filter_func)(void *,
923 struct mad_stream const *, struct mad_frame *); 923 struct mad_stream const *, struct mad_frame *);
924 enum mad_flow (*output_func)(void *, 924 enum mad_flow (*output_func)(void *,
925 struct mad_header const *, struct mad_pcm *); 925 struct mad_header const *, struct mad_pcm *);
926 enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); 926 enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
927 enum mad_flow (*message_func)(void *, void *, unsigned int *); 927 enum mad_flow (*message_func)(void *, void *, unsigned int *);
928}; 928};
929 929
930void mad_decoder_init(struct mad_decoder *, void *, 930void mad_decoder_init(struct mad_decoder *, void *,
931 enum mad_flow (*)(void *, struct mad_stream *), 931 enum mad_flow (*)(void *, struct mad_stream *),
932 enum mad_flow (*)(void *, struct mad_header const *), 932 enum mad_flow (*)(void *, struct mad_header const *),
933 enum mad_flow (*)(void *, 933 enum mad_flow (*)(void *,
934 struct mad_stream const *, 934 struct mad_stream const *,
935 struct mad_frame *), 935 struct mad_frame *),
936 enum mad_flow (*)(void *, 936 enum mad_flow (*)(void *,
937 struct mad_header const *, 937 struct mad_header const *,
938 struct mad_pcm *), 938 struct mad_pcm *),
939 enum mad_flow (*)(void *, 939 enum mad_flow (*)(void *,
940 struct mad_stream *, 940 struct mad_stream *,
941 struct mad_frame *), 941 struct mad_frame *),
942 enum mad_flow (*)(void *, void *, unsigned int *)); 942 enum mad_flow (*)(void *, void *, unsigned int *));
943int mad_decoder_finish(struct mad_decoder *); 943int mad_decoder_finish(struct mad_decoder *);
944 944
945# define mad_decoder_options(decoder, opts) \ 945# define mad_decoder_options(decoder, opts) \
diff --git a/apps/codecs/libmad/minimad.c b/apps/codecs/libmad/minimad.c
index e32e0d6a38..6b443cf859 100644
--- a/apps/codecs/libmad/minimad.c
+++ b/apps/codecs/libmad/minimad.c
@@ -82,7 +82,7 @@ struct buffer {
82 82
83static 83static
84enum mad_flow input(void *data, 84enum mad_flow input(void *data,
85 struct mad_stream *stream) 85 struct mad_stream *stream)
86{ 86{
87 struct buffer *buffer = data; 87 struct buffer *buffer = data;
88 88
@@ -128,8 +128,8 @@ signed int scale(mad_fixed_t sample)
128 128
129static 129static
130enum mad_flow output(void *data, 130enum mad_flow output(void *data,
131 struct mad_header const *header, 131 struct mad_header const *header,
132 struct mad_pcm *pcm) 132 struct mad_pcm *pcm)
133{ 133{
134 unsigned int nchannels, nsamples; 134 unsigned int nchannels, nsamples;
135 mad_fixed_t const *left_ch, *right_ch; 135 mad_fixed_t const *left_ch, *right_ch;
@@ -169,14 +169,14 @@ enum mad_flow output(void *data,
169 169
170static 170static
171enum mad_flow error(void *data, 171enum mad_flow error(void *data,
172 struct mad_stream *stream, 172 struct mad_stream *stream,
173 struct mad_frame *frame) 173 struct mad_frame *frame)
174{ 174{
175 struct buffer *buffer = data; 175 struct buffer *buffer = data;
176 176
177 fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %u\n", 177 fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %u\n",
178 stream->error, mad_stream_errorstr(stream), 178 stream->error, mad_stream_errorstr(stream),
179 stream->this_frame - buffer->start); 179 stream->this_frame - buffer->start);
180 180
181 /* return MAD_FLOW_BREAK here to stop decoding (and propagate an error) */ 181 /* return MAD_FLOW_BREAK here to stop decoding (and propagate an error) */
182 182
@@ -207,8 +207,8 @@ int decode(unsigned char const *start, unsigned long length)
207 /* configure input, output, and error functions */ 207 /* configure input, output, and error functions */
208 208
209 mad_decoder_init(&decoder, &buffer, 209 mad_decoder_init(&decoder, &buffer,
210 input, 0 /* header */, 0 /* filter */, output, 210 input, 0 /* header */, 0 /* filter */, output,
211 error, 0 /* message */); 211 error, 0 /* message */);
212 212
213 /* start decoding */ 213 /* start decoding */
214 214
diff --git a/apps/codecs/libmad/stream.c b/apps/codecs/libmad/stream.c
index 69c963bb0d..2936736f76 100644
--- a/apps/codecs/libmad/stream.c
+++ b/apps/codecs/libmad/stream.c
@@ -29,8 +29,8 @@
29# include "stream.h" 29# include "stream.h"
30 30
31/* 31/*
32 * NAME: stream->init() 32 * NAME: stream->init()
33 * DESCRIPTION: initialize stream struct 33 * DESCRIPTION: initialize stream struct
34 */ 34 */
35void mad_stream_init(struct mad_stream *stream) 35void mad_stream_init(struct mad_stream *stream)
36{ 36{
@@ -56,8 +56,8 @@ void mad_stream_init(struct mad_stream *stream)
56} 56}
57 57
58/* 58/*
59 * NAME: stream->finish() 59 * NAME: stream->finish()
60 * DESCRIPTION: deallocate any dynamic memory associated with stream 60 * DESCRIPTION: deallocate any dynamic memory associated with stream
61 */ 61 */
62void mad_stream_finish(struct mad_stream *stream) 62void mad_stream_finish(struct mad_stream *stream)
63{ 63{
@@ -71,11 +71,11 @@ void mad_stream_finish(struct mad_stream *stream)
71} 71}
72 72
73/* 73/*
74 * NAME: stream->buffer() 74 * NAME: stream->buffer()
75 * DESCRIPTION: set stream buffer pointers 75 * DESCRIPTION: set stream buffer pointers
76 */ 76 */
77void mad_stream_buffer(struct mad_stream *stream, 77void mad_stream_buffer(struct mad_stream *stream,
78 unsigned char const *buffer, unsigned long length) 78 unsigned char const *buffer, unsigned long length)
79{ 79{
80 stream->buffer = buffer; 80 stream->buffer = buffer;
81 stream->bufend = buffer + length; 81 stream->bufend = buffer + length;
@@ -89,8 +89,8 @@ void mad_stream_buffer(struct mad_stream *stream,
89} 89}
90 90
91/* 91/*
92 * NAME: stream->skip() 92 * NAME: stream->skip()
93 * DESCRIPTION: arrange to skip bytes before the next frame 93 * DESCRIPTION: arrange to skip bytes before the next frame
94 */ 94 */
95void mad_stream_skip(struct mad_stream *stream, unsigned long length) 95void mad_stream_skip(struct mad_stream *stream, unsigned long length)
96{ 96{
@@ -98,8 +98,8 @@ void mad_stream_skip(struct mad_stream *stream, unsigned long length)
98} 98}
99 99
100/* 100/*
101 * NAME: stream->sync() 101 * NAME: stream->sync()
102 * DESCRIPTION: locate the next stream sync word 102 * DESCRIPTION: locate the next stream sync word
103 */ 103 */
104int mad_stream_sync(struct mad_stream *stream) 104int mad_stream_sync(struct mad_stream *stream)
105{ 105{
@@ -109,7 +109,7 @@ int mad_stream_sync(struct mad_stream *stream)
109 end = stream->bufend; 109 end = stream->bufend;
110 110
111 while (ptr < end - 1 && 111 while (ptr < end - 1 &&
112 !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) 112 !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0))
113 ++ptr; 113 ++ptr;
114 114
115 if (end - ptr < MAD_BUFFER_GUARD) 115 if (end - ptr < MAD_BUFFER_GUARD)
@@ -121,38 +121,38 @@ int mad_stream_sync(struct mad_stream *stream)
121} 121}
122 122
123/* 123/*
124 * NAME: stream->errorstr() 124 * NAME: stream->errorstr()
125 * DESCRIPTION: return a string description of the current error condition 125 * DESCRIPTION: return a string description of the current error condition
126 */ 126 */
127char const *mad_stream_errorstr(struct mad_stream const *stream) 127char const *mad_stream_errorstr(struct mad_stream const *stream)
128{ 128{
129 switch (stream->error) { 129 switch (stream->error) {
130 case MAD_ERROR_NONE: return "no error"; 130 case MAD_ERROR_NONE: return "no error";
131 131
132 case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)"; 132 case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)";
133 case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer"; 133 case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer";
134 134
135 case MAD_ERROR_NOMEM: return "not enough memory"; 135 case MAD_ERROR_NOMEM: return "not enough memory";
136 136
137 case MAD_ERROR_LOSTSYNC: return "lost synchronization"; 137 case MAD_ERROR_LOSTSYNC: return "lost synchronization";
138 case MAD_ERROR_BADLAYER: return "reserved header layer value"; 138 case MAD_ERROR_BADLAYER: return "reserved header layer value";
139 case MAD_ERROR_BADBITRATE: return "forbidden bitrate value"; 139 case MAD_ERROR_BADBITRATE: return "forbidden bitrate value";
140 case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value"; 140 case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value";
141 case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value"; 141 case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value";
142 142
143 case MAD_ERROR_BADCRC: return "CRC check failed"; 143 case MAD_ERROR_BADCRC: return "CRC check failed";
144 case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value"; 144 case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value";
145 case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index"; 145 case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index";
146 case MAD_ERROR_BADMODE: return "bad bitrate/mode combination"; 146 case MAD_ERROR_BADMODE: return "bad bitrate/mode combination";
147 case MAD_ERROR_BADFRAMELEN: return "bad frame length"; 147 case MAD_ERROR_BADFRAMELEN: return "bad frame length";
148 case MAD_ERROR_BADBIGVALUES: return "bad big_values count"; 148 case MAD_ERROR_BADBIGVALUES: return "bad big_values count";
149 case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type"; 149 case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type";
150 case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info"; 150 case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info";
151 case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer"; 151 case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer";
152 case MAD_ERROR_BADPART3LEN: return "bad audio data length"; 152 case MAD_ERROR_BADPART3LEN: return "bad audio data length";
153 case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select"; 153 case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select";
154 case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun"; 154 case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun";
155 case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS"; 155 case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS";
156 } 156 }
157 157
158 return 0; 158 return 0;
diff --git a/apps/codecs/libmad/stream.h b/apps/codecs/libmad/stream.h
index 5fca48fdb8..c89c40e088 100644
--- a/apps/codecs/libmad/stream.h
+++ b/apps/codecs/libmad/stream.h
@@ -24,70 +24,70 @@
24 24
25# include "bit.h" 25# include "bit.h"
26 26
27# define MAD_BUFFER_GUARD 8 27# define MAD_BUFFER_GUARD 8
28# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) 28# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
29 29
30enum mad_error { 30enum mad_error {
31 MAD_ERROR_NONE = 0x0000, /* no error */ 31 MAD_ERROR_NONE = 0x0000, /* no error */
32 32
33 MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ 33 MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
34 MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ 34 MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
35 35
36 MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ 36 MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
37 37
38 MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ 38 MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
39 MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ 39 MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */
40 MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ 40 MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */
41 MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ 41 MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
42 MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ 42 MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
43 43
44 MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ 44 MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
45 MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ 45 MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */
46 MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ 46 MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */
47 MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ 47 MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */
48 MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ 48 MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */
49 MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ 49 MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */
50 MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ 50 MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */
51 MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ 51 MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */
52 MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ 52 MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */
53 MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ 53 MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */
54 MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ 54 MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */
55 MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ 55 MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */
56 MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ 56 MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */
57}; 57};
58 58
59# define MAD_RECOVERABLE(error) ((error) & 0xff00) 59# define MAD_RECOVERABLE(error) ((error) & 0xff00)
60 60
61struct mad_stream { 61struct mad_stream {
62 unsigned char const *buffer; /* input bitstream buffer */ 62 unsigned char const *buffer; /* input bitstream buffer */
63 unsigned char const *bufend; /* end of buffer */ 63 unsigned char const *bufend; /* end of buffer */
64 unsigned long skiplen; /* bytes to skip before next frame */ 64 unsigned long skiplen; /* bytes to skip before next frame */
65 65
66 int sync; /* stream sync found */ 66 int sync; /* stream sync found */
67 unsigned long freerate; /* free bitrate (fixed) */ 67 unsigned long freerate; /* free bitrate (fixed) */
68 68
69 unsigned char const *this_frame; /* start of current frame */ 69 unsigned char const *this_frame; /* start of current frame */
70 unsigned char const *next_frame; /* start of next frame */ 70 unsigned char const *next_frame; /* start of next frame */
71 struct mad_bitptr ptr; /* current processing bit pointer */ 71 struct mad_bitptr ptr; /* current processing bit pointer */
72 72
73 struct mad_bitptr anc_ptr; /* ancillary bits pointer */ 73 struct mad_bitptr anc_ptr; /* ancillary bits pointer */
74 unsigned int anc_bitlen; /* number of ancillary bits */ 74 unsigned int anc_bitlen; /* number of ancillary bits */
75 75
76 unsigned char (*main_data)[MAD_BUFFER_MDLEN]; 76 unsigned char (*main_data)[MAD_BUFFER_MDLEN];
77 /* Layer III main_data() */ 77 /* Layer III main_data() */
78 unsigned int md_len; /* bytes in main_data */ 78 unsigned int md_len; /* bytes in main_data */
79 79
80 int options; /* decoding options (see below) */ 80 int options; /* decoding options (see below) */
81 enum mad_error error; /* error code (see above) */ 81 enum mad_error error; /* error code (see above) */
82}; 82};
83 83
84enum { 84enum {
85 MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ 85 MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
86 MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ 86 MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
87# if 0 /* not yet implemented */ 87# if 0 /* not yet implemented */
88 MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ 88 MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
89 MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ 89 MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
90 MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ 90 MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
91# endif 91# endif
92}; 92};
93 93
@@ -98,7 +98,7 @@ void mad_stream_finish(struct mad_stream *);
98 ((void) ((stream)->options = (opts))) 98 ((void) ((stream)->options = (opts)))
99 99
100void mad_stream_buffer(struct mad_stream *, 100void mad_stream_buffer(struct mad_stream *,
101 unsigned char const *, unsigned long); 101 unsigned char const *, unsigned long);
102void mad_stream_skip(struct mad_stream *, unsigned long); 102void mad_stream_skip(struct mad_stream *, unsigned long);
103 103
104int mad_stream_sync(struct mad_stream *); 104int mad_stream_sync(struct mad_stream *);
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c
index bc7ac742fe..9b320b594d 100644
--- a/apps/codecs/libmad/synth.c
+++ b/apps/codecs/libmad/synth.c
@@ -30,8 +30,8 @@
30# include "synth.h" 30# include "synth.h"
31 31
32/* 32/*
33 * NAME: synth->init() 33 * NAME: synth->init()
34 * DESCRIPTION: initialize synth struct 34 * DESCRIPTION: initialize synth struct
35 */ 35 */
36void mad_synth_init(struct mad_synth *synth) 36void mad_synth_init(struct mad_synth *synth)
37{ 37{
@@ -50,8 +50,8 @@ void mad_synth_init(struct mad_synth *synth)
50} 50}
51 51
52/* 52/*
53 * NAME: synth->mute() 53 * NAME: synth->mute()
54 * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis 54 * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
55 */ 55 */
56void mad_synth_mute(struct mad_synth *synth) 56void mad_synth_mute(struct mad_synth *synth)
57{ 57{
@@ -60,8 +60,8 @@ void mad_synth_mute(struct mad_synth *synth)
60 for (ch = 0; ch < 2; ++ch) { 60 for (ch = 0; ch < 2; ++ch) {
61 for (s = 0; s < 16; ++s) { 61 for (s = 0; s < 16; ++s) {
62 for (v = 0; v < 8; ++v) { 62 for (v = 0; v < 8; ++v) {
63 synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] = 63 synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
64 synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0; 64 synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
65 } 65 }
66 } 66 }
67 } 67 }
@@ -142,12 +142,12 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
142# endif 142# endif
143 143
144/* 144/*
145 * NAME: dct32() 145 * NAME: dct32()
146 * DESCRIPTION: perform fast in[32]->out[32] DCT 146 * DESCRIPTION: perform fast in[32]->out[32] DCT
147 */ 147 */
148static 148static
149void dct32(mad_fixed_t const in[32], unsigned int slot, 149void dct32(mad_fixed_t const in[32], unsigned int slot,
150 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) 150 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8])
151{ 151{
152 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; 152 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7;
153 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; 153 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15;
@@ -176,69 +176,69 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
176 /* costab[i] = cos(PI / (2 * 32) * i) */ 176 /* costab[i] = cos(PI / (2 * 32) * i) */
177 177
178# if defined(OPT_DCTO) 178# if defined(OPT_DCTO)
179# define costab1 MAD_F(0x7fd8878e) 179# define costab1 MAD_F(0x7fd8878e)
180# define costab2 MAD_F(0x7f62368f) 180# define costab2 MAD_F(0x7f62368f)
181# define costab3 MAD_F(0x7e9d55fc) 181# define costab3 MAD_F(0x7e9d55fc)
182# define costab4 MAD_F(0x7d8a5f40) 182# define costab4 MAD_F(0x7d8a5f40)
183# define costab5 MAD_F(0x7c29fbee) 183# define costab5 MAD_F(0x7c29fbee)
184# define costab6 MAD_F(0x7a7d055b) 184# define costab6 MAD_F(0x7a7d055b)
185# define costab7 MAD_F(0x78848414) 185# define costab7 MAD_F(0x78848414)
186# define costab8 MAD_F(0x7641af3d) 186# define costab8 MAD_F(0x7641af3d)
187# define costab9 MAD_F(0x73b5ebd1) 187# define costab9 MAD_F(0x73b5ebd1)
188# define costab10 MAD_F(0x70e2cbc6) 188# define costab10 MAD_F(0x70e2cbc6)
189# define costab11 MAD_F(0x6dca0d14) 189# define costab11 MAD_F(0x6dca0d14)
190# define costab12 MAD_F(0x6a5d98a4) 190# define costab12 MAD_F(0x6a5d98a4)
191# define costab13 MAD_F(0x66cf8120) 191# define costab13 MAD_F(0x66cf8120)
192# define costab14 MAD_F(0x62f201ac) 192# define costab14 MAD_F(0x62f201ac)
193# define costab15 MAD_F(0x5ed77c8a) 193# define costab15 MAD_F(0x5ed77c8a)
194# define costab16 MAD_F(0x5a82799a) 194# define costab16 MAD_F(0x5a82799a)
195# define costab17 MAD_F(0x55f5a4d2) 195# define costab17 MAD_F(0x55f5a4d2)
196# define costab18 MAD_F(0x5133cc94) 196# define costab18 MAD_F(0x5133cc94)
197# define costab19 MAD_F(0x4c3fdff4) 197# define costab19 MAD_F(0x4c3fdff4)
198# define costab20 MAD_F(0x471cece7) 198# define costab20 MAD_F(0x471cece7)
199# define costab21 MAD_F(0x41ce1e65) 199# define costab21 MAD_F(0x41ce1e65)
200# define costab22 MAD_F(0x3c56ba70) 200# define costab22 MAD_F(0x3c56ba70)
201# define costab23 MAD_F(0x36ba2014) 201# define costab23 MAD_F(0x36ba2014)
202# define costab24 MAD_F(0x30fbc54d) 202# define costab24 MAD_F(0x30fbc54d)
203# define costab25 MAD_F(0x2b1f34eb) 203# define costab25 MAD_F(0x2b1f34eb)
204# define costab26 MAD_F(0x25280c5e) 204# define costab26 MAD_F(0x25280c5e)
205# define costab27 MAD_F(0x1f19f97b) 205# define costab27 MAD_F(0x1f19f97b)
206# define costab28 MAD_F(0x18f8b83c) 206# define costab28 MAD_F(0x18f8b83c)
207# define costab29 MAD_F(0x12c8106f) 207# define costab29 MAD_F(0x12c8106f)
208# define costab30 MAD_F(0x0c8bd35e) 208# define costab30 MAD_F(0x0c8bd35e)
209# define costab31 MAD_F(0x0647d97c) 209# define costab31 MAD_F(0x0647d97c)
210# else 210# else
211# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */ 211# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
212# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */ 212# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
213# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */ 213# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
214# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */ 214# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
215# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */ 215# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
216# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */ 216# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
217# define costab7 MAD_F(0x0f109082) /* 0.941544065 */ 217# define costab7 MAD_F(0x0f109082) /* 0.941544065 */
218# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */ 218# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
219# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */ 219# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
220# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */ 220# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
221# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */ 221# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
222# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */ 222# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
223# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */ 223# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
224# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */ 224# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
225# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */ 225# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
226# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */ 226# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
227# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */ 227# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
228# define costab18 MAD_F(0x0a267993) /* 0.634393284 */ 228# define costab18 MAD_F(0x0a267993) /* 0.634393284 */
229# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */ 229# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
230# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */ 230# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
231# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */ 231# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
232# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */ 232# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
233# define costab23 MAD_F(0x06d74402) /* 0.427555093 */ 233# define costab23 MAD_F(0x06d74402) /* 0.427555093 */
234# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */ 234# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
235# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */ 235# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
236# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */ 236# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
237# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */ 237# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
238# define costab28 MAD_F(0x031f1708) /* 0.195090322 */ 238# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
239# define costab29 MAD_F(0x0259020e) /* 0.146730474 */ 239# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
240# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */ 240# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */
241# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */ 241# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
242# endif 242# endif
243 243
244 t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1); 244 t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
@@ -395,7 +395,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
395 395
396 /* 8 */ hi[ 7][slot] = SHIFT(t143); 396 /* 8 */ hi[ 7][slot] = SHIFT(t143);
397 /* 24 */ lo[ 8][slot] = 397 /* 24 */ lo[ 8][slot] =
398 SHIFT((MUL(t141 - t142, costab16) * 2) - t143); 398 SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
399 399
400 t144 = MUL(t73 - t74, costab8); 400 t144 = MUL(t73 - t74, costab8);
401 t145 = MUL(t75 - t76, costab24); 401 t145 = MUL(t75 - t76, costab24);
@@ -435,7 +435,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
435 435
436 /* 20 */ lo[ 4][slot] = SHIFT(t160); 436 /* 20 */ lo[ 4][slot] = SHIFT(t160);
437 /* 28 */ lo[12][slot] = 437 /* 28 */ lo[12][slot] =
438 SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160); 438 SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
439 439
440 t161 = MUL(t94 - t95, costab8); 440 t161 = MUL(t94 - t95, costab8);
441 t162 = MUL(t96 - t97, costab24); 441 t162 = MUL(t96 - t97, costab24);
@@ -473,8 +473,8 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
473 473
474 /* 26 */ lo[10][slot] = SHIFT(t170); 474 /* 26 */ lo[10][slot] = SHIFT(t170);
475 /* 30 */ lo[14][slot] = 475 /* 30 */ lo[14][slot] =
476 SHIFT((((((MUL(t166 - t167, costab16) * 2) - 476 SHIFT((((((MUL(t166 - t167, costab16) * 2) -
477 t168) * 2) - t169) * 2) - t170); 477 t168) * 2) - t169) * 2) - t170);
478 478
479 t171 = MUL(t106 - t107, costab8); 479 t171 = MUL(t106 - t107, costab8);
480 t172 = MUL(t108 - t109, costab24); 480 t172 = MUL(t108 - t109, costab24);
@@ -521,12 +521,12 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
521 /* 27 */ lo[11][slot] = SHIFT(t165); 521 /* 27 */ lo[11][slot] = SHIFT(t165);
522 522
523 t176 = (((((MUL(t161 - t162, costab16) * 2) - 523 t176 = (((((MUL(t161 - t162, costab16) * 2) -
524 t163) * 2) - t164) * 2) - t165; 524 t163) * 2) - t164) * 2) - t165;
525 525
526 /* 29 */ lo[13][slot] = SHIFT(t176); 526 /* 29 */ lo[13][slot] = SHIFT(t176);
527 /* 31 */ lo[15][slot] = 527 /* 31 */ lo[15][slot] =
528 SHIFT((((((((MUL(t171 - t172, costab16) * 2) - 528 SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
529 t173) * 2) - t174) * 2) - t175) * 2) - t176); 529 t173) * 2) - t174) * 2) - t175) * 2) - t176);
530 530
531 /* 531 /*
532 * Totals: 532 * Totals:
@@ -548,24 +548,24 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
548# if MAD_F_FRACBITS != 28 548# if MAD_F_FRACBITS != 28
549# error "MAD_F_FRACBITS must be 28 to use OPT_SSO" 549# error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
550# endif 550# endif
551# define ML0(hi, lo, x, y) ((lo) = (x) * (y)) 551# define ML0(hi, lo, x, y) ((lo) = (x) * (y))
552# define MLA(hi, lo, x, y) ((lo) += (x) * (y)) 552# define MLA(hi, lo, x, y) ((lo) += (x) * (y))
553# define MLN(hi, lo) ((lo) = -(lo)) 553# define MLN(hi, lo) ((lo) = -(lo))
554# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) 554# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
555# define SHIFT(x) ((x) >> 2) 555# define SHIFT(x) ((x) >> 2)
556# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14) 556# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
557# else 557# else
558# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y)) 558# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
559# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y)) 559# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
560# define MLN(hi, lo) MAD_F_MLN((hi), (lo)) 560# define MLN(hi, lo) MAD_F_MLN((hi), (lo))
561# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo)) 561# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
562# define SHIFT(x) (x) 562# define SHIFT(x) (x)
563# if defined(MAD_F_SCALEBITS) 563# if defined(MAD_F_SCALEBITS)
564# undef MAD_F_SCALEBITS 564# undef MAD_F_SCALEBITS
565# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12) 565# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
566# define PRESHIFT(x) (MAD_F(x) >> 12) 566# define PRESHIFT(x) (MAD_F(x) >> 12)
567# else 567# else
568# define PRESHIFT(x) MAD_F(x) 568# define PRESHIFT(x) MAD_F(x)
569# endif 569# endif
570# endif 570# endif
571 571
@@ -576,18 +576,18 @@ mad_fixed_t const D[17][32] ICONST_ATTR = {
576 576
577# if defined(ASO_SYNTH) 577# if defined(ASO_SYNTH)
578void synth_full(struct mad_synth *, struct mad_frame const *, 578void synth_full(struct mad_synth *, struct mad_frame const *,
579 unsigned int, unsigned int); 579 unsigned int, unsigned int);
580# else 580# else
581/* 581/*
582 * NAME: synth->full() 582 * NAME: synth->full()
583 * DESCRIPTION: perform full frequency PCM synthesis 583 * DESCRIPTION: perform full frequency PCM synthesis
584 */ 584 */
585 585
586/* optimised version of synth_full */ 586/* optimised version of synth_full */
587# ifdef FPM_COLDFIRE_EMAC 587# ifdef FPM_COLDFIRE_EMAC
588static 588static
589void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 589void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
590 unsigned int nch, unsigned int ns) 590 unsigned int nch, unsigned int ns)
591{ 591{
592 int sb; 592 int sb;
593 unsigned int phase, ch, s, p; 593 unsigned int phase, ch, s, p;
@@ -606,7 +606,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
606 606
607 for (s = 0; s < ns; ++s) { 607 for (s = 0; s < ns; ++s) {
608 dct32((*sbsample)[s], phase >> 1, 608 dct32((*sbsample)[s], phase >> 1,
609 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 609 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
610 610
611 p = (phase - 1) & 0xf; 611 p = (phase - 1) & 0xf;
612 612
@@ -649,11 +649,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
649 pcm += 16; 649 pcm += 16;
650 650
651 for (sb = 15; sb; sb--, fo++) { 651 for (sb = 15; sb; sb--, fo++) {
652 ++fe; 652 ++fe;
653 ++D0ptr; 653 ++D0ptr;
654 ++D1ptr; 654 ++D1ptr;
655 655
656 /* D[32 - sb][i] == -D[sb][31 - i] */ 656 /* D[32 - sb][i] == -D[sb][31 - i] */
657 asm volatile ( 657 asm volatile (
658 "movem.l (%0), %%d0-%%d7\n\t" 658 "movem.l (%0), %%d0-%%d7\n\t"
659 "move.l 4(%2), %%a5\n\t" 659 "move.l 4(%2), %%a5\n\t"
@@ -697,8 +697,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
697 "movclr.l %%acc0, %0\n\t" 697 "movclr.l %%acc0, %0\n\t"
698 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) ); 698 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
699 699
700 pcm[-sb] = hi0 << 3; 700 pcm[-sb] = hi0 << 3;
701 pcm[ sb] = hi1 << 3; 701 pcm[ sb] = hi1 << 3;
702 } 702 }
703 703
704 ++D0ptr; 704 ++D0ptr;
@@ -750,11 +750,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
750 pcm += 16; 750 pcm += 16;
751 751
752 for (sb = 15; sb; sb--, fo++) { 752 for (sb = 15; sb; sb--, fo++) {
753 ++fe; 753 ++fe;
754 ++D0ptr; 754 ++D0ptr;
755 ++D1ptr; 755 ++D1ptr;
756 756
757 /* D[32 - sb][i] == -D[sb][31 - i] */ 757 /* D[32 - sb][i] == -D[sb][31 - i] */
758 asm volatile ( 758 asm volatile (
759 "movem.l (%0), %%d0-%%d7\n\t" 759 "movem.l (%0), %%d0-%%d7\n\t"
760 "move.l (%2), %%a5\n\t" 760 "move.l (%2), %%a5\n\t"
@@ -798,8 +798,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
798 "movclr.l %%acc0, %0\n\t" 798 "movclr.l %%acc0, %0\n\t"
799 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) ); 799 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
800 800
801 pcm[-sb] = hi0 << 3; 801 pcm[-sb] = hi0 << 3;
802 pcm[ sb] = hi1 << 3; 802 pcm[ sb] = hi1 << 3;
803 } 803 }
804 804
805 ++D0ptr; 805 ++D0ptr;
@@ -1045,10 +1045,10 @@ void synth_full2(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
1045 1045
1046static 1046static
1047void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 1047void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1048 unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH; 1048 unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH;
1049static 1049static
1050void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 1050void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1051 unsigned int nch, unsigned int ns) 1051 unsigned int nch, unsigned int ns)
1052{ 1052{
1053 int p; 1053 int p;
1054 unsigned int phase, ch, s; 1054 unsigned int phase, ch, s;
@@ -1068,7 +1068,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1068 1068
1069 for (s = 0; s < ns; ++s) { 1069 for (s = 0; s < ns; ++s) {
1070 dct32((*sbsample)[s], phase >> 1, 1070 dct32((*sbsample)[s], phase >> 1,
1071 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 1071 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1072 1072
1073 p = (phase - 1) & 0xf; 1073 p = (phase - 1) & 0xf;
1074 1074
@@ -1189,7 +1189,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1189 1189
1190static 1190static
1191void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 1191void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1192 unsigned int nch, unsigned int ns) 1192 unsigned int nch, unsigned int ns)
1193{ 1193{
1194 int p, sb; 1194 int p, sb;
1195 unsigned int phase, ch, s; 1195 unsigned int phase, ch, s;
@@ -1209,7 +1209,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1209 1209
1210 for (s = 0; s < ns; ++s) { 1210 for (s = 0; s < ns; ++s) {
1211 dct32((*sbsample)[s], phase >> 1, 1211 dct32((*sbsample)[s], phase >> 1,
1212 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 1212 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1213 1213
1214 p = (phase - 1) & 0xf; 1214 p = (phase - 1) & 0xf;
1215 1215
@@ -1246,49 +1246,49 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1246 1246
1247 for (sb = 15; sb; sb--, fo++) 1247 for (sb = 15; sb; sb--, fo++)
1248 { 1248 {
1249 ++fe; 1249 ++fe;
1250 ++D0ptr; 1250 ++D0ptr;
1251 ++D1ptr; 1251 ++D1ptr;
1252 1252
1253 /* D[32 - sb][i] == -D[sb][31 - i] */ 1253 /* D[32 - sb][i] == -D[sb][31 - i] */
1254 ptr = *D0ptr; 1254 ptr = *D0ptr;
1255 ML0(hi, lo, (*fo)[0], ptr[ 1]); 1255 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1256 MLA(hi, lo, (*fo)[1], ptr[15]); 1256 MLA(hi, lo, (*fo)[1], ptr[15]);
1257 MLA(hi, lo, (*fo)[2], ptr[13]); 1257 MLA(hi, lo, (*fo)[2], ptr[13]);
1258 MLA(hi, lo, (*fo)[3], ptr[11]); 1258 MLA(hi, lo, (*fo)[3], ptr[11]);
1259 MLA(hi, lo, (*fo)[4], ptr[ 9]); 1259 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1260 MLA(hi, lo, (*fo)[5], ptr[ 7]); 1260 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1261 MLA(hi, lo, (*fo)[6], ptr[ 5]); 1261 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1262 MLA(hi, lo, (*fo)[7], ptr[ 3]); 1262 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1263 MLN(hi, lo); 1263 MLN(hi, lo);
1264 MLA(hi, lo, (*fe)[7], ptr[ 2]); 1264 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1265 MLA(hi, lo, (*fe)[6], ptr[ 4]); 1265 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1266 MLA(hi, lo, (*fe)[5], ptr[ 6]); 1266 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1267 MLA(hi, lo, (*fe)[4], ptr[ 8]); 1267 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1268 MLA(hi, lo, (*fe)[3], ptr[10]); 1268 MLA(hi, lo, (*fe)[3], ptr[10]);
1269 MLA(hi, lo, (*fe)[2], ptr[12]); 1269 MLA(hi, lo, (*fe)[2], ptr[12]);
1270 MLA(hi, lo, (*fe)[1], ptr[14]); 1270 MLA(hi, lo, (*fe)[1], ptr[14]);
1271 MLA(hi, lo, (*fe)[0], ptr[ 0]); 1271 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1272 pcm[-sb] = SHIFT(MLZ(hi, lo)); 1272 pcm[-sb] = SHIFT(MLZ(hi, lo));
1273 1273
1274 ptr = *D1ptr; 1274 ptr = *D1ptr;
1275 ML0(hi, lo, (*fe)[0], ptr[31 - 16]); 1275 ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
1276 MLA(hi, lo, (*fe)[1], ptr[31 - 14]); 1276 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1277 MLA(hi, lo, (*fe)[2], ptr[31 - 12]); 1277 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1278 MLA(hi, lo, (*fe)[3], ptr[31 - 10]); 1278 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1279 MLA(hi, lo, (*fe)[4], ptr[31 - 8]); 1279 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1280 MLA(hi, lo, (*fe)[5], ptr[31 - 6]); 1280 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1281 MLA(hi, lo, (*fe)[6], ptr[31 - 4]); 1281 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1282 MLA(hi, lo, (*fe)[7], ptr[31 - 2]); 1282 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1283 MLA(hi, lo, (*fo)[7], ptr[31 - 3]); 1283 MLA(hi, lo, (*fo)[7], ptr[31 - 3]);
1284 MLA(hi, lo, (*fo)[6], ptr[31 - 5]); 1284 MLA(hi, lo, (*fo)[6], ptr[31 - 5]);
1285 MLA(hi, lo, (*fo)[5], ptr[31 - 7]); 1285 MLA(hi, lo, (*fo)[5], ptr[31 - 7]);
1286 MLA(hi, lo, (*fo)[4], ptr[31 - 9]); 1286 MLA(hi, lo, (*fo)[4], ptr[31 - 9]);
1287 MLA(hi, lo, (*fo)[3], ptr[31 - 11]); 1287 MLA(hi, lo, (*fo)[3], ptr[31 - 11]);
1288 MLA(hi, lo, (*fo)[2], ptr[31 - 13]); 1288 MLA(hi, lo, (*fo)[2], ptr[31 - 13]);
1289 MLA(hi, lo, (*fo)[1], ptr[31 - 15]); 1289 MLA(hi, lo, (*fo)[1], ptr[31 - 15]);
1290 MLA(hi, lo, (*fo)[0], ptr[31 - 1]); 1290 MLA(hi, lo, (*fo)[0], ptr[31 - 1]);
1291 pcm[sb] = SHIFT(MLZ(hi, lo)); 1291 pcm[sb] = SHIFT(MLZ(hi, lo));
1292 } 1292 }
1293 1293
1294 ptr = *(D0ptr + 1); 1294 ptr = *(D0ptr + 1);
@@ -1327,49 +1327,49 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1327 1327
1328 for (sb = 15; sb; sb--, fo++) 1328 for (sb = 15; sb; sb--, fo++)
1329 { 1329 {
1330 ++fe; 1330 ++fe;
1331 ++D0ptr; 1331 ++D0ptr;
1332 ++D1ptr; 1332 ++D1ptr;
1333 1333
1334 /* D[32 - sb][i] == -D[sb][31 - i] */ 1334 /* D[32 - sb][i] == -D[sb][31 - i] */
1335 ptr = *D0ptr; 1335 ptr = *D0ptr;
1336 ML0(hi, lo, (*fo)[0], ptr[ 0]); 1336 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1337 MLA(hi, lo, (*fo)[1], ptr[14]); 1337 MLA(hi, lo, (*fo)[1], ptr[14]);
1338 MLA(hi, lo, (*fo)[2], ptr[12]); 1338 MLA(hi, lo, (*fo)[2], ptr[12]);
1339 MLA(hi, lo, (*fo)[3], ptr[10]); 1339 MLA(hi, lo, (*fo)[3], ptr[10]);
1340 MLA(hi, lo, (*fo)[4], ptr[ 8]); 1340 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1341 MLA(hi, lo, (*fo)[5], ptr[ 6]); 1341 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1342 MLA(hi, lo, (*fo)[6], ptr[ 4]); 1342 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1343 MLA(hi, lo, (*fo)[7], ptr[ 2]); 1343 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1344 MLN(hi, lo); 1344 MLN(hi, lo);
1345 MLA(hi, lo, (*fe)[7], ptr[ 3]); 1345 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1346 MLA(hi, lo, (*fe)[6], ptr[ 5]); 1346 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1347 MLA(hi, lo, (*fe)[5], ptr[ 7]); 1347 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1348 MLA(hi, lo, (*fe)[4], ptr[ 9]); 1348 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1349 MLA(hi, lo, (*fe)[3], ptr[11]); 1349 MLA(hi, lo, (*fe)[3], ptr[11]);
1350 MLA(hi, lo, (*fe)[2], ptr[13]); 1350 MLA(hi, lo, (*fe)[2], ptr[13]);
1351 MLA(hi, lo, (*fe)[1], ptr[15]); 1351 MLA(hi, lo, (*fe)[1], ptr[15]);
1352 MLA(hi, lo, (*fe)[0], ptr[ 1]); 1352 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1353 pcm[-sb] = SHIFT(MLZ(hi, lo)); 1353 pcm[-sb] = SHIFT(MLZ(hi, lo));
1354 1354
1355 ptr = *D1ptr; 1355 ptr = *D1ptr;
1356 ML0(hi, lo, (*fe)[0], ptr[31 - 1]); 1356 ML0(hi, lo, (*fe)[0], ptr[31 - 1]);
1357 MLA(hi, lo, (*fe)[1], ptr[31 - 15]); 1357 MLA(hi, lo, (*fe)[1], ptr[31 - 15]);
1358 MLA(hi, lo, (*fe)[2], ptr[31 - 13]); 1358 MLA(hi, lo, (*fe)[2], ptr[31 - 13]);
1359 MLA(hi, lo, (*fe)[3], ptr[31 - 11]); 1359 MLA(hi, lo, (*fe)[3], ptr[31 - 11]);
1360 MLA(hi, lo, (*fe)[4], ptr[31 - 9]); 1360 MLA(hi, lo, (*fe)[4], ptr[31 - 9]);
1361 MLA(hi, lo, (*fe)[5], ptr[31 - 7]); 1361 MLA(hi, lo, (*fe)[5], ptr[31 - 7]);
1362 MLA(hi, lo, (*fe)[6], ptr[31 - 5]); 1362 MLA(hi, lo, (*fe)[6], ptr[31 - 5]);
1363 MLA(hi, lo, (*fe)[7], ptr[31 - 3]); 1363 MLA(hi, lo, (*fe)[7], ptr[31 - 3]);
1364 MLA(hi, lo, (*fo)[7], ptr[31 - 2]); 1364 MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
1365 MLA(hi, lo, (*fo)[6], ptr[31 - 4]); 1365 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1366 MLA(hi, lo, (*fo)[5], ptr[31 - 6]); 1366 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1367 MLA(hi, lo, (*fo)[4], ptr[31 - 8]); 1367 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1368 MLA(hi, lo, (*fo)[3], ptr[31 - 10]); 1368 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1369 MLA(hi, lo, (*fo)[2], ptr[31 - 12]); 1369 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1370 MLA(hi, lo, (*fo)[1], ptr[31 - 14]); 1370 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1371 MLA(hi, lo, (*fo)[0], ptr[31 - 16]); 1371 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1372 pcm[sb] = SHIFT(MLZ(hi, lo)); 1372 pcm[sb] = SHIFT(MLZ(hi, lo));
1373 } 1373 }
1374 1374
1375 ptr = *(D0ptr + 1); 1375 ptr = *(D0ptr + 1);
@@ -1394,12 +1394,12 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1394# endif 1394# endif
1395 1395
1396/* 1396/*
1397 * NAME: synth->half() 1397 * NAME: synth->half()
1398 * DESCRIPTION: perform half frequency PCM synthesis 1398 * DESCRIPTION: perform half frequency PCM synthesis
1399 */ 1399 */
1400static 1400static
1401void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 1401void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1402 unsigned int nch, unsigned int ns) 1402 unsigned int nch, unsigned int ns)
1403{ 1403{
1404 unsigned int phase, ch, s, sb, pe, po; 1404 unsigned int phase, ch, s, sb, pe, po;
1405 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; 1405 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
@@ -1417,7 +1417,7 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1417 1417
1418 for (s = 0; s < ns; ++s) { 1418 for (s = 0; s < ns; ++s) {
1419 dct32((*sbsample)[s], phase >> 1, 1419 dct32((*sbsample)[s], phase >> 1,
1420 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 1420 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1421 1421
1422 pe = phase & ~1; 1422 pe = phase & ~1;
1423 po = ((phase - 1) & 0xf) | 1; 1423 po = ((phase - 1) & 0xf) | 1;
@@ -1456,59 +1456,59 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1456 pcm2 = pcm1 + 14; 1456 pcm2 = pcm1 + 14;
1457 1457
1458 for (sb = 1; sb < 16; ++sb) { 1458 for (sb = 1; sb < 16; ++sb) {
1459 ++fe; 1459 ++fe;
1460 ++Dptr; 1460 ++Dptr;
1461 1461
1462 /* D[32 - sb][i] == -D[sb][31 - i] */ 1462 /* D[32 - sb][i] == -D[sb][31 - i] */
1463 1463
1464 if (!(sb & 1)) { 1464 if (!(sb & 1)) {
1465 ptr = *Dptr + po; 1465 ptr = *Dptr + po;
1466 ML0(hi, lo, (*fo)[0], ptr[ 0]); 1466 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1467 MLA(hi, lo, (*fo)[1], ptr[14]); 1467 MLA(hi, lo, (*fo)[1], ptr[14]);
1468 MLA(hi, lo, (*fo)[2], ptr[12]); 1468 MLA(hi, lo, (*fo)[2], ptr[12]);
1469 MLA(hi, lo, (*fo)[3], ptr[10]); 1469 MLA(hi, lo, (*fo)[3], ptr[10]);
1470 MLA(hi, lo, (*fo)[4], ptr[ 8]); 1470 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1471 MLA(hi, lo, (*fo)[5], ptr[ 6]); 1471 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1472 MLA(hi, lo, (*fo)[6], ptr[ 4]); 1472 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1473 MLA(hi, lo, (*fo)[7], ptr[ 2]); 1473 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1474 MLN(hi, lo); 1474 MLN(hi, lo);
1475 1475
1476 ptr = *Dptr + pe; 1476 ptr = *Dptr + pe;
1477 MLA(hi, lo, (*fe)[7], ptr[ 2]); 1477 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1478 MLA(hi, lo, (*fe)[6], ptr[ 4]); 1478 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1479 MLA(hi, lo, (*fe)[5], ptr[ 6]); 1479 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1480 MLA(hi, lo, (*fe)[4], ptr[ 8]); 1480 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1481 MLA(hi, lo, (*fe)[3], ptr[10]); 1481 MLA(hi, lo, (*fe)[3], ptr[10]);
1482 MLA(hi, lo, (*fe)[2], ptr[12]); 1482 MLA(hi, lo, (*fe)[2], ptr[12]);
1483 MLA(hi, lo, (*fe)[1], ptr[14]); 1483 MLA(hi, lo, (*fe)[1], ptr[14]);
1484 MLA(hi, lo, (*fe)[0], ptr[ 0]); 1484 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1485 1485
1486 *pcm1++ = SHIFT(MLZ(hi, lo)); 1486 *pcm1++ = SHIFT(MLZ(hi, lo));
1487 1487
1488 ptr = *Dptr - po; 1488 ptr = *Dptr - po;
1489 ML0(hi, lo, (*fo)[7], ptr[31 - 2]); 1489 ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
1490 MLA(hi, lo, (*fo)[6], ptr[31 - 4]); 1490 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1491 MLA(hi, lo, (*fo)[5], ptr[31 - 6]); 1491 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1492 MLA(hi, lo, (*fo)[4], ptr[31 - 8]); 1492 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1493 MLA(hi, lo, (*fo)[3], ptr[31 - 10]); 1493 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1494 MLA(hi, lo, (*fo)[2], ptr[31 - 12]); 1494 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1495 MLA(hi, lo, (*fo)[1], ptr[31 - 14]); 1495 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1496 MLA(hi, lo, (*fo)[0], ptr[31 - 16]); 1496 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1497 1497
1498 ptr = *Dptr - pe; 1498 ptr = *Dptr - pe;
1499 MLA(hi, lo, (*fe)[0], ptr[31 - 16]); 1499 MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
1500 MLA(hi, lo, (*fe)[1], ptr[31 - 14]); 1500 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1501 MLA(hi, lo, (*fe)[2], ptr[31 - 12]); 1501 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1502 MLA(hi, lo, (*fe)[3], ptr[31 - 10]); 1502 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1503 MLA(hi, lo, (*fe)[4], ptr[31 - 8]); 1503 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1504 MLA(hi, lo, (*fe)[5], ptr[31 - 6]); 1504 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1505 MLA(hi, lo, (*fe)[6], ptr[31 - 4]); 1505 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1506 MLA(hi, lo, (*fe)[7], ptr[31 - 2]); 1506 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1507 1507
1508 *pcm2-- = SHIFT(MLZ(hi, lo)); 1508 *pcm2-- = SHIFT(MLZ(hi, lo));
1509 } 1509 }
1510 1510
1511 ++fo; 1511 ++fo;
1512 } 1512 }
1513 1513
1514 ++Dptr; 1514 ++Dptr;
@@ -1532,14 +1532,14 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1532} 1532}
1533 1533
1534/* 1534/*
1535 * NAME: synth->frame() 1535 * NAME: synth->frame()
1536 * DESCRIPTION: perform PCM synthesis of frame subband samples 1536 * DESCRIPTION: perform PCM synthesis of frame subband samples
1537 */ 1537 */
1538void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) 1538void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
1539{ 1539{
1540 unsigned int nch, ns; 1540 unsigned int nch, ns;
1541 void (*synth_frame)(struct mad_synth *, struct mad_frame const *, 1541 void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
1542 unsigned int, unsigned int); 1542 unsigned int, unsigned int);
1543 1543
1544 nch = MAD_NCHANNELS(&frame->header); 1544 nch = MAD_NCHANNELS(&frame->header);
1545 ns = MAD_NSBSAMPLES(&frame->header); 1545 ns = MAD_NSBSAMPLES(&frame->header);
diff --git a/apps/codecs/libmad/synth.h b/apps/codecs/libmad/synth.h
index d284d01556..74975b9ad8 100644
--- a/apps/codecs/libmad/synth.h
+++ b/apps/codecs/libmad/synth.h
@@ -26,19 +26,19 @@
26# include "frame.h" 26# include "frame.h"
27 27
28struct mad_pcm { 28struct mad_pcm {
29 unsigned int samplerate; /* sampling frequency (Hz) */ 29 unsigned int samplerate; /* sampling frequency (Hz) */
30 unsigned short channels; /* number of channels */ 30 unsigned short channels; /* number of channels */
31 unsigned short length; /* number of samples per channel */ 31 unsigned short length; /* number of samples per channel */
32 mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ 32 mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
33}; 33};
34 34
35struct mad_synth { 35struct mad_synth {
36 mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ 36 mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
37 /* [ch][eo][peo][s][v] */ 37 /* [ch][eo][peo][s][v] */
38 38
39 unsigned int phase; /* current processing phase */ 39 unsigned int phase; /* current processing phase */
40 40
41 struct mad_pcm pcm; /* PCM output */ 41 struct mad_pcm pcm; /* PCM output */
42}; 42};
43 43
44/* single channel PCM selector */ 44/* single channel PCM selector */
diff --git a/apps/codecs/libmad/timer.c b/apps/codecs/libmad/timer.c
index a24595dde3..33ea4a6fbc 100644
--- a/apps/codecs/libmad/timer.c
+++ b/apps/codecs/libmad/timer.c
@@ -36,8 +36,8 @@
36mad_timer_t const mad_timer_zero = { 0, 0 }; 36mad_timer_t const mad_timer_zero = { 0, 0 };
37 37
38/* 38/*
39 * NAME: timer->compare() 39 * NAME: timer->compare()
40 * DESCRIPTION: indicate relative order of two timers 40 * DESCRIPTION: indicate relative order of two timers
41 */ 41 */
42int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) 42int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
43{ 43{
@@ -59,8 +59,8 @@ int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
59} 59}
60 60
61/* 61/*
62 * NAME: timer->negate() 62 * NAME: timer->negate()
63 * DESCRIPTION: invert the sign of a timer 63 * DESCRIPTION: invert the sign of a timer
64 */ 64 */
65void mad_timer_negate(mad_timer_t *timer) 65void mad_timer_negate(mad_timer_t *timer)
66{ 66{
@@ -73,8 +73,8 @@ void mad_timer_negate(mad_timer_t *timer)
73} 73}
74 74
75/* 75/*
76 * NAME: timer->abs() 76 * NAME: timer->abs()
77 * DESCRIPTION: return the absolute value of a timer 77 * DESCRIPTION: return the absolute value of a timer
78 */ 78 */
79mad_timer_t mad_timer_abs(mad_timer_t timer) 79mad_timer_t mad_timer_abs(mad_timer_t timer)
80{ 80{
@@ -85,8 +85,8 @@ mad_timer_t mad_timer_abs(mad_timer_t timer)
85} 85}
86 86
87/* 87/*
88 * NAME: reduce_timer() 88 * NAME: reduce_timer()
89 * DESCRIPTION: carry timer fraction into seconds 89 * DESCRIPTION: carry timer fraction into seconds
90 */ 90 */
91static 91static
92void reduce_timer(mad_timer_t *timer) 92void reduce_timer(mad_timer_t *timer)
@@ -96,8 +96,8 @@ void reduce_timer(mad_timer_t *timer)
96} 96}
97 97
98/* 98/*
99 * NAME: gcd() 99 * NAME: gcd()
100 * DESCRIPTION: compute greatest common denominator 100 * DESCRIPTION: compute greatest common denominator
101 */ 101 */
102static 102static
103unsigned long gcd(unsigned long num1, unsigned long num2) 103unsigned long gcd(unsigned long num1, unsigned long num2)
@@ -114,8 +114,8 @@ unsigned long gcd(unsigned long num1, unsigned long num2)
114} 114}
115 115
116/* 116/*
117 * NAME: reduce_rational() 117 * NAME: reduce_rational()
118 * DESCRIPTION: convert rational expression to lowest terms 118 * DESCRIPTION: convert rational expression to lowest terms
119 */ 119 */
120static 120static
121void reduce_rational(unsigned long *numer, unsigned long *denom) 121void reduce_rational(unsigned long *numer, unsigned long *denom)
@@ -131,12 +131,12 @@ void reduce_rational(unsigned long *numer, unsigned long *denom)
131} 131}
132 132
133/* 133/*
134 * NAME: scale_rational() 134 * NAME: scale_rational()
135 * DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing 135 * DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing
136 */ 136 */
137static 137static
138unsigned long scale_rational(unsigned long numer, unsigned long denom, 138unsigned long scale_rational(unsigned long numer, unsigned long denom,
139 unsigned long scale) 139 unsigned long scale)
140{ 140{
141 reduce_rational(&numer, &denom); 141 reduce_rational(&numer, &denom);
142 reduce_rational(&scale, &denom); 142 reduce_rational(&scale, &denom);
@@ -152,11 +152,11 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom,
152} 152}
153 153
154/* 154/*
155 * NAME: timer->set() 155 * NAME: timer->set()
156 * DESCRIPTION: set timer to specific (positive) value 156 * DESCRIPTION: set timer to specific (positive) value
157 */ 157 */
158void mad_timer_set(mad_timer_t *timer, unsigned long seconds, 158void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
159 unsigned long numer, unsigned long denom) 159 unsigned long numer, unsigned long denom)
160{ 160{
161 timer->seconds = seconds; 161 timer->seconds = seconds;
162 if (numer >= denom && denom > 0) { 162 if (numer >= denom && denom > 0) {
@@ -224,8 +224,8 @@ void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
224} 224}
225 225
226/* 226/*
227 * NAME: timer->add() 227 * NAME: timer->add()
228 * DESCRIPTION: add one timer to another 228 * DESCRIPTION: add one timer to another
229 */ 229 */
230void mad_timer_add(mad_timer_t *timer, mad_timer_t incr) 230void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
231{ 231{
@@ -237,8 +237,8 @@ void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
237} 237}
238 238
239/* 239/*
240 * NAME: timer->multiply() 240 * NAME: timer->multiply()
241 * DESCRIPTION: multiply a timer by a scalar value 241 * DESCRIPTION: multiply a timer by a scalar value
242 */ 242 */
243void mad_timer_multiply(mad_timer_t *timer, signed long scalar) 243void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
244{ 244{
@@ -264,8 +264,8 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
264} 264}
265 265
266/* 266/*
267 * NAME: timer->count() 267 * NAME: timer->count()
268 * DESCRIPTION: return timer value in selected units 268 * DESCRIPTION: return timer value in selected units
269 */ 269 */
270signed long mad_timer_count(mad_timer_t timer, enum mad_units units) 270signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
271{ 271{
@@ -302,7 +302,7 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
302 case MAD_UNITS_75_FPS: 302 case MAD_UNITS_75_FPS:
303 return timer.seconds * (signed long) units + 303 return timer.seconds * (signed long) units +
304 (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, 304 (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION,
305 units); 305 units);
306 306
307 case MAD_UNITS_23_976_FPS: 307 case MAD_UNITS_23_976_FPS:
308 case MAD_UNITS_24_975_FPS: 308 case MAD_UNITS_24_975_FPS:
@@ -318,8 +318,8 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
318} 318}
319 319
320/* 320/*
321 * NAME: timer->fraction() 321 * NAME: timer->fraction()
322 * DESCRIPTION: return fractional part of timer in arbitrary terms 322 * DESCRIPTION: return fractional part of timer in arbitrary terms
323 */ 323 */
324unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) 324unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
325{ 325{
@@ -339,12 +339,12 @@ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
339} 339}
340 340
341/* 341/*
342 * NAME: timer->string() 342 * NAME: timer->string()
343 * DESCRIPTION: write a string representation of a timer using a template 343 * DESCRIPTION: write a string representation of a timer using a template
344 */ 344 */
345void mad_timer_string(mad_timer_t timer, 345void mad_timer_string(mad_timer_t timer,
346 char *dest, char const *format, enum mad_units units, 346 char *dest, char const *format, enum mad_units units,
347 enum mad_units fracunits, unsigned long subparts) 347 enum mad_units fracunits, unsigned long subparts)
348{ 348{
349 unsigned long hours, minutes, seconds, sub; 349 unsigned long hours, minutes, seconds, sub;
350 unsigned int frac; 350 unsigned int frac;
@@ -413,7 +413,7 @@ void mad_timer_string(mad_timer_t timer,
413 m = frame % cycle; 413 m = frame % cycle;
414 frame += (10 - 1) * 2 * d; 414 frame += (10 - 1) * 2 * d;
415 if (m > 2) 415 if (m > 2)
416 frame += 2 * ((m - 2) / (cycle / 10)); 416 frame += 2 * ((m - 2) / (cycle / 10));
417 417
418 frac = frame % -fracunits; 418 frac = frame % -fracunits;
419 seconds = frame / -fracunits; 419 seconds = frame / -fracunits;
@@ -427,25 +427,25 @@ void mad_timer_string(mad_timer_t timer,
427 hours = minutes / 60; 427 hours = minutes / 60;
428 428
429// sprintf(dest, format, 429// sprintf(dest, format,
430// hours, 430// hours,
431// (unsigned int) (minutes % 60), 431// (unsigned int) (minutes % 60),
432// (unsigned int) (seconds % 60), 432// (unsigned int) (seconds % 60),
433// frac, sub); 433// frac, sub);
434 break; 434 break;
435 435
436 case MAD_UNITS_MINUTES: 436 case MAD_UNITS_MINUTES:
437 minutes = seconds / 60; 437 minutes = seconds / 60;
438 438
439// sprintf(dest, format, 439// sprintf(dest, format,
440// minutes, 440// minutes,
441// (unsigned int) (seconds % 60), 441// (unsigned int) (seconds % 60),
442// frac, sub); 442// frac, sub);
443 break; 443 break;
444 444
445 case MAD_UNITS_SECONDS: 445 case MAD_UNITS_SECONDS:
446// sprintf(dest, format, 446// sprintf(dest, format,
447// seconds, 447// seconds,
448// frac, sub); 448// frac, sub);
449 break; 449 break;
450 450
451 case MAD_UNITS_23_976_FPS: 451 case MAD_UNITS_23_976_FPS:
diff --git a/apps/codecs/libmad/timer.h b/apps/codecs/libmad/timer.h
index 4f2be57b46..23fdccf929 100644
--- a/apps/codecs/libmad/timer.h
+++ b/apps/codecs/libmad/timer.h
@@ -23,67 +23,67 @@
23# define LIBMAD_TIMER_H 23# define LIBMAD_TIMER_H
24 24
25typedef struct { 25typedef struct {
26 signed long seconds; /* whole seconds */ 26 signed long seconds; /* whole seconds */
27 unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */ 27 unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
28} mad_timer_t; 28} mad_timer_t;
29 29
30extern mad_timer_t const mad_timer_zero; 30extern mad_timer_t const mad_timer_zero;
31 31
32# define MAD_TIMER_RESOLUTION 352800000UL 32# define MAD_TIMER_RESOLUTION 352800000UL
33 33
34enum mad_units { 34enum mad_units {
35 MAD_UNITS_HOURS = -2, 35 MAD_UNITS_HOURS = -2,
36 MAD_UNITS_MINUTES = -1, 36 MAD_UNITS_MINUTES = -1,
37 MAD_UNITS_SECONDS = 0, 37 MAD_UNITS_SECONDS = 0,
38 38
39 /* metric units */ 39 /* metric units */
40 40
41 MAD_UNITS_DECISECONDS = 10, 41 MAD_UNITS_DECISECONDS = 10,
42 MAD_UNITS_CENTISECONDS = 100, 42 MAD_UNITS_CENTISECONDS = 100,
43 MAD_UNITS_MILLISECONDS = 1000, 43 MAD_UNITS_MILLISECONDS = 1000,
44 44
45 /* audio sample units */ 45 /* audio sample units */
46 46
47 MAD_UNITS_8000_HZ = 8000, 47 MAD_UNITS_8000_HZ = 8000,
48 MAD_UNITS_11025_HZ = 11025, 48 MAD_UNITS_11025_HZ = 11025,
49 MAD_UNITS_12000_HZ = 12000, 49 MAD_UNITS_12000_HZ = 12000,
50 50
51 MAD_UNITS_16000_HZ = 16000, 51 MAD_UNITS_16000_HZ = 16000,
52 MAD_UNITS_22050_HZ = 22050, 52 MAD_UNITS_22050_HZ = 22050,
53 MAD_UNITS_24000_HZ = 24000, 53 MAD_UNITS_24000_HZ = 24000,
54 54
55 MAD_UNITS_32000_HZ = 32000, 55 MAD_UNITS_32000_HZ = 32000,
56 MAD_UNITS_44100_HZ = 44100, 56 MAD_UNITS_44100_HZ = 44100,
57 MAD_UNITS_48000_HZ = 48000, 57 MAD_UNITS_48000_HZ = 48000,
58 58
59 /* video frame/field units */ 59 /* video frame/field units */
60 60
61 MAD_UNITS_24_FPS = 24, 61 MAD_UNITS_24_FPS = 24,
62 MAD_UNITS_25_FPS = 25, 62 MAD_UNITS_25_FPS = 25,
63 MAD_UNITS_30_FPS = 30, 63 MAD_UNITS_30_FPS = 30,
64 MAD_UNITS_48_FPS = 48, 64 MAD_UNITS_48_FPS = 48,
65 MAD_UNITS_50_FPS = 50, 65 MAD_UNITS_50_FPS = 50,
66 MAD_UNITS_60_FPS = 60, 66 MAD_UNITS_60_FPS = 60,
67 67
68 /* CD audio frames */ 68 /* CD audio frames */
69 69
70 MAD_UNITS_75_FPS = 75, 70 MAD_UNITS_75_FPS = 75,
71 71
72 /* video drop-frame units */ 72 /* video drop-frame units */
73 73
74 MAD_UNITS_23_976_FPS = -24, 74 MAD_UNITS_23_976_FPS = -24,
75 MAD_UNITS_24_975_FPS = -25, 75 MAD_UNITS_24_975_FPS = -25,
76 MAD_UNITS_29_97_FPS = -30, 76 MAD_UNITS_29_97_FPS = -30,
77 MAD_UNITS_47_952_FPS = -48, 77 MAD_UNITS_47_952_FPS = -48,
78 MAD_UNITS_49_95_FPS = -50, 78 MAD_UNITS_49_95_FPS = -50,
79 MAD_UNITS_59_94_FPS = -60 79 MAD_UNITS_59_94_FPS = -60
80}; 80};
81 81
82# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero)) 82# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
83 83
84int mad_timer_compare(mad_timer_t, mad_timer_t); 84int mad_timer_compare(mad_timer_t, mad_timer_t);
85 85
86# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero) 86# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
87 87
88void mad_timer_negate(mad_timer_t *); 88void mad_timer_negate(mad_timer_t *);
89mad_timer_t mad_timer_abs(mad_timer_t); 89mad_timer_t mad_timer_abs(mad_timer_t);
@@ -95,6 +95,6 @@ void mad_timer_multiply(mad_timer_t *, signed long);
95signed long mad_timer_count(mad_timer_t, enum mad_units); 95signed long mad_timer_count(mad_timer_t, enum mad_units);
96unsigned long mad_timer_fraction(mad_timer_t, unsigned long); 96unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
97void mad_timer_string(mad_timer_t, char *, char const *, 97void mad_timer_string(mad_timer_t, char *, char const *,
98 enum mad_units, enum mad_units, unsigned long); 98 enum mad_units, enum mad_units, unsigned long);
99 99
100# endif 100# endif
diff --git a/apps/codecs/libmad/version.h b/apps/codecs/libmad/version.h
index d40e42538a..3a98543de3 100644
--- a/apps/codecs/libmad/version.h
+++ b/apps/codecs/libmad/version.h
@@ -22,22 +22,22 @@
22# ifndef LIBMAD_VERSION_H 22# ifndef LIBMAD_VERSION_H
23# define LIBMAD_VERSION_H 23# define LIBMAD_VERSION_H
24 24
25# define MAD_VERSION_MAJOR 0 25# define MAD_VERSION_MAJOR 0
26# define MAD_VERSION_MINOR 15 26# define MAD_VERSION_MINOR 15
27# define MAD_VERSION_PATCH 1 27# define MAD_VERSION_PATCH 1
28# define MAD_VERSION_EXTRA " (beta)" 28# define MAD_VERSION_EXTRA " (beta)"
29 29
30# define MAD_VERSION_STRINGIZE(str) #str 30# define MAD_VERSION_STRINGIZE(str) #str
31# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) 31# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
32 32
33# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ 33# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
34 MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ 34 MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
35 MAD_VERSION_STRING(MAD_VERSION_PATCH) \ 35 MAD_VERSION_STRING(MAD_VERSION_PATCH) \
36 MAD_VERSION_EXTRA 36 MAD_VERSION_EXTRA
37 37
38# define MAD_PUBLISHYEAR "2000-2004" 38# define MAD_PUBLISHYEAR "2000-2004"
39# define MAD_AUTHOR "Underbit Technologies, Inc." 39# define MAD_AUTHOR "Underbit Technologies, Inc."
40# define MAD_EMAIL "info@underbit.com" 40# define MAD_EMAIL "info@underbit.com"
41 41
42extern char const mad_version[]; 42extern char const mad_version[];
43extern char const mad_copyright[]; 43extern char const mad_copyright[];
diff --git a/apps/codecs/librm/rm.c b/apps/codecs/librm/rm.c
index d721ceb81f..a179688e7a 100644
--- a/apps/codecs/librm/rm.c
+++ b/apps/codecs/librm/rm.c
@@ -430,7 +430,7 @@ int real_parse_header(int fd, RMContext *rmctx)
430 read_uint32be(fd,&next_data_off); 430 read_uint32be(fd,&next_data_off);
431 skipped += 4; 431 skipped += 4;
432 if (!rmctx->nb_packets && (rmctx->flags & 4)) 432 if (!rmctx->nb_packets && (rmctx->flags & 4))
433 rmctx->nb_packets = 3600 * 25; 433 rmctx->nb_packets = 3600 * 25;
434 434
435 /*** 435 /***
436 * nb_packets correction : 436 * nb_packets correction :
@@ -444,7 +444,7 @@ int real_parse_header(int fd, RMContext *rmctx)
444 444
445 DEBUGF(" data_nb_packets = %d\n",rmctx->nb_packets); 445 DEBUGF(" data_nb_packets = %d\n",rmctx->nb_packets);
446 DEBUGF(" next DATA offset = %d\n",next_data_off); 446 DEBUGF(" next DATA offset = %d\n",next_data_off);
447 header_end = 1; 447 header_end = 1;
448 break; 448 break;
449 } 449 }
450 if(header_end) break; 450 if(header_end) break;
diff --git a/apps/codecs/libspeex/_kiss_fft_guts.h b/apps/codecs/libspeex/_kiss_fft_guts.h
index e9bb018c4b..12c055040f 100644
--- a/apps/codecs/libspeex/_kiss_fft_guts.h
+++ b/apps/codecs/libspeex/_kiss_fft_guts.h
@@ -60,8 +60,8 @@ struct kiss_fft_state{
60 60
61#if defined(CHECK_OVERFLOW) 61#if defined(CHECK_OVERFLOW)
62# define CHECK_OVERFLOW_OP(a,op,b) \ 62# define CHECK_OVERFLOW_OP(a,op,b) \
63 if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ 63 if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
64 fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } 64 fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
65#endif 65#endif
66 66
67 67
@@ -79,11 +79,11 @@ struct kiss_fft_state{
79 (m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0) 79 (m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0)
80 80
81# define DIVSCALAR(x,k) \ 81# define DIVSCALAR(x,k) \
82 (x) = sround( smul( x, SAMP_MAX/k ) ) 82 (x) = sround( smul( x, SAMP_MAX/k ) )
83 83
84# define C_FIXDIV(c,div) \ 84# define C_FIXDIV(c,div) \
85 do { DIVSCALAR( (c).r , div); \ 85 do { DIVSCALAR( (c).r , div); \
86 DIVSCALAR( (c).i , div); }while (0) 86 DIVSCALAR( (c).i , div); }while (0)
87 87
88# define C_MULBYSCALAR( c, s ) \ 88# define C_MULBYSCALAR( c, s ) \
89 do{ (c).r = sround( smul( (c).r , s ) ) ;\ 89 do{ (c).r = sround( smul( (c).r , s ) ) ;\
@@ -110,28 +110,28 @@ struct kiss_fft_state{
110 110
111#define C_ADD( res, a,b)\ 111#define C_ADD( res, a,b)\
112 do { \ 112 do { \
113 CHECK_OVERFLOW_OP((a).r,+,(b).r)\ 113 CHECK_OVERFLOW_OP((a).r,+,(b).r)\
114 CHECK_OVERFLOW_OP((a).i,+,(b).i)\ 114 CHECK_OVERFLOW_OP((a).i,+,(b).i)\
115 (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ 115 (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
116 }while(0) 116 }while(0)
117#define C_SUB( res, a,b)\ 117#define C_SUB( res, a,b)\
118 do { \ 118 do { \
119 CHECK_OVERFLOW_OP((a).r,-,(b).r)\ 119 CHECK_OVERFLOW_OP((a).r,-,(b).r)\
120 CHECK_OVERFLOW_OP((a).i,-,(b).i)\ 120 CHECK_OVERFLOW_OP((a).i,-,(b).i)\
121 (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ 121 (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
122 }while(0) 122 }while(0)
123#define C_ADDTO( res , a)\ 123#define C_ADDTO( res , a)\
124 do { \ 124 do { \
125 CHECK_OVERFLOW_OP((res).r,+,(a).r)\ 125 CHECK_OVERFLOW_OP((res).r,+,(a).r)\
126 CHECK_OVERFLOW_OP((res).i,+,(a).i)\ 126 CHECK_OVERFLOW_OP((res).i,+,(a).i)\
127 (res).r += (a).r; (res).i += (a).i;\ 127 (res).r += (a).r; (res).i += (a).i;\
128 }while(0) 128 }while(0)
129 129
130#define C_SUBFROM( res , a)\ 130#define C_SUBFROM( res , a)\
131 do {\ 131 do {\
132 CHECK_OVERFLOW_OP((res).r,-,(a).r)\ 132 CHECK_OVERFLOW_OP((res).r,-,(a).r)\
133 CHECK_OVERFLOW_OP((res).i,-,(a).i)\ 133 CHECK_OVERFLOW_OP((res).i,-,(a).i)\
134 (res).r -= (a).r; (res).i -= (a).i; \ 134 (res).r -= (a).r; (res).i -= (a).i; \
135 }while(0) 135 }while(0)
136 136
137 137
@@ -150,10 +150,10 @@ struct kiss_fft_state{
150#endif 150#endif
151 151
152#define kf_cexp(x,phase) \ 152#define kf_cexp(x,phase) \
153 do{ \ 153 do{ \
154 (x)->r = KISS_FFT_COS(phase);\ 154 (x)->r = KISS_FFT_COS(phase);\
155 (x)->i = KISS_FFT_SIN(phase);\ 155 (x)->i = KISS_FFT_SIN(phase);\
156 }while(0) 156 }while(0)
157#define kf_cexp2(x,phase) \ 157#define kf_cexp2(x,phase) \
158 do{ \ 158 do{ \
159 (x)->r = spx_cos_norm((phase));\ 159 (x)->r = spx_cos_norm((phase));\
diff --git a/apps/codecs/libspeex/cb_search.c b/apps/codecs/libspeex/cb_search.c
index 8a190e535d..f9ff0a6784 100644
--- a/apps/codecs/libspeex/cb_search.c
+++ b/apps/codecs/libspeex/cb_search.c
@@ -99,10 +99,10 @@ static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *
99 99
100 100
101static void split_cb_search_shape_sign_N1( 101static void split_cb_search_shape_sign_N1(
102spx_word16_t target[], /* target vector */ 102spx_word16_t target[], /* target vector */
103spx_coef_t ak[], /* LPCs for this subframe */ 103spx_coef_t ak[], /* LPCs for this subframe */
104spx_coef_t awk1[], /* Weighted LPCs for this subframe */ 104spx_coef_t awk1[], /* Weighted LPCs for this subframe */
105spx_coef_t awk2[], /* Weighted LPCs for this subframe */ 105spx_coef_t awk2[], /* Weighted LPCs for this subframe */
106const void *par, /* Codebook/search parameters*/ 106const void *par, /* Codebook/search parameters*/
107int p, /* number of LPC coeffs */ 107int p, /* number of LPC coeffs */
108int nsf, /* number of samples in subframe */ 108int nsf, /* number of samples in subframe */
@@ -241,10 +241,10 @@ int update_target
241 241
242 242
243void split_cb_search_shape_sign( 243void split_cb_search_shape_sign(
244spx_word16_t target[], /* target vector */ 244spx_word16_t target[], /* target vector */
245spx_coef_t ak[], /* LPCs for this subframe */ 245spx_coef_t ak[], /* LPCs for this subframe */
246spx_coef_t awk1[], /* Weighted LPCs for this subframe */ 246spx_coef_t awk1[], /* Weighted LPCs for this subframe */
247spx_coef_t awk2[], /* Weighted LPCs for this subframe */ 247spx_coef_t awk2[], /* Weighted LPCs for this subframe */
248const void *par, /* Codebook/search parameters*/ 248const void *par, /* Codebook/search parameters*/
249int p, /* number of LPC coeffs */ 249int p, /* number of LPC coeffs */
250int nsf, /* number of samples in subframe */ 250int nsf, /* number of samples in subframe */
@@ -576,10 +576,10 @@ spx_int32_t *seed
576 576
577#ifndef SPEEX_DISABLE_ENCODER 577#ifndef SPEEX_DISABLE_ENCODER
578void noise_codebook_quant( 578void noise_codebook_quant(
579spx_word16_t target[], /* target vector */ 579spx_word16_t target[], /* target vector */
580spx_coef_t ak[], /* LPCs for this subframe */ 580spx_coef_t ak[], /* LPCs for this subframe */
581spx_coef_t awk1[], /* Weighted LPCs for this subframe */ 581spx_coef_t awk1[], /* Weighted LPCs for this subframe */
582spx_coef_t awk2[], /* Weighted LPCs for this subframe */ 582spx_coef_t awk2[], /* Weighted LPCs for this subframe */
583const void *par, /* Codebook/search parameters*/ 583const void *par, /* Codebook/search parameters*/
584int p, /* number of LPC coeffs */ 584int p, /* number of LPC coeffs */
585int nsf, /* number of samples in subframe */ 585int nsf, /* number of samples in subframe */
diff --git a/apps/codecs/libspeex/kiss_fft.c b/apps/codecs/libspeex/kiss_fft.c
index bff826d754..5b699a362f 100644
--- a/apps/codecs/libspeex/kiss_fft.c
+++ b/apps/codecs/libspeex/kiss_fft.c
@@ -184,7 +184,7 @@ static void kf_bfly3(
184 do{ 184 do{
185 if (!st->inverse) { 185 if (!st->inverse) {
186 C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); 186 C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3);
187 } 187 }
188 188
189 C_MUL(scratch[1],Fout[m] , *tw1); 189 C_MUL(scratch[1],Fout[m] , *tw1);
190 C_MUL(scratch[2],Fout[m2] , *tw2); 190 C_MUL(scratch[2],Fout[m2] , *tw2);
@@ -237,7 +237,7 @@ static void kf_bfly5(
237 for ( u=0; u<m; ++u ) { 237 for ( u=0; u<m; ++u ) {
238 if (!st->inverse) { 238 if (!st->inverse) {
239 C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5); 239 C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5);
240 } 240 }
241 scratch[0] = *Fout0; 241 scratch[0] = *Fout0;
242 242
243 C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); 243 C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
@@ -299,7 +299,7 @@ static void kf_bfly_generic(
299 scratchbuf[q1] = Fout[ k ]; 299 scratchbuf[q1] = Fout[ k ];
300 if (!st->inverse) { 300 if (!st->inverse) {
301 C_FIXDIV(scratchbuf[q1],p); 301 C_FIXDIV(scratchbuf[q1],p);
302 } 302 }
303 k += m; 303 k += m;
304 } 304 }
305 305
diff --git a/apps/codecs/libspeex/kiss_fft.h b/apps/codecs/libspeex/kiss_fft.h
index fa3f2c6042..43319b1ba8 100644
--- a/apps/codecs/libspeex/kiss_fft.h
+++ b/apps/codecs/libspeex/kiss_fft.h
@@ -26,13 +26,13 @@ extern "C" {
26# include <xmmintrin.h> 26# include <xmmintrin.h>
27# define kiss_fft_scalar __m128 27# define kiss_fft_scalar __m128
28#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) 28#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
29#else 29#else
30#define KISS_FFT_MALLOC speex_alloc 30#define KISS_FFT_MALLOC speex_alloc
31#endif 31#endif
32 32
33 33
34#ifdef FIXED_POINT 34#ifdef FIXED_POINT
35#include "arch.h" 35#include "arch.h"
36# define kiss_fft_scalar spx_int16_t 36# define kiss_fft_scalar spx_int16_t
37#else 37#else
38# ifndef kiss_fft_scalar 38# ifndef kiss_fft_scalar
@@ -99,7 +99,7 @@ void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout
99 your compiler output to call this before you exit. 99 your compiler output to call this before you exit.
100*/ 100*/
101void kiss_fft_cleanup(void); 101void kiss_fft_cleanup(void);
102 102
103 103
104#ifdef __cplusplus 104#ifdef __cplusplus
105} 105}
diff --git a/apps/codecs/libspeex/lsp.c b/apps/codecs/libspeex/lsp.c
index edf480e8bc..8408d782aa 100644
--- a/apps/codecs/libspeex/lsp.c
+++ b/apps/codecs/libspeex/lsp.c
@@ -1,8 +1,8 @@
1/*---------------------------------------------------------------------------*\ 1/*---------------------------------------------------------------------------*\
2Original copyright 2Original copyright
3 FILE........: lsp.c 3 FILE........: lsp.c
4 AUTHOR......: David Rowe 4 AUTHOR......: David Rowe
5 DATE CREATED: 24/2/93 5 DATE CREATED: 24/2/93
6 6
7Heavily modified by Jean-Marc Valin (c) 2002-2006 (fixed-point, 7Heavily modified by Jean-Marc Valin (c) 2002-2006 (fixed-point,
8 optimizations, additional functions, ...) 8 optimizations, additional functions, ...)
@@ -219,31 +219,31 @@ static float cheb_poly_eva(spx_word32_t *coef, spx_word16_t x, int m, char *stac
219 219
220 220
221int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack) 221int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack)
222/* float *a lpc coefficients */ 222/* float *a lpc coefficients */
223/* int lpcrdr order of LPC coefficients (10) */ 223/* int lpcrdr order of LPC coefficients (10) */
224/* float *freq LSP frequencies in the x domain */ 224/* float *freq LSP frequencies in the x domain */
225/* int nb number of sub-intervals (4) */ 225/* int nb number of sub-intervals (4) */
226/* float delta grid spacing interval (0.02) */ 226/* float delta grid spacing interval (0.02) */
227 227
228 228
229{ 229{
230 spx_word16_t temp_xr,xl,xr,xm=0; 230 spx_word16_t temp_xr,xl,xr,xm=0;
231 spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/; 231 spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/;
232 int i,j,m,flag,k; 232 int i,j,m,flag,k;
233 VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */ 233 VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */
234 VARDECL(spx_word32_t *P); 234 VARDECL(spx_word32_t *P);
235 VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */ 235 VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */
236 VARDECL(spx_word16_t *P16); 236 VARDECL(spx_word16_t *P16);
237 spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */ 237 spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */
238 spx_word32_t *qx; 238 spx_word32_t *qx;
239 spx_word32_t *p; 239 spx_word32_t *p;
240 spx_word32_t *q; 240 spx_word32_t *q;
241 spx_word16_t *pt; /* ptr used for cheb_poly_eval() 241 spx_word16_t *pt; /* ptr used for cheb_poly_eval()
242 whether P' or Q' */ 242 whether P' or Q' */
243 int roots=0; /* DR 8/2/94: number of roots found */ 243 int roots=0; /* DR 8/2/94: number of roots found */
244 flag = 1; /* program is searching for a root when, 244 flag = 1; /* program is searching for a root when,
245 1 else has found one */ 245 1 else has found one */
246 m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */ 246 m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */
247 247
248 /* Allocate memory space for polynomials */ 248 /* Allocate memory space for polynomials */
249 ALLOC(Q, (m+1), spx_word32_t); 249 ALLOC(Q, (m+1), spx_word32_t);
@@ -252,7 +252,7 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
252 /* determine P'(z)'s and Q'(z)'s coefficients where 252 /* determine P'(z)'s and Q'(z)'s coefficients where
253 P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ 253 P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
254 254
255 px = P; /* initialise ptrs */ 255 px = P; /* initialise ptrs */
256 qx = Q; 256 qx = Q;
257 p = px; 257 p = px;
258 q = qx; 258 q = qx;
@@ -297,7 +297,7 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
297 } 297 }
298#endif 298#endif
299 299
300 px = P; /* re-initialise ptrs */ 300 px = P; /* re-initialise ptrs */
301 qx = Q; 301 qx = Q;
302 302
303 /* now that we have computed P and Q convert to 16 bits to 303 /* now that we have computed P and Q convert to 16 bits to
@@ -313,20 +313,20 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
313 } 313 }
314 314
315 /* Search for a zero in P'(z) polynomial first and then alternate to Q'(z). 315 /* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
316 Keep alternating between the two polynomials as each zero is found */ 316 Keep alternating between the two polynomials as each zero is found */
317 317
318 xr = 0; /* initialise xr to zero */ 318 xr = 0; /* initialise xr to zero */
319 xl = FREQ_SCALE; /* start at point xl = 1 */ 319 xl = FREQ_SCALE; /* start at point xl = 1 */
320 320
321 for(j=0;j<lpcrdr;j++){ 321 for(j=0;j<lpcrdr;j++){
322 if(j&1) /* determines whether P' or Q' is eval. */ 322 if(j&1) /* determines whether P' or Q' is eval. */
323 pt = Q16; 323 pt = Q16;
324 else 324 else
325 pt = P16; 325 pt = P16;
326 326
327 psuml = cheb_poly_eva(pt,xl,m,stack); /* evals poly. at xl */ 327 psuml = cheb_poly_eva(pt,xl,m,stack); /* evals poly. at xl */
328 flag = 1; 328 flag = 1;
329 while(flag && (xr >= -FREQ_SCALE)){ 329 while(flag && (xr >= -FREQ_SCALE)){
330 spx_word16_t dd; 330 spx_word16_t dd;
331 /* Modified by JMV to provide smaller steps around x=+-1 */ 331 /* Modified by JMV to provide smaller steps around x=+-1 */
332#ifdef FIXED_POINT 332#ifdef FIXED_POINT
@@ -338,10 +338,10 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
338 if (fabs(psuml)<.2) 338 if (fabs(psuml)<.2)
339 dd *= .5; 339 dd *= .5;
340#endif 340#endif
341 xr = SUB16(xl, dd); /* interval spacing */ 341 xr = SUB16(xl, dd); /* interval spacing */
342 psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */ 342 psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */
343 temp_psumr = psumr; 343 temp_psumr = psumr;
344 temp_xr = xr; 344 temp_xr = xr;
345 345
346 /* if no sign change increment xr and re-evaluate poly(xr). Repeat til 346 /* if no sign change increment xr and re-evaluate poly(xr). Repeat til
347 sign change. 347 sign change.
@@ -350,41 +350,41 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
350 interval the zero lies in. 350 interval the zero lies in.
351 If there is no sign change between poly(xm) and poly(xl) set interval 351 If there is no sign change between poly(xm) and poly(xl) set interval
352 between xm and xr else set interval between xl and xr and repeat till 352 between xm and xr else set interval between xl and xr and repeat till
353 root is located within the specified limits */ 353 root is located within the specified limits */
354 354
355 if(SIGN_CHANGE(psumr,psuml)) 355 if(SIGN_CHANGE(psumr,psuml))
356 { 356 {
357 roots++; 357 roots++;
358 358
359 psumm=psuml; 359 psumm=psuml;
360 for(k=0;k<=nb;k++){ 360 for(k=0;k<=nb;k++){
361#ifdef FIXED_POINT 361#ifdef FIXED_POINT
362 xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */ 362 xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */
363#else 363#else
364 xm = .5*(xl+xr); /* bisect the interval */ 364 xm = .5*(xl+xr); /* bisect the interval */
365#endif 365#endif
366 psumm=cheb_poly_eva(pt,xm,m,stack); 366 psumm=cheb_poly_eva(pt,xm,m,stack);
367 /*if(psumm*psuml>0.)*/ 367 /*if(psumm*psuml>0.)*/
368 if(!SIGN_CHANGE(psumm,psuml)) 368 if(!SIGN_CHANGE(psumm,psuml))
369 { 369 {
370 psuml=psumm; 370 psuml=psumm;
371 xl=xm; 371 xl=xm;
372 } else { 372 } else {
373 psumr=psumm; 373 psumr=psumm;
374 xr=xm; 374 xr=xm;
375 } 375 }
376 } 376 }
377 377
378 /* once zero is found, reset initial interval to xr */ 378 /* once zero is found, reset initial interval to xr */
379 freq[j] = X2ANGLE(xm); 379 freq[j] = X2ANGLE(xm);
380 xl = xm; 380 xl = xm;
381 flag = 0; /* reset flag for next search */ 381 flag = 0; /* reset flag for next search */
382 } 382 }
383 else{ 383 else{
384 psuml=temp_psumr; 384 psuml=temp_psumr;
385 xl=temp_xr; 385 xl=temp_xr;
386 } 386 }
387 } 387 }
388 } 388 }
389 return(roots); 389 return(roots);
390} 390}
@@ -393,10 +393,10 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
393 393
394/*---------------------------------------------------------------------------*\ 394/*---------------------------------------------------------------------------*\
395 395
396 FUNCTION....: lsp_to_lpc() 396 FUNCTION....: lsp_to_lpc()
397 397
398 AUTHOR......: David Rowe 398 AUTHOR......: David Rowe
399 DATE CREATED: 24/2/93 399 DATE CREATED: 24/2/93
400 400
401 Converts LSP coefficients to LPC coefficients. 401 Converts LSP coefficients to LPC coefficients.
402 402
@@ -405,9 +405,9 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
405#ifdef FIXED_POINT 405#ifdef FIXED_POINT
406 406
407void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) 407void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
408/* float *freq array of LSP frequencies in the x domain */ 408/* float *freq array of LSP frequencies in the x domain */
409/* float *ak array of LPC coefficients */ 409/* float *ak array of LPC coefficients */
410/* int lpcrdr order of LPC coefficients */ 410/* int lpcrdr order of LPC coefficients */
411{ 411{
412 (void)stack; 412 (void)stack;
413 int i,j; 413 int i,j;
@@ -488,10 +488,10 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
488 for(i=1;i<m;i++) { 488 for(i=1;i<m;i++) {
489 489
490 for(j=1;j<2*(i+1)-1;j++) { 490 for(j=1;j<2*(i+1)-1;j++) {
491 mult = MULT16_32_Q14(freqn[2*i],xp[i][j+1]); 491 mult = MULT16_32_Q14(freqn[2*i],xp[i][j+1]);
492 xp[i+1][j+2] = ADD32(SUB32(xp[i][j+2], mult), xp[i][j]); 492 xp[i+1][j+2] = ADD32(SUB32(xp[i][j+2], mult), xp[i][j]);
493 mult = MULT16_32_Q14(freqn[2*i+1],xq[i][j+1]); 493 mult = MULT16_32_Q14(freqn[2*i+1],xq[i][j+1]);
494 xq[i+1][j+2] = ADD32(SUB32(xq[i][j+2], mult), xq[i][j]); 494 xq[i+1][j+2] = ADD32(SUB32(xq[i][j+2], mult), xq[i][j]);
495 } 495 }
496 496
497 /* for last col xp[i][j+2] = xq[i][j+2] = 0 */ 497 /* for last col xp[i][j+2] = xq[i][j+2] = 0 */
@@ -525,9 +525,9 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
525#else 525#else
526 526
527void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) 527void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
528/* float *freq array of LSP frequencies in the x domain */ 528/* float *freq array of LSP frequencies in the x domain */
529/* float *ak array of LPC coefficients */ 529/* float *ak array of LPC coefficients */
530/* int lpcrdr order of LPC coefficients */ 530/* int lpcrdr order of LPC coefficients */
531 531
532 532
533{ 533{
@@ -543,8 +543,8 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
543 543
544 /* initialise contents of array */ 544 /* initialise contents of array */
545 545
546 for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */ 546 for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
547 *pw++ = 0.0; 547 *pw++ = 0.0;
548 } 548 }
549 549
550 /* Set pointers up */ 550 /* Set pointers up */
@@ -563,29 +563,29 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
563 563
564 for(j=0;j<=lpcrdr;j++){ 564 for(j=0;j<=lpcrdr;j++){
565 int i2=0; 565 int i2=0;
566 for(i=0;i<m;i++,i2+=2){ 566 for(i=0;i<m;i++,i2+=2){
567 n1 = pw+(i*4); 567 n1 = pw+(i*4);
568 n2 = n1 + 1; 568 n2 = n1 + 1;
569 n3 = n2 + 1; 569 n3 = n2 + 1;
570 n4 = n3 + 1; 570 n4 = n3 + 1;
571 xout1 = xin1 - 2.f*x_freq[i2] * *n1 + *n2; 571 xout1 = xin1 - 2.f*x_freq[i2] * *n1 + *n2;
572 xout2 = xin2 - 2.f*x_freq[i2+1] * *n3 + *n4; 572 xout2 = xin2 - 2.f*x_freq[i2+1] * *n3 + *n4;
573 *n2 = *n1; 573 *n2 = *n1;
574 *n4 = *n3; 574 *n4 = *n3;
575 *n1 = xin1; 575 *n1 = xin1;
576 *n3 = xin2; 576 *n3 = xin2;
577 xin1 = xout1; 577 xin1 = xout1;
578 xin2 = xout2; 578 xin2 = xout2;
579 } 579 }
580 xout1 = xin1 + *(n4+1); 580 xout1 = xin1 + *(n4+1);
581 xout2 = xin2 - *(n4+2); 581 xout2 = xin2 - *(n4+2);
582 if (j>0) 582 if (j>0)
583 ak[j-1] = (xout1 + xout2)*0.5f; 583 ak[j-1] = (xout1 + xout2)*0.5f;
584 *(n4+1) = xin1; 584 *(n4+1) = xin1;
585 *(n4+2) = xin2; 585 *(n4+2) = xin2;
586 586
587 xin1 = 0.0; 587 xin1 = 0.0;
588 xin2 = 0.0; 588 xin2 = 0.0;
589 } 589 }
590 590
591} 591}
diff --git a/apps/codecs/libspeex/lsp.h b/apps/codecs/libspeex/lsp.h
index 648652fb9e..2841e4b747 100644
--- a/apps/codecs/libspeex/lsp.h
+++ b/apps/codecs/libspeex/lsp.h
@@ -1,10 +1,10 @@
1/*---------------------------------------------------------------------------*\ 1/*---------------------------------------------------------------------------*\
2Original Copyright 2Original Copyright
3 FILE........: AK2LSPD.H 3 FILE........: AK2LSPD.H
4 TYPE........: Turbo C header file 4 TYPE........: Turbo C header file
5 COMPANY.....: Voicetronix 5 COMPANY.....: Voicetronix
6 AUTHOR......: James Whitehall 6 AUTHOR......: James Whitehall
7 DATE CREATED: 21/11/95 7 DATE CREATED: 21/11/95
8 8
9Modified by Jean-Marc Valin 9Modified by Jean-Marc Valin
10 10
@@ -61,4 +61,4 @@ void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
61 61
62void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes); 62void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
63 63
64#endif /* __AK2LSPD__ */ 64#endif /* __AK2LSPD__ */
diff --git a/apps/codecs/libspeex/ltp_bfin.h b/apps/codecs/libspeex/ltp_bfin.h
index b530f85986..8d7225b017 100644
--- a/apps/codecs/libspeex/ltp_bfin.h
+++ b/apps/codecs/libspeex/ltp_bfin.h
@@ -220,7 +220,7 @@ void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *p
220 normalize16(energy, ener16, 180, end-start+1); 220 normalize16(energy, ener16, 180, end-start+1);
221 221
222 if (N == 1) { 222 if (N == 1) {
223 /* optimised asm to handle N==1 case */ 223 /* optimised asm to handle N==1 case */
224 __asm__ __volatile__ 224 __asm__ __volatile__
225 ( 225 (
226" I0 = %1;\n\t" /* I0: corr16[] */ 226" I0 = %1;\n\t" /* I0: corr16[] */
@@ -253,35 +253,35 @@ void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *p
253 253
254 } 254 }
255 else { 255 else {
256 for (i=start;i<=end;i++) 256 for (i=start;i<=end;i++)
257 { 257 {
258 spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]); 258 spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]);
259 /* Instead of dividing the tmp by the energy, we multiply on the other side */ 259 /* Instead of dividing the tmp by the energy, we multiply on the other side */
260 if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start]))) 260 if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start])))
261 { 261 {
262 /* We can safely put it last and then check */ 262 /* We can safely put it last and then check */
263 best_score[N-1]=tmp; 263 best_score[N-1]=tmp;
264 best_ener[N-1]=ener16[i-start]+1; 264 best_ener[N-1]=ener16[i-start]+1;
265 pitch[N-1]=i; 265 pitch[N-1]=i;
266 /* Check if it comes in front of others */ 266 /* Check if it comes in front of others */
267 for (j=0;j<N-1;j++) 267 for (j=0;j<N-1;j++)
268 { 268 {
269 if (MULT16_16(tmp,best_ener[j])>MULT16_16(best_score[j],ADD16(1,ener16[i-start]))) 269 if (MULT16_16(tmp,best_ener[j])>MULT16_16(best_score[j],ADD16(1,ener16[i-start])))
270 { 270 {
271 for (k=N-1;k>j;k--) 271 for (k=N-1;k>j;k--)
272 { 272 {
273 best_score[k]=best_score[k-1]; 273 best_score[k]=best_score[k-1];
274 best_ener[k]=best_ener[k-1]; 274 best_ener[k]=best_ener[k-1];
275 pitch[k]=pitch[k-1]; 275 pitch[k]=pitch[k-1];
276 } 276 }
277 best_score[j]=tmp; 277 best_score[j]=tmp;
278 best_ener[j]=ener16[i-start]+1; 278 best_ener[j]=ener16[i-start]+1;
279 pitch[j]=i; 279 pitch[j]=i;
280 break; 280 break;
281 } 281 }
282 } 282 }
283 } 283 }
284 } 284 }
285 } 285 }
286 } 286 }
287 287
diff --git a/apps/codecs/libspeex/nb_celp.c b/apps/codecs/libspeex/nb_celp.c
index 31eaa06b6b..90a5d1e991 100644
--- a/apps/codecs/libspeex/nb_celp.c
+++ b/apps/codecs/libspeex/nb_celp.c
@@ -1019,7 +1019,7 @@ void nb_decoder_destroy(void *state)
1019*/ 1019*/
1020} 1020}
1021 1021
1022#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a)))) 1022#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a))))
1023 1023
1024#ifdef FIXED_POINT 1024#ifdef FIXED_POINT
1025const spx_word16_t attenuation[10] = {32767, 31483, 27923, 22861, 17278, 12055, 7764, 4616, 2533, 1283}; 1025const spx_word16_t attenuation[10] = {32767, 31483, 27923, 22861, 17278, 12055, 7764, 4616, 2533, 1283};
@@ -1353,10 +1353,10 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
1353*/ 1353*/
1354 pit_min = ol_pitch-margin+1; 1354 pit_min = ol_pitch-margin+1;
1355 if (pit_min < st->min_pitch) 1355 if (pit_min < st->min_pitch)
1356 pit_min = st->min_pitch; 1356 pit_min = st->min_pitch;
1357 pit_max = ol_pitch+margin; 1357 pit_max = ol_pitch+margin;
1358 if (pit_max > st->max_pitch) 1358 if (pit_max > st->max_pitch)
1359 pit_max = st->max_pitch; 1359 pit_max = st->max_pitch;
1360 } else { 1360 } else {
1361 pit_min = pit_max = ol_pitch; 1361 pit_min = pit_max = ol_pitch;
1362 } 1362 }
diff --git a/apps/codecs/libspeex/oggframing.c b/apps/codecs/libspeex/oggframing.c
index 6a0ee21412..42d29502a8 100644
--- a/apps/codecs/libspeex/oggframing.c
+++ b/apps/codecs/libspeex/oggframing.c
@@ -58,16 +58,16 @@ spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og){
58 58
59int spx_ogg_page_serialno(spx_ogg_page *og){ 59int spx_ogg_page_serialno(spx_ogg_page *og){
60 return(og->header[14] | 60 return(og->header[14] |
61 (og->header[15]<<8) | 61 (og->header[15]<<8) |
62 (og->header[16]<<16) | 62 (og->header[16]<<16) |
63 (og->header[17]<<24)); 63 (og->header[17]<<24));
64} 64}
65 65
66long spx_ogg_page_pageno(spx_ogg_page *og){ 66long spx_ogg_page_pageno(spx_ogg_page *og){
67 return(og->header[18] | 67 return(og->header[18] |
68 (og->header[19]<<8) | 68 (og->header[19]<<8) |
69 (og->header[20]<<16) | 69 (og->header[20]<<16) |
70 (og->header[21]<<24)); 70 (og->header[21]<<24));
71} 71}
72 72
73 73
@@ -109,9 +109,9 @@ static spx_ogg_uint32_t _spx_ogg_crc_entry(unsigned long index){
109 for (i=0; i<8; i++) 109 for (i=0; i<8; i++)
110 if (r & 0x80000000UL) 110 if (r & 0x80000000UL)
111 r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator 111 r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator
112 polynomial, although we use an 112 polynomial, although we use an
113 unreflected alg and an init/final 113 unreflected alg and an init/final
114 of 0, not 0xffffffff */ 114 of 0, not 0xffffffff */
115 else 115 else
116 r<<=1; 116 r<<=1;
117 return (r & 0xffffffffUL); 117 return (r & 0xffffffffUL);
@@ -280,7 +280,7 @@ int spx_ogg_stream_packetin(spx_ogg_stream_state *os,spx_ogg_packet *op){
280 os->body_fill-=os->body_returned; 280 os->body_fill-=os->body_returned;
281 if(os->body_fill) 281 if(os->body_fill)
282 memmove(os->body_data,os->body_data+os->body_returned, 282 memmove(os->body_data,os->body_data+os->body_returned,
283 os->body_fill); 283 os->body_fill);
284 os->body_returned=0; 284 os->body_returned=0;
285 } 285 }
286 286
@@ -350,8 +350,8 @@ int spx_ogg_stream_flush(spx_ogg_stream_state *os,spx_ogg_page *og){
350 granule_pos=0; 350 granule_pos=0;
351 for(vals=0;vals<maxvals;vals++){ 351 for(vals=0;vals<maxvals;vals++){
352 if((os->lacing_vals[vals]&0x0ff)<255){ 352 if((os->lacing_vals[vals]&0x0ff)<255){
353 vals++; 353 vals++;
354 break; 354 break;
355 } 355 }
356 } 356 }
357 }else{ 357 }else{
@@ -396,10 +396,10 @@ int spx_ogg_stream_flush(spx_ogg_stream_state *os,spx_ogg_page *og){
396 /* 32 bits of page counter (we have both counter and page header 396 /* 32 bits of page counter (we have both counter and page header
397 because this val can roll over) */ 397 because this val can roll over) */
398 if(os->pageno==-1)os->pageno=0; /* because someone called 398 if(os->pageno==-1)os->pageno=0; /* because someone called
399 stream_reset; this would be a 399 stream_reset; this would be a
400 strange thing to do in an 400 strange thing to do in an
401 encode stream, but it has 401 encode stream, but it has
402 plausible uses */ 402 plausible uses */
403 { 403 {
404 long pageno=os->pageno++; 404 long pageno=os->pageno++;
405 for(i=18;i<22;i++){ 405 for(i=18;i<22;i++){
@@ -595,7 +595,7 @@ long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og){
595 /* Compare */ 595 /* Compare */
596 if(memcmp(chksum,page+22,4)){ 596 if(memcmp(chksum,page+22,4)){
597 /* D'oh. Mismatch! Corrupt page (or miscapture and not a page 597 /* D'oh. Mismatch! Corrupt page (or miscapture and not a page
598 at all) */ 598 at all) */
599 /* replace the computed checksum with the one actually read in */ 599 /* replace the computed checksum with the one actually read in */
600 memcpy(page+22,chksum,4); 600 memcpy(page+22,chksum,4);
601 601
@@ -703,17 +703,17 @@ int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){
703 if(br){ 703 if(br){
704 os->body_fill-=br; 704 os->body_fill-=br;
705 if(os->body_fill) 705 if(os->body_fill)
706 memmove(os->body_data,os->body_data+br,os->body_fill); 706 memmove(os->body_data,os->body_data+br,os->body_fill);
707 os->body_returned=0; 707 os->body_returned=0;
708 } 708 }
709 709
710 if(lr){ 710 if(lr){
711 /* segment table */ 711 /* segment table */
712 if(os->lacing_fill-lr){ 712 if(os->lacing_fill-lr){
713 memmove(os->lacing_vals,os->lacing_vals+lr, 713 memmove(os->lacing_vals,os->lacing_vals+lr,
714 (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); 714 (os->lacing_fill-lr)*sizeof(*os->lacing_vals));
715 memmove(os->granule_vals,os->granule_vals+lr, 715 memmove(os->granule_vals,os->granule_vals+lr,
716 (os->lacing_fill-lr)*sizeof(*os->granule_vals)); 716 (os->lacing_fill-lr)*sizeof(*os->granule_vals));
717 } 717 }
718 os->lacing_fill-=lr; 718 os->lacing_fill-=lr;
719 os->lacing_packet-=lr; 719 os->lacing_packet-=lr;
@@ -750,13 +750,13 @@ int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){
750 os->lacing_vals[os->lacing_fill-1]==0x400){ 750 os->lacing_vals[os->lacing_fill-1]==0x400){
751 bos=0; 751 bos=0;
752 for(;segptr<segments;segptr++){ 752 for(;segptr<segments;segptr++){
753 int val=header[27+segptr]; 753 int val=header[27+segptr];
754 body+=val; 754 body+=val;
755 bodysize-=val; 755 bodysize-=val;
756 if(val<255){ 756 if(val<255){
757 segptr++; 757 segptr++;
758 break; 758 break;
759 } 759 }
760 } 760 }
761 } 761 }
762 } 762 }
@@ -775,8 +775,8 @@ int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){
775 os->granule_vals[os->lacing_fill]=-1; 775 os->granule_vals[os->lacing_fill]=-1;
776 776
777 if(bos){ 777 if(bos){
778 os->lacing_vals[os->lacing_fill]|=0x100; 778 os->lacing_vals[os->lacing_fill]|=0x100;
779 bos=0; 779 bos=0;
780 } 780 }
781 781
782 if(val<255)saved=os->lacing_fill; 782 if(val<255)saved=os->lacing_fill;
diff --git a/apps/codecs/libspeex/quant_lsp_bfin.h b/apps/codecs/libspeex/quant_lsp_bfin.h
index c884078e6b..917047bb56 100644
--- a/apps/codecs/libspeex/quant_lsp_bfin.h
+++ b/apps/codecs/libspeex/quant_lsp_bfin.h
@@ -55,9 +55,9 @@ static int lsp_quant(
55 55
56 __asm__ __volatile__ 56 __asm__ __volatile__
57 ( 57 (
58" %0 = 1 (X);\n\t" /* %0: best_dist */ 58" %0 = 1 (X);\n\t" /* %0: best_dist */
59" %0 <<= 30;\n\t" 59" %0 <<= 30;\n\t"
60" %1 = 0 (X);\n\t" /* %1: best_i */ 60" %1 = 0 (X);\n\t" /* %1: best_i */
61" P2 = %3\n\t" /* P2: ptr to cdbk */ 61" P2 = %3\n\t" /* P2: ptr to cdbk */
62" R5 = 0;\n\t" /* R5: best cb entry */ 62" R5 = 0;\n\t" /* R5: best cb entry */
63 63
@@ -68,18 +68,18 @@ static int lsp_quant(
68" B0 = %2;\n\t" 68" B0 = %2;\n\t"
69 69
70" R2.L = W [I0++];\n\t" 70" R2.L = W [I0++];\n\t"
71" LSETUP (lq1, lq2) LC0 = %4;\n\t" 71" LSETUP (lq1, lq2) LC0 = %4;\n\t"
72"lq1: R3 = 0;\n\t" /* R3: dist */ 72"lq1: R3 = 0;\n\t" /* R3: dist */
73" LSETUP (lq3, lq4) LC1 = %5;\n\t" 73" LSETUP (lq3, lq4) LC1 = %5;\n\t"
74"lq3: R1 = B [P2++] (X);\n\t" 74"lq3: R1 = B [P2++] (X);\n\t"
75" R1 <<= 5;\n\t" 75" R1 <<= 5;\n\t"
76" R0.L = R2.L - R1.L || R2.L = W [I0++];\n\t" 76" R0.L = R2.L - R1.L || R2.L = W [I0++];\n\t"
77" R0 = R0.L*R0.L;\n\t" 77" R0 = R0.L*R0.L;\n\t"
78"lq4: R3 = R3 + R0;\n\t" 78"lq4: R3 = R3 + R0;\n\t"
79 79
80" cc =R3<%0;\n\t" 80" cc =R3<%0;\n\t"
81" if cc %0=R3;\n\t" 81" if cc %0=R3;\n\t"
82" if cc %1=R5;\n\t" 82" if cc %1=R5;\n\t"
83"lq2: R5 += 1;\n\t" 83"lq2: R5 += 1;\n\t"
84" L0 = 0;\n\t" 84" L0 = 0;\n\t"
85 : "=&d" (best_dist), "=&d" (best_id) 85 : "=&d" (best_dist), "=&d" (best_id)
@@ -117,9 +117,9 @@ static int lsp_weight_quant(
117 117
118 __asm__ __volatile__ 118 __asm__ __volatile__
119 ( 119 (
120" %0 = 1 (X);\n\t" /* %0: best_dist */ 120" %0 = 1 (X);\n\t" /* %0: best_dist */
121" %0 <<= 30;\n\t" 121" %0 <<= 30;\n\t"
122" %1 = 0 (X);\n\t" /* %1: best_i */ 122" %1 = 0 (X);\n\t" /* %1: best_i */
123" P2 = %4\n\t" /* P2: ptr to cdbk */ 123" P2 = %4\n\t" /* P2: ptr to cdbk */
124" R5 = 0;\n\t" /* R5: best cb entry */ 124" R5 = 0;\n\t" /* R5: best cb entry */
125 125
@@ -128,26 +128,26 @@ static int lsp_weight_quant(
128" L0 = R0;\n\t" 128" L0 = R0;\n\t"
129" L1 = R0;\n\t" 129" L1 = R0;\n\t"
130" I0 = %2;\n\t" /* %2: &x[0] */ 130" I0 = %2;\n\t" /* %2: &x[0] */
131" I1 = %3;\n\t" /* %3: &weight[0] */ 131" I1 = %3;\n\t" /* %3: &weight[0] */
132" B0 = %2;\n\t" 132" B0 = %2;\n\t"
133" B1 = %3;\n\t" 133" B1 = %3;\n\t"
134 134
135" LSETUP (lwq1, lwq2) LC0 = %5;\n\t" 135" LSETUP (lwq1, lwq2) LC0 = %5;\n\t"
136"lwq1: R3 = 0 (X);\n\t" /* R3: dist */ 136"lwq1: R3 = 0 (X);\n\t" /* R3: dist */
137" LSETUP (lwq3, lwq4) LC1 = %6;\n\t" 137" LSETUP (lwq3, lwq4) LC1 = %6;\n\t"
138"lwq3: R0.L = W [I0++] || R2.L = W [I1++];\n\t" 138"lwq3: R0.L = W [I0++] || R2.L = W [I1++];\n\t"
139" R1 = B [P2++] (X);\n\t" 139" R1 = B [P2++] (X);\n\t"
140" R1 <<= 5;\n\t" 140" R1 <<= 5;\n\t"
141" R0.L = R0.L - R1.L;\n\t" 141" R0.L = R0.L - R1.L;\n\t"
142" R0 = R0.L*R0.L;\n\t" 142" R0 = R0.L*R0.L;\n\t"
143" A1 = R2.L*R0.L (M,IS);\n\t" 143" A1 = R2.L*R0.L (M,IS);\n\t"
144" A1 = A1 >>> 16;\n\t" 144" A1 = A1 >>> 16;\n\t"
145" R1 = (A1 += R2.L*R0.H) (IS);\n\t" 145" R1 = (A1 += R2.L*R0.H) (IS);\n\t"
146"lwq4: R3 = R3 + R1;\n\t" 146"lwq4: R3 = R3 + R1;\n\t"
147 147
148" cc =R3<%0;\n\t" 148" cc =R3<%0;\n\t"
149" if cc %0=R3;\n\t" 149" if cc %0=R3;\n\t"
150" if cc %1=R5;\n\t" 150" if cc %1=R5;\n\t"
151"lwq2: R5 += 1;\n\t" 151"lwq2: R5 += 1;\n\t"
152" L0 = 0;\n\t" 152" L0 = 0;\n\t"
153" L1 = 0;\n\t" 153" L1 = 0;\n\t"
diff --git a/apps/codecs/libspeex/sb_celp.c b/apps/codecs/libspeex/sb_celp.c
index 51f255661f..b28744812f 100644
--- a/apps/codecs/libspeex/sb_celp.c
+++ b/apps/codecs/libspeex/sb_celp.c
@@ -459,7 +459,7 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
459 spx_int32_t modeid; 459 spx_int32_t modeid;
460 modeid = mode->nb_modes-1; 460 modeid = mode->nb_modes-1;
461 st->relative_quality+=1.0*(ratio+2); 461 st->relative_quality+=1.0*(ratio+2);
462 if (st->relative_quality<-1) 462 if (st->relative_quality<-1)
463 st->relative_quality=-1; 463 st->relative_quality=-1;
464 while (modeid) 464 while (modeid)
465 { 465 {
diff --git a/apps/codecs/libspeex/smallft.c b/apps/codecs/libspeex/smallft.c
index 6ff46a8445..6e3a927b5f 100644
--- a/apps/codecs/libspeex/smallft.c
+++ b/apps/codecs/libspeex/smallft.c
@@ -96,10 +96,10 @@ static void drfti1(int n, float *wa, int *ifac){
96 argld=(float)ld*argh; 96 argld=(float)ld*argh;
97 fi=0.f; 97 fi=0.f;
98 for (ii=2;ii<ido;ii+=2){ 98 for (ii=2;ii<ido;ii+=2){
99 fi+=1.f; 99 fi+=1.f;
100 arg=fi*argld; 100 arg=fi*argld;
101 wa[i++]=cos(arg); 101 wa[i++]=cos(arg);
102 wa[i++]=sin(arg); 102 wa[i++]=sin(arg);
103 } 103 }
104 is+=ido; 104 is+=ido;
105 } 105 }
@@ -169,7 +169,7 @@ static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){
169} 169}
170 170
171static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1, 171static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1,
172 float *wa2,float *wa3){ 172 float *wa2,float *wa3){
173 static float hsqt2 = .70710678118654752f; 173 static float hsqt2 = .70710678118654752f;
174 int i,k,t0,t1,t2,t3,t4,t5,t6; 174 int i,k,t0,t1,t2,t3,t4,t5,t6;
175 float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4; 175 float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
@@ -749,7 +749,7 @@ static void dradb3(int ido,int l1,float *cc,float *ch,float *wa1,
749} 749}
750 750
751static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1, 751static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1,
752 float *wa2,float *wa3){ 752 float *wa2,float *wa3){
753 static float sqrt2=1.414213562373095f; 753 static float sqrt2=1.414213562373095f;
754 int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8; 754 int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8;
755 float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4; 755 float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
diff --git a/apps/codecs/libspeex/speex/ogg.h b/apps/codecs/libspeex/speex/ogg.h
index d42851f10c..8898b99582 100644
--- a/apps/codecs/libspeex/speex/ogg.h
+++ b/apps/codecs/libspeex/speex/ogg.h
@@ -66,8 +66,8 @@ typedef struct {
66 66
67 int *lacing_vals; /* The values that will go to the segment table */ 67 int *lacing_vals; /* The values that will go to the segment table */
68 spx_ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact 68 spx_ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
69 this way, but it is simple coupled to the 69 this way, but it is simple coupled to the
70 lacing fifo */ 70 lacing fifo */
71 long lacing_storage; 71 long lacing_storage;
72 long lacing_fill; 72 long lacing_fill;
73 long lacing_packet; 73 long lacing_packet;
@@ -103,10 +103,10 @@ typedef struct {
103 spx_ogg_int64_t granulepos; 103 spx_ogg_int64_t granulepos;
104 104
105 spx_ogg_int64_t packetno; /* sequence number for decode; the framing 105 spx_ogg_int64_t packetno; /* sequence number for decode; the framing
106 knows where there's a hole in the data, 106 knows where there's a hole in the data,
107 but we need coupling so that the codec 107 but we need coupling so that the codec
108 (which is in a seperate abstraction 108 (which is in a seperate abstraction
109 layer) also knows about the gap */ 109 layer) also knows about the gap */
110} spx_ogg_packet; 110} spx_ogg_packet;
111 111
112typedef struct { 112typedef struct {
@@ -169,7 +169,7 @@ extern int spx_ogg_stream_flush(spx_ogg_stream_state *os, spx_ogg_page *og)
169extern int spx_ogg_sync_init(spx_ogg_sync_state *oy); 169extern int spx_ogg_sync_init(spx_ogg_sync_state *oy);
170extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy); 170extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy);
171extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy); 171extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy);
172extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy); 172extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy);
173 173
174extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size); 174extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size);
175extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size); 175extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size);
diff --git a/apps/codecs/libspeex/vorbis_psy.c b/apps/codecs/libspeex/vorbis_psy.c
index 91cf49c69c..2032bf63e2 100644
--- a/apps/codecs/libspeex/vorbis_psy.c
+++ b/apps/codecs/libspeex/vorbis_psy.c
@@ -90,9 +90,9 @@ static void _analysis_output(char *base,int i,float *v,int n,int bark,int dB){
90 if(dB){ 90 if(dB){
91 float val; 91 float val;
92 if(v[j]==0.) 92 if(v[j]==0.)
93 val=-140.; 93 val=-140.;
94 else 94 else
95 val=todB(v[j]); 95 val=todB(v[j]);
96 fprintf(of,"%f\n",val); 96 fprintf(of,"%f\n",val);
97 }else{ 97 }else{
98 fprintf(of,"%f\n",v[j]); 98 fprintf(of,"%f\n",v[j]);
@@ -254,19 +254,19 @@ static void bark_noise_hybridmp(int n,const long *b,
254} 254}
255 255
256static void _vp_noisemask(VorbisPsy *p, 256static void _vp_noisemask(VorbisPsy *p,
257 float *logfreq, 257 float *logfreq,
258 float *logmask){ 258 float *logmask){
259 259
260 int i,n=p->n/2; 260 int i,n=p->n/2;
261 float *work=alloca(n*sizeof(*work)); 261 float *work=alloca(n*sizeof(*work));
262 262
263 bark_noise_hybridmp(n,p->bark,logfreq,logmask, 263 bark_noise_hybridmp(n,p->bark,logfreq,logmask,
264 140.,-1); 264 140.,-1);
265 265
266 for(i=0;i<n;i++)work[i]=logfreq[i]-logmask[i]; 266 for(i=0;i<n;i++)work[i]=logfreq[i]-logmask[i];
267 267
268 bark_noise_hybridmp(n,p->bark,work,logmask,0., 268 bark_noise_hybridmp(n,p->bark,work,logmask,0.,
269 p->vi->noisewindowfixed); 269 p->vi->noisewindowfixed);
270 270
271 for(i=0;i<n;i++)work[i]=logfreq[i]-work[i]; 271 for(i=0;i<n;i++)work[i]=logfreq[i]-work[i];
272 272
@@ -319,10 +319,10 @@ VorbisPsy *vorbis_psy_init(int rate, int n)
319 float bark=toBARK(rate/(2*n)*i); 319 float bark=toBARK(rate/(2*n)*i);
320 320
321 for(;lo+p->vi->noisewindowlomin<i && 321 for(;lo+p->vi->noisewindowlomin<i &&
322 toBARK(rate/(2*n)*lo)<(bark-p->vi->noisewindowlo);lo++); 322 toBARK(rate/(2*n)*lo)<(bark-p->vi->noisewindowlo);lo++);
323 323
324 for(;hi<=n && (hi<i+p->vi->noisewindowhimin || 324 for(;hi<=n && (hi<i+p->vi->noisewindowhimin ||
325 toBARK(rate/(2*n)*hi)<(bark+p->vi->noisewindowhi));hi++); 325 toBARK(rate/(2*n)*hi)<(bark+p->vi->noisewindowhi));hi++);
326 326
327 p->bark[i]=((lo-1)<<16)+(hi-1); 327 p->bark[i]=((lo-1)<<16)+(hi-1);
328 328
diff --git a/apps/codecs/libtremor/asm_arm.h b/apps/codecs/libtremor/asm_arm.h
index 577dc91566..8da7ed75cc 100644
--- a/apps/codecs/libtremor/asm_arm.h
+++ b/apps/codecs/libtremor/asm_arm.h
@@ -34,55 +34,55 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
34 34
35static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { 35static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
36 int lo,hi; 36 int lo,hi;
37 asm volatile("smull %0, %1, %2, %3\n\t" 37 asm volatile("smull %0, %1, %2, %3\n\t"
38 "movs %0, %0, lsr #15\n\t" 38 "movs %0, %0, lsr #15\n\t"
39 "adc %1, %0, %1, lsl #17\n\t" 39 "adc %1, %0, %1, lsl #17\n\t"
40 : "=&r"(lo),"=&r"(hi) 40 : "=&r"(lo),"=&r"(hi)
41 : "%r"(x),"r"(y) 41 : "%r"(x),"r"(y)
42 : "cc"); 42 : "cc");
43 return(hi); 43 return(hi);
44} 44}
45 45
46#define XPROD32(a, b, t, v, x, y) \ 46#define XPROD32(a, b, t, v, x, y) \
47{ \ 47{ \
48 long l; \ 48 long l; \
49 asm( "smull %0, %1, %4, %6\n\t" \ 49 asm( "smull %0, %1, %4, %6\n\t" \
50 "rsb %3, %4, #0\n\t" \ 50 "rsb %3, %4, #0\n\t" \
51 "smlal %0, %1, %5, %7\n\t" \ 51 "smlal %0, %1, %5, %7\n\t" \
52 "smull %0, %2, %5, %6\n\t" \ 52 "smull %0, %2, %5, %6\n\t" \
53 "smlal %0, %2, %3, %7" \ 53 "smlal %0, %2, %3, %7" \
54 : "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \ 54 : "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \
55 : "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \ 55 : "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \
56} 56}
57 57
58static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, 58static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
59 ogg_int32_t t, ogg_int32_t v, 59 ogg_int32_t t, ogg_int32_t v,
60 ogg_int32_t *x, ogg_int32_t *y) 60 ogg_int32_t *x, ogg_int32_t *y)
61{ 61{
62 int x1, y1, l; 62 int x1, y1, l;
63 asm( "smull %0, %1, %4, %6\n\t" 63 asm( "smull %0, %1, %4, %6\n\t"
64 "rsb %3, %4, #0\n\t" 64 "rsb %3, %4, #0\n\t"
65 "smlal %0, %1, %5, %7\n\t" 65 "smlal %0, %1, %5, %7\n\t"
66 "smull %0, %2, %5, %6\n\t" 66 "smull %0, %2, %5, %6\n\t"
67 "smlal %0, %2, %3, %7" 67 "smlal %0, %2, %3, %7"
68 : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a) 68 : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
69 : "3" (a), "r" (b), "r" (t), "r" (v) ); 69 : "3" (a), "r" (b), "r" (t), "r" (v) );
70 *x = x1 << 1; 70 *x = x1 << 1;
71 *y = y1 << 1; 71 *y = y1 << 1;
72} 72}
73 73
74static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, 74static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
75 ogg_int32_t t, ogg_int32_t v, 75 ogg_int32_t t, ogg_int32_t v,
76 ogg_int32_t *x, ogg_int32_t *y) 76 ogg_int32_t *x, ogg_int32_t *y)
77{ 77{
78 int x1, y1, l; 78 int x1, y1, l;
79 asm( "smull %0, %1, %3, %5\n\t" 79 asm( "smull %0, %1, %3, %5\n\t"
80 "rsb %2, %4, #0\n\t" 80 "rsb %2, %4, #0\n\t"
81 "smlal %0, %1, %2, %6\n\t" 81 "smlal %0, %1, %2, %6\n\t"
82 "smull %0, %2, %4, %5\n\t" 82 "smull %0, %2, %4, %5\n\t"
83 "smlal %0, %2, %3, %6" 83 "smlal %0, %2, %3, %6"
84 : "=&r" (l), "=&r" (x1), "=&r" (y1) 84 : "=&r" (l), "=&r" (x1), "=&r" (y1)
85 : "r" (a), "r" (b), "r" (t), "r" (v) ); 85 : "r" (a), "r" (b), "r" (t), "r" (v) );
86 *x = x1 << 1; 86 *x = x1 << 1;
87 *y = y1 << 1; 87 *y = y1 << 1;
88} 88}
@@ -216,14 +216,14 @@ static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n)
216 216
217static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { 217static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
218 int tmp; 218 int tmp;
219 asm volatile("subs %1, %0, #32768\n\t" 219 asm volatile("subs %1, %0, #32768\n\t"
220 "movpl %0, #0x7f00\n\t" 220 "movpl %0, #0x7f00\n\t"
221 "orrpl %0, %0, #0xff\n" 221 "orrpl %0, %0, #0xff\n"
222 "adds %1, %0, #32768\n\t" 222 "adds %1, %0, #32768\n\t"
223 "movmi %0, #0x8000" 223 "movmi %0, #0x8000"
224 : "+r"(x),"=r"(tmp) 224 : "+r"(x),"=r"(tmp)
225 : 225 :
226 : "cc"); 226 : "cc");
227 return(x); 227 return(x);
228} 228}
229 229
@@ -233,9 +233,9 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
233#define _V_LSP_MATH_ASM 233#define _V_LSP_MATH_ASM
234 234
235static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, 235static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
236 ogg_int32_t *qexpp, 236 ogg_int32_t *qexpp,
237 ogg_int32_t *ilsp,ogg_int32_t wi, 237 ogg_int32_t *ilsp,ogg_int32_t wi,
238 ogg_int32_t m){ 238 ogg_int32_t m){
239 239
240 ogg_uint32_t qi=*qip,pi=*pip; 240 ogg_uint32_t qi=*qip,pi=*pip;
241 ogg_int32_t qexp=*qexpp; 241 ogg_int32_t qexp=*qexpp;
@@ -291,7 +291,7 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
291 //qexp+=shift; 291 //qexp+=shift;
292 292
293 //} 293 //}
294 294
295 /* normalize to max 16 sig figs */ 295 /* normalize to max 16 sig figs */
296 "2:" 296 "2:"
297 "mov r2,#0;" 297 "mov r2,#0;"
diff --git a/apps/codecs/libtremor/backends.h b/apps/codecs/libtremor/backends.h
index 50c1c45cfd..677bc8fdc2 100644
--- a/apps/codecs/libtremor/backends.h
+++ b/apps/codecs/libtremor/backends.h
@@ -34,12 +34,12 @@
34typedef struct{ 34typedef struct{
35 vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); 35 vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
36 vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, 36 vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
37 vorbis_info_floor *); 37 vorbis_info_floor *);
38 void (*free_info) (vorbis_info_floor *); 38 void (*free_info) (vorbis_info_floor *);
39 void (*free_look) (vorbis_look_floor *); 39 void (*free_look) (vorbis_look_floor *);
40 void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); 40 void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
41 int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, 41 int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
42 void *buffer,ogg_int32_t *); 42 void *buffer,ogg_int32_t *);
43} vorbis_func_floor; 43} vorbis_func_floor;
44 44
45typedef struct{ 45typedef struct{
@@ -77,11 +77,11 @@ typedef struct{
77typedef struct{ 77typedef struct{
78 vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *); 78 vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
79 vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *, 79 vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
80 vorbis_info_residue *); 80 vorbis_info_residue *);
81 void (*free_info) (vorbis_info_residue *); 81 void (*free_info) (vorbis_info_residue *);
82 void (*free_look) (vorbis_look_residue *); 82 void (*free_look) (vorbis_look_residue *);
83 int (*inverse) (struct vorbis_block *,vorbis_look_residue *, 83 int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
84 ogg_int32_t **,int *,int); 84 ogg_int32_t **,int *,int);
85} vorbis_func_residue; 85} vorbis_func_residue;
86 86
87typedef struct vorbis_info_residue0{ 87typedef struct vorbis_info_residue0{
@@ -101,7 +101,7 @@ typedef struct vorbis_info_residue0{
101typedef struct{ 101typedef struct{
102 vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *); 102 vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
103 vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *, 103 vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
104 vorbis_info_mapping *); 104 vorbis_info_mapping *);
105 void (*free_info) (vorbis_info_mapping *); 105 void (*free_info) (vorbis_info_mapping *);
106 void (*free_look) (vorbis_look_mapping *); 106 void (*free_look) (vorbis_look_mapping *);
107 int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *); 107 int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);
diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c
index c6027480a7..6ed6a08672 100644
--- a/apps/codecs/libtremor/codebook.c
+++ b/apps/codecs/libtremor/codebook.c
@@ -49,19 +49,19 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
49 /* yes, unused entries */ 49 /* yes, unused entries */
50 50
51 for(i=0;i<s->entries;i++){ 51 for(i=0;i<s->entries;i++){
52 if(oggpack_read(opb,1)){ 52 if(oggpack_read(opb,1)){
53 long num=oggpack_read(opb,5); 53 long num=oggpack_read(opb,5);
54 if(num==-1)goto _eofout; 54 if(num==-1)goto _eofout;
55 s->lengthlist[i]=num+1; 55 s->lengthlist[i]=num+1;
56 }else 56 }else
57 s->lengthlist[i]=0; 57 s->lengthlist[i]=0;
58 } 58 }
59 }else{ 59 }else{
60 /* all entries used; no tagging */ 60 /* all entries used; no tagging */
61 for(i=0;i<s->entries;i++){ 61 for(i=0;i<s->entries;i++){
62 long num=oggpack_read(opb,5); 62 long num=oggpack_read(opb,5);
63 if(num==-1)goto _eofout; 63 if(num==-1)goto _eofout;
64 s->lengthlist[i]=num+1; 64 s->lengthlist[i]=num+1;
65 } 65 }
66 } 66 }
67 67
@@ -73,11 +73,11 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
73 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); 73 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
74 74
75 for(i=0;i<s->entries;){ 75 for(i=0;i<s->entries;){
76 long num=oggpack_read(opb,_ilog(s->entries-i)); 76 long num=oggpack_read(opb,_ilog(s->entries-i));
77 if(num==-1)goto _eofout; 77 if(num==-1)goto _eofout;
78 for(j=0;j<num && i<s->entries;j++,i++) 78 for(j=0;j<num && i<s->entries;j++,i++)
79 s->lengthlist[i]=length; 79 s->lengthlist[i]=length;
80 length++; 80 length++;
81 } 81 }
82 } 82 }
83 break; 83 break;
@@ -104,17 +104,17 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
104 int quantvals=0; 104 int quantvals=0;
105 switch(s->maptype){ 105 switch(s->maptype){
106 case 1: 106 case 1:
107 quantvals=_book_maptype1_quantvals(s); 107 quantvals=_book_maptype1_quantvals(s);
108 break; 108 break;
109 case 2: 109 case 2:
110 quantvals=s->entries*s->dim; 110 quantvals=s->entries*s->dim;
111 break; 111 break;
112 } 112 }
113 113
114 /* quantized values */ 114 /* quantized values */
115 s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); 115 s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
116 for(i=0;i<quantvals;i++) 116 for(i=0;i<quantvals;i++)
117 s->quantlist[i]=oggpack_read(opb,s->q_quant); 117 s->quantlist[i]=oggpack_read(opb,s->q_quant);
118 118
119 if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; 119 if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
120 } 120 }
@@ -216,7 +216,7 @@ static inline ogg_uint32_t bitreverse(register ogg_uint32_t x)
216} 216}
217 217
218STIN long decode_packed_entry_number(codebook *book, 218STIN long decode_packed_entry_number(codebook *book,
219 oggpack_buffer *b){ 219 oggpack_buffer *b){
220 int read=book->dec_maxlength; 220 int read=book->dec_maxlength;
221 long lo,hi; 221 long lo,hi;
222 long lok = oggpack_look(b,book->dec_firsttablen); 222 long lok = oggpack_look(b,book->dec_firsttablen);
@@ -284,25 +284,25 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
284 ptr = (ogg_uint32_t *)(adr&~3); 284 ptr = (ogg_uint32_t *)(adr&~3);
285 bitend = ((adr&3)+b->headend)*8; 285 bitend = ((adr&3)+b->headend)*8;
286 while (bufptr<bufend){ 286 while (bufptr<bufend){
287 long entry, lo, hi; 287 long entry, lo, hi;
288 if (UNLIKELY(cachesize<book->dec_maxlength)) { 288 if (UNLIKELY(cachesize<book->dec_maxlength)) {
289 if (bit-cachesize+32>=bitend) 289 if (bit-cachesize+32>=bitend)
290 break; 290 break;
291 bit-=cachesize; 291 bit-=cachesize;
292 cache=letoh32(ptr[bit>>5]) >> (bit&31); 292 cache=letoh32(ptr[bit>>5]) >> (bit&31);
293 if (bit&31) 293 if (bit&31)
294 cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31)); 294 cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31));
295 cachesize=32; 295 cachesize=32;
296 bit+=32; 296 bit+=32;
297 } 297 }
298 298
299 entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)]; 299 entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
300 if(UNLIKELY(entry&0x80000000UL)){ 300 if(UNLIKELY(entry&0x80000000UL)){
301 lo=(entry>>15)&0x7fff; 301 lo=(entry>>15)&0x7fff;
302 hi=book->used_entries-(entry&0x7fff); 302 hi=book->used_entries-(entry&0x7fff);
303 { 303 {
304 ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); 304 ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
305 305
306 while(LIKELY(hi-lo>1)){ 306 while(LIKELY(hi-lo>1)){
307 long p=(hi-lo)>>1; 307 long p=(hi-lo)>>1;
308 if (book->codelist[lo+p]>testword) 308 if (book->codelist[lo+p]>testword)
@@ -312,15 +312,15 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
312 } 312 }
313 entry=lo; 313 entry=lo;
314 } 314 }
315 }else 315 }else
316 entry--; 316 entry--;
317 317
318 *bufptr++=entry; 318 *bufptr++=entry;
319 { 319 {
320 int l=book->dec_codelengths[entry]; 320 int l=book->dec_codelengths[entry];
321 cachesize-=l; 321 cachesize-=l;
322 cache>>=l; 322 cache>>=l;
323 } 323 }
324 } 324 }
325 325
326 adr=(unsigned long)b->headptr; 326 adr=(unsigned long)b->headptr;
@@ -366,7 +366,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
366 366
367/* returns 0 on OK or -1 on eof *************************************/ 367/* returns 0 on OK or -1 on eof *************************************/
368long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, 368long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
369 oggpack_buffer *b,int n,int point){ 369 oggpack_buffer *b,int n,int point){
370 if(book->used_entries>0){ 370 if(book->used_entries>0){
371 int step=n/book->dim; 371 int step=n/book->dim;
372 long *entry = (long *)alloca(sizeof(*entry)*step); 372 long *entry = (long *)alloca(sizeof(*entry)*step);
@@ -376,29 +376,29 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
376 376
377 if(shift>=0){ 377 if(shift>=0){
378 for (i = 0; i < step; i++) { 378 for (i = 0; i < step; i++) {
379 entry[i]=decode_packed_entry_number(book,b); 379 entry[i]=decode_packed_entry_number(book,b);
380 if(entry[i]==-1)return(-1); 380 if(entry[i]==-1)return(-1);
381 t[i] = book->valuelist+entry[i]*book->dim; 381 t[i] = book->valuelist+entry[i]*book->dim;
382 } 382 }
383 for(i=0,o=0;i<book->dim;i++,o+=step) 383 for(i=0,o=0;i<book->dim;i++,o+=step)
384 for (j=0;j<step;j++) 384 for (j=0;j<step;j++)
385 a[o+j]+=t[j][i]>>shift; 385 a[o+j]+=t[j][i]>>shift;
386 }else{ 386 }else{
387 for (i = 0; i < step; i++) { 387 for (i = 0; i < step; i++) {
388 entry[i]=decode_packed_entry_number(book,b); 388 entry[i]=decode_packed_entry_number(book,b);
389 if(entry[i]==-1)return(-1); 389 if(entry[i]==-1)return(-1);
390 t[i] = book->valuelist+entry[i]*book->dim; 390 t[i] = book->valuelist+entry[i]*book->dim;
391 } 391 }
392 for(i=0,o=0;i<book->dim;i++,o+=step) 392 for(i=0,o=0;i<book->dim;i++,o+=step)
393 for (j=0;j<step;j++) 393 for (j=0;j<step;j++)
394 a[o+j]+=t[j][i]<<-shift; 394 a[o+j]+=t[j][i]<<-shift;
395 } 395 }
396 } 396 }
397 return(0); 397 return(0);
398} 398}
399 399
400long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a, 400long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
401 oggpack_buffer *b,int n,int point){ 401 oggpack_buffer *b,int n,int point){
402 if(book->used_entries>0){ 402 if(book->used_entries>0){
403 int i,j,entry; 403 int i,j,entry;
404 ogg_int32_t *t; 404 ogg_int32_t *t;
@@ -406,20 +406,20 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
406 406
407 if(shift>=0){ 407 if(shift>=0){
408 for(i=0;i<n;){ 408 for(i=0;i<n;){
409 entry = decode_packed_entry_number(book,b); 409 entry = decode_packed_entry_number(book,b);
410 if(entry==-1)return(-1); 410 if(entry==-1)return(-1);
411 t = book->valuelist+entry*book->dim; 411 t = book->valuelist+entry*book->dim;
412 for (j=0;j<book->dim;) 412 for (j=0;j<book->dim;)
413 a[i++]+=t[j++]>>shift; 413 a[i++]+=t[j++]>>shift;
414 } 414 }
415 }else{ 415 }else{
416 shift = -shift; 416 shift = -shift;
417 for(i=0;i<n;){ 417 for(i=0;i<n;){
418 entry = decode_packed_entry_number(book,b); 418 entry = decode_packed_entry_number(book,b);
419 if(entry==-1)return(-1); 419 if(entry==-1)return(-1);
420 t = book->valuelist+entry*book->dim; 420 t = book->valuelist+entry*book->dim;
421 for (j=0;j<book->dim;) 421 for (j=0;j<book->dim;)
422 a[i++]+=t[j++]<<shift; 422 a[i++]+=t[j++]<<shift;
423 } 423 }
424 } 424 }
425 } 425 }
@@ -427,7 +427,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
427} 427}
428 428
429long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, 429long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
430 oggpack_buffer *b,int n,int point){ 430 oggpack_buffer *b,int n,int point){
431 if(book->used_entries>0){ 431 if(book->used_entries>0){
432 int i,j,entry; 432 int i,j,entry;
433 ogg_int32_t *t; 433 ogg_int32_t *t;
@@ -436,22 +436,22 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
436 if(shift>=0){ 436 if(shift>=0){
437 437
438 for(i=0;i<n;){ 438 for(i=0;i<n;){
439 entry = decode_packed_entry_number(book,b); 439 entry = decode_packed_entry_number(book,b);
440 if(entry==-1)return(-1); 440 if(entry==-1)return(-1);
441 t = book->valuelist+entry*book->dim; 441 t = book->valuelist+entry*book->dim;
442 for (j=0;j<book->dim;){ 442 for (j=0;j<book->dim;){
443 a[i++]=t[j++]>>shift; 443 a[i++]=t[j++]>>shift;
444 } 444 }
445 } 445 }
446 }else{ 446 }else{
447 shift = -shift; 447 shift = -shift;
448 for(i=0;i<n;){ 448 for(i=0;i<n;){
449 entry = decode_packed_entry_number(book,b); 449 entry = decode_packed_entry_number(book,b);
450 if(entry==-1)return(-1); 450 if(entry==-1)return(-1);
451 t = book->valuelist+entry*book->dim; 451 t = book->valuelist+entry*book->dim;
452 for (j=0;j<book->dim;){ 452 for (j=0;j<book->dim;){
453 a[i++]=t[j++]<<shift; 453 a[i++]=t[j++]<<shift;
454 } 454 }
455 } 455 }
456 } 456 }
457 }else{ 457 }else{
@@ -459,7 +459,7 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
459 int i,j; 459 int i,j;
460 for(i=0;i<n;){ 460 for(i=0;i<n;){
461 for (j=0;j<book->dim;){ 461 for (j=0;j<book->dim;){
462 a[i++]=0; 462 a[i++]=0;
463 } 463 }
464 } 464 }
465 } 465 }
@@ -516,8 +516,8 @@ static long vorbis_book_decodevv_add_2ch_even(codebook *book,ogg_int32_t **a,
516} 516}
517 517
518long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a, 518long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
519 long offset,int ch, 519 long offset,int ch,
520 oggpack_buffer *b,int n,int point){ 520 oggpack_buffer *b,int n,int point){
521 if(LIKELY(book->used_entries>0)){ 521 if(LIKELY(book->used_entries>0)){
522 long i,j,k,chunk,read; 522 long i,j,k,chunk,read;
523 int chptr=0; 523 int chptr=0;
@@ -535,14 +535,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
535 chunk=((offset+n-i)*ch+book->dim-1)/book->dim; 535 chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
536 read = decode_packed_block(book,b,entries,chunk); 536 read = decode_packed_block(book,b,entries,chunk);
537 for(k=0;k<read;k++){ 537 for(k=0;k<read;k++){
538 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; 538 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
539 for (j=0;j<book->dim;j++){ 539 for (j=0;j<book->dim;j++){
540 a[chptr++][i]+=t[j]>>shift; 540 a[chptr++][i]+=t[j]>>shift;
541 if(chptr==ch){ 541 if(chptr==ch){
542 chptr=0; 542 chptr=0;
543 i++; 543 i++;
544 } 544 }
545 } 545 }
546 } 546 }
547 if (read<chunk)return-1; 547 if (read<chunk)return-1;
548 } 548 }
@@ -554,14 +554,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
554 chunk=((offset+n-i)*ch+book->dim-1)/book->dim; 554 chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
555 read = decode_packed_block(book,b,entries,chunk); 555 read = decode_packed_block(book,b,entries,chunk);
556 for(k=0;k<read;k++){ 556 for(k=0;k<read;k++){
557 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim; 557 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
558 for (j=0;j<book->dim;j++){ 558 for (j=0;j<book->dim;j++){
559 a[chptr++][i]+=t[j]<<shift; 559 a[chptr++][i]+=t[j]<<shift;
560 if(chptr==ch){ 560 if(chptr==ch){
561 chptr=0; 561 chptr=0;
562 i++; 562 i++;
563 } 563 }
564 } 564 }
565 } 565 }
566 if (read<chunk)return-1; 566 if (read<chunk)return-1;
567 } 567 }
diff --git a/apps/codecs/libtremor/codebook.h b/apps/codecs/libtremor/codebook.h
index 14f65382dd..0fc6834daa 100644
--- a/apps/codecs/libtremor/codebook.h
+++ b/apps/codecs/libtremor/codebook.h
@@ -40,8 +40,8 @@ typedef struct static_codebook{
40 40
41 /* mapping ***************************************************************/ 41 /* mapping ***************************************************************/
42 int maptype; /* 0=none 42 int maptype; /* 0=none
43 1=implicitly populated values from map column 43 1=implicitly populated values from map column
44 2=listed arbitrary values */ 44 2=listed arbitrary values */
45 45
46 /* The below does a linear, single monotonic sequence mapping. */ 46 /* The below does a linear, single monotonic sequence mapping. */
47 long q_min; /* packed 32 bit float; quant value 0 maps to minval */ 47 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
@@ -50,8 +50,8 @@ typedef struct static_codebook{
50 int q_sequencep; /* bitflag */ 50 int q_sequencep; /* bitflag */
51 51
52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map 52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
53 map == 2: list of dim*entries quantized entry vals 53 map == 2: list of dim*entries quantized entry vals
54 */ 54 */
55} static_codebook; 55} static_codebook;
56 56
57typedef struct codebook{ 57typedef struct codebook{
@@ -87,14 +87,14 @@ extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
87 87
88extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); 88extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
89extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 89extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
90 oggpack_buffer *b,int n,int point); 90 oggpack_buffer *b,int n,int point);
91extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, 91extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
92 oggpack_buffer *b,int n,int point); 92 oggpack_buffer *b,int n,int point);
93extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, 93extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
94 oggpack_buffer *b,int n,int point); 94 oggpack_buffer *b,int n,int point);
95extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, 95extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
96 long off,int ch, 96 long off,int ch,
97 oggpack_buffer *b,int n,int point); 97 oggpack_buffer *b,int n,int point);
98 98
99extern int _ilog(unsigned int v); 99extern int _ilog(unsigned int v);
100 100
diff --git a/apps/codecs/libtremor/floor0.c b/apps/codecs/libtremor/floor0.c
index cceb113a6b..9c890e6bad 100644
--- a/apps/codecs/libtremor/floor0.c
+++ b/apps/codecs/libtremor/floor0.c
@@ -74,7 +74,7 @@ static inline ogg_int32_t vorbis_coslook_i(long a){
74 int i=a>>COS_LOOKUP_I_SHIFT; 74 int i=a>>COS_LOOKUP_I_SHIFT;
75 int d=a&COS_LOOKUP_I_MASK; 75 int d=a&COS_LOOKUP_I_MASK;
76 return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> 76 return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
77 COS_LOOKUP_I_SHIFT); 77 COS_LOOKUP_I_SHIFT);
78} 78}
79 79
80/* interpolated lookup based cos function */ 80/* interpolated lookup based cos function */
@@ -181,7 +181,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
181 qi=((qi*qi)>>16); 181 qi=((qi*qi)>>16);
182 182
183 if(m&1){ 183 if(m&1){
184 qexp= qexp*2-28*((m+1)>>1)+m; 184 qexp= qexp*2-28*((m+1)>>1)+m;
185 pi*=(1<<14)-((wi*wi)>>14); 185 pi*=(1<<14)-((wi*wi)>>14);
186 qi+=pi>>14; 186 qi+=pi>>14;
187 }else{ 187 }else{
@@ -205,15 +205,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
205 205
206 for(j=3;j<m;j+=2){ 206 for(j=3;j<m;j+=2){
207 if(!(shift=MLOOP_1[(pi|qi)>>25])) 207 if(!(shift=MLOOP_1[(pi|qi)>>25]))
208 if(!(shift=MLOOP_2[(pi|qi)>>19])) 208 if(!(shift=MLOOP_2[(pi|qi)>>19]))
209 shift=MLOOP_3[(pi|qi)>>16]; 209 shift=MLOOP_3[(pi|qi)>>16];
210 qi=(qi>>shift)*labs(ilsp[j-1]-wi); 210 qi=(qi>>shift)*labs(ilsp[j-1]-wi);
211 pi=(pi>>shift)*labs(ilsp[j]-wi); 211 pi=(pi>>shift)*labs(ilsp[j]-wi);
212 qexp+=shift; 212 qexp+=shift;
213 } 213 }
214 if(!(shift=MLOOP_1[(pi|qi)>>25])) 214 if(!(shift=MLOOP_1[(pi|qi)>>25]))
215 if(!(shift=MLOOP_2[(pi|qi)>>19])) 215 if(!(shift=MLOOP_2[(pi|qi)>>19]))
216 shift=MLOOP_3[(pi|qi)>>16]; 216 shift=MLOOP_3[(pi|qi)>>16];
217 217
218 /* pi,qi normalized collectively, both tracked using qexp */ 218 /* pi,qi normalized collectively, both tracked using qexp */
219 219
@@ -225,8 +225,8 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
225 qexp+=shift; 225 qexp+=shift;
226 226
227 if(!(shift=MLOOP_1[(pi|qi)>>25])) 227 if(!(shift=MLOOP_1[(pi|qi)>>25]))
228 if(!(shift=MLOOP_2[(pi|qi)>>19])) 228 if(!(shift=MLOOP_2[(pi|qi)>>19]))
229 shift=MLOOP_3[(pi|qi)>>16]; 229 shift=MLOOP_3[(pi|qi)>>16];
230 230
231 pi>>=shift; 231 pi>>=shift;
232 qi>>=shift; 232 qi>>=shift;
@@ -243,7 +243,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
243 /* even order filter; still symmetric */ 243 /* even order filter; still symmetric */
244 244
245 /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't 245 /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
246 worth tracking step by step */ 246 worth tracking step by step */
247 247
248 pi>>=shift; 248 pi>>=shift;
249 qi>>=shift; 249 qi>>=shift;
@@ -268,15 +268,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
268 qi>>=1; qexp++; 268 qi>>=1; qexp++;
269 }else 269 }else
270 while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ 270 while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
271 qi<<=1; qexp--; 271 qi<<=1; qexp--;
272 } 272 }
273 273
274#endif 274#endif
275 275
276 amp=vorbis_fromdBlook_i(ampi* /* n.4 */ 276 amp=vorbis_fromdBlook_i(ampi* /* n.4 */
277 vorbis_invsqlook_i(qi,qexp)- 277 vorbis_invsqlook_i(qi,qexp)-
278 /* m.8, m+n<=8 */ 278 /* m.8, m+n<=8 */
279 ampoffseti); /* 8.12[0] */ 279 ampoffseti); /* 8.12[0] */
280 280
281#ifdef _LOW_ACCURACY_ 281#ifdef _LOW_ACCURACY_
282 amp>>=9; 282 amp>>=9;
@@ -366,7 +366,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
366 for(j=0;j<look->n;j++){ 366 for(j=0;j<look->n;j++){
367 367
368 int val=(look->ln* 368 int val=(look->ln*
369 ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11; 369 ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
370 370
371 if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ 371 if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
372 look->linearmap[j]=val; 372 look->linearmap[j]=val;
@@ -398,10 +398,10 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
398 ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1)); 398 ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
399 399
400 for(j=0;j<look->m;j+=b->dim) 400 for(j=0;j<look->m;j+=b->dim)
401 if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop; 401 if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop;
402 for(j=0;j<look->m;){ 402 for(j=0;j<look->m;){
403 for(k=0;k<b->dim;k++,j++)lsp[j]+=last; 403 for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
404 last=lsp[j-1]; 404 last=lsp[j-1];
405 } 405 }
406 406
407 lsp[look->m]=amp; 407 lsp[look->m]=amp;
@@ -413,7 +413,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
413} 413}
414 414
415static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, 415static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
416 void *memo,ogg_int32_t *out){ 416 void *memo,ogg_int32_t *out){
417 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; 417 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
418 vorbis_info_floor0 *info=look->vi; 418 vorbis_info_floor0 *info=look->vi;
419 (void)vb; 419 (void)vb;
@@ -424,7 +424,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
424 424
425 /* take the coefficients back to a spectral envelope curve */ 425 /* take the coefficients back to a spectral envelope curve */
426 vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln, 426 vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
427 lsp,look->m,amp,info->ampdB,look->lsp_look); 427 lsp,look->m,amp,info->ampdB,look->lsp_look);
428 return(1); 428 return(1);
429 } 429 }
430 memset(out,0,sizeof(*out)*look->n); 430 memset(out,0,sizeof(*out)*look->n);
diff --git a/apps/codecs/libtremor/framing.c b/apps/codecs/libtremor/framing.c
index ec1e4c34c2..0b08167da8 100644
--- a/apps/codecs/libtremor/framing.c
+++ b/apps/codecs/libtremor/framing.c
@@ -1003,11 +1003,11 @@ STATICIRAM_NOT_MDCT int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
1003 /* split the body contents off */ 1003 /* split the body contents off */
1004 if(op){ 1004 if(op){
1005 op->packet=ogg_buffer_split(&os->body_tail,&os->body_head, 1005 op->packet=ogg_buffer_split(&os->body_tail,&os->body_head,
1006 os->body_fill&FINMASK); 1006 os->body_fill&FINMASK);
1007 op->bytes=os->body_fill&FINMASK; 1007 op->bytes=os->body_fill&FINMASK;
1008 }else{ 1008 }else{
1009 os->body_tail=ogg_buffer_pretruncate(os->body_tail, 1009 os->body_tail=ogg_buffer_pretruncate(os->body_tail,
1010 os->body_fill&FINMASK); 1010 os->body_fill&FINMASK);
1011 if(os->body_tail==0)os->body_head=0; 1011 if(os->body_tail==0)os->body_head=0;
1012 } 1012 }
1013 1013
diff --git a/apps/codecs/libtremor/info.c b/apps/codecs/libtremor/info.c
index afa9497cf0..935fa03269 100644
--- a/apps/codecs/libtremor/info.c
+++ b/apps/codecs/libtremor/info.c
@@ -47,7 +47,7 @@ void vorbis_comment_clear(vorbis_comment *vc){
47 for(i=0;i<vc->comments;i++) 47 for(i=0;i<vc->comments;i++)
48 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); 48 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
49 if(vc->user_comments)_ogg_free(vc->user_comments); 49 if(vc->user_comments)_ogg_free(vc->user_comments);
50 if(vc->comment_lengths)_ogg_free(vc->comment_lengths); 50 if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
51 if(vc->vendor)_ogg_free(vc->vendor); 51 if(vc->vendor)_ogg_free(vc->vendor);
52 memset(vc,0,sizeof(*vc)); 52 memset(vc,0,sizeof(*vc));
53 } 53 }
@@ -77,26 +77,26 @@ void vorbis_info_clear(vorbis_info *vi){
77 77
78 for(i=0;i<ci->maps;i++) /* unpack does the range checking */ 78 for(i=0;i<ci->maps;i++) /* unpack does the range checking */
79 if(ci->map_param[i]) 79 if(ci->map_param[i])
80 _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); 80 _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
81 81
82 for(i=0;i<ci->floors;i++) /* unpack does the range checking */ 82 for(i=0;i<ci->floors;i++) /* unpack does the range checking */
83 if(ci->floor_param[i]) 83 if(ci->floor_param[i])
84 _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); 84 _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
85 85
86 for(i=0;i<ci->residues;i++) /* unpack does the range checking */ 86 for(i=0;i<ci->residues;i++) /* unpack does the range checking */
87 if(ci->residue_param[i]) 87 if(ci->residue_param[i])
88 _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); 88 _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
89 89
90 for(i=0;i<ci->books;i++){ 90 for(i=0;i<ci->books;i++){
91 if(ci->book_param[i]){ 91 if(ci->book_param[i]){
92 /* knows if the book was not alloced */ 92 /* knows if the book was not alloced */
93 vorbis_staticbook_destroy(ci->book_param[i]); 93 vorbis_staticbook_destroy(ci->book_param[i]);
94 } 94 }
95 if(ci->fullbooks) 95 if(ci->fullbooks)
96 vorbis_book_clear(ci->fullbooks+i); 96 vorbis_book_clear(ci->fullbooks+i);
97 } 97 }
98 if(ci->fullbooks) 98 if(ci->fullbooks)
99 _ogg_free(ci->fullbooks); 99 _ogg_free(ci->fullbooks);
100 100
101 _ogg_free(ci); 101 _ogg_free(ci);
102 } 102 }
@@ -278,42 +278,42 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
278 memset(buffer,0,6); 278 memset(buffer,0,6);
279 _v_readstring(&opb,buffer,6); 279 _v_readstring(&opb,buffer,6);
280 if(memcmp(buffer,"vorbis",6)){ 280 if(memcmp(buffer,"vorbis",6)){
281 /* not a vorbis header */ 281 /* not a vorbis header */
282 return(OV_ENOTVORBIS); 282 return(OV_ENOTVORBIS);
283 } 283 }
284 switch(packtype){ 284 switch(packtype){
285 case 0x01: /* least significant *bit* is read first */ 285 case 0x01: /* least significant *bit* is read first */
286 if(!op->b_o_s){ 286 if(!op->b_o_s){
287 /* Not the initial packet */ 287 /* Not the initial packet */
288 return(OV_EBADHEADER); 288 return(OV_EBADHEADER);
289 } 289 }
290 if(vi->rate!=0){ 290 if(vi->rate!=0){
291 /* previously initialized info header */ 291 /* previously initialized info header */
292 return(OV_EBADHEADER); 292 return(OV_EBADHEADER);
293 } 293 }
294 294
295 return(_vorbis_unpack_info(vi,&opb)); 295 return(_vorbis_unpack_info(vi,&opb));
296 296
297 case 0x03: /* least significant *bit* is read first */ 297 case 0x03: /* least significant *bit* is read first */
298 if(vi->rate==0){ 298 if(vi->rate==0){
299 /* um... we didn't get the initial header */ 299 /* um... we didn't get the initial header */
300 return(OV_EBADHEADER); 300 return(OV_EBADHEADER);
301 } 301 }
302 302
303 return(_vorbis_unpack_comment(vc,&opb)); 303 return(_vorbis_unpack_comment(vc,&opb));
304 304
305 case 0x05: /* least significant *bit* is read first */ 305 case 0x05: /* least significant *bit* is read first */
306 if(vi->rate==0 || vc->vendor==NULL){ 306 if(vi->rate==0 || vc->vendor==NULL){
307 /* um... we didn;t get the initial header or comments yet */ 307 /* um... we didn;t get the initial header or comments yet */
308 return(OV_EBADHEADER); 308 return(OV_EBADHEADER);
309 } 309 }
310 310
311 return(_vorbis_unpack_books(vi,&opb)); 311 return(_vorbis_unpack_books(vi,&opb));
312 312
313 default: 313 default:
314 /* Not a valid vorbis header type */ 314 /* Not a valid vorbis header type */
315 return(OV_EBADHEADER); 315 return(OV_EBADHEADER);
316 break; 316 break;
317 } 317 }
318 } 318 }
319 } 319 }
diff --git a/apps/codecs/libtremor/ivorbiscodec.h b/apps/codecs/libtremor/ivorbiscodec.h
index f17c57a86d..0f3c940216 100644
--- a/apps/codecs/libtremor/ivorbiscodec.h
+++ b/apps/codecs/libtremor/ivorbiscodec.h
@@ -157,7 +157,7 @@ extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
157extern void vorbis_comment_init(vorbis_comment *vc); 157extern void vorbis_comment_init(vorbis_comment *vc);
158extern void vorbis_comment_add(vorbis_comment *vc, char *comment); 158extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
159extern void vorbis_comment_add_tag(vorbis_comment *vc, 159extern void vorbis_comment_add_tag(vorbis_comment *vc,
160 char *tag, char *contents); 160 char *tag, char *contents);
161extern void vorbis_comment_clear(vorbis_comment *vc); 161extern void vorbis_comment_clear(vorbis_comment *vc);
162 162
163extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); 163extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
@@ -167,7 +167,7 @@ extern void vorbis_dsp_clear(vorbis_dsp_state *v);
167/* Vorbis PRIMITIVES: synthesis layer *******************************/ 167/* Vorbis PRIMITIVES: synthesis layer *******************************/
168extern int vorbis_synthesis_idheader(ogg_packet *op); 168extern int vorbis_synthesis_idheader(ogg_packet *op);
169extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, 169extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
170 ogg_packet *op); 170 ogg_packet *op);
171 171
172extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); 172extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
173extern int vorbis_synthesis_restart(vorbis_dsp_state *v); 173extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
diff --git a/apps/codecs/libtremor/ivorbisfile.h b/apps/codecs/libtremor/ivorbisfile.h
index 9ff446ab10..4aa82cf9a0 100644
--- a/apps/codecs/libtremor/ivorbisfile.h
+++ b/apps/codecs/libtremor/ivorbisfile.h
@@ -89,11 +89,11 @@ typedef struct OggVorbis_File {
89extern int ov_clear(OggVorbis_File *vf); 89extern int ov_clear(OggVorbis_File *vf);
90 //extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); 90 //extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
91extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, 91extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
92 char *initial, long ibytes, ov_callbacks callbacks); 92 char *initial, long ibytes, ov_callbacks callbacks);
93 93
94 //extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); 94 //extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
95extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, 95extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
96 char *initial, long ibytes, ov_callbacks callbacks); 96 char *initial, long ibytes, ov_callbacks callbacks);
97extern int ov_test_open(OggVorbis_File *vf); 97extern int ov_test_open(OggVorbis_File *vf);
98 98
99extern long ov_bitrate(OggVorbis_File *vf,int i); 99extern long ov_bitrate(OggVorbis_File *vf,int i);
@@ -120,7 +120,7 @@ extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
120extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); 120extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
121 121
122extern long ov_read(OggVorbis_File *vf,char *buffer,int length, 122extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
123 int *bitstream); 123 int *bitstream);
124extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels, 124extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,
125 int length,int *bitstream); 125 int length,int *bitstream);
126 126
diff --git a/apps/codecs/libtremor/lsp_lookup.h b/apps/codecs/libtremor/lsp_lookup.h
index cced7c9282..42940bd39b 100644
--- a/apps/codecs/libtremor/lsp_lookup.h
+++ b/apps/codecs/libtremor/lsp_lookup.h
@@ -51,23 +51,23 @@ static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={
51#define INVSQ_LOOKUP_I_SHIFT 10 51#define INVSQ_LOOKUP_I_SHIFT 10
52#define INVSQ_LOOKUP_I_MASK 1023 52#define INVSQ_LOOKUP_I_MASK 1023
53static const long INVSQ_LOOKUP_I[64+1] ={ 53static const long INVSQ_LOOKUP_I[64+1] ={
54 92682, 91966, 91267, 90583, 54 92682, 91966, 91267, 90583,
55 89915, 89261, 88621, 87995, 55 89915, 89261, 88621, 87995,
56 87381, 86781, 86192, 85616, 56 87381, 86781, 86192, 85616,
57 85051, 84497, 83953, 83420, 57 85051, 84497, 83953, 83420,
58 82897, 82384, 81880, 81385, 58 82897, 82384, 81880, 81385,
59 80899, 80422, 79953, 79492, 59 80899, 80422, 79953, 79492,
60 79039, 78594, 78156, 77726, 60 79039, 78594, 78156, 77726,
61 77302, 76885, 76475, 76072, 61 77302, 76885, 76475, 76072,
62 75674, 75283, 74898, 74519, 62 75674, 75283, 74898, 74519,
63 74146, 73778, 73415, 73058, 63 74146, 73778, 73415, 73058,
64 72706, 72359, 72016, 71679, 64 72706, 72359, 72016, 71679,
65 71347, 71019, 70695, 70376, 65 71347, 71019, 70695, 70376,
66 70061, 69750, 69444, 69141, 66 70061, 69750, 69444, 69141,
67 68842, 68548, 68256, 67969, 67 68842, 68548, 68256, 67969,
68 67685, 67405, 67128, 66855, 68 67685, 67405, 67128, 66855,
69 66585, 66318, 66054, 65794, 69 66585, 66318, 66054, 65794,
70 65536, 70 65536,
71}; 71};
72 72
73static const long INVSQ_LOOKUP_IDel[64] ={ 73static const long INVSQ_LOOKUP_IDel[64] ={
@@ -93,39 +93,39 @@ static const long INVSQ_LOOKUP_IDel[64] ={
93#define COS_LOOKUP_I_MASK 511 93#define COS_LOOKUP_I_MASK 511
94#define COS_LOOKUP_I_SZ 128 94#define COS_LOOKUP_I_SZ 128
95static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={ 95static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={
96 16384, 16379, 16364, 16340, 96 16384, 16379, 16364, 16340,
97 16305, 16261, 16207, 16143, 97 16305, 16261, 16207, 16143,
98 16069, 15986, 15893, 15791, 98 16069, 15986, 15893, 15791,
99 15679, 15557, 15426, 15286, 99 15679, 15557, 15426, 15286,
100 15137, 14978, 14811, 14635, 100 15137, 14978, 14811, 14635,
101 14449, 14256, 14053, 13842, 101 14449, 14256, 14053, 13842,
102 13623, 13395, 13160, 12916, 102 13623, 13395, 13160, 12916,
103 12665, 12406, 12140, 11866, 103 12665, 12406, 12140, 11866,
104 11585, 11297, 11003, 10702, 104 11585, 11297, 11003, 10702,
105 10394, 10080, 9760, 9434, 105 10394, 10080, 9760, 9434,
106 9102, 8765, 8423, 8076, 106 9102, 8765, 8423, 8076,
107 7723, 7366, 7005, 6639, 107 7723, 7366, 7005, 6639,
108 6270, 5897, 5520, 5139, 108 6270, 5897, 5520, 5139,
109 4756, 4370, 3981, 3590, 109 4756, 4370, 3981, 3590,
110 3196, 2801, 2404, 2006, 110 3196, 2801, 2404, 2006,
111 1606, 1205, 804, 402, 111 1606, 1205, 804, 402,
112 0, -401, -803, -1204, 112 0, -401, -803, -1204,
113 -1605, -2005, -2403, -2800, 113 -1605, -2005, -2403, -2800,
114 -3195, -3589, -3980, -4369, 114 -3195, -3589, -3980, -4369,
115 -4755, -5138, -5519, -5896, 115 -4755, -5138, -5519, -5896,
116 -6269, -6638, -7004, -7365, 116 -6269, -6638, -7004, -7365,
117 -7722, -8075, -8422, -8764, 117 -7722, -8075, -8422, -8764,
118 -9101, -9433, -9759, -10079, 118 -9101, -9433, -9759, -10079,
119 -10393, -10701, -11002, -11296, 119 -10393, -10701, -11002, -11296,
120 -11584, -11865, -12139, -12405, 120 -11584, -11865, -12139, -12405,
121 -12664, -12915, -13159, -13394, 121 -12664, -12915, -13159, -13394,
122 -13622, -13841, -14052, -14255, 122 -13622, -13841, -14052, -14255,
123 -14448, -14634, -14810, -14977, 123 -14448, -14634, -14810, -14977,
124 -15136, -15285, -15425, -15556, 124 -15136, -15285, -15425, -15556,
125 -15678, -15790, -15892, -15985, 125 -15678, -15790, -15892, -15985,
126 -16068, -16142, -16206, -16260, 126 -16068, -16142, -16206, -16260,
127 -16304, -16339, -16363, -16378, 127 -16304, -16339, -16363, -16378,
128 -16383, 128 -16383,
129}; 129};
130 130
131#endif 131#endif
diff --git a/apps/codecs/libtremor/misc.h b/apps/codecs/libtremor/misc.h
index 59ce6dbb74..6e22f20008 100644
--- a/apps/codecs/libtremor/misc.h
+++ b/apps/codecs/libtremor/misc.h
@@ -119,33 +119,33 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
119 119
120/* replaced XPROD32 with a macro to avoid memory reference 120/* replaced XPROD32 with a macro to avoid memory reference
121 _x, _y are the results (must be l-values) */ 121 _x, _y are the results (must be l-values) */
122#define XPROD32(_a, _b, _t, _v, _x, _y) \ 122#define XPROD32(_a, _b, _t, _v, _x, _y) \
123 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ 123 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
124 (_y)=MULT32(_b,_t)-MULT32(_a,_v); } 124 (_y)=MULT32(_b,_t)-MULT32(_a,_v); }
125 125
126 126
127#ifdef __i386__ 127#ifdef __i386__
128 128
129#define XPROD31(_a, _b, _t, _v, _x, _y) \ 129#define XPROD31(_a, _b, _t, _v, _x, _y) \
130 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ 130 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
131 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } 131 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
132#define XNPROD31(_a, _b, _t, _v, _x, _y) \ 132#define XNPROD31(_a, _b, _t, _v, _x, _y) \
133 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ 133 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
134 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } 134 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
135 135
136#else 136#else
137 137
138static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, 138static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
139 ogg_int32_t t, ogg_int32_t v, 139 ogg_int32_t t, ogg_int32_t v,
140 ogg_int32_t *x, ogg_int32_t *y) 140 ogg_int32_t *x, ogg_int32_t *y)
141{ 141{
142 *x = MULT31(a, t) + MULT31(b, v); 142 *x = MULT31(a, t) + MULT31(b, v);
143 *y = MULT31(b, t) - MULT31(a, v); 143 *y = MULT31(b, t) - MULT31(a, v);
144} 144}
145 145
146static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, 146static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
147 ogg_int32_t t, ogg_int32_t v, 147 ogg_int32_t t, ogg_int32_t v,
148 ogg_int32_t *x, ogg_int32_t *y) 148 ogg_int32_t *x, ogg_int32_t *y)
149{ 149{
150 *x = MULT31(a, t) - MULT31(b, v); 150 *x = MULT31(a, t) - MULT31(b, v);
151 *y = MULT31(b, t) + MULT31(a, v); 151 *y = MULT31(b, t) + MULT31(a, v);
@@ -217,8 +217,8 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
217#endif 217#endif
218 218
219static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, 219static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
220 ogg_int32_t b,ogg_int32_t bp, 220 ogg_int32_t b,ogg_int32_t bp,
221 ogg_int32_t *p){ 221 ogg_int32_t *p){
222 if(a && b){ 222 if(a && b){
223#ifndef _LOW_ACCURACY_ 223#ifndef _LOW_ACCURACY_
224 *p=ap+bp+32; 224 *p=ap+bp+32;
@@ -232,16 +232,16 @@ static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
232} 232}
233 233
234static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, 234static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
235 ogg_int32_t i, 235 ogg_int32_t i,
236 ogg_int32_t *p){ 236 ogg_int32_t *p){
237 237
238 int ip=_ilog(abs(i))-31; 238 int ip=_ilog(abs(i))-31;
239 return VFLOAT_MULT(a,ap,i<<-ip,ip,p); 239 return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
240} 240}
241 241
242static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, 242static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
243 ogg_int32_t b,ogg_int32_t bp, 243 ogg_int32_t b,ogg_int32_t bp,
244 ogg_int32_t *p){ 244 ogg_int32_t *p){
245 245
246 if(!a){ 246 if(!a){
247 *p=bp; 247 *p=bp;
diff --git a/apps/codecs/libtremor/sharedbook.c b/apps/codecs/libtremor/sharedbook.c
index 853d1f5d61..10fae80c84 100644
--- a/apps/codecs/libtremor/sharedbook.c
+++ b/apps/codecs/libtremor/sharedbook.c
@@ -80,45 +80,45 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
80 ogg_uint32_t entry=marker[length]; 80 ogg_uint32_t entry=marker[length];
81 81
82 /* when we claim a node for an entry, we also claim the nodes 82 /* when we claim a node for an entry, we also claim the nodes
83 below it (pruning off the imagined tree that may have dangled 83 below it (pruning off the imagined tree that may have dangled
84 from it) as well as blocking the use of any nodes directly 84 from it) as well as blocking the use of any nodes directly
85 above for leaves */ 85 above for leaves */
86 86
87 /* update ourself */ 87 /* update ourself */
88 if(length<32 && (entry>>length)){ 88 if(length<32 && (entry>>length)){
89 /* error condition; the lengths must specify an overpopulated tree */ 89 /* error condition; the lengths must specify an overpopulated tree */
90 _ogg_free(r); 90 _ogg_free(r);
91 return(NULL); 91 return(NULL);
92 } 92 }
93 r[count++]=entry; 93 r[count++]=entry;
94 94
95 /* Look to see if the next shorter marker points to the node 95 /* Look to see if the next shorter marker points to the node
96 above. if so, update it and repeat. */ 96 above. if so, update it and repeat. */
97 { 97 {
98 for(j=length;j>0;j--){ 98 for(j=length;j>0;j--){
99 99
100 if(marker[j]&1){ 100 if(marker[j]&1){
101 /* have to jump branches */ 101 /* have to jump branches */
102 if(j==1) 102 if(j==1)
103 marker[1]++; 103 marker[1]++;
104 else 104 else
105 marker[j]=marker[j-1]<<1; 105 marker[j]=marker[j-1]<<1;
106 break; /* invariant says next upper marker would already 106 break; /* invariant says next upper marker would already
107 have been moved if it was on the same path */ 107 have been moved if it was on the same path */
108 } 108 }
109 marker[j]++; 109 marker[j]++;
110 } 110 }
111 } 111 }
112 112
113 /* prune the tree; the implicit invariant says all the longer 113 /* prune the tree; the implicit invariant says all the longer
114 markers were dangling from our just-taken node. Dangle them 114 markers were dangling from our just-taken node. Dangle them
115 from our *new* node. */ 115 from our *new* node. */
116 for(j=length+1;j<33;j++) 116 for(j=length+1;j<33;j++)
117 if((marker[j]>>1) == entry){ 117 if((marker[j]>>1) == entry){
118 entry=marker[j]; 118 entry=marker[j];
119 marker[j]=marker[j-1]<<1; 119 marker[j]=marker[j-1]<<1;
120 }else 120 }else
121 break; 121 break;
122 }else 122 }else
123 if(sparsecount==0)count++; 123 if(sparsecount==0)count++;
124 } 124 }
@@ -134,7 +134,7 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
134 134
135 if(sparsecount){ 135 if(sparsecount){
136 if(l[i]) 136 if(l[i])
137 r[count++]=temp; 137 r[count++]=temp;
138 }else 138 }else
139 r[count++]=temp; 139 r[count++]=temp;
140 } 140 }
@@ -162,9 +162,9 @@ long _book_maptype1_quantvals(const static_codebook *b){
162 return(vals); 162 return(vals);
163 }else{ 163 }else{
164 if(acc>b->entries){ 164 if(acc>b->entries){
165 vals--; 165 vals--;
166 }else{ 166 }else{
167 vals++; 167 vals++;
168 } 168 }
169 } 169 }
170 } 170 }
@@ -197,85 +197,85 @@ static ogg_int32_t *_book_unquantize(const static_codebook *b,int n,
197 switch(b->maptype){ 197 switch(b->maptype){
198 case 1: 198 case 1:
199 /* most of the time, entries%dimensions == 0, but we need to be 199 /* most of the time, entries%dimensions == 0, but we need to be
200 well defined. We define that the possible vales at each 200 well defined. We define that the possible vales at each
201 scalar is values == entries/dim. If entries%dim != 0, we'll 201 scalar is values == entries/dim. If entries%dim != 0, we'll
202 have 'too few' values (values*dim<entries), which means that 202 have 'too few' values (values*dim<entries), which means that
203 we'll have 'left over' entries; left over entries use zeroed 203 we'll have 'left over' entries; left over entries use zeroed
204 values (and are wasted). So don't generate codebooks like 204 values (and are wasted). So don't generate codebooks like
205 that */ 205 that */
206 quantvals=_book_maptype1_quantvals(b); 206 quantvals=_book_maptype1_quantvals(b);
207 for(j=0;j<b->entries;j++){ 207 for(j=0;j<b->entries;j++){
208 if((sparsemap && b->lengthlist[j]) || !sparsemap){ 208 if((sparsemap && b->lengthlist[j]) || !sparsemap){
209 ogg_int32_t last=0; 209 ogg_int32_t last=0;
210 int lastpoint=0; 210 int lastpoint=0;
211 int indexdiv=1; 211 int indexdiv=1;
212 for(k=0;k<b->dim;k++){ 212 for(k=0;k<b->dim;k++){
213 int index= (j/indexdiv)%quantvals; 213 int index= (j/indexdiv)%quantvals;
214 int point=0; 214 int point=0;
215 int val=VFLOAT_MULTI(delta,delpoint, 215 int val=VFLOAT_MULTI(delta,delpoint,
216 abs(b->quantlist[index]),&point); 216 abs(b->quantlist[index]),&point);
217 217
218 val=VFLOAT_ADD(mindel,minpoint,val,point,&point); 218 val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
219 val=VFLOAT_ADD(last,lastpoint,val,point,&point); 219 val=VFLOAT_ADD(last,lastpoint,val,point,&point);
220 220
221 if(b->q_sequencep){ 221 if(b->q_sequencep){
222 last=val; 222 last=val;
223 lastpoint=point; 223 lastpoint=point;
224 } 224 }
225 225
226 if(sparsemap){ 226 if(sparsemap){
227 r[sparsemap[count]*b->dim+k]=val; 227 r[sparsemap[count]*b->dim+k]=val;
228 rp[sparsemap[count]*b->dim+k]=point; 228 rp[sparsemap[count]*b->dim+k]=point;
229 }else{ 229 }else{
230 r[count*b->dim+k]=val; 230 r[count*b->dim+k]=val;
231 rp[count*b->dim+k]=point; 231 rp[count*b->dim+k]=point;
232 } 232 }
233 if(*maxpoint<point)*maxpoint=point; 233 if(*maxpoint<point)*maxpoint=point;
234 indexdiv*=quantvals; 234 indexdiv*=quantvals;
235 } 235 }
236 count++; 236 count++;
237 } 237 }
238 238
239 } 239 }
240 break; 240 break;
241 case 2: 241 case 2:
242 for(j=0;j<b->entries;j++){ 242 for(j=0;j<b->entries;j++){
243 if((sparsemap && b->lengthlist[j]) || !sparsemap){ 243 if((sparsemap && b->lengthlist[j]) || !sparsemap){
244 ogg_int32_t last=0; 244 ogg_int32_t last=0;
245 int lastpoint=0; 245 int lastpoint=0;
246 246
247 for(k=0;k<b->dim;k++){ 247 for(k=0;k<b->dim;k++){
248 int point=0; 248 int point=0;
249 int val=VFLOAT_MULTI(delta,delpoint, 249 int val=VFLOAT_MULTI(delta,delpoint,
250 abs(b->quantlist[j*b->dim+k]),&point); 250 abs(b->quantlist[j*b->dim+k]),&point);
251 251
252 val=VFLOAT_ADD(mindel,minpoint,val,point,&point); 252 val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
253 val=VFLOAT_ADD(last,lastpoint,val,point,&point); 253 val=VFLOAT_ADD(last,lastpoint,val,point,&point);
254 254
255 if(b->q_sequencep){ 255 if(b->q_sequencep){
256 last=val; 256 last=val;
257 lastpoint=point; 257 lastpoint=point;
258 } 258 }
259 259
260 if(sparsemap){ 260 if(sparsemap){
261 r[sparsemap[count]*b->dim+k]=val; 261 r[sparsemap[count]*b->dim+k]=val;
262 rp[sparsemap[count]*b->dim+k]=point; 262 rp[sparsemap[count]*b->dim+k]=point;
263 }else{ 263 }else{
264 r[count*b->dim+k]=val; 264 r[count*b->dim+k]=val;
265 rp[count*b->dim+k]=point; 265 rp[count*b->dim+k]=point;
266 } 266 }
267 if(*maxpoint<point)*maxpoint=point; 267 if(*maxpoint<point)*maxpoint=point;
268 } 268 }
269 count++; 269 count++;
270 } 270 }
271 } 271 }
272 break; 272 break;
273 } 273 }
274 274
275 for(j=0;j<n*b->dim;j++) 275 for(j=0;j<n*b->dim;j++)
276 if(rp[j]<*maxpoint) 276 if(rp[j]<*maxpoint)
277 r[j]>>=*maxpoint-rp[j]; 277 r[j]>>=*maxpoint-rp[j];
278 278
279 _ogg_free(rp); 279 _ogg_free(rp);
280 return(r); 280 return(r);
281 } 281 }
@@ -383,12 +383,12 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
383 383
384 for(n=0,i=0;i<s->entries;i++) 384 for(n=0,i=0;i<s->entries;i++)
385 if(s->lengthlist[i]>0) 385 if(s->lengthlist[i]>0)
386 c->dec_index[sortindex[n++]]=i; 386 c->dec_index[sortindex[n++]]=i;
387 387
388 c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); 388 c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
389 for(n=0,i=0;i<s->entries;i++) 389 for(n=0,i=0;i<s->entries;i++)
390 if(s->lengthlist[i]>0) 390 if(s->lengthlist[i]>0)
391 c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; 391 c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
392 392
393 _ogg_free(sortindex); 393 _ogg_free(sortindex);
394 c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ 394 c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
@@ -401,11 +401,11 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
401 401
402 for(i=0;i<n;i++){ 402 for(i=0;i<n;i++){
403 if(c->dec_maxlength<c->dec_codelengths[i]) 403 if(c->dec_maxlength<c->dec_codelengths[i])
404 c->dec_maxlength=c->dec_codelengths[i]; 404 c->dec_maxlength=c->dec_codelengths[i];
405 if(c->dec_codelengths[i]<=c->dec_firsttablen){ 405 if(c->dec_codelengths[i]<=c->dec_firsttablen){
406 ogg_uint32_t orig=bitreverse(c->codelist[i]); 406 ogg_uint32_t orig=bitreverse(c->codelist[i]);
407 for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) 407 for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
408 c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1; 408 c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
409 } 409 }
410 } 410 }
411 411
@@ -416,24 +416,24 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
416 long lo=0,hi=0; 416 long lo=0,hi=0;
417 417
418 for(i=0;i<tabn;i++){ 418 for(i=0;i<tabn;i++){
419 ogg_uint32_t word=i<<(32-c->dec_firsttablen); 419 ogg_uint32_t word=i<<(32-c->dec_firsttablen);
420 if(c->dec_firsttable[bitreverse(word)]==0){ 420 if(c->dec_firsttable[bitreverse(word)]==0){
421 while((lo+1)<n && c->codelist[lo+1]<=word)lo++; 421 while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
422 while( hi<n && word>=(c->codelist[hi]&mask))hi++; 422 while( hi<n && word>=(c->codelist[hi]&mask))hi++;
423 423
424 /* we only actually have 15 bits per hint to play with here. 424 /* we only actually have 15 bits per hint to play with here.
425 In order to overflow gracefully (nothing breaks, efficiency 425 In order to overflow gracefully (nothing breaks, efficiency
426 just drops), encode as the difference from the extremes. */ 426 just drops), encode as the difference from the extremes. */
427 { 427 {
428 unsigned long loval=lo; 428 unsigned long loval=lo;
429 unsigned long hival=n-hi; 429 unsigned long hival=n-hi;
430 430
431 if(loval>0x7fff)loval=0x7fff; 431 if(loval>0x7fff)loval=0x7fff;
432 if(hival>0x7fff)hival=0x7fff; 432 if(hival>0x7fff)hival=0x7fff;
433 c->dec_firsttable[bitreverse(word)]= 433 c->dec_firsttable[bitreverse(word)]=
434 0x80000000UL | (loval<<15) | hival; 434 0x80000000UL | (loval<<15) | hival;
435 } 435 }
436 } 436 }
437 } 437 }
438 } 438 }
439 } 439 }
diff --git a/apps/codecs/libtremor/window.h b/apps/codecs/libtremor/window.h
index 27647fe62e..f11742e1dd 100644
--- a/apps/codecs/libtremor/window.h
+++ b/apps/codecs/libtremor/window.h
@@ -20,8 +20,8 @@
20 20
21extern const void *_vorbis_window(int type,int left); 21extern const void *_vorbis_window(int type,int left);
22extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], 22extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
23 long *blocksizes, 23 long *blocksizes,
24 int lW,int W,int nW); 24 int lW,int W,int nW);
25 25
26 26
27#endif 27#endif
diff --git a/apps/codecs/libwavpack/pack.c b/apps/codecs/libwavpack/pack.c
index 9ccfa07261..a46d05fe14 100644
--- a/apps/codecs/libwavpack/pack.c
+++ b/apps/codecs/libwavpack/pack.c
@@ -409,13 +409,13 @@ static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32
409 int32_t 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);
diff --git a/apps/codecs/libwma/asf.h b/apps/codecs/libwma/asf.h
index 8cae8fae1d..3f7cc2e557 100644
--- a/apps/codecs/libwma/asf.h
+++ b/apps/codecs/libwma/asf.h
@@ -10,14 +10,14 @@
10struct asf_waveformatex_s { 10struct asf_waveformatex_s {
11 uint32_t packet_size; 11 uint32_t packet_size;
12 int audiostream; 12 int audiostream;
13 uint16_t codec_id; 13 uint16_t codec_id;
14 uint16_t channels; 14 uint16_t channels;
15 uint32_t rate; 15 uint32_t rate;
16 uint32_t bitrate; 16 uint32_t bitrate;
17 uint16_t blockalign; 17 uint16_t blockalign;
18 uint16_t bitspersample; 18 uint16_t bitspersample;
19 uint16_t datalen; 19 uint16_t datalen;
20 uint8_t data[6]; 20 uint8_t data[6];
21}; 21};
22typedef struct asf_waveformatex_s asf_waveformatex_t; 22typedef struct asf_waveformatex_s asf_waveformatex_t;
23 23