pwc-dec23.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /* Linux driver for Philips webcam
  2. Decompression for chipset version 2 et 3
  3. (C) 2004 Luc Saillard (luc@saillard.org)
  4. NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
  5. driver and thus may have bugs that are not present in the original version.
  6. Please send bug reports and support requests to <luc@saillard.org>.
  7. The decompression routines have been implemented by reverse-engineering the
  8. Nemosoft binary pwcx module. Caveat emptor.
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13. This program 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
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include "pwc-timon.h"
  22. #include "pwc-kiara.h"
  23. #include "pwc-dec23.h"
  24. #include "pwc-ioctl.h"
  25. #include <linux/string.h>
  26. /****
  27. *
  28. *
  29. *
  30. */
  31. static void fill_table_a000(unsigned int *p)
  32. {
  33. static unsigned int initial_values[12] = {
  34. 0xFFAD9B00, 0xFFDDEE00, 0x00221200, 0x00526500,
  35. 0xFFC21E00, 0x003DE200, 0xFF924B80, 0xFFD2A300,
  36. 0x002D5D00, 0x006DB480, 0xFFED3E00, 0x0012C200
  37. };
  38. static unsigned int values_derivated[12] = {
  39. 0x0000A4CA, 0x00004424, 0xFFFFBBDC, 0xFFFF5B36,
  40. 0x00007BC4, 0xFFFF843C, 0x0000DB69, 0x00005ABA,
  41. 0xFFFFA546, 0xFFFF2497, 0x00002584, 0xFFFFDA7C
  42. };
  43. unsigned int temp_values[12];
  44. int i,j;
  45. memcpy(temp_values,initial_values,sizeof(initial_values));
  46. for (i=0;i<256;i++)
  47. {
  48. for (j=0;j<12;j++)
  49. {
  50. *p++ = temp_values[j];
  51. temp_values[j] += values_derivated[j];
  52. }
  53. }
  54. }
  55. static void fill_table_d000(unsigned char *p)
  56. {
  57. int bit,byte;
  58. for (bit=0; bit<8; bit++)
  59. {
  60. unsigned char bitpower = 1<<bit;
  61. unsigned char mask = bitpower-1;
  62. for (byte=0; byte<256; byte++)
  63. {
  64. if (byte & bitpower)
  65. *p++ = -(byte & mask);
  66. else
  67. *p++ = (byte & mask);
  68. }
  69. }
  70. }
  71. /*
  72. *
  73. * Kiara: 0 <= ver <= 7
  74. * Timon: 0 <= ver <= 15
  75. *
  76. */
  77. static void fill_table_color(unsigned int version, const unsigned int *romtable,
  78. unsigned char *p0004,
  79. unsigned char *p8004)
  80. {
  81. const unsigned int *table;
  82. unsigned char *p0, *p8;
  83. int i,j,k;
  84. int dl,bit,pw;
  85. romtable += version*256;
  86. for (i=0; i<2; i++)
  87. {
  88. table = romtable + i*128;
  89. for (dl=0; dl<16; dl++)
  90. {
  91. p0 = p0004 + (i<<14) + (dl<<10);
  92. p8 = p8004 + (i<<12) + (dl<<8);
  93. for (j=0; j<8; j++ , table++, p0+=128)
  94. {
  95. for (k=0; k<16; k++)
  96. {
  97. if (k==0)
  98. bit=1;
  99. else if (k>=1 && k<3)
  100. bit=(table[0]>>15)&7;
  101. else if (k>=3 && k<6)
  102. bit=(table[0]>>12)&7;
  103. else if (k>=6 && k<10)
  104. bit=(table[0]>>9)&7;
  105. else if (k>=10 && k<13)
  106. bit=(table[0]>>6)&7;
  107. else if (k>=13 && k<15)
  108. bit=(table[0]>>3)&7;
  109. else
  110. bit=(table[0])&7;
  111. if (k == 0)
  112. *(unsigned char *)p8++ = 8;
  113. else
  114. *(unsigned char *)p8++ = j - bit;
  115. *(unsigned char *)p8++ = bit;
  116. pw = 1<<bit;
  117. p0[k+0x00] = (1*pw) + 0x80;
  118. p0[k+0x10] = (2*pw) + 0x80;
  119. p0[k+0x20] = (3*pw) + 0x80;
  120. p0[k+0x30] = (4*pw) + 0x80;
  121. p0[k+0x40] = (-pw) + 0x80;
  122. p0[k+0x50] = (2*-pw) + 0x80;
  123. p0[k+0x60] = (3*-pw) + 0x80;
  124. p0[k+0x70] = (4*-pw) + 0x80;
  125. } /* end of for (k=0; k<16; k++, p8++) */
  126. } /* end of for (j=0; j<8; j++ , table++) */
  127. } /* end of for (dl=0; dl<16; dl++) */
  128. } /* end of for (i=0; i<2; i++) */
  129. }
  130. /*
  131. * precision = (pdev->xx + pdev->yy)
  132. *
  133. */
  134. static void fill_table_dc00_d800(unsigned int precision, unsigned int *pdc00, unsigned int *pd800)
  135. {
  136. int i;
  137. unsigned int offset1, offset2;
  138. for(i=0,offset1=0x4000, offset2=0; i<256 ; i++,offset1+=0x7BC4, offset2+=0x7BC4)
  139. {
  140. unsigned int msb = offset1 >> 15;
  141. if ( msb > 255)
  142. {
  143. if (msb)
  144. msb=0;
  145. else
  146. msb=255;
  147. }
  148. *pdc00++ = msb << precision;
  149. *pd800++ = offset2;
  150. }
  151. }
  152. /*
  153. * struct {
  154. * unsigned char op; // operation to execute
  155. * unsigned char bits; // bits use to perform operation
  156. * unsigned char offset1; // offset to add to access in the table_0004 % 16
  157. * unsigned char offset2; // offset to add to access in the table_0004
  158. * }
  159. *
  160. */
  161. static unsigned int table_ops[] = {
  162. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x01,0x30,
  163. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x20, 0x01,0x00,0x00,0x00,
  164. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x00,
  165. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x00, 0x01,0x00,0x00,0x00,
  166. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x02,0x10,
  167. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x60, 0x01,0x00,0x00,0x00,
  168. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x40,
  169. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x40, 0x01,0x00,0x00,0x00,
  170. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x01,0x70,
  171. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x20, 0x01,0x00,0x00,0x00,
  172. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x00,
  173. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x00, 0x01,0x00,0x00,0x00,
  174. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x10, 0x00,0x06,0x02,0x50,
  175. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x01,0x60, 0x01,0x00,0x00,0x00,
  176. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x00, 0x00,0x04,0x01,0x50, 0x00,0x05,0x02,0x40,
  177. 0x02,0x00,0x00,0x00, 0x00,0x03,0x01,0x40, 0x00,0x05,0x03,0x40, 0x01,0x00,0x00,0x00
  178. };
  179. /*
  180. * TODO: multiply by 4 all values
  181. *
  182. */
  183. static unsigned int MulIdx[256] = {
  184. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  185. 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
  186. 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
  187. 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,
  188. 6, 7, 8, 9, 7,10,11, 8, 8,11,10, 7, 9, 8, 7, 6,
  189. 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4,
  190. 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2,
  191. 0, 3, 3, 0, 1, 2, 2, 1, 2, 1, 1, 2, 3, 0, 0, 3,
  192. 0, 1, 2, 3, 3, 2, 1, 0, 3, 2, 1, 0, 0, 1, 2, 3,
  193. 1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0, 2, 2, 2, 2,
  194. 7,10,11, 8, 9, 8, 7, 6, 6, 7, 8, 9, 8,11,10, 7,
  195. 4, 5, 5, 4, 5, 4, 4, 5, 5, 4, 4, 5, 4, 5, 5, 4,
  196. 7, 9, 6, 8,10, 8, 7,11,11, 7, 8,10, 8, 6, 9, 7,
  197. 1, 3, 0, 2, 2, 0, 3, 1, 2, 0, 3, 1, 1, 3, 0, 2,
  198. 1, 2, 2, 1, 3, 0, 0, 3, 0, 3, 3, 0, 2, 1, 1, 2,
  199. 10, 8, 7,11, 8, 6, 9, 7, 7, 9, 6, 8,11, 7, 8,10
  200. };
  201. void pwc_dec23_init(int type, int release, unsigned char *mode, void *data)
  202. {
  203. int flags;
  204. struct pwc_dec23_private *pdev = data;
  205. release = release;
  206. switch (type)
  207. {
  208. case 720:
  209. case 730:
  210. case 740:
  211. case 750:
  212. flags = mode[2]&0x18; /* our: flags = 8, mode[2]==e8 */
  213. if (flags==8)
  214. pdev->zz = 7;
  215. else if (flags==0x10)
  216. pdev->zz = 8;
  217. else
  218. pdev->zz = 6;
  219. flags = mode[2]>>5; /* our: 7 */
  220. fill_table_color(flags, (unsigned int *)KiaraRomTable, pdev->table_0004, pdev->table_8004);
  221. break;
  222. case 675:
  223. case 680:
  224. case 690:
  225. flags = mode[2]&6;
  226. if (flags==2)
  227. pdev->zz = 7;
  228. else if (flags==4)
  229. pdev->zz = 8;
  230. else
  231. pdev->zz = 6;
  232. flags = mode[2]>>3;
  233. fill_table_color(flags, (unsigned int *)TimonRomTable, pdev->table_0004, pdev->table_8004);
  234. break;
  235. default:
  236. /* Not supported */
  237. return;
  238. }
  239. /* * * * ** */
  240. pdev->xx = 8 - pdev->zz;
  241. pdev->yy = 15 - pdev->xx;
  242. pdev->zzmask = 0xFF>>pdev->xx;
  243. //pdev->zzmask = (1U<<pdev->zz)-1;
  244. fill_table_dc00_d800(pdev->xx + pdev->yy, pdev->table_dc00, pdev->table_d800);
  245. fill_table_a000(pdev->table_a004);
  246. fill_table_d000(pdev->table_d004);
  247. }
  248. /*
  249. * To manage the stream, we keep in a 32 bits variables,
  250. * the next bits in the stream. fill_reservoir() add to
  251. * the reservoir at least wanted nbits.
  252. *
  253. *
  254. */
  255. #define fill_nbits(reservoir,nbits_in_reservoir,stream,nbits_wanted) do { \
  256. while (nbits_in_reservoir<nbits_wanted) \
  257. { \
  258. reservoir |= (*(stream)++) << nbits_in_reservoir; \
  259. nbits_in_reservoir+=8; \
  260. } \
  261. } while(0);
  262. #define get_nbits(reservoir,nbits_in_reservoir,stream,nbits_wanted,result) do { \
  263. fill_nbits(reservoir,nbits_in_reservoir,stream,nbits_wanted); \
  264. result = (reservoir) & ((1U<<nbits_wanted)-1); \
  265. reservoir >>= nbits_wanted; \
  266. nbits_in_reservoir -= nbits_wanted; \
  267. } while(0);
  268. static void DecompressBand23(const struct pwc_dec23_private *pdev,
  269. const unsigned char *rawyuv,
  270. unsigned char *planar_y,
  271. unsigned char *planar_u,
  272. unsigned char *planar_v,
  273. unsigned int image_x, /* aka number of pixels wanted ??? */
  274. unsigned int pixels_per_line, /* aka number of pixels per line */
  275. int flags)
  276. {
  277. unsigned int reservoir, nbits_in_reservoir;
  278. int first_4_bits;
  279. unsigned int bytes_per_channel;
  280. int line_size; /* size of the line (4Y+U+V) */
  281. int passes;
  282. const unsigned char *ptable0004, *ptable8004;
  283. int even_line;
  284. unsigned int temp_colors[16];
  285. int nblocks;
  286. const unsigned char *stream;
  287. unsigned char *dest_y, *dest_u=NULL, *dest_v=NULL;
  288. unsigned int offset_to_plane_u, offset_to_plane_v;
  289. int i;
  290. reservoir = 0;
  291. nbits_in_reservoir = 0;
  292. stream = rawyuv+1; /* The first byte of the stream is skipped */
  293. even_line = 1;
  294. get_nbits(reservoir,nbits_in_reservoir,stream,4,first_4_bits);
  295. line_size = pixels_per_line*3;
  296. for (passes=0;passes<2;passes++)
  297. {
  298. if (passes==0)
  299. {
  300. bytes_per_channel = pixels_per_line;
  301. dest_y = planar_y;
  302. nblocks = image_x/4;
  303. }
  304. else
  305. {
  306. /* Format planar: All Y, then all U, then all V */
  307. bytes_per_channel = pixels_per_line/2;
  308. dest_u = planar_u;
  309. dest_v = planar_v;
  310. dest_y = dest_u;
  311. nblocks = image_x/8;
  312. }
  313. offset_to_plane_u = bytes_per_channel*2;
  314. offset_to_plane_v = bytes_per_channel*3;
  315. /*
  316. printf("bytes_per_channel = %d\n",bytes_per_channel);
  317. printf("offset_to_plane_u = %d\n",offset_to_plane_u);
  318. printf("offset_to_plane_v = %d\n",offset_to_plane_v);
  319. */
  320. while (nblocks-->0)
  321. {
  322. unsigned int gray_index;
  323. fill_nbits(reservoir,nbits_in_reservoir,stream,16);
  324. gray_index = reservoir & pdev->zzmask;
  325. reservoir >>= pdev->zz;
  326. nbits_in_reservoir -= pdev->zz;
  327. fill_nbits(reservoir,nbits_in_reservoir,stream,2);
  328. if ( (reservoir & 3) == 0)
  329. {
  330. reservoir>>=2;
  331. nbits_in_reservoir-=2;
  332. for (i=0;i<16;i++)
  333. temp_colors[i] = pdev->table_dc00[gray_index];
  334. }
  335. else
  336. {
  337. unsigned int channel_v, offset1;
  338. /* swap bit 0 and 2 of offset_OR */
  339. channel_v = ((reservoir & 1) << 2) | (reservoir & 2) | ((reservoir & 4)>>2);
  340. reservoir>>=3;
  341. nbits_in_reservoir-=3;
  342. for (i=0;i<16;i++)
  343. temp_colors[i] = pdev->table_d800[gray_index];
  344. ptable0004 = pdev->table_0004 + (passes*16384) + (first_4_bits*1024) + (channel_v*128);
  345. ptable8004 = pdev->table_8004 + (passes*4096) + (first_4_bits*256) + (channel_v*32);
  346. offset1 = 0;
  347. while(1)
  348. {
  349. unsigned int index_in_table_ops, op, rows=0;
  350. fill_nbits(reservoir,nbits_in_reservoir,stream,16);
  351. /* mode is 0,1 or 2 */
  352. index_in_table_ops = (reservoir&0x3F);
  353. op = table_ops[ index_in_table_ops*4 ];
  354. if (op == 2)
  355. {
  356. reservoir >>= 2;
  357. nbits_in_reservoir -= 2;
  358. break; /* exit the while(1) */
  359. }
  360. if (op == 0)
  361. {
  362. unsigned int shift;
  363. offset1 = (offset1 + table_ops[index_in_table_ops*4+2]) & 0x0F;
  364. shift = table_ops[ index_in_table_ops*4+1 ];
  365. reservoir >>= shift;
  366. nbits_in_reservoir -= shift;
  367. rows = ptable0004[ offset1 + table_ops[index_in_table_ops*4+3] ];
  368. }
  369. if (op == 1)
  370. {
  371. /* 10bits [ xxxx xxxx yyyy 000 ]
  372. * yyy => offset in the table8004
  373. * xxx => offset in the tabled004
  374. */
  375. unsigned int mask, shift;
  376. unsigned int col1, row1, total_bits;
  377. offset1 = (offset1 + ((reservoir>>3)&0x0F)+1) & 0x0F;
  378. col1 = (reservoir>>7) & 0xFF;
  379. row1 = ptable8004 [ offset1*2 ];
  380. /* Bit mask table */
  381. mask = pdev->table_d004[ (row1<<8) + col1 ];
  382. shift = ptable8004 [ offset1*2 + 1];
  383. rows = ((mask << shift) + 0x80) & 0xFF;
  384. total_bits = row1 + 8;
  385. reservoir >>= total_bits;
  386. nbits_in_reservoir -= total_bits;
  387. }
  388. {
  389. const unsigned int *table_a004 = pdev->table_a004 + rows*12;
  390. unsigned int *poffset = MulIdx + offset1*16; /* 64/4 (int) */
  391. for (i=0;i<16;i++)
  392. {
  393. temp_colors[i] += table_a004[ *poffset ];
  394. poffset++;
  395. }
  396. }
  397. }
  398. }
  399. #define USE_SIGNED_INT_FOR_COLOR
  400. #ifdef USE_SIGNED_INT_FOR_COLOR
  401. # define CLAMP(x) ((x)>255?255:((x)<0?0:x))
  402. #else
  403. # define CLAMP(x) ((x)>255?255:x)
  404. #endif
  405. if (passes == 0)
  406. {
  407. #ifdef USE_SIGNED_INT_FOR_COLOR
  408. const int *c = temp_colors;
  409. #else
  410. const unsigned int *c = temp_colors;
  411. #endif
  412. unsigned char *d;
  413. d = dest_y;
  414. for (i=0;i<4;i++,c++)
  415. *d++ = CLAMP((*c) >> pdev->yy);
  416. d = dest_y + bytes_per_channel;
  417. for (i=0;i<4;i++,c++)
  418. *d++ = CLAMP((*c) >> pdev->yy);
  419. d = dest_y + offset_to_plane_u;
  420. for (i=0;i<4;i++,c++)
  421. *d++ = CLAMP((*c) >> pdev->yy);
  422. d = dest_y + offset_to_plane_v;
  423. for (i=0;i<4;i++,c++)
  424. *d++ = CLAMP((*c) >> pdev->yy);
  425. dest_y += 4;
  426. }
  427. else if (passes == 1)
  428. {
  429. #ifdef USE_SIGNED_INT_FOR_COLOR
  430. int *c1 = temp_colors;
  431. int *c2 = temp_colors+4;
  432. #else
  433. unsigned int *c1 = temp_colors;
  434. unsigned int *c2 = temp_colors+4;
  435. #endif
  436. unsigned char *d;
  437. d = dest_y;
  438. for (i=0;i<4;i++,c1++,c2++)
  439. {
  440. *d++ = CLAMP((*c1) >> pdev->yy);
  441. *d++ = CLAMP((*c2) >> pdev->yy);
  442. }
  443. c1 = temp_colors+12;
  444. //c2 = temp_colors+8;
  445. d = dest_y + bytes_per_channel;
  446. for (i=0;i<4;i++,c1++,c2++)
  447. {
  448. *d++ = CLAMP((*c1) >> pdev->yy);
  449. *d++ = CLAMP((*c2) >> pdev->yy);
  450. }
  451. if (even_line) /* Each line, swap u/v */
  452. {
  453. even_line=0;
  454. dest_y = dest_v;
  455. dest_u += 8;
  456. }
  457. else
  458. {
  459. even_line=1;
  460. dest_y = dest_u;
  461. dest_v += 8;
  462. }
  463. }
  464. } /* end of while (nblocks-->0) */
  465. } /* end of for (passes=0;passes<2;passes++) */
  466. }
  467. /**
  468. *
  469. * image: size of the image wanted
  470. * view : size of the image returned by the camera
  471. * offset: (x,y) to displayer image in the view
  472. *
  473. * src: raw data
  474. * dst: image output
  475. * flags: PWCX_FLAG_PLANAR
  476. * pdev: private buffer
  477. * bandlength:
  478. *
  479. */
  480. void pwc_dec23_decompress(const struct pwc_coord *image,
  481. const struct pwc_coord *view,
  482. const struct pwc_coord *offset,
  483. const void *src,
  484. void *dst,
  485. int flags,
  486. const void *data,
  487. int bandlength)
  488. {
  489. const struct pwc_dec23_private *pdev = data;
  490. unsigned char *pout, *pout_planar_y=NULL, *pout_planar_u=NULL, *pout_planar_v=NULL;
  491. int i,n,stride,pixel_size;
  492. if (flags & PWCX_FLAG_BAYER)
  493. {
  494. pout = dst + (view->x * offset->y) + offset->x;
  495. pixel_size = view->x * 4;
  496. }
  497. else
  498. {
  499. n = view->x * view->y;
  500. /* offset in Y plane */
  501. stride = view->x * offset->y;
  502. pout_planar_y = dst + stride + offset->x;
  503. /* offsets in U/V planes */
  504. stride = (view->x * offset->y)/4 + offset->x/2;
  505. pout_planar_u = dst + n + + stride;
  506. pout_planar_v = dst + n + n/4 + stride;
  507. pixel_size = view->x * 4;
  508. }
  509. for (i=0;i<image->y;i+=4)
  510. {
  511. if (flags & PWCX_FLAG_BAYER)
  512. {
  513. //TODO:
  514. //DecompressBandBayer(pdev,src,pout,image.x,view->x,flags);
  515. src += bandlength;
  516. pout += pixel_size;
  517. }
  518. else
  519. {
  520. DecompressBand23(pdev,src,pout_planar_y,pout_planar_u,pout_planar_v,image->x,view->x,flags);
  521. src += bandlength;
  522. pout_planar_y += pixel_size;
  523. pout_planar_u += view->x;
  524. pout_planar_v += view->x;
  525. }
  526. }
  527. }
  528. void pwc_dec23_exit(void)
  529. {
  530. /* Do nothing */
  531. }