comparison ac3.c @ 4879:60603c9c89d1 libavcodec

move ac3 tables from a .h to a .c
author aurel
date Wed, 25 Apr 2007 22:12:51 +0000
parents 40f3a7f2b1fd
children b24bcdd0ae86
comparison
equal deleted inserted replaced
4878:0e38c828bdae 4879:60603c9c89d1
24 * Common code between AC3 encoder and decoder. 24 * Common code between AC3 encoder and decoder.
25 */ 25 */
26 26
27 #include "avcodec.h" 27 #include "avcodec.h"
28 #include "ac3.h" 28 #include "ac3.h"
29 #include "ac3tab.h"
30 #include "bitstream.h" 29 #include "bitstream.h"
30
31 static uint8_t bndtab[51];
32 static uint8_t masktab[253];
31 33
32 static inline int calc_lowcomp1(int a, int b0, int b1, int c) 34 static inline int calc_lowcomp1(int a, int b0, int b1, int c)
33 { 35 {
34 if ((b0 + 256) == b1) { 36 if ((b0 + 256) == b1) {
35 a = c; 37 a = c;
68 j++; 70 j++;
69 end1 = FFMIN(bndtab[k+1], end); 71 end1 = FFMIN(bndtab[k+1], end);
70 for(i=j;i<end1;i++) { 72 for(i=j;i<end1;i++) {
71 /* logadd */ 73 /* logadd */
72 int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255); 74 int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255);
73 v = FFMAX(v, psd[j]) + latab[adr]; 75 v = FFMAX(v, psd[j]) + ff_ac3_latab[adr];
74 j++; 76 j++;
75 } 77 }
76 bndpsd[k]=v; 78 bndpsd[k]=v;
77 k++; 79 k++;
78 } while (end > bndtab[k]); 80 } while (end > bndtab[k]);
145 for (bin = bndstrt; bin < bndend; bin++) { 147 for (bin = bndstrt; bin < bndend; bin++) {
146 tmp = s->dbknee - bndpsd[bin]; 148 tmp = s->dbknee - bndpsd[bin];
147 if (tmp > 0) { 149 if (tmp > 0) {
148 excite[bin] += tmp >> 2; 150 excite[bin] += tmp >> 2;
149 } 151 }
150 mask[bin] = FFMAX(hth[bin >> s->halfratecod][s->fscod], excite[bin]); 152 mask[bin] = FFMAX(ff_ac3_hth[bin >> s->halfratecod][s->fscod], excite[bin]);
151 } 153 }
152 154
153 /* delta bit allocation */ 155 /* delta bit allocation */
154 156
155 if (deltbae == 0 || deltbae == 1) { 157 if (deltbae == 0 || deltbae == 1) {
183 185
184 i = start; 186 i = start;
185 j = masktab[start]; 187 j = masktab[start];
186 do { 188 do {
187 v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor; 189 v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor;
188 end1 = FFMIN(bndtab[j] + bndsz[j], end); 190 end1 = FFMIN(bndtab[j] + ff_ac3_bndsz[j], end);
189 for (k = i; k < end1; k++) { 191 for (k = i; k < end1; k++) {
190 address = av_clip((psd[i] - v) >> 5, 0, 63); 192 address = av_clip((psd[i] - v) >> 5, 0, 63);
191 bap[i] = baptab[address]; 193 bap[i] = ff_ac3_baptab[address];
192 i++; 194 i++;
193 } 195 }
194 } while (end > bndtab[j++]); 196 } while (end > bndtab[j++]);
195 } 197 }
196 198
227 /* compute bndtab and masktab from bandsz */ 229 /* compute bndtab and masktab from bandsz */
228 k = 0; 230 k = 0;
229 l = 0; 231 l = 0;
230 for(i=0;i<50;i++) { 232 for(i=0;i<50;i++) {
231 bndtab[i] = l; 233 bndtab[i] = l;
232 v = bndsz[i]; 234 v = ff_ac3_bndsz[i];
233 for(j=0;j<v;j++) masktab[k++]=i; 235 for(j=0;j<v;j++) masktab[k++]=i;
234 l += v; 236 l += v;
235 } 237 }
236 bndtab[50] = l; 238 bndtab[50] = l;
237 } 239 }