Mercurial > libavcodec.hg
annotate simple_idct.c @ 1074:d90c350454da libavcodec
* using $(MAKE)
author | kabi |
---|---|
date | Tue, 18 Feb 2003 19:10:57 +0000 |
parents | b32afefe7d33 |
children | 1e39f273ecd6 |
rev | line source |
---|---|
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
1 /* |
429 | 2 * Simple IDCT |
3 * | |
4 * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at> | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
20 /* |
429 | 21 based upon some outcommented c code from mpeg2dec (idct_mmx.c |
22 written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>) | |
23 */ | |
396
fce0a2520551
removed useless header includes - use av memory functions
glantau
parents:
352
diff
changeset
|
24 #include "avcodec.h" |
479 | 25 #include "dsputil.h" |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
26 #include "simple_idct.h" |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
27 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
28 #if 0 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
29 #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
30 #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
31 #define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
32 #define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
33 #define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
34 #define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
35 #define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
36 #define ROW_SHIFT 8 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
37 #define COL_SHIFT 17 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
38 #else |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
39 #define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
40 #define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
41 #define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
352
5a8eb5cf9f92
C4=16383 for the c version too and even for some outcommented code
michaelni
parents:
215
diff
changeset
|
42 #define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
43 #define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
44 #define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
45 #define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
46 #define ROW_SHIFT 11 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
47 #define COL_SHIFT 20 // 6 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
48 #endif |
205 | 49 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
50 #if defined(ARCH_POWERPC_405) |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
51 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
52 /* signed 16x16 -> 32 multiply add accumulate */ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
53 #define MAC16(rt, ra, rb) \ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
54 asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb)); |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
55 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
56 /* signed 16x16 -> 32 multiply */ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
57 #define MUL16(rt, ra, rb) \ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
58 asm ("mullhw %0, %1, %2" : "=r" (rt) : "r" (ra), "r" (rb)); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
59 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
60 #else |
205 | 61 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
62 /* signed 16x16 -> 32 multiply add accumulate */ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
63 #define MAC16(rt, ra, rb) rt += (ra) * (rb) |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
64 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
65 /* signed 16x16 -> 32 multiply */ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
66 #define MUL16(rt, ra, rb) rt = (ra) * (rb) |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
67 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
68 #endif |
205 | 69 |
1008 | 70 static inline void idctRowCondDC (DCTELEM * row) |
205 | 71 { |
72 int a0, a1, a2, a3, b0, b1, b2, b3; | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
73 #ifdef FAST_64BIT |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
74 uint64_t temp; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
75 #else |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
76 uint32_t temp; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
77 #endif |
205 | 78 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
79 #ifdef FAST_64BIT |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
80 #ifdef WORDS_BIGENDIAN |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
81 #define ROW0_MASK 0xffff000000000000LL |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
82 #else |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
83 #define ROW0_MASK 0xffffLL |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
84 #endif |
1008 | 85 if(sizeof(DCTELEM)==2){ |
86 if ( ((((uint64_t *)row)[0] & ~ROW0_MASK) | | |
87 ((uint64_t *)row)[1]) == 0) { | |
88 temp = (row[0] << 3) & 0xffff; | |
89 temp += temp << 16; | |
90 temp += temp << 32; | |
91 ((uint64_t *)row)[0] = temp; | |
92 ((uint64_t *)row)[1] = temp; | |
93 return; | |
94 } | |
95 }else{ | |
96 if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) { | |
97 row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3; | |
98 return; | |
99 } | |
100 } | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
101 #else |
1008 | 102 if(sizeof(DCTELEM)==2){ |
103 if (!(((uint32_t*)row)[1] | | |
104 ((uint32_t*)row)[2] | | |
105 ((uint32_t*)row)[3] | | |
106 row[1])) { | |
107 temp = (row[0] << 3) & 0xffff; | |
108 temp += temp << 16; | |
109 ((uint32_t*)row)[0]=((uint32_t*)row)[1] = | |
110 ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; | |
111 return; | |
112 } | |
113 }else{ | |
114 if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) { | |
115 row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3; | |
116 return; | |
117 } | |
118 } | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
119 #endif |
205 | 120 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
121 a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1)); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
122 a1 = a0; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
123 a2 = a0; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
124 a3 = a0; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
125 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
126 /* no need to optimize : gcc does it */ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
127 a0 += W2 * row[2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
128 a1 += W6 * row[2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
129 a2 -= W6 * row[2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
130 a3 -= W2 * row[2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
131 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
132 MUL16(b0, W1, row[1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
133 MAC16(b0, W3, row[3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
134 MUL16(b1, W3, row[1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
135 MAC16(b1, -W7, row[3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
136 MUL16(b2, W5, row[1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
137 MAC16(b2, -W1, row[3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
138 MUL16(b3, W7, row[1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
139 MAC16(b3, -W5, row[3]); |
205 | 140 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
141 #ifdef FAST_64BIT |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
142 temp = ((uint64_t*)row)[1]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
143 #else |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
144 temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
145 #endif |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
146 if (temp != 0) { |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
147 a0 += W4*row[4] + W6*row[6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
148 a1 += - W4*row[4] - W2*row[6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
149 a2 += - W4*row[4] + W2*row[6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
150 a3 += W4*row[4] - W6*row[6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
151 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
152 MAC16(b0, W5, row[5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
153 MAC16(b0, W7, row[7]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
154 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
155 MAC16(b1, -W1, row[5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
156 MAC16(b1, -W5, row[7]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
157 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
158 MAC16(b2, W7, row[5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
159 MAC16(b2, W3, row[7]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
160 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
161 MAC16(b3, W3, row[5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
162 MAC16(b3, -W1, row[7]); |
205 | 163 } |
164 | |
165 row[0] = (a0 + b0) >> ROW_SHIFT; | |
166 row[7] = (a0 - b0) >> ROW_SHIFT; | |
167 row[1] = (a1 + b1) >> ROW_SHIFT; | |
168 row[6] = (a1 - b1) >> ROW_SHIFT; | |
169 row[2] = (a2 + b2) >> ROW_SHIFT; | |
170 row[5] = (a2 - b2) >> ROW_SHIFT; | |
171 row[3] = (a3 + b3) >> ROW_SHIFT; | |
172 row[4] = (a3 - b3) >> ROW_SHIFT; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
173 } |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
174 |
1064 | 175 static inline void idctSparseColPut (uint8_t *dest, int line_size, |
1008 | 176 DCTELEM * col) |
205 | 177 { |
178 int a0, a1, a2, a3, b0, b1, b2, b3; | |
1064 | 179 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
180 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
181 /* XXX: I did that only to give same values as previous code */ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
182 a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
183 a1 = a0; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
184 a2 = a0; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
185 a3 = a0; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
186 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
187 a0 += + W2*col[8*2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
188 a1 += + W6*col[8*2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
189 a2 += - W6*col[8*2]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
190 a3 += - W2*col[8*2]; |
205 | 191 |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
192 MUL16(b0, W1, col[8*1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
193 MUL16(b1, W3, col[8*1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
194 MUL16(b2, W5, col[8*1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
195 MUL16(b3, W7, col[8*1]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
196 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
197 MAC16(b0, + W3, col[8*3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
198 MAC16(b1, - W7, col[8*3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
199 MAC16(b2, - W1, col[8*3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
200 MAC16(b3, - W5, col[8*3]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
201 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
202 if(col[8*4]){ |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
203 a0 += + W4*col[8*4]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
204 a1 += - W4*col[8*4]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
205 a2 += - W4*col[8*4]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
206 a3 += + W4*col[8*4]; |
205 | 207 } |
208 | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
209 if (col[8*5]) { |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
210 MAC16(b0, + W5, col[8*5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
211 MAC16(b1, - W1, col[8*5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
212 MAC16(b2, + W7, col[8*5]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
213 MAC16(b3, + W3, col[8*5]); |
205 | 214 } |
215 | |
216 if(col[8*6]){ | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
217 a0 += + W6*col[8*6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
218 a1 += - W2*col[8*6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
219 a2 += + W2*col[8*6]; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
220 a3 += - W6*col[8*6]; |
205 | 221 } |
222 | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
223 if (col[8*7]) { |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
224 MAC16(b0, + W7, col[8*7]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
225 MAC16(b1, - W5, col[8*7]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
226 MAC16(b2, + W3, col[8*7]); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
227 MAC16(b3, - W1, col[8*7]); |
205 | 228 } |
229 | |
479 | 230 dest[0] = cm[(a0 + b0) >> COL_SHIFT]; |
231 dest += line_size; | |
232 dest[0] = cm[(a1 + b1) >> COL_SHIFT]; | |
233 dest += line_size; | |
234 dest[0] = cm[(a2 + b2) >> COL_SHIFT]; | |
235 dest += line_size; | |
236 dest[0] = cm[(a3 + b3) >> COL_SHIFT]; | |
237 dest += line_size; | |
238 dest[0] = cm[(a3 - b3) >> COL_SHIFT]; | |
239 dest += line_size; | |
240 dest[0] = cm[(a2 - b2) >> COL_SHIFT]; | |
241 dest += line_size; | |
242 dest[0] = cm[(a1 - b1) >> COL_SHIFT]; | |
243 dest += line_size; | |
244 dest[0] = cm[(a0 - b0) >> COL_SHIFT]; | |
245 } | |
246 | |
1064 | 247 static inline void idctSparseColAdd (uint8_t *dest, int line_size, |
1008 | 248 DCTELEM * col) |
479 | 249 { |
250 int a0, a1, a2, a3, b0, b1, b2, b3; | |
1064 | 251 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
479 | 252 |
253 /* XXX: I did that only to give same values as previous code */ | |
254 a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); | |
255 a1 = a0; | |
256 a2 = a0; | |
257 a3 = a0; | |
258 | |
259 a0 += + W2*col[8*2]; | |
260 a1 += + W6*col[8*2]; | |
261 a2 += - W6*col[8*2]; | |
262 a3 += - W2*col[8*2]; | |
263 | |
264 MUL16(b0, W1, col[8*1]); | |
265 MUL16(b1, W3, col[8*1]); | |
266 MUL16(b2, W5, col[8*1]); | |
267 MUL16(b3, W7, col[8*1]); | |
268 | |
269 MAC16(b0, + W3, col[8*3]); | |
270 MAC16(b1, - W7, col[8*3]); | |
271 MAC16(b2, - W1, col[8*3]); | |
272 MAC16(b3, - W5, col[8*3]); | |
273 | |
274 if(col[8*4]){ | |
275 a0 += + W4*col[8*4]; | |
276 a1 += - W4*col[8*4]; | |
277 a2 += - W4*col[8*4]; | |
278 a3 += + W4*col[8*4]; | |
279 } | |
280 | |
281 if (col[8*5]) { | |
282 MAC16(b0, + W5, col[8*5]); | |
283 MAC16(b1, - W1, col[8*5]); | |
284 MAC16(b2, + W7, col[8*5]); | |
285 MAC16(b3, + W3, col[8*5]); | |
286 } | |
287 | |
288 if(col[8*6]){ | |
289 a0 += + W6*col[8*6]; | |
290 a1 += - W2*col[8*6]; | |
291 a2 += + W2*col[8*6]; | |
292 a3 += - W6*col[8*6]; | |
293 } | |
294 | |
295 if (col[8*7]) { | |
296 MAC16(b0, + W7, col[8*7]); | |
297 MAC16(b1, - W5, col[8*7]); | |
298 MAC16(b2, + W3, col[8*7]); | |
299 MAC16(b3, - W1, col[8*7]); | |
300 } | |
301 | |
302 dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)]; | |
303 dest += line_size; | |
304 dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)]; | |
305 dest += line_size; | |
306 dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)]; | |
307 dest += line_size; | |
308 dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)]; | |
309 dest += line_size; | |
310 dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)]; | |
311 dest += line_size; | |
312 dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)]; | |
313 dest += line_size; | |
314 dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)]; | |
315 dest += line_size; | |
316 dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)]; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
317 } |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
318 |
1008 | 319 static inline void idctSparseCol (DCTELEM * col) |
633 | 320 { |
321 int a0, a1, a2, a3, b0, b1, b2, b3; | |
322 | |
323 /* XXX: I did that only to give same values as previous code */ | |
324 a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); | |
325 a1 = a0; | |
326 a2 = a0; | |
327 a3 = a0; | |
328 | |
329 a0 += + W2*col[8*2]; | |
330 a1 += + W6*col[8*2]; | |
331 a2 += - W6*col[8*2]; | |
332 a3 += - W2*col[8*2]; | |
333 | |
334 MUL16(b0, W1, col[8*1]); | |
335 MUL16(b1, W3, col[8*1]); | |
336 MUL16(b2, W5, col[8*1]); | |
337 MUL16(b3, W7, col[8*1]); | |
338 | |
339 MAC16(b0, + W3, col[8*3]); | |
340 MAC16(b1, - W7, col[8*3]); | |
341 MAC16(b2, - W1, col[8*3]); | |
342 MAC16(b3, - W5, col[8*3]); | |
343 | |
344 if(col[8*4]){ | |
345 a0 += + W4*col[8*4]; | |
346 a1 += - W4*col[8*4]; | |
347 a2 += - W4*col[8*4]; | |
348 a3 += + W4*col[8*4]; | |
349 } | |
350 | |
351 if (col[8*5]) { | |
352 MAC16(b0, + W5, col[8*5]); | |
353 MAC16(b1, - W1, col[8*5]); | |
354 MAC16(b2, + W7, col[8*5]); | |
355 MAC16(b3, + W3, col[8*5]); | |
356 } | |
357 | |
358 if(col[8*6]){ | |
359 a0 += + W6*col[8*6]; | |
360 a1 += - W2*col[8*6]; | |
361 a2 += + W2*col[8*6]; | |
362 a3 += - W6*col[8*6]; | |
363 } | |
364 | |
365 if (col[8*7]) { | |
366 MAC16(b0, + W7, col[8*7]); | |
367 MAC16(b1, - W5, col[8*7]); | |
368 MAC16(b2, + W3, col[8*7]); | |
369 MAC16(b3, - W1, col[8*7]); | |
370 } | |
371 | |
372 col[0 ] = ((a0 + b0) >> COL_SHIFT); | |
373 col[8 ] = ((a1 + b1) >> COL_SHIFT); | |
374 col[16] = ((a2 + b2) >> COL_SHIFT); | |
375 col[24] = ((a3 + b3) >> COL_SHIFT); | |
376 col[32] = ((a3 - b3) >> COL_SHIFT); | |
377 col[40] = ((a2 - b2) >> COL_SHIFT); | |
378 col[48] = ((a1 - b1) >> COL_SHIFT); | |
379 col[56] = ((a0 - b0) >> COL_SHIFT); | |
380 } | |
381 | |
1064 | 382 void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block) |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
383 { |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
384 int i; |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
385 for(i=0; i<8; i++) |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
386 idctRowCondDC(block + i*8); |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
387 |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
388 for(i=0; i<8; i++) |
479 | 389 idctSparseColPut(dest + i, line_size, block + i); |
390 } | |
391 | |
1064 | 392 void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block) |
479 | 393 { |
394 int i; | |
395 for(i=0; i<8; i++) | |
396 idctRowCondDC(block + i*8); | |
397 | |
398 for(i=0; i<8; i++) | |
399 idctSparseColAdd(dest + i, line_size, block + i); | |
476
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
400 } |
ec13b0a726c3
removed unused code - began to merge alpha specific stuff - added mac macros for suitable CPUs
bellard
parents:
464
diff
changeset
|
401 |
1008 | 402 void simple_idct(DCTELEM *block) |
633 | 403 { |
404 int i; | |
405 for(i=0; i<8; i++) | |
406 idctRowCondDC(block + i*8); | |
407 | |
408 for(i=0; i<8; i++) | |
409 idctSparseCol(block + i); | |
410 } | |
411 | |
719 | 412 /* 2x4x8 idct */ |
413 | |
414 #define CN_SHIFT 12 | |
415 #define C_FIX(x) ((int)((x) * (1 << CN_SHIFT) + 0.5)) | |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
416 #define C1 C_FIX(0.6532814824) |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
417 #define C2 C_FIX(0.2705980501) |
719 | 418 |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
419 /* row idct is multiple by 16 * sqrt(2.0), col idct4 is normalized, |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
420 and the butterfly must be multiplied by 0.5 * sqrt(2.0) */ |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
421 #define C_SHIFT (4+1+12) |
719 | 422 |
1064 | 423 static inline void idct4col(uint8_t *dest, int line_size, const DCTELEM *col) |
719 | 424 { |
425 int c0, c1, c2, c3, a0, a1, a2, a3; | |
1064 | 426 const uint8_t *cm = cropTbl + MAX_NEG_CROP; |
719 | 427 |
428 a0 = col[8*0]; | |
429 a1 = col[8*2]; | |
430 a2 = col[8*4]; | |
431 a3 = col[8*6]; | |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
432 c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
719
diff
changeset
|
433 c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); |
719 | 434 c1 = a1 * C1 + a3 * C2; |
435 c3 = a1 * C2 - a3 * C1; | |
436 dest[0] = cm[(c0 + c1) >> C_SHIFT]; | |
437 dest += line_size; | |
438 dest[0] = cm[(c2 + c3) >> C_SHIFT]; | |
439 dest += line_size; | |
440 dest[0] = cm[(c2 - c3) >> C_SHIFT]; | |
441 dest += line_size; | |
442 dest[0] = cm[(c0 - c1) >> C_SHIFT]; | |
443 } | |
444 | |
445 #define BF(k) \ | |
446 {\ | |
447 int a0, a1;\ | |
448 a0 = ptr[k];\ | |
449 a1 = ptr[8 + k];\ | |
450 ptr[k] = a0 + a1;\ | |
451 ptr[8 + k] = a0 - a1;\ | |
452 } | |
453 | |
454 /* only used by DV codec. The input must be interlaced. 128 is added | |
455 to the pixels before clamping to avoid systematic error | |
456 (1024*sqrt(2)) offset would be needed otherwise. */ | |
457 /* XXX: I think a 1.0/sqrt(2) normalization should be needed to | |
458 compensate the extra butterfly stage - I don't have the full DV | |
459 specification */ | |
1064 | 460 void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block) |
719 | 461 { |
462 int i; | |
1008 | 463 DCTELEM *ptr; |
719 | 464 |
465 /* butterfly */ | |
466 ptr = block; | |
467 for(i=0;i<4;i++) { | |
468 BF(0); | |
469 BF(1); | |
470 BF(2); | |
471 BF(3); | |
472 BF(4); | |
473 BF(5); | |
474 BF(6); | |
475 BF(7); | |
476 ptr += 2 * 8; | |
477 } | |
478 | |
479 /* IDCT8 on each line */ | |
480 for(i=0; i<8; i++) { | |
481 idctRowCondDC(block + i*8); | |
482 } | |
483 | |
484 /* IDCT4 and store */ | |
485 for(i=0;i<8;i++) { | |
486 idct4col(dest + i, 2 * line_size, block + i); | |
487 idct4col(dest + line_size + i, 2 * line_size, block + 8 + i); | |
488 } | |
489 } | |
936 | 490 |
491 /* 8x4 & 4x8 WMV2 IDCT */ | |
492 #undef CN_SHIFT | |
493 #undef C_SHIFT | |
494 #undef C_FIX | |
495 #undef C1 | |
496 #undef C2 | |
497 #define CN_SHIFT 12 | |
498 #define C_FIX(x) ((int)((x) * 1.414213562 * (1 << CN_SHIFT) + 0.5)) | |
499 #define C1 C_FIX(0.6532814824) | |
500 #define C2 C_FIX(0.2705980501) | |
501 #define C3 C_FIX(0.5) | |
502 #define C_SHIFT (4+1+12) | |
1064 | 503 static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col) |
936 | 504 { |
505 int c0, c1, c2, c3, a0, a1, a2, a3; | |
1064 | 506 const uint8_t *cm = cropTbl + MAX_NEG_CROP; |
936 | 507 |
508 a0 = col[8*0]; | |
509 a1 = col[8*1]; | |
510 a2 = col[8*2]; | |
511 a3 = col[8*3]; | |
512 c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1)); | |
513 c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1)); | |
514 c1 = a1 * C1 + a3 * C2; | |
515 c3 = a1 * C2 - a3 * C1; | |
516 dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)]; | |
517 dest += line_size; | |
518 dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)]; | |
519 dest += line_size; | |
520 dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)]; | |
521 dest += line_size; | |
522 dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)]; | |
523 } | |
524 | |
525 #define RN_SHIFT 15 | |
526 #define R_FIX(x) ((int)((x) * 1.414213562 * (1 << RN_SHIFT) + 0.5)) | |
527 #define R1 R_FIX(0.6532814824) | |
528 #define R2 R_FIX(0.2705980501) | |
529 #define R3 R_FIX(0.5) | |
530 #define R_SHIFT 11 | |
1008 | 531 static inline void idct4row(DCTELEM *row) |
936 | 532 { |
533 int c0, c1, c2, c3, a0, a1, a2, a3; | |
1064 | 534 //const uint8_t *cm = cropTbl + MAX_NEG_CROP; |
936 | 535 |
536 a0 = row[0]; | |
537 a1 = row[1]; | |
538 a2 = row[2]; | |
539 a3 = row[3]; | |
540 c0 = (a0 + a2)*R3 + (1 << (R_SHIFT - 1)); | |
541 c2 = (a0 - a2)*R3 + (1 << (R_SHIFT - 1)); | |
542 c1 = a1 * R1 + a3 * R2; | |
543 c3 = a1 * R2 - a3 * R1; | |
544 row[0]= (c0 + c1) >> R_SHIFT; | |
545 row[1]= (c2 + c3) >> R_SHIFT; | |
546 row[2]= (c2 - c3) >> R_SHIFT; | |
547 row[3]= (c0 - c1) >> R_SHIFT; | |
548 } | |
549 | |
1064 | 550 void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block) |
936 | 551 { |
552 int i; | |
553 | |
554 /* IDCT8 on each line */ | |
555 for(i=0; i<4; i++) { | |
556 idctRowCondDC(block + i*8); | |
557 } | |
558 | |
559 /* IDCT4 and store */ | |
560 for(i=0;i<8;i++) { | |
561 idct4col_add(dest + i, line_size, block + i); | |
562 } | |
563 } | |
564 | |
1064 | 565 void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block) |
936 | 566 { |
567 int i; | |
568 | |
569 /* IDCT4 on each line */ | |
570 for(i=0; i<8; i++) { | |
571 idct4row(block + i*8); | |
572 } | |
573 | |
574 /* IDCT8 and store */ | |
575 for(i=0; i<4; i++){ | |
576 idctSparseColAdd(dest + i, line_size, block + i); | |
577 } | |
578 } | |
579 |