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.

630 lines
20 KiB

  1. /* File: sv_h263_mres.c */
  2. /*****************************************************************************
  3. ** Copyright (c) Digital Equipment Corporation, 1995, 1997 **
  4. ** **
  5. ** All Rights Reserved. Unpublished rights reserved under the copyright **
  6. ** laws of the United States. **
  7. ** **
  8. ** The software contained on this media is proprietary to and embodies **
  9. ** the confidential technology of Digital Equipment Corporation. **
  10. ** Possession, use, duplication or dissemination of the software and **
  11. ** media is authorized only pursuant to a valid written license from **
  12. ** Digital Equipment Corporation. **
  13. ** **
  14. ** RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the U.S. **
  15. ** Government is subject to restrictions as set forth in Subparagraph **
  16. ** (c)(1)(ii) of DFARS 252.227-7013, or in FAR 52.227-19, as applicable. **
  17. ******************************************************************************/
  18. #include "sv_h263.h"
  19. #include "proto.h"
  20. static void hfilt121(unsigned char *img, unsigned char *filtd,
  21. unsigned char s, unsigned char gain,
  22. int rows, int cols) ;
  23. static void hfilt5(unsigned char *img, unsigned char *filtd,
  24. unsigned char s, unsigned char gain,
  25. int rows, int cols) ;
  26. static void vfilt121(unsigned char *img, unsigned char *filtd,
  27. unsigned char s, unsigned char gain,
  28. int rows, int cols) ;
  29. static void vfilt5(unsigned char *img, unsigned char *filtd,
  30. unsigned char s, unsigned char gain,
  31. int rows, int cols) ;
  32. static void lowpass(unsigned char *img, unsigned char *lp,
  33. int rows, int cols, int ntaps) ;
  34. static void reduce(unsigned char *img, unsigned char *red,
  35. int rows, int cols, int ntaps) ;
  36. static void hpad(unsigned char *img, unsigned char *zp,
  37. unsigned char s,
  38. int rows, int cols, char mode) ;
  39. static void Expand(unsigned char *img, unsigned char *exp,
  40. int rows, int cols, char mode, int ntaps) ;
  41. static void gaussp(unsigned char *img, unsigned char **pyr,
  42. int depth, int rows, int cols, int ntaps) ;
  43. static unsigned char **palloc(int depth, int rows, int cols) ;
  44. static H263_PictImage **PictPyr(H263_PictImage *img, int depth, int rows,
  45. int cols, int ntaps);
  46. static void expyr(unsigned char **pyr, unsigned char **filtd,
  47. int depth, int rows, int cols,
  48. char mode, int ntaps);
  49. static H263_PictImage **GaussFilt(H263_PictImage *img, int depth, int rows,
  50. int cols, int ntaps);
  51. /******************************************************************
  52. * Function hfilt121
  53. * Filters img horizontally with a 1:2:1 filter, subsampling by s.
  54. * rows, cols are the dimensions of img
  55. *****************************************************************/
  56. static void hfilt121(unsigned char *img, unsigned char *filtd,
  57. unsigned char s, unsigned char gain,
  58. int rows, int cols)
  59. {
  60. unsigned char *pimg, *pf;
  61. float conv, tmp;
  62. int i, j;
  63. pf = filtd;
  64. pimg = img;
  65. for(i=0; i<rows; i++) {
  66. /* Do first pixel */
  67. conv = (float)gain * ((float)*pimg * (float)2.0 + (float)*(pimg+1) * (float)2.0) / (float)4.0;
  68. tmp = (conv > 255 ? 255 : conv);
  69. *(pf++) = (unsigned char) (tmp < 0 ? 0 : tmp);
  70. pimg+=s;
  71. /* Do line */
  72. for(j=s; j<cols-1; j+=s, pimg+=s) {
  73. conv = (float) gain * ((float)*(pimg-1) + (float)*pimg * (float)2 + (float)*(pimg+1)) / (float)4.0;
  74. tmp = (conv > 255 ? 255 : conv);
  75. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  76. }
  77. /* Do last pixel if s equals one */
  78. if(s==1) {
  79. conv = (float)gain * ((float)*pimg * (float)2.0 + (float)*(pimg-1) * (float)2.0) / (float)4.0;
  80. tmp = (conv > 255 ? 255 : conv);
  81. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  82. pimg+=s;
  83. }
  84. }
  85. }
  86. /******************************************************************
  87. * Function hfilt5
  88. * Filters img horizontally with a 5 tap gaussian filter, subsampling by s.
  89. * rows, cols are the dimensions of img
  90. *****************************************************************/
  91. static void hfilt5(unsigned char *img, unsigned char *filtd,
  92. unsigned char s, unsigned char gain,
  93. int rows, int cols)
  94. {
  95. unsigned char *pimg, *pf;
  96. float conv, tmp;
  97. int i, j;
  98. pf = filtd;
  99. pimg = img;
  100. for(i=0; i<rows; i++) {
  101. /* Do line */
  102. for(j=0; j<cols; j+=s, pimg+=s) {
  103. if (j==0)
  104. conv = (float)gain * ((float)6.0 * (float)*pimg + (float)8.0 * (float)*(pimg+1) + (float)2.0 * *(pimg+2)) / (float)16.0;
  105. else if(j==1)
  106. conv = (float)gain * ((float)4.0 * (float)*(pimg-1) + (float)6.0 * (float)*pimg + (float)4.0 * (float)*(pimg+1) + (float)2.0 * (float)*(pimg+2)) / (float)16.0;
  107. else if (j==cols-2)
  108. conv = (float)gain * ((float)2.0 * (float)*(pimg-2) + (float)4.0 * (float)*(pimg-1) + (float)6.0 * (float)*pimg + (float)4.0 * (float)*(pimg+1)) / (float)16.0;
  109. else if (j==cols-1)
  110. conv = (float)gain * ((float)2.0 * (float)*(pimg-2) + (float)8.0 * (float)*(pimg-1) + (float)6.0 * (float)*pimg) / (float)16.0;
  111. else
  112. conv = (float)gain * ((float)*(pimg-2) + (float)4.0 * (float)*(pimg-1) + (float)6.0 * (float)*pimg + (float)4.0 * (float)*(pimg+1) + (float)*(pimg+2)) / (float)16.0;
  113. tmp = (float)(conv > 255 ? 255 : conv);
  114. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  115. }
  116. }
  117. }
  118. /******************************************************************
  119. * Function vfilt121
  120. * Filters img vertically with a 1:2:1 filter, subsampling by s.
  121. * rows, cols are the dimensions of img
  122. *****************************************************************/
  123. static void vfilt121(unsigned char *img, unsigned char *filtd,
  124. unsigned char s, unsigned char gain,
  125. int rows, int cols)
  126. {
  127. unsigned char *pimg, *pf;
  128. float tmp, conv;
  129. int i, j;
  130. pf = filtd;
  131. pimg = img;
  132. /* Do first line */
  133. for(j=0; j<cols; j++, pimg++) {
  134. conv = (float)gain * ((float) *pimg * (float)2 + (float)2 * (float)*(pimg+cols)) / (float)4.0;
  135. tmp = (conv > 255 ? 255 : conv);
  136. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  137. }
  138. pimg+= (s-1)*cols;
  139. /* Do image center */
  140. for(i=s; i<rows-1; i+=s) {
  141. for(j=0; j<cols; j++, pimg++) {
  142. conv = (float)gain * ((float)*(pimg-cols) + (float)*pimg * (float)2 + (float)*(pimg+cols)) / (float)4.0;
  143. tmp = (conv > 255 ? 255 : conv);
  144. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  145. }
  146. pimg+=(s-1)*cols;
  147. }
  148. /* Do last line if s equals one */
  149. if(s==1) {
  150. for(j=0; j<cols; j++, pimg++) {
  151. conv = (float)gain * ((float)*pimg * (float)2 + (float)2 * (float)*(pimg-cols)) / (float)4.0;
  152. tmp = (float)(conv > 255 ? 255 : conv);
  153. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  154. }
  155. }
  156. }
  157. /******************************************************************
  158. * Function vfilt5
  159. * Filters img vertically with a 5 tap gaussian filter, subsampling by s.
  160. * rows, cols are the dimensions of img
  161. *****************************************************************/
  162. static void vfilt5(unsigned char *img, unsigned char *filtd,
  163. unsigned char s, unsigned char gain,
  164. int rows, int cols)
  165. {
  166. unsigned char *pimg, *pf;
  167. float conv, tmp;
  168. int i, j, tcols;
  169. pf = filtd;
  170. pimg = img;
  171. tcols = 2*cols;
  172. for(i=0; i<rows; i+=s) {
  173. for(j=0; j<cols; j++, pimg++) {
  174. if (i==0)
  175. conv = (float)gain * ((float)6.0 * (float)*pimg + (float)8.0 * (float)*(pimg+cols) + (float)2.0 * (float)*(pimg+tcols)) / (float)16.0;
  176. else if (i==1)
  177. conv = (float)gain * ((float)4.0 * (float)*(pimg-cols) + (float)6.0 * (float)*pimg + (float)4.0 * (float)*(pimg+cols) + (float)2.0 * (float)*(pimg+tcols)) / (float)16.0;
  178. else if (i==rows-2)
  179. conv = (float)gain * ((float)2.0 * (float)*(pimg-tcols) + (float)4.0 * (float)*(pimg-cols) + (float)6.0 * (float)*pimg + (float)4.0 * (float)*(pimg+cols)) / (float)16.0;
  180. else if (i==rows-1)
  181. conv = (float)gain * ((float)2.0 * (float)*(pimg-tcols) + (float)8.0 * (float)*(pimg-cols) + (float)6.0 * (float)*pimg) / (float)16.0;
  182. else
  183. conv = (float)gain * (float)(*(pimg-tcols) + (float)4.0 * (float)*(pimg-cols) + (float)6.0 * (float)*pimg +
  184. (float)4.0 * (float)*(pimg+cols) + (float)*(pimg+tcols)) / (float)16.0;
  185. tmp = (float)(conv > 255 ? 255 : conv);
  186. *(pf++) = (unsigned char)(tmp < 0 ? 0 : tmp);
  187. }
  188. pimg+=(s-1)*cols;
  189. }
  190. }
  191. /******************************************************************
  192. * Function lowpass
  193. * 2D low pass filtering of img into lp. rows,
  194. * cols are the dimensions of img.
  195. ******************************************************************/
  196. static void lowpass(unsigned char *img, unsigned char *lp,
  197. int rows, int cols, int ntaps)
  198. {
  199. unsigned char *tmp;
  200. if (!(tmp = (unsigned char *)ScAlloc(rows*cols))) {
  201. /* fprintf(stderr,"ScAlloc failed\n");
  202. exit(-1); */
  203. return;
  204. }
  205. switch (ntaps) {
  206. case 3:
  207. hfilt121(img, tmp, 1, 1, rows, cols);
  208. vfilt121(tmp, lp, 1, 1, rows, cols);
  209. break;
  210. case 5:
  211. hfilt5(img, tmp, 1, 1, rows, cols);
  212. vfilt5(tmp, lp, 1, 1, rows, cols);
  213. break;
  214. default:
  215. /* printf("Unknown filter in lowpass\n");
  216. exit(0); */
  217. ScFree(tmp);
  218. return;
  219. }
  220. ScFree(tmp);
  221. }
  222. /******************************************************************
  223. * Function reduce
  224. * 2D low pass filtering and subsampling by two of img into red. rows,
  225. * cols are the dimensions of img.
  226. ******************************************************************/
  227. static void reduce(unsigned char *img, unsigned char *red,
  228. int rows, int cols, int ntaps)
  229. {
  230. unsigned char *tmp;
  231. if (!(tmp = (unsigned char *)ScAlloc(rows*cols/2))) {
  232. /* fprintf(stderr,"ScAlloc failed\n");
  233. exit(-1); */
  234. return;
  235. }
  236. switch (ntaps) {
  237. case 3:
  238. hfilt121(img, tmp, 2, 1, rows, cols);
  239. vfilt121(tmp, red, 2, 1, rows, cols>>1);
  240. break;
  241. case 5:
  242. hfilt5(img, tmp, 2, 1, rows, cols);
  243. vfilt5(tmp, red, 2, 1, rows, cols>>1);
  244. break;
  245. default:
  246. /*
  247. printf("Unknown filter in reduce\n");
  248. exit(0); */
  249. ScFree(tmp);
  250. return;
  251. }
  252. ScFree(tmp);
  253. }
  254. /******************************************************************
  255. * Function hpad
  256. * Zero-pads img horizontaly by the factor s. Returns zero-paded
  257. * image in zp. rows, cols are the dimensions of img
  258. *****************************************************************/
  259. static void hpad(unsigned char *img, unsigned char *zp,
  260. unsigned char s,
  261. int rows, int cols, char mode)
  262. {
  263. int i, j;
  264. unsigned char *pf, *pimg, fill;
  265. switch (mode) {
  266. case 'l':
  267. fill = 0;
  268. break;
  269. case 'c':
  270. fill = 0;
  271. break;
  272. default:
  273. /*
  274. printf("Unknown fill mode in hpad\n");
  275. exit(0);
  276. */
  277. return;
  278. }
  279. pimg = img;
  280. pf = zp;
  281. for(i=0; i<rows; i++)
  282. for(j=0; j<cols*s; j++)
  283. *(pf++) = (j%s ? fill: *(pimg++));
  284. }
  285. /******************************************************************
  286. * Function vpad
  287. * Zero-pads img verticaly by the factor s. Returns zero-paded
  288. * image in zp. rows, cols are the dimensions of img
  289. *****************************************************************/
  290. static void vpad(unsigned char *img, unsigned char *zp,
  291. unsigned char s,
  292. int rows, int cols, char mode)
  293. {
  294. int i, j;
  295. unsigned char *pf, *pimg, fill;
  296. switch (mode) {
  297. case 'l':
  298. fill = 0;
  299. break;
  300. case 'c':
  301. fill = 0;
  302. break;
  303. default:
  304. /*
  305. printf("Unknown fill mode in hpad\n");
  306. exit(0); */
  307. return;
  308. }
  309. pimg = img;
  310. pf = zp;
  311. for(i=0; i<rows*s; i++)
  312. for(j=0; j<cols; j++)
  313. *(pf++) = (i%s ? fill: *(pimg++));
  314. }
  315. /******************************************************************
  316. * Function Expand
  317. * 2D upsampling by two and low pass filtering of img into exp. rows,
  318. * cols are the dimensions of img.
  319. ******************************************************************/
  320. static void Expand(unsigned char *img, unsigned char *exp,
  321. int rows, int cols, char mode, int ntaps)
  322. {
  323. unsigned char *tmp, *tmp2, *tmp3;
  324. if (!(tmp = (unsigned char *)ScAlloc(rows*cols*2))) {
  325. /*
  326. fprintf(stderr,"ScAlloc failed\n");
  327. exit(-1); */
  328. return;
  329. }
  330. hpad(img, tmp, 2, rows, cols, mode);
  331. if (!(tmp2 = (unsigned char *)ScAlloc(rows*cols*2))) {
  332. /* fprintf(stderr,"ScAlloc failed\n");
  333. exit(-1); */
  334. return;
  335. }
  336. switch (ntaps) {
  337. case 3:
  338. hfilt121(tmp, tmp2, 1, 2, rows, cols<<1);
  339. break;
  340. case 5:
  341. hfilt5(tmp, tmp2, 1, 2, rows, cols<<1);
  342. break;
  343. default:
  344. /*
  345. printf("Unknown filter in Expand\n");
  346. exit(0); */
  347. return;
  348. }
  349. if (!(tmp3 = (unsigned char *)ScAlloc(rows*cols*4))) {
  350. /*
  351. fprintf(stderr,"ScAlloc failed\n");
  352. exit(-1);
  353. */
  354. return;
  355. }
  356. vpad(tmp2, tmp3, 2, rows, cols<<1, mode);
  357. switch (ntaps) {
  358. case 3:
  359. vfilt121(tmp3, exp, 1, 2, rows<<1, cols<<1);
  360. break;
  361. case 5:
  362. vfilt5(tmp3, exp, 1, 2, rows<<1, cols<<1);
  363. break;
  364. default:
  365. /*
  366. printf("Unknown filter in Expand\n");
  367. exit(0); */
  368. return;
  369. }
  370. ScFree(tmp); ScFree(tmp2); ScFree(tmp3);
  371. }
  372. /*****************************************************************
  373. * Function gaussp
  374. * Builds a Gaussian pyramid of depth levels.
  375. *****************************************************************/
  376. static void gaussp(unsigned char *img, unsigned char **pyr,
  377. int depth, int rows, int cols, int ntaps)
  378. {
  379. int d;
  380. memcpy(pyr[0], img, rows*cols);
  381. for(d=1; d<depth; d++) {
  382. reduce(pyr[d-1], pyr[d], rows, cols, ntaps);
  383. rows /= 2;
  384. cols /= 2;
  385. }
  386. }
  387. /*****************************************************************
  388. * Function palloc
  389. * Allocates memory for a Gaussian pyramid of depth levels.
  390. * Higher resolution is level 0, with dimensions rows, cols.
  391. *****************************************************************/
  392. static unsigned char **palloc(int depth, int rows, int cols)
  393. {
  394. int d;
  395. unsigned char **pyr;
  396. if (!(pyr = (unsigned char **)ScAlloc(depth*sizeof(unsigned char *)))) {
  397. /*
  398. fprintf(stderr,"ScAlloc failed\n");
  399. exit(-1);
  400. */
  401. return(NULL);
  402. }
  403. for(d=0; d<depth; d++) {
  404. if (!(pyr[d] = (unsigned char *)ScAlloc(rows*cols))) {
  405. /*
  406. fprintf(stderr,"ScAlloc failed\n");
  407. exit(-1);
  408. */
  409. return(NULL);
  410. }
  411. rows /= 2;
  412. cols /= 2;
  413. }
  414. return pyr;
  415. }
  416. /****************************************************************
  417. * Function PictPyr
  418. * Buids a Gaussian pyramid of picture images with depth levels.
  419. ****************************************************************/
  420. static H263_PictImage **PictPyr(H263_PictImage *img, int depth, int rows, int cols, int ntaps)
  421. {
  422. unsigned char **tmp;
  423. H263_PictImage ** PictPyr;
  424. int d;
  425. if (!(PictPyr = (H263_PictImage **)ScAlloc(depth*sizeof(H263_PictImage *)))) {
  426. /*
  427. fprintf(stderr,"ScAlloc failed\n");
  428. exit(-1);
  429. */
  430. return(NULL);
  431. }
  432. for(d=0; d< depth; d++) {
  433. if ((PictPyr[d] = (H263_PictImage *)ScAlloc(sizeof(H263_PictImage))) == NULL) {
  434. /*
  435. fprintf(stderr,"Couldn't allocate (PictImage *)\n");
  436. exit(-1);
  437. */
  438. return(NULL);
  439. }
  440. }
  441. /* Luminance */
  442. tmp = palloc(depth, rows, cols);
  443. gaussp(img->lum, tmp, depth, rows, cols, ntaps);
  444. for(d=0; d<depth; d++) PictPyr[d]->lum = tmp[d];
  445. rows/=2; cols/=2;
  446. /* Chroma 1 */
  447. tmp = palloc(depth, rows, cols);
  448. gaussp(img->Cr, tmp, depth, rows, cols, ntaps);
  449. for(d=0; d<depth; d++) PictPyr[d]->Cr = tmp[d];
  450. /* Chroma 2 */
  451. tmp = palloc(depth, rows, cols);
  452. gaussp(img->Cb, tmp, depth, rows, cols, ntaps);
  453. for(d=0; d<depth; d++) PictPyr[d]->Cb = tmp[d];
  454. ScFree(tmp);
  455. return PictPyr;
  456. }
  457. /*****************************************************************
  458. * Function expyr
  459. * Expands the pyramid channels to full resolution. rows, cols
  460. * are the dimensions of the expanded images, and the full resolution
  461. * layer of the pyramid.
  462. *****************************************************************/
  463. static void expyr(unsigned char **pyr, unsigned char **filtd,
  464. int depth, int rows, int cols,
  465. char mode, int ntaps)
  466. {
  467. int d, l, r, c;
  468. r = rows; c = cols;
  469. memcpy(filtd[0], pyr[0], rows*cols);
  470. for(d=1; d<depth; d++) {
  471. r /= 2;
  472. c /= 2;
  473. for(l=d; l>0; l--) Expand(pyr[d], pyr[d-1], r, c, mode, ntaps);
  474. memcpy(filtd[d], pyr[0], rows*cols);
  475. }
  476. }
  477. /*****************************************************************
  478. * Function GaussFilt
  479. * Builds an array of successively more low pass filtered images
  480. * by constructing a gaussian pyramid and expanding each level
  481. * to full resolution
  482. *****************************************************************/
  483. static H263_PictImage **GaussFilt(H263_PictImage *img, int depth, int rows,
  484. int cols, int ntaps)
  485. {
  486. int d;
  487. H263_PictImage **PictFiltd;
  488. unsigned char **tmp, **filtd;
  489. PictFiltd = (H263_PictImage **) ScAlloc(depth*sizeof(H263_PictImage *));
  490. for(d=0; d<depth; d++) {
  491. PictFiltd[d] = sv_H263InitImage(rows*cols);
  492. }
  493. /* Luminance */
  494. filtd = (unsigned char **) ScAlloc(depth*sizeof(unsigned char *));
  495. for(d=0; d<depth; d++) filtd[d] = (unsigned char *) ScAlloc(rows * cols);
  496. tmp = palloc(depth, rows, cols);
  497. gaussp(img->lum, tmp, depth, rows, cols, ntaps);
  498. expyr(tmp, filtd, depth, rows, cols, 'l', ntaps);
  499. for(d=0; d<depth; d++) memcpy(PictFiltd[d]->lum, filtd[d], rows*cols);
  500. for(d=0; d<depth; d++) {
  501. ScFree(tmp[d]);
  502. ScFree(filtd[d]);
  503. }
  504. ScFree(tmp);
  505. ScFree(filtd);
  506. rows/=2; cols/=2;
  507. /* Chroma 1 */
  508. filtd = (unsigned char **) ScAlloc(depth*sizeof(unsigned char *));
  509. for(d=0; d<depth; d++) filtd[d] = (unsigned char *) ScAlloc(rows * cols);
  510. tmp = palloc(depth, rows, cols);
  511. gaussp(img->Cr, tmp, depth, rows, cols, ntaps);
  512. expyr(tmp, filtd, depth, rows, cols, 'c', ntaps);
  513. for(d=0; d<depth; d++) memcpy(PictFiltd[d]->Cr, filtd[d], rows*cols);
  514. for(d=0; d<depth; d++) {
  515. ScFree(tmp[d]);
  516. ScFree(filtd[d]);
  517. }
  518. ScFree((void *) tmp);
  519. ScFree((void *) filtd);
  520. /* Chroma 2 */
  521. filtd = (unsigned char **) ScAlloc(depth*sizeof(unsigned char *));
  522. for(d=0; d<depth; d++) filtd[d] = (unsigned char *) ScAlloc(rows * cols);
  523. tmp = palloc(depth, rows, cols);
  524. gaussp(img->Cb, tmp, depth, rows, cols, ntaps);
  525. expyr(tmp, filtd, depth, rows, cols, 'c', ntaps);
  526. for(d=0; d<depth; d++) memcpy(PictFiltd[d]->Cb, filtd[d], rows*cols);
  527. for(d=0; d<depth; d++) {
  528. ScFree(tmp[d]);
  529. ScFree(filtd[d]);
  530. }
  531. ScFree((void *) tmp);
  532. ScFree((void *) filtd);
  533. return PictFiltd;
  534. }
  535. /*****************************************************************
  536. * Function GaussLayers
  537. * Builds an array of successively more low pass filtered images
  538. *****************************************************************/
  539. H263_PictImage **svH263GaussLayers(H263_PictImage *img, int depth, int rows, int cols, int ntaps)
  540. {
  541. int d;
  542. H263_PictImage **PictFiltd;
  543. PictFiltd = (H263_PictImage **) ScAlloc(depth*sizeof(H263_PictImage *));
  544. for(d=0; d<depth; d++) {
  545. PictFiltd[d] = sv_H263InitImage(rows*cols);
  546. }
  547. /* Luminance */
  548. memcpy(PictFiltd[0]->lum, img->lum, rows*cols);
  549. for(d=1; d<depth; d++)
  550. lowpass(PictFiltd[d-1]->lum, PictFiltd[d]->lum, rows, cols, ntaps);
  551. rows/=2; cols/=2;
  552. /* Chroma 1 */
  553. memcpy(PictFiltd[0]->Cr, img->Cr, rows*cols);
  554. for(d=1; d<depth; d++)
  555. lowpass(PictFiltd[d-1]->Cr, PictFiltd[d]->Cr, rows, cols, ntaps);
  556. /* Chroma 2 */
  557. memcpy(PictFiltd[0]->Cb, img->Cb, rows*cols);
  558. for(d=1; d<depth; d++)
  559. lowpass(PictFiltd[d-1]->Cb, PictFiltd[d]->Cb, rows, cols, ntaps);
  560. return PictFiltd;
  561. }