Leaked source code of windows server 2003
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.

1132 lines
42 KiB

  1. /*++
  2. Copyright (c) 1998 Philips CE - I&C
  3. Module Name:
  4. mdecoder.c
  5. Abstract:
  6. this module converts the raw USB data to video data.
  7. Original Author:
  8. Ronald v.d.Meer
  9. Environment:
  10. Kernel mode only
  11. Revision History:
  12. Date Reason
  13. 14-04-1998 Initial version
  14. --*/
  15. #include "wdm.h"
  16. #include "mcamdrv.h"
  17. #include "mstreams.h"
  18. #include "mcodec.h"
  19. #include "mdecoder.h"
  20. /*******************************************************************************
  21. *
  22. * START LOCAL DEFINES
  23. *
  24. ******************************************************************************/
  25. #define CLIP(x) (((unsigned) (x) > 255) ? (((x) < 0) ? 0 : 255) : (x))
  26. /*
  27. * The following code clips x between 0 and 255, it is crafted to let the
  28. * compiler generate good code:
  29. */
  30. #define CLIP2(i1, i2) \
  31. {\
  32. long x = b[i2] >> 15;\
  33. *(pDst + i1) = (BYTE) ((DWORD) x > 255) ? ((x < 0) ? 0 : 255) : (BYTE) x;\
  34. }
  35. /*
  36. * The following code clips x between 0 and 255, it is crafted to let the
  37. * compiler generate good code:
  38. * YGain is doubled (used for camera's with SII version 4)
  39. */
  40. #define CLIP2YGAIN(i1, i2) \
  41. {\
  42. long x = (b[i2] << 1) >> 15;\
  43. *(pDst + i1) = (BYTE) ((DWORD) x > 255) ? ((x < 0) ? 0 : 255) : (BYTE) x;\
  44. }
  45. /* these values are used in table[]: */
  46. #define SHORT_SYMBOL 0
  47. #define LONG_SYMBOL 1
  48. #define END_OF_BLOCK 2
  49. #define UNUSED 0
  50. /*******************************************************************************
  51. *
  52. * START TYPEDEFS
  53. *
  54. ******************************************************************************/
  55. typedef struct
  56. {
  57. BYTE bitc;
  58. BYTE qsteplog;
  59. } QB;
  60. typedef struct
  61. {
  62. BYTE level;
  63. BYTE length;
  64. BYTE run;
  65. BYTE index;
  66. } TABLE_ELEMENT;
  67. /*******************************************************************************
  68. *
  69. * START STATIC VARIABLES
  70. *
  71. ******************************************************************************/
  72. /*
  73. * Order of arrays emperically optimized for cache behaviour:
  74. */
  75. #define STRAT 8
  76. #define DRAC 4
  77. #define DC 512
  78. static short rs[STRAT][DRAC][8][16]; /* if long, then table[].index wouldn't fit in a byte */
  79. static QB qb[STRAT][DRAC][16]; /* qsteplog/bitc table */
  80. static long multiply[DC][6];
  81. static long table_val[9][DC];
  82. static DWORD valuesDC[DC];
  83. static DWORD value0coef[DC];
  84. /*
  85. * This table is used by the variable length decoder part of the decompressor.
  86. * The first 6 bits of the next symbol(s) are used as index into this table.
  87. *
  88. * table[].level : classifies the kind of symbol encountered.
  89. *
  90. * The following entries are only used in case of a short (<= 6 bits) symbol.
  91. *
  92. * table[].length : the number of bits of the symbol.
  93. * table[].run : the number of 0 coeficients until the next non-zeo
  94. * coeficient, + 1.
  95. * table[].index : used to index the rs[] table, it is optimized for the
  96. * assembly version, not the C version.
  97. */
  98. static TABLE_ELEMENT table[64] = {
  99. /* level: length: run: index: */
  100. /* 0 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  101. /* 1 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  102. /* 2 */ SHORT_SYMBOL, 4, 1, 1 * 16 * 2,
  103. /* 3 */ SHORT_SYMBOL, 6, 1, 3 * 16 * 2,
  104. /* 4 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  105. /* 5 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  106. /* 6 */ SHORT_SYMBOL, 5, 1, 2 * 16 * 2,
  107. /* 7 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  108. /* 8 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  109. /* 9 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  110. /* 10 */ SHORT_SYMBOL, 4, 1, 5 * 16 * 2,
  111. /* 11 */ SHORT_SYMBOL, 5, 2, 0 * 16 * 2,
  112. /* 12 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  113. /* 13 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  114. /* 14 */ SHORT_SYMBOL, 5, 3, 0 * 16 * 2,
  115. /* 15 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  116. /* 16 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  117. /* 17 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  118. /* 18 */ SHORT_SYMBOL, 4, 1, 1 * 16 * 2,
  119. /* 19 */ SHORT_SYMBOL, 6, 2, 1 * 16 * 2,
  120. /* 20 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  121. /* 21 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  122. /* 22 */ SHORT_SYMBOL, 5, 1, 6 * 16 * 2,
  123. /* 23 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  124. /* 24 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  125. /* 25 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  126. /* 26 */ SHORT_SYMBOL, 4, 1, 5 * 16 * 2,
  127. /* 27 */ SHORT_SYMBOL, 5, 2, 4 * 16 * 2,
  128. /* 28 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  129. /* 29 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  130. /* 30 */ SHORT_SYMBOL, 5, 3, 4 * 16 * 2,
  131. /* 31 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  132. /* 32 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  133. /* 33 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  134. /* 34 */ SHORT_SYMBOL, 4, 1, 1 * 16 * 2,
  135. /* 35 */ SHORT_SYMBOL, 6, 1, 7 * 16 * 2,
  136. /* 36 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  137. /* 37 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  138. /* 38 */ SHORT_SYMBOL, 5, 1, 2 * 16 * 2,
  139. /* 39 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  140. /* 40 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  141. /* 41 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  142. /* 42 */ SHORT_SYMBOL, 4, 1, 5 * 16 * 2,
  143. /* 43 */ SHORT_SYMBOL, 5, 2, 0 * 16 * 2,
  144. /* 44 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  145. /* 45 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  146. /* 46 */ SHORT_SYMBOL, 5, 3, 0 * 16 * 2,
  147. /* 47 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  148. /* 48 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  149. /* 49 */ SHORT_SYMBOL, 3, 1, 0 * 16 * 2,
  150. /* 50 */ SHORT_SYMBOL, 4, 1, 1 * 16 * 2,
  151. /* 51 */ SHORT_SYMBOL, 6, 2, 5 * 16 * 2,
  152. /* 52 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  153. /* 53 */ SHORT_SYMBOL, 3, 1, 4 * 16 * 2,
  154. /* 54 */ SHORT_SYMBOL, 5, 1, 6 * 16 * 2,
  155. /* 55 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED,
  156. /* 56 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  157. /* 57 */ SHORT_SYMBOL, 2 + 1, 1, 0 * 16 * 2,
  158. /* 58 */ SHORT_SYMBOL, 3 + 1, 1, 5 * 16 * 2,
  159. /* 59 */ SHORT_SYMBOL, 4 + 1, 2, 4 * 16 * 2,
  160. /* 60 */ END_OF_BLOCK, UNUSED, UNUSED, UNUSED,
  161. /* 61 */ SHORT_SYMBOL, 2 + 1, 1, 4 * 16 * 2,
  162. /* 62 */ SHORT_SYMBOL, 4 + 1, 3, 4 * 16 * 2,
  163. /* 63 */ LONG_SYMBOL, UNUSED, UNUSED, UNUSED
  164. };
  165. /*******************************************************************************
  166. *
  167. * START STATIC VARIABLES
  168. *
  169. ******************************************************************************/
  170. /* init the bit cost array for the different strategies and dynamic ranges */
  171. static int bitzz[512] =
  172. {
  173. // strategy 0
  174. 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  175. 9, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  176. 9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
  177. 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
  178. // strategy 1
  179. 9, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
  180. 9, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
  181. 9, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4,
  182. 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
  183. // strategy 2
  184. 9, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
  185. 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
  186. 9, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4,
  187. 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
  188. // strategy 3
  189. 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
  190. 9, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
  191. 9, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3,
  192. 9, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
  193. // strategy 4
  194. 9, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  195. 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
  196. 9, 5, 5, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3,
  197. 9, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5,
  198. // strategy 5
  199. 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  200. 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  201. 9, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2,
  202. 9, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4,
  203. // strategy 6
  204. 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  205. 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  206. 9, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
  207. 9, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4,
  208. // strategy 7
  209. 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  210. 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  211. 9, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
  212. 9, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3
  213. };
  214. /*
  215. * quantizatioon array for the different strategies and dynamic ranges
  216. */
  217. static int qzz[512] =
  218. {
  219. // strategy 0
  220. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  221. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  222. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  223. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  224. // strategy 1
  225. 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4,
  226. 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4,
  227. 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4,
  228. 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4,
  229. // strategy 2
  230. 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4,
  231. 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4,
  232. 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4,
  233. 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4,
  234. // strategy 3
  235. 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4,
  236. 1, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16,
  237. 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8,
  238. 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8,
  239. // strategy 4
  240. 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  241. 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16,
  242. 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8,
  243. 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8,
  244. // strategy 5
  245. 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  246. 1, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  247. 1, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16,
  248. 1, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16,
  249. // strategy 6
  250. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  251. 1, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  252. 1, 4, 4, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16,
  253. 1, 4, 4, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16,
  254. // strategy 7
  255. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  256. 1, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  257. 1, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32,
  258. 1, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32
  259. };
  260. /*******************************************************************************
  261. *
  262. * START EXPORTED METHODS DEFINITIONS
  263. *
  264. ******************************************************************************/
  265. /*
  266. *
  267. */
  268. extern void
  269. InitDecoder ()
  270. {
  271. int i;
  272. int j;
  273. int dc;
  274. int strat;
  275. int drac;
  276. DWORD x;
  277. int val;
  278. int *p_zz;
  279. for (dc = 0; dc < 512; dc++)
  280. {
  281. x = CLIP ((dc * 31684L + 32768L / 2L) >> 15);
  282. x |= x << 8;
  283. x |= x << 16;
  284. value0coef[dc] = x;
  285. i = dc - 256;
  286. valuesDC[dc] = dc * 31684L;
  287. multiply[dc][0] = i * 31684L;
  288. multiply[dc][1] = i * 42186L;
  289. multiply[dc][2] = i * 17444L;
  290. multiply[dc][3] = i * 56169L;
  291. multiply[dc][4] = i * 23226L;
  292. multiply[dc][5] = i * 9604L;
  293. }
  294. /* Warning: it is assumed that the qstep values are of the form 2^n, n e [0,7] */
  295. p_zz = &qzz[0];
  296. for (strat = 0; strat < 8; strat++)
  297. {
  298. for (drac = 0; drac <= 3; drac++)
  299. {
  300. for (i = 0; i <= 15; i++)
  301. {
  302. val = *p_zz++;
  303. for (j = 0; j < 8; j++)
  304. {
  305. if (val & (1 << j))
  306. {
  307. qb[strat][drac][i].qsteplog = (BYTE) j;
  308. break;
  309. }
  310. }
  311. rs[strat][drac][0][i] = (short) ( val * 1 + 256) * 3;
  312. rs[strat][drac][1][i] = (short) ( val * 2 + 256) * 3;
  313. rs[strat][drac][2][i] = (short) ( val * 3 + 256) * 3;
  314. rs[strat][drac][3][i] = (short) ( val * 4 + 256) * 3;
  315. rs[strat][drac][4][i] = (short) (-val * 1 + 256) * 3;
  316. rs[strat][drac][5][i] = (short) (-val * 2 + 256) * 3;
  317. rs[strat][drac][6][i] = (short) (-val * 3 + 256) * 3;
  318. rs[strat][drac][7][i] = (short) (-val * 4 + 256) * 3;
  319. }
  320. }
  321. }
  322. p_zz = &bitzz[0];
  323. for (strat = 0; strat < 8; strat++)
  324. {
  325. for (drac = 0; drac <= 3; drac++)
  326. {
  327. for (i = 0; i <= 15; i++)
  328. {
  329. qb[strat][drac][i].bitc = (BYTE) *p_zz++;
  330. }
  331. }
  332. }
  333. for (dc = 0; dc < 512; dc++)
  334. {
  335. table_val[0][dc] = 0;
  336. }
  337. for (i = 1; i <= 8; i++)
  338. {
  339. j = 0;
  340. while ((j * (1 << i)) < 512)
  341. {
  342. for (dc = j * (1 << i); dc < 512; dc++)
  343. {
  344. if ((j % 2) == 0)
  345. {
  346. table_val[i][dc] = dc & ((1 << i) - 1);
  347. }
  348. else
  349. {
  350. table_val[i][dc] = -(dc & ((1 << i) - 1));
  351. }
  352. }
  353. j++;
  354. }
  355. }
  356. }
  357. /*
  358. *
  359. */
  360. //------------------------------------------------------------------------------
  361. /*
  362. *
  363. */
  364. extern void
  365. DcDecompressBandToI420 (PBYTE pSrc, PBYTE pDst, DWORD camVersion,
  366. BOOLEAN YBlockBand, BOOLEAN Cropping)
  367. {
  368. long b[16];
  369. long k;
  370. long level;
  371. DWORD code_word;
  372. DWORD strat;
  373. QB *p_qb;
  374. long result;
  375. BOOLEAN Uval;
  376. PBYTE pDstEnd;
  377. long cm1, cm2, cm3;
  378. int ix;
  379. unsigned short *p_rs;
  380. PBYTE pInputLimit;
  381. long *pMultiply = (long *) multiply; /* Help compiler avoid a divide. */
  382. static BYTE bitIndex;
  383. static PBYTE bytePtr;
  384. // BYTE DummyRead; /* Force data cache line loads before repeated writes. */
  385. /*
  386. * The way input bits are read via *bit_pt is dependant on the endianess
  387. * of the machine.
  388. */
  389. if (YBlockBand)
  390. {
  391. bytePtr = pSrc + 1; // 1st bit and band_nr (7 bits) are not used
  392. bitIndex = 3;
  393. strat = (* (PDWORD) (bytePtr)) & 0x7;
  394. pDstEnd = pDst + CIF_X;
  395. }
  396. else // UV BlockBand
  397. {
  398. // derive the strategy used for the UV data
  399. // from the strategy used for the Y data
  400. strat = (* (PDWORD) ((PBYTE) pSrc + 1)) & 0x7;
  401. if (strat != 0)
  402. {
  403. if (strat >= 6)
  404. {
  405. strat = 7;
  406. }
  407. else if (strat == 5)
  408. {
  409. strat = 6;
  410. }
  411. else
  412. {
  413. strat += 2;
  414. }
  415. }
  416. pDstEnd = pDst + (CIF_X / 2);
  417. }
  418. Uval = TRUE;
  419. pInputLimit = pSrc + ((camVersion >= SSI_CIF3) ? BytesPerBandCIF3
  420. : BytesPerBandCIF4);
  421. do
  422. {
  423. if (bytePtr >= pInputLimit)
  424. {
  425. return;
  426. }
  427. bytePtr += (bitIndex / 8);
  428. bitIndex = (bitIndex % 8);
  429. code_word = (* (PDWORD) bytePtr) >> bitIndex;
  430. bitIndex += 11;
  431. result = (code_word >> 2) & 0x1FF; // dc value
  432. if ((code_word & 0x00001800) == 0x00) // the same as statement below
  433. // if (((code_word >> 11) & 0x3) == 0x0)
  434. {
  435. /*
  436. * EOB detected, 4x4 block contains only DC
  437. * Executed 0.27 times per IDCT block.
  438. */
  439. DWORD yuvVal = value0coef[result];
  440. // DummyRead += pDst[0];
  441. // DummyRead += pDst[BLOCK_BAND_WIDTH];
  442. if (YBlockBand)
  443. {
  444. if (camVersion == SSI_YGAIN_MUL2)
  445. {
  446. yuvVal <<= 1;
  447. }
  448. * (PDWORD) (pDst + (0 * CIF_X) + 0) = yuvVal;
  449. * (PDWORD) (pDst + (1 * CIF_X) + 0) = yuvVal;
  450. // DummyRead += pDst[2 * CIF_X];
  451. * (PDWORD) (pDst + (2 * CIF_X) + 0) = yuvVal;
  452. // DummyRead += pDst[3 * CIF_X];
  453. * (PDWORD) (pDst + (3 * CIF_X) + 0) = yuvVal;
  454. pDst += 4;
  455. }
  456. else // UV_BLOCK_BAND
  457. {
  458. if (Cropping)
  459. {
  460. if (Uval)
  461. {
  462. * (PDWORD) (pDst + 0 + (0 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  463. * (PDWORD) (pDst + 0 + (0 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  464. * (PDWORD) (pDst + 0 + (1 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  465. * (PDWORD) (pDst + 0 + (1 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  466. Uval = FALSE;
  467. }
  468. else // Vval
  469. {
  470. * (PDWORD) (pDst + I420_NO_U_PER_BAND_CIF + (0 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  471. * (PDWORD) (pDst + I420_NO_U_PER_BAND_CIF + (0 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  472. * (PDWORD) (pDst + I420_NO_U_PER_BAND_CIF + (1 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  473. * (PDWORD) (pDst + I420_NO_U_PER_BAND_CIF + (1 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  474. Uval = TRUE;
  475. pDst += 8;
  476. }
  477. }
  478. else // CIF OUT
  479. {
  480. if (Uval)
  481. {
  482. * (PDWORD) (pDst + 0 + (0 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  483. * (PDWORD) (pDst + 0 + (0 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  484. * (PDWORD) (pDst + 0 + (1 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  485. * (PDWORD) (pDst + 0 + (1 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  486. Uval = FALSE;
  487. }
  488. else // Vval
  489. {
  490. * (PDWORD) (pDst + I420_NO_U_CIF + (0 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  491. * (PDWORD) (pDst + I420_NO_U_CIF + (0 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  492. * (PDWORD) (pDst + I420_NO_U_CIF + (1 * I420_NO_C_PER_LINE_CIF) + 0) = yuvVal;
  493. * (PDWORD) (pDst + I420_NO_U_CIF + (1 * I420_NO_C_PER_LINE_CIF) + 4) = yuvVal;
  494. Uval = TRUE;
  495. pDst += 8;
  496. }
  497. }
  498. }
  499. bitIndex += 2;
  500. continue;
  501. }
  502. k = 0;
  503. if (camVersion < SSI_8117_N3)
  504. {
  505. // for old 8117 versions (N2 and before) sometimes a decompressed
  506. // line contains coloured artifacts. This occurs when the DC
  507. // value equals 256. The code below fixes this.
  508. if (result == 256)
  509. {
  510. k = 0 - 1;
  511. }
  512. }
  513. p_qb = qb[strat][code_word & 0x3];
  514. p_rs = (unsigned short *) &rs[strat][code_word & 0x3];
  515. result = valuesDC[result];
  516. b[ 0] = result; b[ 1] = result; b[ 2] = result; b[ 3] = result;
  517. b[ 4] = result; b[ 5] = result; b[ 6] = result; b[ 7] = result;
  518. b[ 8] = result; b[ 9] = result; b[10] = result; b[11] = result;
  519. b[12] = result; b[13] = result; b[14] = result; b[15] = result;
  520. while (1)
  521. {
  522. /*
  523. * On average 4.32 iterations per IDCT block.
  524. */
  525. if (bytePtr >= pInputLimit)
  526. {
  527. return;
  528. }
  529. bytePtr += (bitIndex / 8);
  530. bitIndex = (bitIndex % 8);
  531. code_word = (* (PDWORD) bytePtr) >> bitIndex;
  532. ix = code_word & 0x3F;
  533. level = table[ix].level;
  534. if (level >= LONG_SYMBOL) /* level == LONG_SYMBOL or END_OF_BLOCK */
  535. {
  536. if (level > LONG_SYMBOL) /* level == END_OF_BLOCK */
  537. {
  538. /*
  539. * Executed 0.73 times per IDCT block.
  540. */
  541. bitIndex += 2;
  542. break;
  543. }
  544. /*
  545. * Executed 0.81 times per IDCT block.
  546. */
  547. k += ((code_word >> 3) & 15) + 1;
  548. k &= 0xF;
  549. level = p_qb[k].bitc;
  550. bitIndex += ((BYTE) level + 8);
  551. level = table_val[level][(code_word >> 7) & 511];
  552. result = level << p_qb[k].qsteplog;
  553. result += 256;
  554. result *= (3 * 2);
  555. }
  556. else /* level == SHORT_SYMBOL */
  557. {
  558. /*
  559. * Executed 2.79 times per IDCT block.
  560. */
  561. k += table[ix].run;
  562. k &= 0xF;
  563. bitIndex += table[ix].length; // max 6
  564. result = (p_rs[table[ix].index / 2 + k]) * 2;
  565. }
  566. switch (k)
  567. {
  568. case 0:
  569. b[15] += 1; /* Fill slot 0 of jump table */
  570. break;
  571. case 1:
  572. cm1 = pMultiply[result + 1];
  573. cm2 = pMultiply[result + 2];
  574. b[ 0] += cm1;
  575. b[ 1] += cm2;
  576. b[ 2] -= cm2;
  577. b[ 3] -= cm1;
  578. b[ 4] += cm1;
  579. b[ 5] += cm2;
  580. b[ 6] -= cm2;
  581. b[ 7] -= cm1;
  582. b[ 8] += cm1;
  583. b[ 9] += cm2;
  584. b[10] -= cm2;
  585. b[11] -= cm1;
  586. b[12] += cm1;
  587. b[13] += cm2;
  588. b[14] -= cm2;
  589. b[15] -= cm1;
  590. break;
  591. case 5:
  592. cm1 = pMultiply[result + 0];
  593. b[ 0] += cm1;
  594. b[ 1] -= cm1;
  595. b[ 2] -= cm1;
  596. b[ 3] += cm1;
  597. b[ 4] += cm1;
  598. b[ 5] -= cm1;
  599. b[ 6] -= cm1;
  600. b[ 7] += cm1;
  601. b[ 8] += cm1;
  602. b[ 9] -= cm1;
  603. b[10] -= cm1;
  604. b[11] += cm1;
  605. b[12] += cm1;
  606. b[13] -= cm1;
  607. b[14] -= cm1;
  608. b[15] += cm1;
  609. break;
  610. case 6:
  611. cm1 = pMultiply[result + 1];
  612. cm2 = pMultiply[result + 2];
  613. b[ 0] += cm2;
  614. b[ 1] -= cm1;
  615. b[ 2] += cm1;
  616. b[ 3] -= cm2;
  617. b[ 4] += cm2;
  618. b[ 5] -= cm1;
  619. b[ 6] += cm1;
  620. b[ 7] -= cm2;
  621. b[ 8] += cm2;
  622. b[ 9] -= cm1;
  623. b[10] += cm1;
  624. b[11] -= cm2;
  625. b[12] += cm2;
  626. b[13] -= cm1;
  627. b[14] += cm1;
  628. b[15] -= cm2;
  629. break;
  630. case 2:
  631. cm1 = pMultiply[result + 1];
  632. cm2 = pMultiply[result + 2];
  633. b[ 0] += cm1;
  634. b[ 1] += cm1;
  635. b[ 2] += cm1;
  636. b[ 3] += cm1;
  637. b[ 4] += cm2;
  638. b[ 5] += cm2;
  639. b[ 6] += cm2;
  640. b[ 7] += cm2;
  641. b[ 8] -= cm2;
  642. b[ 9] -= cm2;
  643. b[10] -= cm2;
  644. b[11] -= cm2;
  645. b[12] -= cm1;
  646. b[13] -= cm1;
  647. b[14] -= cm1;
  648. b[15] -= cm1;
  649. break;
  650. case 4:
  651. cm1 = pMultiply[result + 3];
  652. cm2 = pMultiply[result + 4];
  653. cm3 = pMultiply[result + 5];
  654. b[ 0] += cm1;
  655. b[ 1] += cm2;
  656. b[ 2] -= cm2;
  657. b[ 3] -= cm1;
  658. b[ 4] += cm2;
  659. b[ 5] += cm3;
  660. b[ 6] -= cm3;
  661. b[ 7] -= cm2;
  662. b[ 8] -= cm2;
  663. b[ 9] -= cm3;
  664. b[10] += cm3;
  665. b[11] += cm2;
  666. b[12] -= cm1;
  667. b[13] -= cm2;
  668. b[14] += cm2;
  669. b[15] += cm1;
  670. break;
  671. case 7:
  672. cm1 = pMultiply[result + 1];
  673. cm2 = pMultiply[result + 2];
  674. b[ 0] += cm1;
  675. b[ 1] -= cm1;
  676. b[ 2] -= cm1;
  677. b[ 3] += cm1;
  678. b[ 4] += cm2;
  679. b[ 5] -= cm2;
  680. b[ 6] -= cm2;
  681. b[ 7] += cm2;
  682. b[ 8] -= cm2;
  683. b[ 9] += cm2;
  684. b[10] += cm2;
  685. b[11] -= cm2;
  686. b[12] -= cm1;
  687. b[13] += cm1;
  688. b[14] += cm1;
  689. b[15] -= cm1;
  690. break;
  691. case 12:
  692. cm1 = pMultiply[result + 3];
  693. cm2 = pMultiply[result + 4];
  694. cm3 = pMultiply[result + 5];
  695. b[ 0] += cm2;
  696. b[ 1] -= cm1;
  697. b[ 2] += cm1;
  698. b[ 3] -= cm2;
  699. b[ 4] += cm3;
  700. b[ 5] -= cm2;
  701. b[ 6] += cm2;
  702. b[ 7] -= cm3;
  703. b[ 8] -= cm3;
  704. b[ 9] += cm2;
  705. b[10] -= cm2;
  706. b[11] += cm3;
  707. b[12] -= cm2;
  708. b[13] += cm1;
  709. b[14] -= cm1;
  710. b[15] += cm2;
  711. break;
  712. case 3:
  713. cm1 = pMultiply[result + 0];
  714. b[ 0] += cm1;
  715. b[ 1] += cm1;
  716. b[ 2] += cm1;
  717. b[ 3] += cm1;
  718. b[ 4] -= cm1;
  719. b[ 5] -= cm1;
  720. b[ 6] -= cm1;
  721. b[ 7] -= cm1;
  722. b[ 8] -= cm1;
  723. b[ 9] -= cm1;
  724. b[10] -= cm1;
  725. b[11] -= cm1;
  726. b[12] += cm1;
  727. b[13] += cm1;
  728. b[14] += cm1;
  729. b[15] += cm1;
  730. break;
  731. case 8:
  732. cm1 = pMultiply[result + 1];
  733. cm2 = pMultiply[result + 2];
  734. b[ 0] += cm1;
  735. b[ 1] += cm2;
  736. b[ 2] -= cm2;
  737. b[ 3] -= cm1;
  738. b[ 4] -= cm1;
  739. b[ 5] -= cm2;
  740. b[ 6] += cm2;
  741. b[ 7] += cm1;
  742. b[ 8] -= cm1;
  743. b[ 9] -= cm2;
  744. b[10] += cm2;
  745. b[11] += cm1;
  746. b[12] += cm1;
  747. b[13] += cm2;
  748. b[14] -= cm2;
  749. b[15] -= cm1;
  750. break;
  751. case 11:
  752. cm1 = pMultiply[result + 0];
  753. b[ 0] += cm1;
  754. b[ 1] -= cm1;
  755. b[ 2] -= cm1;
  756. b[ 3] += cm1;
  757. b[ 4] -= cm1;
  758. b[ 5] += cm1;
  759. b[ 6] += cm1;
  760. b[ 7] -= cm1;
  761. b[ 8] -= cm1;
  762. b[ 9] += cm1;
  763. b[10] += cm1;
  764. b[11] -= cm1;
  765. b[12] += cm1;
  766. b[13] -= cm1;
  767. b[14] -= cm1;
  768. b[15] += cm1;
  769. break;
  770. case 13:
  771. cm1 = pMultiply[result + 1];
  772. cm2 = pMultiply[result + 2];
  773. b[ 0] += cm2;
  774. b[ 1] -= cm1;
  775. b[ 2] += cm1;
  776. b[ 3] -= cm2;
  777. b[ 4] -= cm2;
  778. b[ 5] += cm1;
  779. b[ 6] -= cm1;
  780. b[ 7] += cm2;
  781. b[ 8] -= cm2;
  782. b[ 9] += cm1;
  783. b[10] -= cm1;
  784. b[11] += cm2;
  785. b[12] += cm2;
  786. b[13] -= cm1;
  787. b[14] += cm1;
  788. b[15] -= cm2;
  789. break;
  790. case 9:
  791. cm1 = pMultiply[result + 1];
  792. cm2 = pMultiply[result + 2];
  793. b[ 0] += cm2;
  794. b[ 1] += cm2;
  795. b[ 2] += cm2;
  796. b[ 3] += cm2;
  797. b[ 4] -= cm1;
  798. b[ 5] -= cm1;
  799. b[ 6] -= cm1;
  800. b[ 7] -= cm1;
  801. b[ 8] += cm1;
  802. b[ 9] += cm1;
  803. b[10] += cm1;
  804. b[11] += cm1;
  805. b[12] -= cm2;
  806. b[13] -= cm2;
  807. b[14] -= cm2;
  808. b[15] -= cm2;
  809. break;
  810. case 10:
  811. cm1 = pMultiply[result + 3];
  812. cm2 = pMultiply[result + 4];
  813. cm3 = pMultiply[result + 5];
  814. b[ 0] += cm2;
  815. b[ 1] += cm3;
  816. b[ 2] -= cm3;
  817. b[ 3] -= cm2;
  818. b[ 4] -= cm1;
  819. b[ 5] -= cm2;
  820. b[ 6] += cm2;
  821. b[ 7] += cm1;
  822. b[ 8] += cm1;
  823. b[ 9] += cm2;
  824. b[10] -= cm2;
  825. b[11] -= cm1;
  826. b[12] -= cm2;
  827. b[13] -= cm3;
  828. b[14] += cm3;
  829. b[15] += cm2;
  830. break;
  831. case 14:
  832. cm1 = pMultiply[result + 1];
  833. cm2 = pMultiply[result + 2];
  834. b[ 0] += cm2;
  835. b[ 1] -= cm2;
  836. b[ 2] -= cm2;
  837. b[ 3] += cm2;
  838. b[ 4] -= cm1;
  839. b[ 5] += cm1;
  840. b[ 6] += cm1;
  841. b[ 7] -= cm1;
  842. b[ 8] += cm1;
  843. b[ 9] -= cm1;
  844. b[10] -= cm1;
  845. b[11] += cm1;
  846. b[12] -= cm2;
  847. b[13] += cm2;
  848. b[14] += cm2;
  849. b[15] -= cm2;
  850. break;
  851. case 15:
  852. cm1 = pMultiply[result + 3];
  853. cm2 = pMultiply[result + 4];
  854. cm3 = pMultiply[result + 5];
  855. b[ 0] += cm3;
  856. b[ 1] -= cm2;
  857. b[ 2] += cm2;
  858. b[ 3] -= cm3;
  859. b[ 4] -= cm2;
  860. b[ 5] += cm1;
  861. b[ 6] -= cm1;
  862. b[ 7] += cm2;
  863. b[ 8] += cm2;
  864. b[ 9] -= cm1;
  865. b[10] += cm1;
  866. b[11] -= cm2;
  867. b[12] -= cm3;
  868. b[13] += cm2;
  869. b[14] -= cm2;
  870. b[15] += cm3;
  871. break;
  872. }
  873. }
  874. // DummyRead += pDst[ 0];
  875. // DummyRead += pDst[BLOCK_BAND_WIDTH];
  876. if (YBlockBand)
  877. {
  878. if (camVersion == SSI_YGAIN_MUL2)
  879. {
  880. CLIP2YGAIN (0 * CIF_X + 0, 0); // Y1, line 1
  881. CLIP2YGAIN (0 * CIF_X + 1, 1); // Y2, line 1
  882. CLIP2YGAIN (0 * CIF_X + 2, 2); // Y3, line 1
  883. CLIP2YGAIN (0 * CIF_X + 3, 3); // Y4, line 1
  884. CLIP2YGAIN (1 * CIF_X + 0, 4); // Y1, line 2
  885. CLIP2YGAIN (1 * CIF_X + 1, 5); // Y2, line 2
  886. CLIP2YGAIN (1 * CIF_X + 2, 6); // Y3, line 2
  887. CLIP2YGAIN (1 * CIF_X + 3, 7); // Y4, line 2
  888. // DummyRead += pDst[2 * CIF_X];
  889. CLIP2YGAIN (2 * CIF_X + 0, 8); // Y1, line 3
  890. CLIP2YGAIN (2 * CIF_X + 1, 9); // Y2, line 3
  891. CLIP2YGAIN (2 * CIF_X + 2, 10); // Y3, line 3
  892. CLIP2YGAIN (2 * CIF_X + 3, 11); // Y4, line 3
  893. // DummyRead += pDst[3 * CIF_X];
  894. CLIP2YGAIN (3 * CIF_X + 0, 12); // Y1, line 4
  895. CLIP2YGAIN (3 * CIF_X + 1, 13); // Y2, line 4
  896. CLIP2YGAIN (3 * CIF_X + 2, 14); // Y3, line 4
  897. CLIP2YGAIN (3 * CIF_X + 3, 15); // Y4, line 4
  898. }
  899. else
  900. {
  901. CLIP2 (0 * CIF_X + 0, 0); // Y1, line 1
  902. CLIP2 (0 * CIF_X + 1, 1); // Y2, line 1
  903. CLIP2 (0 * CIF_X + 2, 2); // Y3, line 1
  904. CLIP2 (0 * CIF_X + 3, 3); // Y4, line 1
  905. CLIP2 (1 * CIF_X + 0, 4); // Y1, line 2
  906. CLIP2 (1 * CIF_X + 1, 5); // Y2, line 2
  907. CLIP2 (1 * CIF_X + 2, 6); // Y3, line 2
  908. CLIP2 (1 * CIF_X + 3, 7); // Y4, line 2
  909. // DummyRead += pDst[2 * CIF_X];
  910. CLIP2 (2 * CIF_X + 0, 8); // Y1, line 3
  911. CLIP2 (2 * CIF_X + 1, 9); // Y2, line 3
  912. CLIP2 (2 * CIF_X + 2, 10); // Y3, line 3
  913. CLIP2 (2 * CIF_X + 3, 11); // Y4, line 3
  914. // DummyRead += pDst[3 * CIF_X];
  915. CLIP2 (3 * CIF_X + 0, 12); // Y1, line 4
  916. CLIP2 (3 * CIF_X + 1, 13); // Y2, line 4
  917. CLIP2 (3 * CIF_X + 2, 14); // Y3, line 4
  918. CLIP2 (3 * CIF_X + 3, 15); // Y4, line 4
  919. }
  920. pDst += 4;
  921. }
  922. else // UV_BLOCK_BAND
  923. {
  924. if (Cropping)
  925. {
  926. if (Uval)
  927. {
  928. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 0, 0); // U1, line 1
  929. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 1, 1); // U2, line 1
  930. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 2, 2); // U3, line 1
  931. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 3, 3); // U4, line 1
  932. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 4, 4); // U5, line 1
  933. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 5, 5); // U6, line 1
  934. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 6, 6); // U7, line 1
  935. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 7, 7); // U8, line 1
  936. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 0, 8); // U1, line 3
  937. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 1, 9); // U2, line 3
  938. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 2, 10); // U3, line 3
  939. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 3, 11); // U4, line 3
  940. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 4, 12); // U5, line 3
  941. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 5, 13); // U6, line 3
  942. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 6, 14); // U7, line 3
  943. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 7, 15); // U8, line 3
  944. Uval = FALSE;
  945. }
  946. else // Vval
  947. {
  948. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 0, 0); // V1, line 2
  949. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 1, 1); // V2, line 2
  950. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 2, 2); // V3, line 2
  951. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 3, 3); // V4, line 2
  952. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 4, 4); // V5, line 2
  953. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 5, 5); // V6, line 2
  954. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 6, 6); // V7, line 2
  955. CLIP2 (I420_NO_U_PER_BAND_CIF + 0 * I420_NO_C_PER_LINE_CIF + 7, 7); // V8, line 2
  956. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 0, 8); // V1, line 4
  957. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 1, 9); // V2, line 4
  958. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 2, 10); // V3, line 4
  959. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 3, 11); // V4, line 4
  960. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 4, 12); // V5, line 4
  961. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 5, 13); // V6, line 4
  962. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 6, 14); // V7, line 4
  963. CLIP2 (I420_NO_U_PER_BAND_CIF + 1 * I420_NO_C_PER_LINE_CIF + 7, 15); // V8, line 4
  964. Uval = TRUE;
  965. pDst += 8;
  966. }
  967. }
  968. else // CIF OUT
  969. {
  970. if (Uval)
  971. {
  972. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 0, 0); // U1, line 1
  973. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 1, 1); // U2, line 1
  974. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 2, 2); // U3, line 1
  975. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 3, 3); // U4, line 1
  976. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 4, 4); // U5, line 1
  977. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 5, 5); // U6, line 1
  978. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 6, 6); // U7, line 1
  979. CLIP2 (0 + 0 * I420_NO_C_PER_LINE_CIF + 7, 7); // U8, line 1
  980. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 0, 8); // U1, line 3
  981. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 1, 9); // U2, line 3
  982. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 2, 10); // U3, line 3
  983. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 3, 11); // U4, line 3
  984. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 4, 12); // U5, line 3
  985. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 5, 13); // U6, line 3
  986. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 6, 14); // U7, line 3
  987. CLIP2 (0 + 1 * I420_NO_C_PER_LINE_CIF + 7, 15); // U8, line 3
  988. Uval = FALSE;
  989. }
  990. else // Vval
  991. {
  992. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 0, 0); // V1, line 2
  993. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 1, 1); // V2, line 2
  994. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 2, 2); // V3, line 2
  995. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 3, 3); // V4, line 2
  996. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 4, 4); // V5, line 2
  997. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 5, 5); // V6, line 2
  998. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 6, 6); // V7, line 2
  999. CLIP2 (I420_NO_U_CIF + 0 * I420_NO_C_PER_LINE_CIF + 7, 7); // V8, line 2
  1000. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 0, 8); // V1, line 4
  1001. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 1, 9); // V2, line 4
  1002. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 2, 10); // V3, line 4
  1003. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 3, 11); // V4, line 4
  1004. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 4, 12); // V5, line 4
  1005. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 5, 13); // V6, line 4
  1006. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 6, 14); // V7, line 4
  1007. CLIP2 (I420_NO_U_CIF + 1 * I420_NO_C_PER_LINE_CIF + 7, 15); // V8, line 4
  1008. Uval = TRUE;
  1009. pDst += 8;
  1010. }
  1011. }
  1012. }
  1013. }
  1014. while (pDst < pDstEnd);
  1015. }