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.

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