Mercurial > libavcodec.hg
annotate simple_idct.c @ 212:80edc2aaff86 libavcodec
Added reverting support for -pp and -npp options
author | albeu |
---|---|
date | Sat, 19 Jan 2002 17:01:03 +0000 |
parents | ccf36af385f3 |
children | 73df666cacc7 |
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 /* |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
2 Copyright (C) 2001 Michael Niedermayer (michaelni@gmx.at) |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
3 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
6 the Free Software Foundation; either version 2 of the License, or |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
7 (at your option) any later version. |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
8 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
12 GNU General Public License for more details. |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
13 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
15 along with this program; if not, write to the Free Software |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
17 */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
18 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
19 /* |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
20 based upon some outcommented c code from mpeg2dec (idct_mmx.c written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>) |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
21 */ |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
22 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
23 #include <inttypes.h> |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
24 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
25 #include "simple_idct.h" |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
26 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
27 #if 0 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
28 #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
|
29 #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
|
30 #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
|
31 #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
|
32 #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
|
33 #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
|
34 #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
|
35 #define ROW_SHIFT 8 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
36 #define COL_SHIFT 17 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
37 #else |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
38 #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
|
39 #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
|
40 #define W3 19266 //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 W4 16384 //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
|
42 #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
|
43 #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
|
44 #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
|
45 #define ROW_SHIFT 11 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
46 #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
|
47 #endif |
205 | 48 |
49 /* 8x8 Matrix used to do a trivial (slow) 8 point IDCT */ | |
50 static int coeff[64]={ | |
51 W4, W4, W4, W4, W4, W4, W4, W4, | |
52 W1, W3, W5, W7,-W7,-W5,-W3,-W1, | |
53 W2, W6,-W6,-W2,-W2,-W6, W6, W2, | |
54 W3,-W7,-W1,-W5, W5, W1, W7,-W3, | |
55 W4,-W4,-W4, W4, W4,-W4,-W4, W4, | |
56 W5,-W1, W7, W3,-W3,-W7, W1,-W5, | |
57 W6,-W2, W2,-W6,-W6, W2,-W2, W6, | |
58 W7,-W5, W3,-W1, W1,-W3, W5,-W7 | |
59 }; | |
60 | |
61 static int inline idctRowCondZ (int16_t * row) | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
62 { |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
63 int a0, a1, a2, a3, b0, b1, b2, b3; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
64 |
205 | 65 if( !( ((uint32_t*)row)[0]|((uint32_t*)row)[1] |((uint32_t*)row)[2] |((uint32_t*)row)[3])) { |
66 /* row[0] = row[1] = row[2] = row[3] = row[4] = | |
67 row[5] = row[6] = row[7] = 0;*/ | |
68 return 0; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
69 } |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
70 |
205 | 71 if(!( ((uint32_t*)row)[2] |((uint32_t*)row)[3] )){ |
72 a0 = W4*row[0] + W2*row[2] + (1<<(ROW_SHIFT-1)); | |
73 a1 = W4*row[0] + W6*row[2] + (1<<(ROW_SHIFT-1)); | |
74 a2 = W4*row[0] - W6*row[2] + (1<<(ROW_SHIFT-1)); | |
75 a3 = W4*row[0] - W2*row[2] + (1<<(ROW_SHIFT-1)); | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
76 |
205 | 77 b0 = W1*row[1] + W3*row[3]; |
78 b1 = W3*row[1] - W7*row[3]; | |
79 b2 = W5*row[1] - W1*row[3]; | |
80 b3 = W7*row[1] - W5*row[3]; | |
81 }else{ | |
82 a0 = W4*row[0] + W2*row[2] + W4*row[4] + W6*row[6] + (1<<(ROW_SHIFT-1)); | |
83 a1 = W4*row[0] + W6*row[2] - W4*row[4] - W2*row[6] + (1<<(ROW_SHIFT-1)); | |
84 a2 = W4*row[0] - W6*row[2] - W4*row[4] + W2*row[6] + (1<<(ROW_SHIFT-1)); | |
85 a3 = W4*row[0] - W2*row[2] + W4*row[4] - W6*row[6] + (1<<(ROW_SHIFT-1)); | |
86 | |
87 b0 = W1*row[1] + W3*row[3] + W5*row[5] + W7*row[7]; | |
88 b1 = W3*row[1] - W7*row[3] - W1*row[5] - W5*row[7]; | |
89 b2 = W5*row[1] - W1*row[3] + W7*row[5] + W3*row[7]; | |
90 b3 = W7*row[1] - W5*row[3] + W3*row[5] - W1*row[7]; | |
91 } | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
92 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
93 row[0] = (a0 + b0) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
94 row[1] = (a1 + b1) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
95 row[2] = (a2 + b2) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
96 row[3] = (a3 + b3) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
97 row[4] = (a3 - b3) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
98 row[5] = (a2 - b2) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
99 row[6] = (a1 - b1) >> ROW_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
100 row[7] = (a0 - b0) >> ROW_SHIFT; |
205 | 101 |
102 return 1; | |
103 } | |
104 | |
105 static int inline idctRowCondDC (int16_t * row) | |
106 { | |
107 int a0, a1, a2, a3, b0, b1, b2, b3; | |
108 | |
109 if( !( ((uint32_t*)row)[1] |((uint32_t*)row)[2] |((uint32_t*)row)[3]| row[1])) { | |
110 // row[0] = row[1] = row[2] = row[3] = row[4] = row[5] = row[6] = row[7] = row[0]<<3; | |
111 uint16_t temp= row[0]<<3; | |
112 ((uint32_t*)row)[0]=((uint32_t*)row)[1]= | |
113 ((uint32_t*)row)[2]=((uint32_t*)row)[3]= temp + (temp<<16); | |
114 return 0; | |
115 } | |
116 | |
117 if(!( ((uint32_t*)row)[2] |((uint32_t*)row)[3] )){ | |
118 a0 = W4*row[0] + W2*row[2] + (1<<(ROW_SHIFT-1)); | |
119 a1 = W4*row[0] + W6*row[2] + (1<<(ROW_SHIFT-1)); | |
120 a2 = W4*row[0] - W6*row[2] + (1<<(ROW_SHIFT-1)); | |
121 a3 = W4*row[0] - W2*row[2] + (1<<(ROW_SHIFT-1)); | |
122 | |
123 b0 = W1*row[1] + W3*row[3]; | |
124 b1 = W3*row[1] - W7*row[3]; | |
125 b2 = W5*row[1] - W1*row[3]; | |
126 b3 = W7*row[1] - W5*row[3]; | |
127 }else{ | |
128 a0 = W4*row[0] + W2*row[2] + W4*row[4] + W6*row[6] + (1<<(ROW_SHIFT-1)); | |
129 a1 = W4*row[0] + W6*row[2] - W4*row[4] - W2*row[6] + (1<<(ROW_SHIFT-1)); | |
130 a2 = W4*row[0] - W6*row[2] - W4*row[4] + W2*row[6] + (1<<(ROW_SHIFT-1)); | |
131 a3 = W4*row[0] - W2*row[2] + W4*row[4] - W6*row[6] + (1<<(ROW_SHIFT-1)); | |
132 | |
133 b0 = W1*row[1] + W3*row[3] + W5*row[5] + W7*row[7]; | |
134 b1 = W3*row[1] - W7*row[3] - W1*row[5] - W5*row[7]; | |
135 b2 = W5*row[1] - W1*row[3] + W7*row[5] + W3*row[7]; | |
136 b3 = W7*row[1] - W5*row[3] + W3*row[5] - W1*row[7]; | |
137 } | |
138 | |
139 row[0] = (a0 + b0) >> ROW_SHIFT; | |
140 row[7] = (a0 - b0) >> ROW_SHIFT; | |
141 row[1] = (a1 + b1) >> ROW_SHIFT; | |
142 row[6] = (a1 - b1) >> ROW_SHIFT; | |
143 row[2] = (a2 + b2) >> ROW_SHIFT; | |
144 row[5] = (a2 - b2) >> ROW_SHIFT; | |
145 row[3] = (a3 + b3) >> ROW_SHIFT; | |
146 row[4] = (a3 - b3) >> ROW_SHIFT; | |
147 | |
148 return 1; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
149 } |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
150 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
151 static void inline idctCol (int16_t * col) |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
152 { |
205 | 153 |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
154 /* |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
155 if( !(col[8*1] | col[8*2] |col[8*3] |col[8*4] |col[8*5] |col[8*6] | col[8*7])) { |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
156 col[8*0] = col[8*1] = col[8*2] = col[8*3] = col[8*4] = |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
157 col[8*5] = col[8*6] = col[8*7] = col[8*0]<<3; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
158 return; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
159 }*/ |
205 | 160 |
161 int a0, a1, a2, a3, b0, b1, b2, b3; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
162 col[0] += (1<<(COL_SHIFT-1))/W4; |
205 | 163 a0 = W4*col[8*0] + W2*col[8*2] + W4*col[8*4] + W6*col[8*6]; |
164 a1 = W4*col[8*0] + W6*col[8*2] - W4*col[8*4] - W2*col[8*6]; | |
165 a2 = W4*col[8*0] - W6*col[8*2] - W4*col[8*4] + W2*col[8*6]; | |
166 a3 = W4*col[8*0] - W2*col[8*2] + W4*col[8*4] - W6*col[8*6]; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
167 |
205 | 168 b0 = W1*col[8*1] + W3*col[8*3] + W5*col[8*5] + W7*col[8*7]; |
169 b1 = W3*col[8*1] - W7*col[8*3] - W1*col[8*5] - W5*col[8*7]; | |
170 b2 = W5*col[8*1] - W1*col[8*3] + W7*col[8*5] + W3*col[8*7]; | |
171 b3 = W7*col[8*1] - W5*col[8*3] + W3*col[8*5] - W1*col[8*7]; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
172 |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
173 col[8*0] = (a0 + b0) >> COL_SHIFT; |
205 | 174 col[8*7] = (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
|
175 col[8*1] = (a1 + b1) >> COL_SHIFT; |
205 | 176 col[8*6] = (a1 - b1) >> COL_SHIFT; |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
177 col[8*2] = (a2 + b2) >> COL_SHIFT; |
205 | 178 col[8*5] = (a2 - b2) >> COL_SHIFT; |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
179 col[8*3] = (a3 + b3) >> COL_SHIFT; |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
180 col[8*4] = (a3 - b3) >> COL_SHIFT; |
205 | 181 } |
182 | |
183 static void inline idctSparseCol (int16_t * col) | |
184 { | |
185 int a0, a1, a2, a3, b0, b1, b2, b3; | |
186 col[0] += (1<<(COL_SHIFT-1))/W4; | |
187 a0 = W4*col[8*0]; | |
188 a1 = W4*col[8*0]; | |
189 a2 = W4*col[8*0]; | |
190 a3 = W4*col[8*0]; | |
191 | |
192 if(col[8*2]){ | |
193 a0 += + W2*col[8*2]; | |
194 a1 += + W6*col[8*2]; | |
195 a2 += - W6*col[8*2]; | |
196 a3 += - W2*col[8*2]; | |
197 } | |
198 | |
199 if(col[8*4]){ | |
200 a0 += + W4*col[8*4]; | |
201 a1 += - W4*col[8*4]; | |
202 a2 += - W4*col[8*4]; | |
203 a3 += + W4*col[8*4]; | |
204 } | |
205 | |
206 if(col[8*6]){ | |
207 a0 += + W6*col[8*6]; | |
208 a1 += - W2*col[8*6]; | |
209 a2 += + W2*col[8*6]; | |
210 a3 += - W6*col[8*6]; | |
211 } | |
212 | |
213 if(col[8*1]){ | |
214 b0 = W1*col[8*1]; | |
215 b1 = W3*col[8*1]; | |
216 b2 = W5*col[8*1]; | |
217 b3 = W7*col[8*1]; | |
218 }else{ | |
219 b0 = | |
220 b1 = | |
221 b2 = | |
222 b3 = 0; | |
223 } | |
224 | |
225 if(col[8*3]){ | |
226 b0 += + W3*col[8*3]; | |
227 b1 += - W7*col[8*3]; | |
228 b2 += - W1*col[8*3]; | |
229 b3 += - W5*col[8*3]; | |
230 } | |
231 | |
232 if(col[8*5]){ | |
233 b0 += + W5*col[8*5]; | |
234 b1 += - W1*col[8*5]; | |
235 b2 += + W7*col[8*5]; | |
236 b3 += + W3*col[8*5]; | |
237 } | |
238 | |
239 if(col[8*7]){ | |
240 b0 += + W7*col[8*7]; | |
241 b1 += - W5*col[8*7]; | |
242 b2 += + W3*col[8*7]; | |
243 b3 += - W1*col[8*7]; | |
244 } | |
245 | |
246 if(!(b0|b1|b2|b3)){ | |
247 col[8*0] = (a0) >> COL_SHIFT; | |
248 col[8*7] = (a0) >> COL_SHIFT; | |
249 col[8*1] = (a1) >> COL_SHIFT; | |
250 col[8*6] = (a1) >> COL_SHIFT; | |
251 col[8*2] = (a2) >> COL_SHIFT; | |
252 col[8*5] = (a2) >> COL_SHIFT; | |
253 col[8*3] = (a3) >> COL_SHIFT; | |
254 col[8*4] = (a3) >> COL_SHIFT; | |
255 }else{ | |
256 col[8*0] = (a0 + b0) >> COL_SHIFT; | |
257 col[8*7] = (a0 - b0) >> COL_SHIFT; | |
258 col[8*1] = (a1 + b1) >> COL_SHIFT; | |
259 col[8*6] = (a1 - b1) >> COL_SHIFT; | |
260 col[8*2] = (a2 + b2) >> COL_SHIFT; | |
261 col[8*5] = (a2 - b2) >> COL_SHIFT; | |
262 col[8*3] = (a3 + b3) >> COL_SHIFT; | |
263 col[8*4] = (a3 - b3) >> COL_SHIFT; | |
264 } | |
265 } | |
266 | |
267 static void inline idctSparse2Col (int16_t * col) | |
268 { | |
269 int a0, a1, a2, a3, b0, b1, b2, b3; | |
270 col[0] += (1<<(COL_SHIFT-1))/W4; | |
271 a0 = W4*col[8*0]; | |
272 a1 = W4*col[8*0]; | |
273 a2 = W4*col[8*0]; | |
274 a3 = W4*col[8*0]; | |
275 | |
276 if(col[8*2]){ | |
277 a0 += + W2*col[8*2]; | |
278 a1 += + W6*col[8*2]; | |
279 a2 += - W6*col[8*2]; | |
280 a3 += - W2*col[8*2]; | |
281 } | |
282 | |
283 if(col[8*4]){ | |
284 a0 += + W4*col[8*4]; | |
285 a1 += - W4*col[8*4]; | |
286 a2 += - W4*col[8*4]; | |
287 a3 += + W4*col[8*4]; | |
288 } | |
289 | |
290 if(col[8*6]){ | |
291 a0 += + W6*col[8*6]; | |
292 a1 += - W2*col[8*6]; | |
293 a2 += + W2*col[8*6]; | |
294 a3 += - W6*col[8*6]; | |
295 } | |
296 | |
297 if(col[8*1] || 1){ | |
298 b0 = W1*col[8*1]; | |
299 b1 = W3*col[8*1]; | |
300 b2 = W5*col[8*1]; | |
301 b3 = W7*col[8*1]; | |
302 }else{ | |
303 b0 = | |
304 b1 = | |
305 b2 = | |
306 b3 = 0; | |
307 } | |
308 | |
309 if(col[8*3]){ | |
310 b0 += + W3*col[8*3]; | |
311 b1 += - W7*col[8*3]; | |
312 b2 += - W1*col[8*3]; | |
313 b3 += - W5*col[8*3]; | |
314 } | |
315 | |
316 if(col[8*5]){ | |
317 b0 += + W5*col[8*5]; | |
318 b1 += - W1*col[8*5]; | |
319 b2 += + W7*col[8*5]; | |
320 b3 += + W3*col[8*5]; | |
321 } | |
322 | |
323 if(col[8*7]){ | |
324 b0 += + W7*col[8*7]; | |
325 b1 += - W5*col[8*7]; | |
326 b2 += + W3*col[8*7]; | |
327 b3 += - W1*col[8*7]; | |
328 } | |
329 | |
330 col[8*0] = (a0 + b0) >> COL_SHIFT; | |
331 col[8*7] = (a0 - b0) >> COL_SHIFT; | |
332 col[8*1] = (a1 + b1) >> COL_SHIFT; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
333 col[8*6] = (a1 - b1) >> COL_SHIFT; |
205 | 334 col[8*2] = (a2 + b2) >> COL_SHIFT; |
335 col[8*5] = (a2 - b2) >> COL_SHIFT; | |
336 col[8*3] = (a3 + b3) >> COL_SHIFT; | |
337 col[8*4] = (a3 - b3) >> COL_SHIFT; | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
338 } |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
339 |
205 | 340 |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
341 void simple_idct (short *block) |
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
342 { |
205 | 343 |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
344 int i; |
205 | 345 |
346 #if 0 | |
347 int nonZero[8]; | |
348 int buffer[64]; | |
349 int nNonZero=0; | |
350 | |
351 idctRowCondDC(block); | |
352 | |
353 for(i=1; i<8; i++) | |
354 { | |
355 nonZero[nNonZero]=i; | |
356 nNonZero+= idctRowCondZ(block + i*8); | |
357 } | |
358 | |
359 if(nNonZero==0) | |
360 { | |
361 for(i=0; i<8; i++) | |
362 { | |
363 block[i ]= | |
364 block[i+8 ]= | |
365 block[i+16]= | |
366 block[i+24]= | |
367 block[i+32]= | |
368 block[i+40]= | |
369 block[i+48]= | |
370 block[i+56]= (W4*block[i] + (1<<(COL_SHIFT-1))) >> COL_SHIFT; | |
371 } | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
372 } |
205 | 373 else if(nNonZero==1) |
374 { | |
375 int index= nonZero[0]*8; | |
376 for(i=0; i<8; i++) | |
377 { | |
378 int bias= W4*block[i] + (1<<(COL_SHIFT-1)); | |
379 int c= block[i + index]; | |
380 block[i ]= (c*coeff[index ] + bias) >> COL_SHIFT; | |
381 block[i+8 ]= (c*coeff[index+1] + bias) >> COL_SHIFT; | |
382 block[i+16]= (c*coeff[index+2] + bias) >> COL_SHIFT; | |
383 block[i+24]= (c*coeff[index+3] + bias) >> COL_SHIFT; | |
384 block[i+32]= (c*coeff[index+4] + bias) >> COL_SHIFT; | |
385 block[i+40]= (c*coeff[index+5] + bias) >> COL_SHIFT; | |
386 block[i+48]= (c*coeff[index+6] + bias) >> COL_SHIFT; | |
387 block[i+56]= (c*coeff[index+7] + bias) >> COL_SHIFT; | |
388 } | |
389 } | |
390 /* else if(nNonZero==2) | |
391 { | |
392 int index1= nonZero[0]*8; | |
393 int index2= nonZero[1]*8; | |
394 for(i=0; i<8; i++) | |
395 { | |
396 int bias= W4*block[i] + (1<<(COL_SHIFT-1)); | |
397 int c1= block[i + index1]; | |
398 int c2= block[i + index2]; | |
399 block[i ]= (c1*coeff[index1 ] + c2*coeff[index2 ] + bias) >> COL_SHIFT; | |
400 block[i+8 ]= (c1*coeff[index1+1] + c2*coeff[index2+1] + bias) >> COL_SHIFT; | |
401 block[i+16]= (c1*coeff[index1+2] + c2*coeff[index2+2] + bias) >> COL_SHIFT; | |
402 block[i+24]= (c1*coeff[index1+3] + c2*coeff[index2+3] + bias) >> COL_SHIFT; | |
403 block[i+32]= (c1*coeff[index1+4] + c2*coeff[index2+4] + bias) >> COL_SHIFT; | |
404 block[i+40]= (c1*coeff[index1+5] + c2*coeff[index2+5] + bias) >> COL_SHIFT; | |
405 block[i+48]= (c1*coeff[index1+6] + c2*coeff[index2+6] + bias) >> COL_SHIFT; | |
406 block[i+56]= (c1*coeff[index1+7] + c2*coeff[index2+7] + bias) >> COL_SHIFT; | |
407 } | |
408 }*/ | |
409 else | |
410 { | |
411 for(i=0; i<8; i++) | |
412 idctSparse2Col(block + i); | |
413 } | |
414 #else | |
415 for(i=0; i<8; i++) | |
416 idctRowCondDC(block + i*8); | |
417 | |
418 for(i=0; i<8; i++) | |
419 idctSparseCol(block + i); | |
420 #endif | |
175
bd77d3cbb233
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
diff
changeset
|
421 } |