Revision d36a2466 libavcodec/simple_idct.c

View differences:

libavcodec/simple_idct.c
22 22
  written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>) 
23 23
 */
24 24
#include "avcodec.h"
25

  
25
#include "dsputil.h"
26 26
#include "simple_idct.h"
27 27

  
28 28
#if 0
......
261 261
}
262 262
#endif /* not ARCH_ALPHA */
263 263

  
264
static inline void idctSparseCol (int16_t * col)
264
static inline void idctSparseColPut (UINT8 *dest, int line_size, 
265
                                     int16_t * col)
266
{
267
	int a0, a1, a2, a3, b0, b1, b2, b3;
268
        UINT8 *cm = cropTbl + MAX_NEG_CROP;
269

  
270
        /* XXX: I did that only to give same values as previous code */
271
	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
272
	a1 = a0;
273
	a2 = a0;
274
	a3 = a0;
275

  
276
        a0 +=  + W2*col[8*2];
277
        a1 +=  + W6*col[8*2];
278
        a2 +=  - W6*col[8*2];
279
        a3 +=  - W2*col[8*2];
280

  
281
        MUL16(b0, W1, col[8*1]);
282
        MUL16(b1, W3, col[8*1]);
283
        MUL16(b2, W5, col[8*1]);
284
        MUL16(b3, W7, col[8*1]);
285

  
286
        MAC16(b0, + W3, col[8*3]);
287
        MAC16(b1, - W7, col[8*3]);
288
        MAC16(b2, - W1, col[8*3]);
289
        MAC16(b3, - W5, col[8*3]);
290

  
291
	if(col[8*4]){
292
            a0 += + W4*col[8*4];
293
            a1 += - W4*col[8*4];
294
            a2 += - W4*col[8*4];
295
            a3 += + W4*col[8*4];
296
	}
297

  
298
	if (col[8*5]) {
299
            MAC16(b0, + W5, col[8*5]);
300
            MAC16(b1, - W1, col[8*5]);
301
            MAC16(b2, + W7, col[8*5]);
302
            MAC16(b3, + W3, col[8*5]);
303
	}
304

  
305
	if(col[8*6]){
306
            a0 += + W6*col[8*6];
307
            a1 += - W2*col[8*6];
308
            a2 += + W2*col[8*6];
309
            a3 += - W6*col[8*6];
310
	}
311

  
312
	if (col[8*7]) {
313
            MAC16(b0, + W7, col[8*7]);
314
            MAC16(b1, - W5, col[8*7]);
315
            MAC16(b2, + W3, col[8*7]);
316
            MAC16(b3, - W1, col[8*7]);
317
	}
318

  
319
        dest[0] = cm[(a0 + b0) >> COL_SHIFT];
320
        dest += line_size;
321
        dest[0] = cm[(a1 + b1) >> COL_SHIFT];
322
        dest += line_size;
323
        dest[0] = cm[(a2 + b2) >> COL_SHIFT];
324
        dest += line_size;
325
        dest[0] = cm[(a3 + b3) >> COL_SHIFT];
326
        dest += line_size;
327
        dest[0] = cm[(a3 - b3) >> COL_SHIFT];
328
        dest += line_size;
329
        dest[0] = cm[(a2 - b2) >> COL_SHIFT];
330
        dest += line_size;
331
        dest[0] = cm[(a1 - b1) >> COL_SHIFT];
332
        dest += line_size;
333
        dest[0] = cm[(a0 - b0) >> COL_SHIFT];
334
}
335

  
336
static inline void idctSparseColAdd (UINT8 *dest, int line_size, 
337
                                     int16_t * col)
265 338
{
266 339
	int a0, a1, a2, a3, b0, b1, b2, b3;
340
        UINT8 *cm = cropTbl + MAX_NEG_CROP;
267 341

  
268 342
        /* XXX: I did that only to give same values as previous code */
269 343
	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
......
314 388
            MAC16(b3, - W1, col[8*7]);
315 389
	}
316 390

  
317
        col[8*0] = (a0 + b0) >> COL_SHIFT;
318
        col[8*7] = (a0 - b0) >> COL_SHIFT;
319
        col[8*1] = (a1 + b1) >> COL_SHIFT;
320
        col[8*6] = (a1 - b1) >> COL_SHIFT;
321
        col[8*2] = (a2 + b2) >> COL_SHIFT;
322
        col[8*5] = (a2 - b2) >> COL_SHIFT;
323
        col[8*3] = (a3 + b3) >> COL_SHIFT;
324
        col[8*4] = (a3 - b3) >> COL_SHIFT;
391
        dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)];
392
        dest += line_size;
393
        dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)];
394
        dest += line_size;
395
        dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)];
396
        dest += line_size;
397
        dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)];
398
        dest += line_size;
399
        dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)];
400
        dest += line_size;
401
        dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)];
402
        dest += line_size;
403
        dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
404
        dest += line_size;
405
        dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
325 406
}
326 407

  
327 408
#ifdef ARCH_ALPHA
......
389 470
	}
390 471
}
391 472

  
473
/* XXX: suppress this mess */
474
void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
475
{
476
    simple_idct(block);
477
    put_pixels_clamped(block, dest, line_size);
478
}
479

  
480
void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
481
{
482
    simple_idct(block);
483
    add_pixels_clamped(block, dest, line_size);
484
}
485

  
392 486
#else
393 487

  
394
void simple_idct (short *block)
488
void simple_idct_put(UINT8 *dest, int line_size, INT16 *block)
489
{
490
    int i;
491
    for(i=0; i<8; i++)
492
        idctRowCondDC(block + i*8);
493
    
494
    for(i=0; i<8; i++)
495
        idctSparseColPut(dest + i, line_size, block + i);
496
}
497

  
498
void simple_idct_add(UINT8 *dest, int line_size, INT16 *block)
395 499
{
396 500
    int i;
397 501
    for(i=0; i<8; i++)
398 502
        idctRowCondDC(block + i*8);
399 503
    
400 504
    for(i=0; i<8; i++)
401
        idctSparseCol(block + i);
505
        idctSparseColAdd(dest + i, line_size, block + i);
402 506
}
403 507

  
404 508
#endif

Also available in: Unified diff