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.

592 lines
14KB

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