You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

590 lines
14KB

  1. /*
  2. Copyright (C) 2001 Michael Niedermayer (michaelni@gmx.at)
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. /*
  16. based upon some outcommented c code from mpeg2dec (idct_mmx.c written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
  17. */
  18. #include <inttypes.h>
  19. #include "simple_idct.h"
  20. #include "../config.h"
  21. #if 0
  22. #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
  23. #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
  24. #define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
  25. #define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
  26. #define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
  27. #define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
  28. #define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
  29. #define ROW_SHIFT 8
  30. #define COL_SHIFT 17
  31. #else
  32. #define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  33. #define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  34. #define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  35. #define W4 16384 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  36. #define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  37. #define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  38. #define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
  39. #define ROW_SHIFT 11
  40. #define COL_SHIFT 20 // 6
  41. #endif
  42. /* 8x8 Matrix used to do a trivial (slow) 8 point IDCT */
  43. static int coeff[64]={
  44. W4, W4, W4, W4, W4, W4, W4, W4,
  45. W1, W3, W5, W7,-W7,-W5,-W3,-W1,
  46. W2, W6,-W6,-W2,-W2,-W6, W6, W2,
  47. W3,-W7,-W1,-W5, W5, W1, W7,-W3,
  48. W4,-W4,-W4, W4, W4,-W4,-W4, W4,
  49. W5,-W1, W7, W3,-W3,-W7, W1,-W5,
  50. W6,-W2, W2,-W6,-W6, W2,-W2, W6,
  51. W7,-W5, W3,-W1, W1,-W3, W5,-W7
  52. };
  53. static int inline idctRowCondZ (int16_t * row)
  54. {
  55. int a0, a1, a2, a3, b0, b1, b2, b3;
  56. if( !( ((uint32_t*)row)[0]|((uint32_t*)row)[1] |((uint32_t*)row)[2] |((uint32_t*)row)[3])) {
  57. /* row[0] = row[1] = row[2] = row[3] = row[4] =
  58. row[5] = row[6] = row[7] = 0;*/
  59. return 0;
  60. }
  61. if(!( ((uint32_t*)row)[2] |((uint32_t*)row)[3] )){
  62. a0 = W4*row[0] + W2*row[2] + (1<<(ROW_SHIFT-1));
  63. a1 = W4*row[0] + W6*row[2] + (1<<(ROW_SHIFT-1));
  64. a2 = W4*row[0] - W6*row[2] + (1<<(ROW_SHIFT-1));
  65. a3 = W4*row[0] - W2*row[2] + (1<<(ROW_SHIFT-1));
  66. b0 = W1*row[1] + W3*row[3];
  67. b1 = W3*row[1] - W7*row[3];
  68. b2 = W5*row[1] - W1*row[3];
  69. b3 = W7*row[1] - W5*row[3];
  70. }else{
  71. a0 = W4*row[0] + W2*row[2] + W4*row[4] + W6*row[6] + (1<<(ROW_SHIFT-1));
  72. a1 = W4*row[0] + W6*row[2] - W4*row[4] - W2*row[6] + (1<<(ROW_SHIFT-1));
  73. a2 = W4*row[0] - W6*row[2] - W4*row[4] + W2*row[6] + (1<<(ROW_SHIFT-1));
  74. a3 = W4*row[0] - W2*row[2] + W4*row[4] - W6*row[6] + (1<<(ROW_SHIFT-1));
  75. b0 = W1*row[1] + W3*row[3] + W5*row[5] + W7*row[7];
  76. b1 = W3*row[1] - W7*row[3] - W1*row[5] - W5*row[7];
  77. b2 = W5*row[1] - W1*row[3] + W7*row[5] + W3*row[7];
  78. b3 = W7*row[1] - W5*row[3] + W3*row[5] - W1*row[7];
  79. }
  80. row[0] = (a0 + b0) >> ROW_SHIFT;
  81. row[1] = (a1 + b1) >> ROW_SHIFT;
  82. row[2] = (a2 + b2) >> ROW_SHIFT;
  83. row[3] = (a3 + b3) >> ROW_SHIFT;
  84. row[4] = (a3 - b3) >> ROW_SHIFT;
  85. row[5] = (a2 - b2) >> ROW_SHIFT;
  86. row[6] = (a1 - b1) >> ROW_SHIFT;
  87. row[7] = (a0 - b0) >> ROW_SHIFT;
  88. return 1;
  89. }
  90. #ifdef ARCH_ALPHA
  91. /* 0: all entries 0, 1: only first entry nonzero, 2: otherwise */
  92. static int inline idctRowCondDC(int16_t *row)
  93. {
  94. int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
  95. uint64_t *lrow = (uint64_t *) row;
  96. if (lrow[1] == 0) {
  97. if (lrow[0] == 0)
  98. return 0;
  99. if ((lrow[0] & ~0xffffULL) == 0) {
  100. uint64_t v;
  101. a0 = W4 * row[0];
  102. a0 += 1 << (ROW_SHIFT - 1);
  103. a0 >>= ROW_SHIFT;
  104. v = (uint16_t) a0;
  105. v += v << 16;
  106. v += v << 32;
  107. lrow[0] = v;
  108. lrow[1] = v;
  109. return 1;
  110. }
  111. }
  112. a0 = W4 * row[0];
  113. a1 = W4 * row[0];
  114. a2 = W4 * row[0];
  115. a3 = W4 * row[0];
  116. if (row[2]) {
  117. a0 += W2 * row[2];
  118. a1 += W6 * row[2];
  119. a2 -= W6 * row[2];
  120. a3 -= W2 * row[2];
  121. }
  122. if (row[4]) {
  123. a0 += W4 * row[4];
  124. a1 -= W4 * row[4];
  125. a2 -= W4 * row[4];
  126. a3 += W4 * row[4];
  127. }
  128. if (row[6]) {
  129. a0 += W6 * row[6];
  130. a1 -= W2 * row[6];
  131. a2 += W2 * row[6];
  132. a3 -= W6 * row[6];
  133. }
  134. a0 += 1 << (ROW_SHIFT - 1);
  135. a1 += 1 << (ROW_SHIFT - 1);
  136. a2 += 1 << (ROW_SHIFT - 1);
  137. a3 += 1 << (ROW_SHIFT - 1);
  138. if (row[1]) {
  139. b0 = W1 * row[1];
  140. b1 = W3 * row[1];
  141. b2 = W5 * row[1];
  142. b3 = W7 * row[1];
  143. } else {
  144. b0 = 0;
  145. b1 = 0;
  146. b2 = 0;
  147. b3 = 0;
  148. }
  149. if (row[3]) {
  150. b0 += W3 * row[3];
  151. b1 -= W7 * row[3];
  152. b2 -= W1 * row[3];
  153. b3 -= W5 * row[3];
  154. }
  155. if (row[5]) {
  156. b0 += W5 * row[5];
  157. b1 -= W1 * row[5];
  158. b2 += W7 * row[5];
  159. b3 += W3 * row[5];
  160. }
  161. if (row[7]) {
  162. b0 += W7 * row[7];
  163. b1 -= W5 * row[7];
  164. b2 += W3 * row[7];
  165. b3 -= W1 * row[7];
  166. }
  167. row[0] = (a0 + b0) >> ROW_SHIFT;
  168. row[1] = (a1 + b1) >> ROW_SHIFT;
  169. row[2] = (a2 + b2) >> ROW_SHIFT;
  170. row[3] = (a3 + b3) >> ROW_SHIFT;
  171. row[4] = (a3 - b3) >> ROW_SHIFT;
  172. row[5] = (a2 - b2) >> ROW_SHIFT;
  173. row[6] = (a1 - b1) >> ROW_SHIFT;
  174. row[7] = (a0 - b0) >> ROW_SHIFT;
  175. return 2;
  176. }
  177. #else /* not ARCH_ALPHA */
  178. static int inline idctRowCondDC (int16_t * row)
  179. {
  180. int a0, a1, a2, a3, b0, b1, b2, b3;
  181. if( !( ((uint32_t*)row)[1] |((uint32_t*)row)[2] |((uint32_t*)row)[3]| row[1])) {
  182. // row[0] = row[1] = row[2] = row[3] = row[4] = row[5] = row[6] = row[7] = row[0]<<3;
  183. uint16_t temp= row[0]<<3;
  184. ((uint32_t*)row)[0]=((uint32_t*)row)[1]=
  185. ((uint32_t*)row)[2]=((uint32_t*)row)[3]= temp + (temp<<16);
  186. return 0;
  187. }
  188. if(!( ((uint32_t*)row)[2] |((uint32_t*)row)[3] )){
  189. a0 = W4*row[0] + W2*row[2] + (1<<(ROW_SHIFT-1));
  190. a1 = W4*row[0] + W6*row[2] + (1<<(ROW_SHIFT-1));
  191. a2 = W4*row[0] - W6*row[2] + (1<<(ROW_SHIFT-1));
  192. a3 = W4*row[0] - W2*row[2] + (1<<(ROW_SHIFT-1));
  193. b0 = W1*row[1] + W3*row[3];
  194. b1 = W3*row[1] - W7*row[3];
  195. b2 = W5*row[1] - W1*row[3];
  196. b3 = W7*row[1] - W5*row[3];
  197. }else{
  198. a0 = W4*row[0] + W2*row[2] + W4*row[4] + W6*row[6] + (1<<(ROW_SHIFT-1));
  199. a1 = W4*row[0] + W6*row[2] - W4*row[4] - W2*row[6] + (1<<(ROW_SHIFT-1));
  200. a2 = W4*row[0] - W6*row[2] - W4*row[4] + W2*row[6] + (1<<(ROW_SHIFT-1));
  201. a3 = W4*row[0] - W2*row[2] + W4*row[4] - W6*row[6] + (1<<(ROW_SHIFT-1));
  202. b0 = W1*row[1] + W3*row[3] + W5*row[5] + W7*row[7];
  203. b1 = W3*row[1] - W7*row[3] - W1*row[5] - W5*row[7];
  204. b2 = W5*row[1] - W1*row[3] + W7*row[5] + W3*row[7];
  205. b3 = W7*row[1] - W5*row[3] + W3*row[5] - W1*row[7];
  206. }
  207. row[0] = (a0 + b0) >> ROW_SHIFT;
  208. row[7] = (a0 - b0) >> ROW_SHIFT;
  209. row[1] = (a1 + b1) >> ROW_SHIFT;
  210. row[6] = (a1 - b1) >> ROW_SHIFT;
  211. row[2] = (a2 + b2) >> ROW_SHIFT;
  212. row[5] = (a2 - b2) >> ROW_SHIFT;
  213. row[3] = (a3 + b3) >> ROW_SHIFT;
  214. row[4] = (a3 - b3) >> ROW_SHIFT;
  215. return 1;
  216. }
  217. #endif /* not ARCH_ALPHA */
  218. static void inline idctCol (int16_t * col)
  219. {
  220. /*
  221. if( !(col[8*1] | col[8*2] |col[8*3] |col[8*4] |col[8*5] |col[8*6] | col[8*7])) {
  222. col[8*0] = col[8*1] = col[8*2] = col[8*3] = col[8*4] =
  223. col[8*5] = col[8*6] = col[8*7] = col[8*0]<<3;
  224. return;
  225. }*/
  226. int a0, a1, a2, a3, b0, b1, b2, b3;
  227. col[0] += (1<<(COL_SHIFT-1))/W4;
  228. a0 = W4*col[8*0] + W2*col[8*2] + W4*col[8*4] + W6*col[8*6];
  229. a1 = W4*col[8*0] + W6*col[8*2] - W4*col[8*4] - W2*col[8*6];
  230. a2 = W4*col[8*0] - W6*col[8*2] - W4*col[8*4] + W2*col[8*6];
  231. a3 = W4*col[8*0] - W2*col[8*2] + W4*col[8*4] - W6*col[8*6];
  232. b0 = W1*col[8*1] + W3*col[8*3] + W5*col[8*5] + W7*col[8*7];
  233. b1 = W3*col[8*1] - W7*col[8*3] - W1*col[8*5] - W5*col[8*7];
  234. b2 = W5*col[8*1] - W1*col[8*3] + W7*col[8*5] + W3*col[8*7];
  235. b3 = W7*col[8*1] - W5*col[8*3] + W3*col[8*5] - W1*col[8*7];
  236. col[8*0] = (a0 + b0) >> COL_SHIFT;
  237. col[8*7] = (a0 - b0) >> COL_SHIFT;
  238. col[8*1] = (a1 + b1) >> COL_SHIFT;
  239. col[8*6] = (a1 - b1) >> COL_SHIFT;
  240. col[8*2] = (a2 + b2) >> COL_SHIFT;
  241. col[8*5] = (a2 - b2) >> COL_SHIFT;
  242. col[8*3] = (a3 + b3) >> COL_SHIFT;
  243. col[8*4] = (a3 - b3) >> COL_SHIFT;
  244. }
  245. static void inline idctSparseCol (int16_t * col)
  246. {
  247. int a0, a1, a2, a3, b0, b1, b2, b3;
  248. col[0] += (1<<(COL_SHIFT-1))/W4;
  249. a0 = W4*col[8*0];
  250. a1 = W4*col[8*0];
  251. a2 = W4*col[8*0];
  252. a3 = W4*col[8*0];
  253. if(col[8*2]){
  254. a0 += + W2*col[8*2];
  255. a1 += + W6*col[8*2];
  256. a2 += - W6*col[8*2];
  257. a3 += - W2*col[8*2];
  258. }
  259. if(col[8*4]){
  260. a0 += + W4*col[8*4];
  261. a1 += - W4*col[8*4];
  262. a2 += - W4*col[8*4];
  263. a3 += + W4*col[8*4];
  264. }
  265. if(col[8*6]){
  266. a0 += + W6*col[8*6];
  267. a1 += - W2*col[8*6];
  268. a2 += + W2*col[8*6];
  269. a3 += - W6*col[8*6];
  270. }
  271. if(col[8*1]){
  272. b0 = W1*col[8*1];
  273. b1 = W3*col[8*1];
  274. b2 = W5*col[8*1];
  275. b3 = W7*col[8*1];
  276. }else{
  277. b0 =
  278. b1 =
  279. b2 =
  280. b3 = 0;
  281. }
  282. if(col[8*3]){
  283. b0 += + W3*col[8*3];
  284. b1 += - W7*col[8*3];
  285. b2 += - W1*col[8*3];
  286. b3 += - W5*col[8*3];
  287. }
  288. if(col[8*5]){
  289. b0 += + W5*col[8*5];
  290. b1 += - W1*col[8*5];
  291. b2 += + W7*col[8*5];
  292. b3 += + W3*col[8*5];
  293. }
  294. if(col[8*7]){
  295. b0 += + W7*col[8*7];
  296. b1 += - W5*col[8*7];
  297. b2 += + W3*col[8*7];
  298. b3 += - W1*col[8*7];
  299. }
  300. #ifndef ARCH_ALPHA
  301. if(!(b0|b1|b2|b3)){
  302. col[8*0] = (a0) >> COL_SHIFT;
  303. col[8*7] = (a0) >> COL_SHIFT;
  304. col[8*1] = (a1) >> COL_SHIFT;
  305. col[8*6] = (a1) >> COL_SHIFT;
  306. col[8*2] = (a2) >> COL_SHIFT;
  307. col[8*5] = (a2) >> COL_SHIFT;
  308. col[8*3] = (a3) >> COL_SHIFT;
  309. col[8*4] = (a3) >> COL_SHIFT;
  310. }else{
  311. #endif
  312. col[8*0] = (a0 + b0) >> COL_SHIFT;
  313. col[8*7] = (a0 - b0) >> COL_SHIFT;
  314. col[8*1] = (a1 + b1) >> COL_SHIFT;
  315. col[8*6] = (a1 - b1) >> COL_SHIFT;
  316. col[8*2] = (a2 + b2) >> COL_SHIFT;
  317. col[8*5] = (a2 - b2) >> COL_SHIFT;
  318. col[8*3] = (a3 + b3) >> COL_SHIFT;
  319. col[8*4] = (a3 - b3) >> COL_SHIFT;
  320. #ifndef ARCH_ALPHA
  321. }
  322. #endif
  323. }
  324. static void inline idctSparse2Col (int16_t * col)
  325. {
  326. int a0, a1, a2, a3, b0, b1, b2, b3;
  327. col[0] += (1<<(COL_SHIFT-1))/W4;
  328. a0 = W4*col[8*0];
  329. a1 = W4*col[8*0];
  330. a2 = W4*col[8*0];
  331. a3 = W4*col[8*0];
  332. if(col[8*2]){
  333. a0 += + W2*col[8*2];
  334. a1 += + W6*col[8*2];
  335. a2 += - W6*col[8*2];
  336. a3 += - W2*col[8*2];
  337. }
  338. if(col[8*4]){
  339. a0 += + W4*col[8*4];
  340. a1 += - W4*col[8*4];
  341. a2 += - W4*col[8*4];
  342. a3 += + W4*col[8*4];
  343. }
  344. if(col[8*6]){
  345. a0 += + W6*col[8*6];
  346. a1 += - W2*col[8*6];
  347. a2 += + W2*col[8*6];
  348. a3 += - W6*col[8*6];
  349. }
  350. if(col[8*1] || 1){
  351. b0 = W1*col[8*1];
  352. b1 = W3*col[8*1];
  353. b2 = W5*col[8*1];
  354. b3 = W7*col[8*1];
  355. }else{
  356. b0 =
  357. b1 =
  358. b2 =
  359. b3 = 0;
  360. }
  361. if(col[8*3]){
  362. b0 += + W3*col[8*3];
  363. b1 += - W7*col[8*3];
  364. b2 += - W1*col[8*3];
  365. b3 += - W5*col[8*3];
  366. }
  367. if(col[8*5]){
  368. b0 += + W5*col[8*5];
  369. b1 += - W1*col[8*5];
  370. b2 += + W7*col[8*5];
  371. b3 += + W3*col[8*5];
  372. }
  373. if(col[8*7]){
  374. b0 += + W7*col[8*7];
  375. b1 += - W5*col[8*7];
  376. b2 += + W3*col[8*7];
  377. b3 += - W1*col[8*7];
  378. }
  379. col[8*0] = (a0 + b0) >> COL_SHIFT;
  380. col[8*7] = (a0 - b0) >> COL_SHIFT;
  381. col[8*1] = (a1 + b1) >> COL_SHIFT;
  382. col[8*6] = (a1 - b1) >> COL_SHIFT;
  383. col[8*2] = (a2 + b2) >> COL_SHIFT;
  384. col[8*5] = (a2 - b2) >> COL_SHIFT;
  385. col[8*3] = (a3 + b3) >> COL_SHIFT;
  386. col[8*4] = (a3 - b3) >> COL_SHIFT;
  387. }
  388. #ifdef ARCH_ALPHA
  389. /* If all rows but the first one are zero after row transformation,
  390. all rows will be identical after column transformation. */
  391. static inline void idctCol2(int16_t *col)
  392. {
  393. int i;
  394. uint64_t l, r;
  395. uint64_t *lcol = (uint64_t *) col;
  396. for (i = 0; i < 8; ++i) {
  397. int a0 = col[0] + (1 << (COL_SHIFT - 1)) / W4;
  398. a0 *= W4;
  399. col[0] = a0 >> COL_SHIFT;
  400. ++col;
  401. }
  402. l = lcol[0];
  403. r = lcol[1];
  404. lcol[ 2] = l; lcol[ 3] = r;
  405. lcol[ 4] = l; lcol[ 5] = r;
  406. lcol[ 6] = l; lcol[ 7] = r;
  407. lcol[ 8] = l; lcol[ 9] = r;
  408. lcol[10] = l; lcol[11] = r;
  409. lcol[12] = l; lcol[13] = r;
  410. lcol[14] = l; lcol[15] = r;
  411. }
  412. #endif
  413. void simple_idct (short *block)
  414. {
  415. int i;
  416. #if 0
  417. int nonZero[8];
  418. int buffer[64];
  419. int nNonZero=0;
  420. idctRowCondDC(block);
  421. for(i=1; i<8; i++)
  422. {
  423. nonZero[nNonZero]=i;
  424. nNonZero+= idctRowCondZ(block + i*8);
  425. }
  426. if(nNonZero==0)
  427. {
  428. for(i=0; i<8; i++)
  429. {
  430. block[i ]=
  431. block[i+8 ]=
  432. block[i+16]=
  433. block[i+24]=
  434. block[i+32]=
  435. block[i+40]=
  436. block[i+48]=
  437. block[i+56]= (W4*block[i] + (1<<(COL_SHIFT-1))) >> COL_SHIFT;
  438. }
  439. }
  440. else if(nNonZero==1)
  441. {
  442. int index= nonZero[0]*8;
  443. for(i=0; i<8; i++)
  444. {
  445. int bias= W4*block[i] + (1<<(COL_SHIFT-1));
  446. int c= block[i + index];
  447. block[i ]= (c*coeff[index ] + bias) >> COL_SHIFT;
  448. block[i+8 ]= (c*coeff[index+1] + bias) >> COL_SHIFT;
  449. block[i+16]= (c*coeff[index+2] + bias) >> COL_SHIFT;
  450. block[i+24]= (c*coeff[index+3] + bias) >> COL_SHIFT;
  451. block[i+32]= (c*coeff[index+4] + bias) >> COL_SHIFT;
  452. block[i+40]= (c*coeff[index+5] + bias) >> COL_SHIFT;
  453. block[i+48]= (c*coeff[index+6] + bias) >> COL_SHIFT;
  454. block[i+56]= (c*coeff[index+7] + bias) >> COL_SHIFT;
  455. }
  456. }
  457. /* else if(nNonZero==2)
  458. {
  459. int index1= nonZero[0]*8;
  460. int index2= nonZero[1]*8;
  461. for(i=0; i<8; i++)
  462. {
  463. int bias= W4*block[i] + (1<<(COL_SHIFT-1));
  464. int c1= block[i + index1];
  465. int c2= block[i + index2];
  466. block[i ]= (c1*coeff[index1 ] + c2*coeff[index2 ] + bias) >> COL_SHIFT;
  467. block[i+8 ]= (c1*coeff[index1+1] + c2*coeff[index2+1] + bias) >> COL_SHIFT;
  468. block[i+16]= (c1*coeff[index1+2] + c2*coeff[index2+2] + bias) >> COL_SHIFT;
  469. block[i+24]= (c1*coeff[index1+3] + c2*coeff[index2+3] + bias) >> COL_SHIFT;
  470. block[i+32]= (c1*coeff[index1+4] + c2*coeff[index2+4] + bias) >> COL_SHIFT;
  471. block[i+40]= (c1*coeff[index1+5] + c2*coeff[index2+5] + bias) >> COL_SHIFT;
  472. block[i+48]= (c1*coeff[index1+6] + c2*coeff[index2+6] + bias) >> COL_SHIFT;
  473. block[i+56]= (c1*coeff[index1+7] + c2*coeff[index2+7] + bias) >> COL_SHIFT;
  474. }
  475. }*/
  476. else
  477. {
  478. for(i=0; i<8; i++)
  479. idctSparse2Col(block + i);
  480. }
  481. #elif defined(ARCH_ALPHA)
  482. int rowsZero = 1; /* all rows except row 0 zero */
  483. int rowsConstant = 1; /* all rows consist of a constant value */
  484. for (i = 0; i < 8; i++) {
  485. int sparseness = idctRowCondDC(block + 8 * i);
  486. if (i > 0 && sparseness > 0)
  487. rowsZero = 0;
  488. if (sparseness == 2)
  489. rowsConstant = 0;
  490. }
  491. if (rowsZero) {
  492. idctCol2(block);
  493. } else if (rowsConstant) {
  494. uint64_t *lblock = (uint64_t *) block;
  495. idctSparseCol(block);
  496. for (i = 0; i < 8; i++) {
  497. uint64_t v = (uint16_t) block[i * 8];
  498. v += v << 16;
  499. v += v << 32;
  500. lblock[0] = v;
  501. lblock[1] = v;
  502. lblock += 2;
  503. }
  504. } else {
  505. for (i = 0; i < 8; i++)
  506. idctSparseCol(block + i);
  507. }
  508. #else
  509. for(i=0; i<8; i++)
  510. idctRowCondDC(block + i*8);
  511. for(i=0; i<8; i++)
  512. idctSparseCol(block + i);
  513. #endif
  514. }