comparison adpcm.c @ 7245:b79a3cd9ed94 libavcodec

Change MS ADPCM table so they fit into int8_t and change array type.
author reimar
date Fri, 11 Jul 2008 21:38:42 +0000
parents 54f8d960f15b
children c9dc58950620
comparison
equal deleted inserted replaced
7244:9aa321d5d510 7245:b79a3cd9ed94
83 static const int AdaptationTable[] = { 83 static const int AdaptationTable[] = {
84 230, 230, 230, 230, 307, 409, 512, 614, 84 230, 230, 230, 230, 307, 409, 512, 614,
85 768, 614, 512, 409, 307, 230, 230, 230 85 768, 614, 512, 409, 307, 230, 230, 230
86 }; 86 };
87 87
88 static const int AdaptCoeff1[] = { 88 static const int8_t AdaptCoeff1[] = {
89 256, 512, 0, 192, 240, 460, 392 89 64, 128, 0, 48, 60, 115, 98
90 }; 90 };
91 91
92 static const int AdaptCoeff2[] = { 92 static const int8_t AdaptCoeff2[] = {
93 0, -256, 0, 64, 0, -208, -232 93 0, -64, 0, 16, 0, -52, -58
94 }; 94 };
95 95
96 /* These are for CD-ROM XA ADPCM */ 96 /* These are for CD-ROM XA ADPCM */
97 static const int xa_adpcm_table[5][2] = { 97 static const int xa_adpcm_table[5][2] = {
98 { 0, 0 }, 98 { 0, 0 },
224 224
225 static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, short sample) 225 static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, short sample)
226 { 226 {
227 int predictor, nibble, bias; 227 int predictor, nibble, bias;
228 228
229 predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256; 229 predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
230 230
231 nibble= sample - predictor; 231 nibble= sample - predictor;
232 if(nibble>=0) bias= c->idelta/2; 232 if(nibble>=0) bias= c->idelta/2;
233 else bias=-c->idelta/2; 233 else bias=-c->idelta/2;
234 234
328 // higher j have higher ssd already, so they're unlikely to use a suboptimal next sample too 328 // higher j have higher ssd already, so they're unlikely to use a suboptimal next sample too
329 const int range = (j < frontier/2) ? 1 : 0; 329 const int range = (j < frontier/2) ? 1 : 0;
330 const int step = nodes[j]->step; 330 const int step = nodes[j]->step;
331 int nidx; 331 int nidx;
332 if(version == CODEC_ID_ADPCM_MS) { 332 if(version == CODEC_ID_ADPCM_MS) {
333 const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 256; 333 const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 64;
334 const int div = (sample - predictor) / step; 334 const int div = (sample - predictor) / step;
335 const int nmin = av_clip(div-range, -8, 6); 335 const int nmin = av_clip(div-range, -8, 6);
336 const int nmax = av_clip(div+range, -7, 7); 336 const int nmax = av_clip(div+range, -7, 7);
337 for(nidx=nmin; nidx<=nmax; nidx++) { 337 for(nidx=nmin; nidx<=nmax; nidx++) {
338 const int nibble = nidx & 0xf; 338 const int nibble = nidx & 0xf;