comparison ra144.c @ 6870:62ce6173d0ea libavcodec

Remove gbuf2 from context
author vitor
date Sun, 25 May 2008 16:10:08 +0000
parents 2ed146e1ff55
children c3a92478875d
comparison
equal deleted inserted replaced
6869:59ae0494b656 6870:62ce6173d0ea
30 30
31 31
32 /* internal globals */ 32 /* internal globals */
33 typedef struct { 33 typedef struct {
34 unsigned int oldval; 34 unsigned int oldval;
35 unsigned short gbuf2[4][30];
36 35
37 /* the swapped buffers */ 36 /* the swapped buffers */
38 unsigned int swapbuffers[4][10]; 37 unsigned int swapbuffers[4][10];
39 unsigned int *swapbuf1; 38 unsigned int *swapbuf1;
40 unsigned int *swapbuf2; 39 unsigned int *swapbuf2;
237 etable2[c], block); 236 etable2[c], block);
238 237
239 final(gsp, block, output_buffer, glob->buffer, BLOCKSIZE); 238 final(gsp, block, output_buffer, glob->buffer, BLOCKSIZE);
240 } 239 }
241 240
242 static int dec1(Real144_internal *glob, const int *data, const int *inp, 241 static int dec1(signed short *decsp, const int *data, const int *inp,
243 int f, int block_idx) 242 int f)
244 { 243 {
245 short *ptr,*end; 244 short *ptr,*end;
246 signed short *decsp = glob->gbuf2[block_idx];
247 245
248 end = (ptr = decsp) + 30; 246 end = (ptr = decsp) + 30;
249 247
250 while (ptr < end) 248 while (ptr < end)
251 *(ptr++) = *(inp++); 249 *(ptr++) = *(inp++);
294 FFSWAP(int *, bp1, bp2); 292 FFSWAP(int *, bp1, bp2);
295 } 293 }
296 return retval; 294 return retval;
297 } 295 }
298 296
299 static int dec2(Real144_internal *glob, const int *data, const int *inp, 297 static int dec2(signed short *decsp, const int *data, const int *inp,
300 int f, const int *inp2, int l) 298 int f, const int *inp2, int l)
301 { 299 {
302 unsigned const int *ptr1,*ptr2; 300 unsigned const int *ptr1,*ptr2;
303 int work[10]; 301 int work[10];
304 int a,b; 302 int a,b;
305 int x; 303 int x;
306 int result; 304 int result;
307 signed short *decsp = glob->gbuf2[l];
308 unsigned short *sptr = decsp; 305 unsigned short *sptr = decsp;
309 306
310 if(l + 1 < NBLOCKS / 2) 307 if(l + 1 < NBLOCKS / 2)
311 a = NBLOCKS - (l + 1); 308 a = NBLOCKS - (l + 1);
312 else 309 else
321 *(sptr++) = (a * (*ptr1++) + b * (*ptr2++)) >> 2; 318 *(sptr++) = (a * (*ptr1++) + b * (*ptr2++)) >> 2;
322 319
323 result = eq(decsp, work); 320 result = eq(decsp, work);
324 321
325 if (result == 1) { 322 if (result == 1) {
326 return dec1(glob, data, inp, f, l); 323 return dec1(decsp, data, inp, f);
327 } else { 324 } else {
328 return rms(work, f); 325 return rms(work, f);
329 } 326 }
330 } 327 }
331 328
334 void *vdata, int *data_size, 331 void *vdata, int *data_size,
335 const uint8_t * buf, int buf_size) 332 const uint8_t * buf, int buf_size)
336 { 333 {
337 static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; 334 static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
338 unsigned int gbuf1[4]; 335 unsigned int gbuf1[4];
336 unsigned short gbuf2[4][30];
339 unsigned int a, c; 337 unsigned int a, c;
340 int i; 338 int i;
341 int16_t *data = vdata; 339 int16_t *data = vdata;
342 unsigned int val; 340 unsigned int val;
343 341
358 do_voice(glob->swapbuf1, glob->swapbuf2); 356 do_voice(glob->swapbuf1, glob->swapbuf2);
359 357
360 val = decodeval[get_bits(&gb, 5) << 1]; // Useless table entries? 358 val = decodeval[get_bits(&gb, 5) << 1]; // Useless table entries?
361 a = t_sqrt(val*glob->oldval) >> 12; 359 a = t_sqrt(val*glob->oldval) >> 12;
362 360
363 gbuf1[0] = dec2(glob, glob->swapbuf1alt, glob->swapbuf2alt, glob->oldval, glob->swapbuf2, 0); 361 gbuf1[0] = dec2(gbuf2[0], glob->swapbuf1alt, glob->swapbuf2alt, glob->oldval, glob->swapbuf2, 0);
364 if (glob->oldval < val) { 362 if (glob->oldval < val) {
365 gbuf1[1] = dec2(glob, glob->swapbuf1, glob->swapbuf2, a, glob->swapbuf2alt, 1); 363 gbuf1[1] = dec2(gbuf2[1], glob->swapbuf1, glob->swapbuf2, a, glob->swapbuf2alt, 1);
366 } else { 364 } else {
367 gbuf1[1] = dec2(glob, glob->swapbuf1alt, glob->swapbuf2alt, a, glob->swapbuf2, 1); 365 gbuf1[1] = dec2(gbuf2[1], glob->swapbuf1alt, glob->swapbuf2alt, a, glob->swapbuf2, 1);
368 } 366 }
369 gbuf1[2] = dec2(glob, glob->swapbuf1, glob->swapbuf2, val, glob->swapbuf2alt, 2); 367 gbuf1[2] = dec2(gbuf2[2], glob->swapbuf1, glob->swapbuf2, val, glob->swapbuf2alt, 2);
370 gbuf1[3] = dec1(glob, glob->swapbuf1, glob->swapbuf2, val, 3); 368 gbuf1[3] = dec1(gbuf2[3], glob->swapbuf1, glob->swapbuf2, val);
371 369
372 /* do output */ 370 /* do output */
373 for (c=0; c<4; c++) { 371 for (c=0; c<4; c++) {
374 do_output_subblock(glob, glob->gbuf2[c], gbuf1[c], data, &gb); 372 do_output_subblock(glob, gbuf2[c], gbuf1[c], data, &gb);
375 373
376 for (i=0; i<BLOCKSIZE; i++) { 374 for (i=0; i<BLOCKSIZE; i++) {
377 *data = av_clip_int16(*data << 2); 375 *data = av_clip_int16(*data << 2);
378 data++; 376 data++;
379 } 377 }