annotate tremor/misc.h @ 35026:4783ed655c94

Add missing newline in error message.
author cehoyos
date Mon, 27 Aug 2012 07:09:34 +0000
parents 997ae534ebfe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
1 /********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
2 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
4 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
8 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
11 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
12 ********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
13
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
14 function: miscellaneous math and prototypes
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
15
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
16 ********************************************************************/
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
17
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
18 #ifndef _V_RANDOM_H_
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
19 #define _V_RANDOM_H_
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
20 #include "ivorbiscodec.h"
29997
997ae534ebfe Add missing #includes to fix a bunch of 'implicit declaration of..' warnings.
diego
parents: 29401
diff changeset
21 #include "codec_internal.h"
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
22 #include "os_types.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
23
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
24 #include "asm_arm.h"
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 14280
diff changeset
25
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
26 #ifndef _V_WIDE_MATH
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
27 #define _V_WIDE_MATH
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 14280
diff changeset
28
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
29 #ifndef _LOW_ACCURACY_
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
30 /* 64 bit multiply */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
31
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
32 #include <sys/types.h>
29997
997ae534ebfe Add missing #includes to fix a bunch of 'implicit declaration of..' warnings.
diego
parents: 29401
diff changeset
33 #include <stdlib.h>
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
34 #include "config.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
35
29401
f01023c524c3 Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents: 29264
diff changeset
36 #if !HAVE_BIGENDIAN
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
37 union magic {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
38 struct {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
39 ogg_int32_t lo;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
40 ogg_int32_t hi;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
41 } halves;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
42 ogg_int64_t whole;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
43 };
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
44 #else
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
45 union magic {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
46 struct {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
47 ogg_int32_t hi;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
48 ogg_int32_t lo;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
49 } halves;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
50 ogg_int64_t whole;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
51 };
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
52 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
53
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
54 static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
55 union magic magic;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
56 magic.whole = (ogg_int64_t)x * y;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
57 return magic.halves.hi;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
58 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
59
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
60 static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
61 return MULT32(x,y)<<1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
62 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
63
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
64 static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
65 union magic magic;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
66 magic.whole = (ogg_int64_t)x * y;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
67 return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
68 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
69
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
70 #else
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
71 /* 32 bit multiply, more portable but less accurate */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
72
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
73 /*
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
74 * Note: Precision is biased towards the first argument therefore ordering
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
75 * is important. Shift values were chosen for the best sound quality after
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
76 * many listening tests.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
77 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
78
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
79 /*
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
80 * For MULT32 and MULT31: The second argument is always a lookup table
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 14280
diff changeset
81 * value already preshifted from 31 to 8 bits. We therefore take the
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
82 * opportunity to save on text space and use unsigned char for those
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
83 * tables in this case.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
84 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
85
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
86 static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
87 return (x >> 9) * y; /* y preshifted >>23 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
88 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
89
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
90 static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
91 return (x >> 8) * y; /* y preshifted >>23 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
92 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
93
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
94 static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
95 return (x >> 6) * y; /* y preshifted >>9 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
96 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
97
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
98 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
99
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
100 /*
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
101 * This should be used as a memory barrier, forcing all cached values in
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
102 * registers to wr writen back to memory. Might or might not be beneficial
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
103 * depending on the architecture and compiler.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
104 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
105 #define MB()
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
106
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
107 /*
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
108 * The XPROD functions are meant to optimize the cross products found all
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
109 * over the place in mdct.c by forcing memory operation ordering to avoid
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
110 * unnecessary register reloads as soon as memory is being written to.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
111 * However this is only beneficial on CPUs with a sane number of general
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
112 * purpose registers which exclude the Intel x86. On Intel, better let the
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
113 * compiler actually reload registers directly from original memory by using
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
114 * macros.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
115 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
116
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
117 #ifdef __i386__
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
118
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
119 #define XPROD32(_a, _b, _t, _v, _x, _y) \
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
120 { *(_x)=MULT32(_a,_t)+MULT32(_b,_v); \
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
121 *(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
122 #define XPROD31(_a, _b, _t, _v, _x, _y) \
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
123 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
124 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
125 #define XNPROD31(_a, _b, _t, _v, _x, _y) \
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
126 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
127 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
128
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
129 #else
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
130
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
131 static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
132 ogg_int32_t t, ogg_int32_t v,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
133 ogg_int32_t *x, ogg_int32_t *y)
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
134 {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
135 *x = MULT32(a, t) + MULT32(b, v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
136 *y = MULT32(b, t) - MULT32(a, v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
137 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
138
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
139 static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
140 ogg_int32_t t, ogg_int32_t v,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
141 ogg_int32_t *x, ogg_int32_t *y)
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
142 {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
143 *x = MULT31(a, t) + MULT31(b, v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
144 *y = MULT31(b, t) - MULT31(a, v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
145 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
146
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
147 static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
148 ogg_int32_t t, ogg_int32_t v,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
149 ogg_int32_t *x, ogg_int32_t *y)
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
150 {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
151 *x = MULT31(a, t) - MULT31(b, v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
152 *y = MULT31(b, t) + MULT31(a, v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
153 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
154
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
155 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
156
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
157 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
158
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
159 #ifndef _V_CLIP_MATH
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
160 #define _V_CLIP_MATH
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
161
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
162 static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
163 int ret=x;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
164 ret-= ((x<=32767)-1)&(x-32767);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
165 ret-= ((x>=-32768)-1)&(x+32768);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
166 return(ret);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
167 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
168
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
169 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
170
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
171 static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
172 ogg_int32_t b,ogg_int32_t bp,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
173 ogg_int32_t *p){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
174 if(a && b){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
175 #ifndef _LOW_ACCURACY_
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
176 *p=ap+bp+32;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
177 return MULT32(a,b);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
178 #else
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
179 *p=ap+bp+31;
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 14280
diff changeset
180 return (a>>15)*(b>>16);
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
181 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
182 }else
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
183 return 0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
184 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
185
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
186 static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
187 ogg_int32_t i,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
188 ogg_int32_t *p){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
189
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
190 int ip=_ilog(abs(i))-31;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
191 return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
192 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
193
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
194 static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
195 ogg_int32_t b,ogg_int32_t bp,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
196 ogg_int32_t *p){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
197
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
198 if(!a){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
199 *p=bp;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
200 return b;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
201 }else if(!b){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
202 *p=ap;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
203 return a;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
204 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
205
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
206 /* yes, this can leak a bit. */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
207 if(ap>bp){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
208 int shift=ap-bp+1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
209 *p=ap+1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
210 a>>=1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
211 if(shift<32){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
212 b=(b+(1<<(shift-1)))>>shift;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
213 }else{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
214 b=0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
215 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
216 }else{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
217 int shift=bp-ap+1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
218 *p=bp+1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
219 b>>=1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
220 if(shift<32){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
221 a=(a+(1<<(shift-1)))>>shift;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
222 }else{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
223 a=0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
224 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
225 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
226
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
227 a+=b;
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 14280
diff changeset
228 if((a&0xc0000000)==0xc0000000 ||
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
229 (a&0xc0000000)==0){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
230 a<<=1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
231 (*p)--;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
232 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
233 return(a);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
234 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
235
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
236 #endif
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
237
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
238
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
239
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
240