simple_idct.c 16 KB

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