~ubuntu-branches/debian/sid/mplayer/sid

« back to all changes in this revision

Viewing changes to libavcodec/simple_idct.c

  • Committer: Bazaar Package Importer
  • Author(s): A Mennucc1
  • Date: 2009-03-23 10:05:45 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090323100545-x8h79obawnnte7kk
Tags: 1.0~rc2+svn20090303-5
debian/control : move docbook-xml,docbook-xsl,xsltproc from 
Build-Depends-Indep to Build-Depends, since they are needed to run
configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 */
22
22
 
23
23
/**
24
 
 * @file simple_idct.c
 
24
 * @file libavcodec/simple_idct.c
25
25
 * simpleidct in C.
26
26
 */
27
27
 
31
31
 */
32
32
#include "avcodec.h"
33
33
#include "dsputil.h"
 
34
#include "mathops.h"
34
35
#include "simple_idct.h"
35
36
 
36
37
#if 0
55
56
#define COL_SHIFT 20 // 6
56
57
#endif
57
58
 
58
 
#if defined(ARCH_POWERPC_405)
59
 
 
60
 
/* signed 16x16 -> 32 multiply add accumulate */
61
 
#define MAC16(rt, ra, rb) \
62
 
    asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
63
 
 
64
 
/* signed 16x16 -> 32 multiply */
65
 
#define MUL16(rt, ra, rb) \
66
 
    asm ("mullhw %0, %1, %2" : "=r" (rt) : "r" (ra), "r" (rb));
67
 
 
68
 
#else
69
 
 
70
 
/* signed 16x16 -> 32 multiply add accumulate */
71
 
#define MAC16(rt, ra, rb) rt += (ra) * (rb)
72
 
 
73
 
/* signed 16x16 -> 32 multiply */
74
 
#define MUL16(rt, ra, rb) rt = (ra) * (rb)
75
 
 
76
 
#endif
77
 
 
78
59
static inline void idctRowCondDC (DCTELEM * row)
79
60
{
80
61
        int a0, a1, a2, a3, b0, b1, b2, b3;
81
 
#ifdef HAVE_FAST_64BIT
 
62
#if HAVE_FAST_64BIT
82
63
        uint64_t temp;
83
64
#else
84
65
        uint32_t temp;
85
66
#endif
86
67
 
87
 
#ifdef HAVE_FAST_64BIT
 
68
#if HAVE_FAST_64BIT
88
69
#ifdef WORDS_BIGENDIAN
89
70
#define ROW0_MASK 0xffff000000000000LL
90
71
#else
137
118
        a2 -= W6 * row[2];
138
119
        a3 -= W2 * row[2];
139
120
 
140
 
        MUL16(b0, W1, row[1]);
 
121
        b0 = MUL16(W1, row[1]);
141
122
        MAC16(b0, W3, row[3]);
142
 
        MUL16(b1, W3, row[1]);
 
123
        b1 = MUL16(W3, row[1]);
143
124
        MAC16(b1, -W7, row[3]);
144
 
        MUL16(b2, W5, row[1]);
 
125
        b2 = MUL16(W5, row[1]);
145
126
        MAC16(b2, -W1, row[3]);
146
 
        MUL16(b3, W7, row[1]);
 
127
        b3 = MUL16(W7, row[1]);
147
128
        MAC16(b3, -W5, row[3]);
148
129
 
149
 
#ifdef HAVE_FAST_64BIT
 
130
#if HAVE_FAST_64BIT
150
131
        temp = ((uint64_t*)row)[1];
151
132
#else
152
133
        temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
197
178
        a2 +=  - W6*col[8*2];
198
179
        a3 +=  - W2*col[8*2];
199
180
 
200
 
        MUL16(b0, W1, col[8*1]);
201
 
        MUL16(b1, W3, col[8*1]);
202
 
        MUL16(b2, W5, col[8*1]);
203
 
        MUL16(b3, W7, col[8*1]);
 
181
        b0 = MUL16(W1, col[8*1]);
 
182
        b1 = MUL16(W3, col[8*1]);
 
183
        b2 = MUL16(W5, col[8*1]);
 
184
        b3 = MUL16(W7, col[8*1]);
204
185
 
205
186
        MAC16(b0, + W3, col[8*3]);
206
187
        MAC16(b1, - W7, col[8*3]);
269
250
        a2 +=  - W6*col[8*2];
270
251
        a3 +=  - W2*col[8*2];
271
252
 
272
 
        MUL16(b0, W1, col[8*1]);
273
 
        MUL16(b1, W3, col[8*1]);
274
 
        MUL16(b2, W5, col[8*1]);
275
 
        MUL16(b3, W7, col[8*1]);
 
253
        b0 = MUL16(W1, col[8*1]);
 
254
        b1 = MUL16(W3, col[8*1]);
 
255
        b2 = MUL16(W5, col[8*1]);
 
256
        b3 = MUL16(W7, col[8*1]);
276
257
 
277
258
        MAC16(b0, + W3, col[8*3]);
278
259
        MAC16(b1, - W7, col[8*3]);
339
320
        a2 +=  - W6*col[8*2];
340
321
        a3 +=  - W2*col[8*2];
341
322
 
342
 
        MUL16(b0, W1, col[8*1]);
343
 
        MUL16(b1, W3, col[8*1]);
344
 
        MUL16(b2, W5, col[8*1]);
345
 
        MUL16(b3, W7, col[8*1]);
 
323
        b0 = MUL16(W1, col[8*1]);
 
324
        b1 = MUL16(W3, col[8*1]);
 
325
        b2 = MUL16(W5, col[8*1]);
 
326
        b3 = MUL16(W7, col[8*1]);
346
327
 
347
328
        MAC16(b0, + W3, col[8*3]);
348
329
        MAC16(b1, - W7, col[8*3]);
387
368
        col[56] = ((a0 - b0) >> COL_SHIFT);
388
369
}
389
370
 
390
 
void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
 
371
void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
391
372
{
392
373
    int i;
393
374
    for(i=0; i<8; i++)
397
378
        idctSparseColPut(dest + i, line_size, block + i);
398
379
}
399
380
 
400
 
void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
 
381
void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
401
382
{
402
383
    int i;
403
384
    for(i=0; i<8; i++)
407
388
        idctSparseColAdd(dest + i, line_size, block + i);
408
389
}
409
390
 
410
 
void simple_idct(DCTELEM *block)
 
391
void ff_simple_idct(DCTELEM *block)
411
392
{
412
393
    int i;
413
394
    for(i=0; i<8; i++)
428
409
   and the butterfly must be multiplied by 0.5 * sqrt(2.0) */
429
410
#define C_SHIFT (4+1+12)
430
411
 
431
 
static inline void idct4col(uint8_t *dest, int line_size, const DCTELEM *col)
 
412
static inline void idct4col_put(uint8_t *dest, int line_size, const DCTELEM *col)
432
413
{
433
414
    int c0, c1, c2, c3, a0, a1, a2, a3;
434
415
    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
465
446
/* XXX: I think a 1.0/sqrt(2) normalization should be needed to
466
447
   compensate the extra butterfly stage - I don't have the full DV
467
448
   specification */
468
 
void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
 
449
void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
469
450
{
470
451
    int i;
471
452
    DCTELEM *ptr;
491
472
 
492
473
    /* IDCT4 and store */
493
474
    for(i=0;i<8;i++) {
494
 
        idct4col(dest + i, 2 * line_size, block + i);
495
 
        idct4col(dest + line_size + i, 2 * line_size, block + 8 + i);
 
475
        idct4col_put(dest + i, 2 * line_size, block + i);
 
476
        idct4col_put(dest + line_size + i, 2 * line_size, block + 8 + i);
496
477
    }
497
478
}
498
479
 
555
536
    row[3]= (c0 - c1) >> R_SHIFT;
556
537
}
557
538
 
558
 
void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
 
539
void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
559
540
{
560
541
    int i;
561
542
 
570
551
    }
571
552
}
572
553
 
573
 
void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
 
554
void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
574
555
{
575
556
    int i;
576
557
 
585
566
    }
586
567
}
587
568
 
 
569
void ff_simple_idct44_add(uint8_t *dest, int line_size, DCTELEM *block)
 
570
{
 
571
    int i;
 
572
 
 
573
    /* IDCT4 on each line */
 
574
    for(i=0; i<4; i++) {
 
575
        idct4row(block + i*8);
 
576
    }
 
577
 
 
578
    /* IDCT4 and store */
 
579
    for(i=0; i<4; i++){
 
580
        idct4col_add(dest + i, line_size, block + i);
 
581
    }
 
582
}