00001
00007 #include "edtinc.h"
00008
00009 #include "pdv_interlace_methods.h"
00010
00011
00012
00013
00014
00015 #ifdef USE_MMX
00016
00017 #include "bayer_filter_asm.h"
00018
00019 #endif
00020
00021
00022 #include <math.h>
00023
00024
00025 #define PDVWARN PDVLIB_MSG_WARNING
00026 #define PDVFATAL PDVLIB_MSG_FATAL
00027 #define DBG1 PDVLIB_MSG_INFO_1
00028 #define DBG2 PDVLIB_MSG_INFO_2
00029
00030 #define PDV_BAYER_ORDER_BGGR 0
00031 #define PDV_BAYER_ORDER_GBRG 1
00032 #define PDV_BAYER_ORDER_RGGB 2
00033 #define PDV_BAYER_ORDER_GRBG 3
00034
00035 #define PDV_BAYER_ORDER(dd_p) ((((Dependent *) dd_p)->kbs_red_row_first << 1) \
00036 | ((Dependent *) dd_p)->kbs_green_pixel_first)
00037
00038
00039
00040
00041
00042 static int
00043 pdv_default_interlace_inplace(int interlace_type)
00044
00045 {
00046 #ifdef USE_MMX
00047 if (interlace_type == 0 ||
00048 interlace_type == PDV_BYTE_INTLV ||
00049
00050 interlace_type == PDV_INTLV_BGR_2_RGB)
00051 #else
00052 if (interlace_type == 0)
00053 #endif
00054 {
00055 return 1;
00056 }
00057
00058 return 0;
00059
00060 }
00061
00062 int
00063 pdv_process_inplace(PdvDev *pdv_p)
00064 {
00065 EdtPostProc *pCntl;
00066
00067 if ((pCntl = (EdtPostProc *) pdv_p->pInterleaver))
00068 {
00069 if (pCntl->doinplace)
00070 return pCntl->doinplace();
00071
00072 }
00073
00074 return pdv_default_interlace_inplace(pdv_p->dd_p->swinterlace);
00075 }
00076
00077
00078 void
00079 pdv_alloc_tmpbuf(PdvDev * pdv_p)
00080
00081 {
00082 Dependent *dd_p = pdv_p->dd_p;
00083
00084
00085 if (dd_p->swinterlace)
00086 {
00087 int size = pdv_get_dmasize(pdv_p);
00088
00089 if (dd_p->imagesize > size)
00090 size = dd_p->imagesize;
00091
00092 if (size != (int) pdv_p->tmpbufsize)
00093 {
00094 if (pdv_p->tmpbuf)
00095 edt_free(pdv_p->tmpbuf);
00096
00097 if (size)
00098 {
00099 pdv_p->tmpbuf = edt_alloc(size);
00100 }
00101 else
00102 pdv_p->tmpbuf = NULL;
00103
00104 pdv_p->tmpbufsize = size;
00105
00106 }
00107 }
00108 }
00109
00110
00111
00112
00113
00114 int
00115 deIntlv_ES10_8(u_char * src, int width, int rows, u_char * dest)
00116 {
00117
00118
00119
00120 #ifdef USE_MMX
00121
00122 if (bayer_can_use_mmx())
00123 {
00124 edt_msg(DBG2, "Using MMX\n");
00125 return deIntlv_ES10_8_mmx_inplace(src, width, rows, dest);
00126
00127 }
00128 else
00129
00130 #endif
00131 {
00132 u_char *even_dst;
00133 u_char *odd_dst;
00134 int x, y;
00135
00136 edt_msg(DBG2, "ES10deInterLeave()\n");
00137
00138 even_dst = dest;
00139 odd_dst = dest + width;
00140
00141 for (y = 0; y + 1 < rows; y += 2)
00142 {
00143 for (x = 0; x < width; x++)
00144 {
00145 *even_dst++ = *src++;
00146 *odd_dst++ = *src++;
00147 }
00148 even_dst += width;
00149 odd_dst += width;
00150 }
00151 }
00152 return (0);
00153 }
00154
00155
00156
00157
00158
00159 int
00160 deIntlv_ES10_16(u_short * src, int width, int rows, u_short * dest)
00161 {
00162 u_short *even_dst;
00163 u_short *odd_dst;
00164 int x, y;
00165
00166 edt_msg(DBG2, "ES10_word_deIntlv()\n");
00167
00168 even_dst = dest;
00169 odd_dst = dest + width;
00170
00171 for (y = 0; y < rows; y += 2)
00172 {
00173 for (x = 0; x < width; x++)
00174 {
00175 *even_dst++ = *src++;
00176 *odd_dst++ = *src++;
00177 }
00178 even_dst += width;
00179 odd_dst += width;
00180 }
00181 return (0);
00182 }
00183
00184
00185
00186
00187 int
00188 deIntlv_ES10_16_odd(u_short * src, int width, int rows, u_short * dest)
00189 {
00190 u_short *even_dst;
00191 u_short *odd_dst;
00192 int x, y;
00193
00194 edt_msg(DBG2, "ES10_word_deIntlv_odd()\n");
00195
00196 odd_dst = dest;
00197 even_dst = dest + width;
00198
00199 for (y = 0; y < rows; y += 2)
00200 {
00201 for (x = 0; x < width; x++)
00202 {
00203 *even_dst++ = *src++;
00204 *odd_dst++ = *src++;
00205 }
00206 odd_dst += width;
00207 even_dst += width;
00208 }
00209 return (0);
00210 }
00211
00212
00213
00214
00215 int
00216 deIntlv_ES10_16_hilo(u_short * src, int width, int rows, u_short * dest)
00217 {
00218 u_short *even_dst;
00219 u_short *odd_dst;
00220 int x, y;
00221
00222 edt_msg(DBG2, "ES10_word_deIntlv_hilo()\n");
00223
00224 even_dst = dest;
00225 odd_dst = dest + (width * (rows / 2));
00226
00227 for (y = 0; y < rows; y += 2)
00228 {
00229 for (x = 0; x < width; x++)
00230 {
00231 *even_dst++ = *src++;
00232 *odd_dst++ = *src++;
00233 }
00234 }
00235 return (0);
00236 }
00237
00238
00239
00240
00241 int
00242 deIntlv_TopBottom8(u_char * src, int width, int rows, u_char * dest)
00243 {
00244 u_char *even_dst;
00245 u_char *odd_dst;
00246 int x, y;
00247
00248 edt_msg(DBG2, "deIntlv_TopBottom8()\n");
00249
00250 even_dst = dest;
00251 odd_dst = dest + (width * (rows-1));
00252
00253 for (y = 0; y < rows; y += 2)
00254 {
00255 for (x = 0; x < width; x++)
00256 {
00257 *even_dst++ = *src++;
00258 *odd_dst++ = *src++;
00259 }
00260 odd_dst -= width*2;
00261 }
00262 return (0);
00263 }
00264
00265
00266
00267
00268 int
00269 deIntlv_TopBottom16(u_short * src, int width, int rows, u_short * dest)
00270 {
00271 u_short *even_dst;
00272 u_short *odd_dst;
00273 int x, y;
00274
00275 edt_msg(DBG2, "deIntlv_TopBottom16()\n");
00276
00277 even_dst = dest;
00278 odd_dst = dest + (width * (rows-1));
00279
00280 for (y = 0; y < rows; y += 2)
00281 {
00282 for (x = 0; x < width; x++)
00283 {
00284 *even_dst++ = *src++;
00285 *odd_dst++ = *src++;
00286 }
00287 odd_dst -= width*2;
00288 }
00289 return (0);
00290 }
00291
00292
00293
00294
00295 int
00296 deIntlv_InOut8(u_char * src, int width, int rows, u_char * dest)
00297 {
00298 u_char *even_dst;
00299 u_char *odd_dst;
00300 int x, y;
00301
00302 edt_msg(DBG2, "deIntlv_InOut8()\n");
00303
00304 for (y = 0; y < rows; y ++)
00305 {
00306 odd_dst = dest + (width / 2);
00307 even_dst = odd_dst - 1;
00308 for (x = 0; x < width; x++)
00309 {
00310 *even_dst-- = *src++;
00311 *odd_dst++ = *src++;
00312 }
00313 dest += width;
00314 }
00315 return (0);
00316 }
00317
00318
00319
00320
00321 int
00322 deIntlv_InOut16(u_short * src, int width, int rows, u_short * dest)
00323 {
00324 u_short *even_dst;
00325 u_short *odd_dst;
00326 int x, y;
00327
00328 edt_msg(DBG2, "deIntlv_InOut16()\n");
00329
00330 for (y = 0; y < rows; y ++)
00331 {
00332 odd_dst = dest + (width / 2);
00333 even_dst = odd_dst - 1;
00334 for (x = 0; x < width; x++)
00335 {
00336 *even_dst-- = *src++;
00337 *odd_dst++ = *src++;
00338 }
00339 dest += width;
00340 }
00341 return (0);
00342 }
00343
00344
00345
00346
00347
00348 int
00349 deIntlv_piranha_8(u_char *src, int width, int rows, u_char *dest)
00350
00351 {
00352 int x, y;
00353 u_char *sx=src;
00354 u_char *dxl, *dxr;
00355
00356 edt_msg(DBG2, "deIntlv_piranha_8()\n");
00357
00358 for (y=0;y<rows;y++)
00359 {
00360 dxl = dest + (width * y);
00361 dxr = (dxl + width) - 1;
00362 for (x=0;x<width;x+=4)
00363 {
00364 *(dxl++) = *(sx++);
00365 *(dxl++) = *(sx++);
00366 *(dxr-1) = *(sx++);
00367 *(dxr) = *(sx++);
00368 dxr -= 2;
00369 }
00370 }
00371 return (0);
00372 }
00373
00374
00375
00376
00377 int
00378 deIntlv_dalsa_4ch_8(u_char * src, int width, int rows, u_char * dest)
00379 {
00380 int x, y;
00381 int dx = 0;
00382 int swidth = width / 4 - 1;
00383 u_char *sp = src;
00384
00385 edt_msg(DBG2, "deIntlv_dalsa_4ch_8() -- %d pixel bands\n", swidth);
00386
00387 sp = src;
00388 for (y = 0; y < rows; y++)
00389 {
00390 dx = y * width;
00391 for (x = 0; x < width / 4; x++, dx++)
00392 {
00393 dest[dx] = *sp++;
00394 dest[dx + swidth] = *sp++;
00395 dest[dx + (swidth * 2)] = *sp++;
00396 dest[dx + (swidth * 3)] = *sp++;
00397 }
00398 }
00399 return (0);
00400 }
00401
00402
00403
00404
00405
00406 int
00407 deIntlv_dalsa_ls_4ch_8(u_char * src, int width, int rows, u_char * dest)
00408 {
00409 int x, y;
00410 u_char *sp = src;
00411 u_char *dp0, *dp1, *dp2, *dp3;
00412
00413 edt_msg(DBG2, "deIntlv_dalsa_ls_4ch_8()");
00414
00415 for (y=0; y<rows; y++)
00416 {
00417 dp0 = dest + (y * width);
00418 dp1 = dp0 + 1;
00419 dp2 = dp0 + width - 2;
00420 dp3 = dp0 + width - 1;
00421
00422 for (x = 0; x < width; x+= 4)
00423 {
00424 *dp0 = *sp++;
00425 *dp1 = *sp++;
00426 *dp2 = *sp++;
00427 *dp3 = *sp++;
00428 dp0 += 2;
00429 dp1 += 2;
00430 dp2 -= 2;
00431 dp3 -= 2;
00432 }
00433 }
00434 return (0);
00435 }
00436
00437
00438
00439
00440
00441
00442 int
00443 deIntlv_specinst_4ch_16(u_short * src, int width, int rows, u_short * dest)
00444 {
00445 int x, y;
00446 int dxul, dxur, dxll, dxlr;
00447 u_short *sp = src;
00448
00449 edt_msg(DBG2, "deIntlv_specinst_4ch_16()\n");
00450
00451 for (y = 0; y < rows / 2; y++)
00452 {
00453 dxul = y * width;
00454 dxur = dxul + (width - 1);
00455 dxll = (width * ((rows - y) - 1));
00456 dxlr = dxll + (width - 1);
00457 for (x = 0; x < width / 2; x++)
00458 {
00459 dest[dxll++] = *sp++;
00460 dest[dxlr--] = *sp++;
00461 dest[dxul++] = *sp++;
00462 dest[dxur--] = *sp++;
00463 }
00464 }
00465 return (0);
00466 }
00467
00468
00469
00470
00471
00472
00473 int
00474 deIntlv_10bit_8tap_packed(u_char * src, int width, int rows, u_short * dest)
00475 {
00476 u_char *sp = src;
00477 u_short *dp = dest;
00478 u_int x, y;
00479
00480 for (y=0; y<(u_int)rows; y++)
00481 {
00482 for (x=0; x<(u_int)width; x+=8)
00483 {
00484 u_char *lsb0 = sp+8;
00485 u_char *lsb1 = sp+9;
00486
00487 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb0) & 0x03) );
00488 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb0) & 0x0c) >> 2);
00489 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb0) & 0x30) >> 4);
00490 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb0) & 0xc0) >> 6);
00491 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb1) & 0x03) );
00492 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb1) & 0x0c) >> 2);
00493 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb1) & 0x30) >> 4);
00494 *dp++ = ((u_short)(*sp++) << 2) | (((u_short)(*lsb1) & 0xc0) >> 6);
00495 sp +=2;
00496 }
00497 }
00498 return 0;
00499 }
00500
00501
00502
00503
00504
00505
00506 int
00507 deIntlv_10bit_8tap_to_8bit(u_char * src, int width, int rows, u_char * dest)
00508 {
00509 u_char *sp = src;
00510 u_char *dp = dest;
00511 u_int x, y;
00512
00513 for (y=0; y<(u_int)rows; y++)
00514 {
00515 for (x=0; x<(u_int)width + (width/4); x+=10)
00516 {
00517 int i;
00518
00519 for (i=0; i<8; i++)
00520 *dp++ = *sp++;
00521 sp +=2;
00522 }
00523 }
00524 return 0;
00525 }
00526
00527
00528
00529
00530
00531
00532 int
00533 deIntlv_quad_16(u_short *src, int width, int rows, u_short *dest)
00534 {
00535 int i,r,c, nrows,ncols,qrows,qcols;
00536
00537 edt_msg(DBG2, "deIntlv_quad_16\n");
00538
00539 nrows = rows;
00540 ncols = width;
00541 qrows = nrows>>1;
00542 qcols = ncols>>1;
00543
00544 for (r = 0,i = 0; r < qrows*ncols; r += ncols)
00545 for (c = 0; c < qcols; ++c, i += 4)
00546 dest[r+c] = src[i];
00547 for (r = 0,i = 1; r < qrows*ncols; r += ncols)
00548 for (c = ncols-1; c >= qcols; --c, i += 4)
00549 dest[r+c] = src[i];
00550 for (r = (nrows-1)*ncols,i = 2; r >= qrows*ncols; r -= ncols)
00551 for (c = 0; c < qcols; ++c, i += 4)
00552 dest[r+c] = src[i];
00553 for (r = (nrows-1)*ncols,i = 3; r >= qrows*ncols; r -= ncols)
00554 for (c = ncols-1; c >= qcols; --c, i += 4)
00555 dest[r+c] = src[i];
00556 return (0);
00557 }
00558
00559 int
00560 deIntlv_quad_8(u_char *src, int width, int rows, u_char *dest)
00561 {
00562 int i,r,c, nrows,ncols,qrows,qcols;
00563
00564 edt_msg(DBG2, "deIntlv_quad_8\n");
00565
00566 nrows = rows;
00567 ncols = width;
00568 qrows = nrows>>1;
00569 qcols = ncols>>1;
00570
00571 for (r = 0,i = 0; r < qrows*ncols; r += ncols)
00572 for (c = 0; c < qcols; ++c, i += 4)
00573 dest[r+c] = src[i];
00574 for (r = 0,i = 1; r < qrows*ncols; r += ncols)
00575 for (c = ncols-1; c >= qcols; --c, i += 4)
00576 dest[r+c] = src[i];
00577 for (r = (nrows-1)*ncols,i = 2; r >= qrows*ncols; r -= ncols)
00578 for (c = 0; c < qcols; ++c, i += 4)
00579 dest[r+c] = src[i];
00580 for (r = (nrows-1)*ncols,i = 3; r >= qrows*ncols; r -= ncols)
00581 for (c = ncols-1; c >= qcols; --c, i += 4)
00582 dest[r+c] = src[i];
00583 return (0);
00584 }
00585
00586
00587
00588
00589
00590
00591 int
00592 deIntlv_quad2_16(u_short *src, int width, int height, u_short *dest)
00593 {
00594 int x, y, qwidth, qheight;
00595 u_short *ul, *um, *ml, *mm;
00596 u_short *sp = src;
00597
00598 edt_msg(DBG2, "deIntlv_quad2_8\n");
00599
00600 qwidth = width/2;
00601 qheight = height/2;
00602
00603 for (y=0; y<qheight; y++)
00604 {
00605 ul = dest + (y * width);
00606 um = ul + qwidth;
00607 ml = ul + (width * y / 2);
00608 mm = ml + qwidth;
00609
00610 for (x=0; x<qwidth; x++)
00611 {
00612 *(ul++) = *sp++;
00613 *(um++) = *sp++;
00614 *(ml++) = *sp++;
00615 *(mm++) = *sp++;
00616 }
00617 }
00618
00619 return (0);
00620 }
00621
00622 int
00623 deIntlv_quad2_8(u_char *src, int width, int height, u_char *dest)
00624 {
00625 int x, y, qwidth, qheight;
00626 u_char *ul, *um, *ml, *mm;
00627 u_char *sp = src;
00628
00629 edt_msg(DBG2, "deIntlv_quad2_8\n");
00630
00631 qwidth = width/2;
00632 qheight = height/2;
00633
00634 for (y=0; y<qheight; y++)
00635 {
00636 ul = dest + (y * width);
00637 um = ul + qwidth;
00638 ml = ul + (width * y / 2);
00639 mm = ml + qwidth;
00640
00641 for (x=0; x<qwidth; x++)
00642 {
00643 *(ul++) = *sp++;
00644 *(um++) = *sp++;
00645 *(ml++) = *sp++;
00646 *(mm++) = *sp++;
00647 }
00648 }
00649
00650 return (0);
00651 }
00652
00653
00654
00655
00656
00657
00658 int
00659 deIntlv_quad3_16(u_short *src, int width, int height, u_short *dest)
00660 {
00661 int x, y, qwidth, qheight;
00662 u_short *ul, *ur, *ll, *lr;
00663 u_short *sp = src;
00664
00665 edt_msg(DBG2, "deIntlv_quad3_16\n");
00666
00667 qwidth = width/2;
00668 qheight = height/2;
00669
00670 for (y=0; y<qheight; y++)
00671 {
00672 ur = dest + (((qheight - y) - 1) * width) + qwidth;
00673 ul = ur - 1;
00674 lr = dest + (( qheight + y) * width) + qwidth;
00675 ll = lr - 1;
00676
00677 for (x=0; x<qwidth; x++)
00678 {
00679 *(ul--) = *sp++;
00680 *(ur++) = *sp++;
00681 *(ll--) = *sp++;
00682 *(lr++) = *sp++;
00683 }
00684 }
00685
00686 return (0);
00687 }
00688
00689 int
00690 deIntlv_quad3_8(u_char *src, int width, int height, u_char *dest)
00691 {
00692 int x, y, qwidth, qheight;
00693 u_char *ul, *ur, *ll, *lr;
00694 u_char *sp = src;
00695
00696 edt_msg(DBG2, "deIntlv_quad3_8\n");
00697
00698 qwidth = width/2;
00699 qheight = height/2;
00700
00701 for (y=0; y<qheight; y++)
00702 {
00703 ur = dest + (((qheight - y) - 1) * width) + qwidth;
00704 ul = ur - 1;
00705 lr = dest + (( qheight + y) * width) + qwidth;
00706 ll = lr - 1;
00707
00708 for (x=0; x<qwidth; x++)
00709 {
00710 *(ul--) = *sp++;
00711 *(ur++) = *sp++;
00712 *(ll--) = *sp++;
00713 *(lr++) = *sp++;
00714 }
00715 }
00716
00717 return (0);
00718 }
00719
00720
00721
00722
00723
00724
00725 int
00726 deIntlv_4ch_ill_16(u_short *src, int width, int height, u_short *dest)
00727 {
00728 int x, y, qwidth, qheight;
00729 u_short *ul, *ur, *ll, *lr;
00730 u_short *sp = src;
00731
00732 edt_msg(DBG2, "deIntlv_4ch_ill_16\n");
00733
00734 qwidth = width/2;
00735 qheight = height/2;
00736
00737 for (y=0; y<qheight; y++)
00738 {
00739 ul = dest + (y * width);
00740 ur = ul + width - 1;
00741 ll = dest + ((height - y) - 1) * width;
00742 lr = ll + width - 1;
00743
00744 for (x=0; x<qwidth; x++)
00745 {
00746 *(lr-x) = *sp++;
00747 *(ur-x) = *sp++;
00748 *(ll+x) = *sp++;
00749 *(ul+x) = *sp++;
00750 }
00751 }
00752
00753 return (0);
00754 }
00755
00756 int
00757 deIntlv_4ch_ill_8(u_char *src, int width, int height, u_char *dest)
00758 {
00759 int x, y, qwidth, qheight;
00760 u_char *ul, *ur, *ll, *lr;
00761 u_char *sp = src;
00762
00763 edt_msg(DBG2, "deIntlv_4ch_ill_8\n");
00764
00765 qwidth = width/2;
00766 qheight = height/2;
00767
00768 for (y=0; y<qheight; y++)
00769 {
00770 ul = dest + (y * width);
00771 ur = ul + width - 1;
00772 ll = dest + ((height - y) - 1) * width;
00773 lr = ll + width - 1;
00774
00775 for (x=0; x<qwidth; x++)
00776 {
00777 *(ul+x) = *sp++;
00778 *(ll+x) = *sp++;
00779 *(ur-x) = *sp++;
00780 *(lr-x) = *sp++;
00781 }
00782 }
00783
00784 return (0);
00785 }
00786
00787
00788
00789 int
00790 deintlv_line_taps_8x4(u_char *src, int width, int rows, u_char *dest, int ntaps, PdvInterleaveTap *taps)
00791
00792 {
00793 int i0, i1, i2, i3, x;
00794
00795 int row;
00796 u_char *sp, *dp;
00797
00798 static int last_alloc = 0;
00799
00800 static u_char * line_buffer;
00801
00802 if (width != last_alloc)
00803 {
00804 line_buffer = edt_alloc(width);
00805 last_alloc = width;
00806 }
00807
00808 sp = src;
00809 dp = dest;
00810
00811 for (row = 0;row < rows;row ++)
00812 {
00813 i0 = taps[0].startx;
00814 i1 = taps[1].startx;
00815 i2 = taps[2].startx;
00816 i3 = taps[3].startx;
00817 for (x = 0; x < width;x += 4)
00818 {
00819 line_buffer[i0] = sp[x];
00820 line_buffer[i1] = sp[x+1];
00821 line_buffer[i2] = sp[x+2];
00822 line_buffer[i3] = sp[x+3];
00823
00824 i0 += taps[0].dx;
00825 i1 += taps[1].dx;
00826 i2 += taps[2].dx;
00827 i3 += taps[3].dx;
00828 }
00829
00830 memcpy(dp, line_buffer, width);
00831 sp += width;
00832 dp += width;
00833
00834 }
00835
00836 return 0;
00837
00838 }
00839
00840
00841
00842
00843
00844 int
00845 deIntlv_line_taps_8x4_inv_rt(u_char * src, int width, int rows, u_char * dest)
00846 {
00847 int i, y, t1, t2, t3, t4;
00848 int offs2 = width/4;
00849 int offs3 = ((width/4)*3) - 1;
00850 int offs4 = width-1;
00851
00852 static int last_alloc = 0;
00853 static u_char * line_buffer;
00854
00855 u_char *sp = src;
00856 u_char *dp = dest;
00857
00858 if (width != last_alloc)
00859 {
00860 line_buffer = edt_alloc(width);
00861 last_alloc = width;
00862 }
00863
00864 for (y=0; y<rows; y++)
00865 {
00866 t1 = 0;
00867 t2 = offs2;
00868 t3 = offs3;
00869 t4 = offs4;
00870
00871 for (i=0; i<width; i+=4)
00872 {
00873 line_buffer[t1++] = *(sp++);
00874 line_buffer[t2++] = *(sp++);
00875 line_buffer[t3--] = *(sp++);
00876 line_buffer[t4--] = *(sp++);
00877 }
00878 memcpy(dp, line_buffer, width);
00879 dp += width;
00880 }
00881
00882 return (0);
00883 }
00884
00885
00892 int
00893 deIntlv_2ch_inv_rt_24_12(u_char * src,
00894 int width,
00895 int rows,
00896 u_short * dest)
00897 {
00898 int y;
00899 u_short *lp, *rp;
00900 u_char *sp = src;
00901
00902
00903 #if 0
00904 #ifdef USE_MMX
00905
00906 if (bayer_can_use_mmx())
00907 {
00908 edt_msg(DBG2, "Using MMX\n");
00909 return Inv_Rt_2ch_deIntlv_2ch_24_12_mmx(src, width, rows, dest);
00910
00911 }
00912 #endif
00913 #endif
00914
00915 for (y = 0; y < rows; y++)
00916 {
00917 lp = dest + (y * width);
00918 rp = lp + width - 1;
00919
00920 while (lp < rp)
00921 {
00922 *rp-- = sp[0] + ((sp[1] & 0xf0) << 4);
00923 *lp++ = sp[2] + ((sp[1] & 15) << 8);
00924
00925 sp += 3;
00926 }
00927 }
00928 return (0);
00929 }
00930
00937 int
00938 deIntlv_2ch_24_12(u_char * src,
00939 int width,
00940 int rows,
00941 u_short * dest)
00942 {
00943 int x, y;
00944 u_short *lp;
00945 u_char *sp = src;
00946
00947
00948 for (y = 0; y < rows; y++)
00949 {
00950
00951 lp = dest + (y * width);
00952
00953 for (x = 0; x < width-1; x +=2)
00954 {
00955 lp[x] = sp[0] + ((sp[1] & 0xf0) << 4);
00956 lp[x+1] = sp[2] + ((sp[1] & 15) << 8);
00957 sp += 3;
00958 }
00959 }
00960 return (0);
00961 }
00962
00963
00964 int
00965 deIntlv_1_8_msb7(u_char * src,
00966 int width,
00967 int rows,
00968 u_char * dest)
00969 {
00970 int x, y;
00971 u_char *lp;
00972 u_char *sp = src;
00973
00974 for (y = 0; y < rows; y++)
00975 {
00976
00977 lp = dest + (y * width);
00978
00979 for (x = 0; x < width-7; x += 8)
00980 {
00981 lp[x] = (sp[0] & 0x80) ? 255:0;
00982 lp[x+1] = (sp[0] & 0x40) ? 255:0;
00983 lp[x+2] = (sp[0] & 0x20) ? 255:0;
00984 lp[x+3] = (sp[0] & 0x10) ? 255:0;
00985 lp[x+4] = (sp[0] & 0x8) ? 255:0;
00986 lp[x+5] = (sp[0] & 0x4) ? 255:0;
00987 lp[x+6] = (sp[0] & 0x2) ? 255:0;
00988 lp[x+7] = (sp[0] & 0x1) ? 255:0;
00989
00990 sp ++;
00991 }
00992 }
00993 return (0);
00994 }
00995
01000 int
01001 deIntlv_1_8_msb0(u_char * src,
01002 int width,
01003 int rows,
01004 u_char * dest)
01005 {
01006 int x, y;
01007 u_char *lp;
01008 u_char *sp = src;
01009
01010
01011 for (y = 0; y < rows; y++)
01012 {
01013
01014 lp = dest + (y * width);
01015
01016 for (x = 0; x < width-7; x += 8)
01017 {
01018 lp[x] = (sp[0] & 0x1) ? 255:0;
01019 lp[x+1] = (sp[0] & 0x2) ? 255:0;
01020 lp[x+2] = (sp[0] & 0x4) ? 255:0;
01021 lp[x+3] = (sp[0] & 0x8) ? 255:0;
01022 lp[x+4] = (sp[0] & 0x10) ? 255:0;
01023 lp[x+5] = (sp[0] & 0x20) ? 255:0;
01024 lp[x+6] = (sp[0] & 0x40) ? 255:0;
01025 lp[x+7] = (sp[0] & 0x80) ? 255:0;
01026
01027 sp ++;
01028 }
01029 }
01030 return (0);
01031 }
01032
01033
01034
01035
01036
01037
01038 int
01039 deIntlv_inv_rt_8(u_char * src, int width, int rows, u_char * dest)
01040 {
01041 int y;
01042 u_char *lp, *rp;
01043 u_char *sp = src;
01044
01045 u_char *line_buffer;
01046
01047
01048
01049 line_buffer = edt_alloc(width);
01050
01051 edt_msg(DBG2, "inv_rt_deIntlv()\n");
01052
01053 for (y = 0; y < rows; y++)
01054 {
01055 lp = line_buffer;
01056 rp = lp + width - 1;
01057 while (lp < rp)
01058 {
01059 *lp++ = *sp++;
01060 *rp-- = *sp++;
01061 }
01062 memcpy(dest + (y * width), line_buffer, width);
01063
01064 }
01065
01066 edt_free(line_buffer);
01067
01068 return (0);
01069 }
01070
01071
01072
01073
01074
01075 int
01076 deIntlv_inv_rt_16(u_short * src, int width, int rows, u_short * dest)
01077 {
01078 int y;
01079 u_short *lp, *rp;
01080 u_short *sp = src;
01081 u_short *line_buffer;
01082
01083 edt_msg(DBG2, "deIntlv_inv_rt_16()\n");
01084
01085
01086 line_buffer = (u_short *) edt_alloc(width * sizeof(u_short));
01087
01088 if (!line_buffer)
01089 return -1;
01090
01091 for (y = 0; y < rows; y++)
01092 {
01093 lp = line_buffer;
01094 rp = lp + width - 1;
01095 while (lp < rp)
01096 {
01097 *lp++ = *sp++;
01098 *rp-- = *sp++;
01099 }
01100
01101 memcpy(dest + y * width,
01102 line_buffer,
01103 width * sizeof(u_short));
01104
01105 }
01106
01107 edt_free((unsigned char *)line_buffer);
01108
01109 return (0);
01110 }
01111
01112
01113
01114
01115
01116
01117 int
01118 deIntlv_inv_rt_16_BGR(u_short * src,
01119 int width, int rows,
01120 u_char * dest,
01121 int order,
01122 int src_depth)
01123 {
01124 int rc;
01125
01126 if ((rc = deIntlv_inv_rt_16(src, width, rows, src)) == 0)
01127 {
01128
01129 return convert_bayer_image_16_BGR(src, width, rows, width, dest,
01130 order, src_depth);
01131 }
01132 else
01133 return rc;
01134 }
01135
01136
01137
01138
01139 int
01140 deIntlv_inv_rt_8_BGR(u_char * src, int width,
01141 int rows,
01142 u_char * dest,
01143 int order)
01144 {
01145 int rc;
01146
01147 if ((rc = deIntlv_inv_rt_8(src, width, rows, src)) == 0)
01148 {
01149
01150 return convert_bayer_image_8_BGR(src, width, rows, width, dest,
01151 order);
01152 }
01153 else
01154 return rc;
01155 }
01156
01157
01158
01159
01160 int
01161 deIntlv_2ch_even_rt_8(u_char * src, int width, int rows, u_char * dest)
01162 {
01163 int y;
01164 u_char *lp, *rp, *ep;
01165 u_char *sp = src;
01166
01167 edt_msg(DBG2, "deIntlv_2ch_even_rt_8()\n");
01168
01169 for (y = 0; y < rows; y++)
01170 {
01171 lp = dest + (y * width);
01172 rp = lp + (width / 2);
01173 ep = lp + width ;
01174 while (rp < ep)
01175 {
01176 *lp++ = *sp++;
01177 *rp++ = *sp++;
01178 }
01179 }
01180 return (0);
01181 }
01182
01183
01184
01185 int
01186 deIntlv_2ch_even_rt_16(u_short * src, int width, int rows, u_short * dest)
01187 {
01188 int y;
01189 u_short *lp, *rp, *ep;
01190 u_short *sp = src;
01191
01192 edt_msg(DBG2, "deIntlv_2ch_even_rt_816()\n");
01193
01194 for (y = 0; y < rows; y++)
01195 {
01196 lp = dest + (y * width);
01197 rp = lp + (width / 2);
01198 ep = lp + width ;
01199 while (rp < ep)
01200 {
01201 *lp++ = *sp++;
01202 *rp++ = *sp++;
01203 }
01204 }
01205 return (0);
01206 }
01207
01208
01209
01210
01211
01212 int
01213 deIntlv_MidTop_Line16(u_short *src, int width, int rows, u_short *dest)
01214 {
01215 int x, y;
01216 int dlower_idx = width * (rows/2);
01217 int dupper_idx = dlower_idx - width;
01218 u_short *p = src;
01219
01220 for (y=0; y<rows; y+=2)
01221 {
01222 for (x=0; x<width; x++)
01223 dest[dupper_idx+x] = *p++;
01224 dupper_idx -= width;
01225
01226 for (x=0; x<width; x++)
01227 dest[dlower_idx+x] = *p++;
01228 dlower_idx += width;
01229 }
01230
01231 return(0);
01232 }
01233
01234 int
01235 deIntlv_MidTop_Line8(u_char *src, int width, int rows, u_char *dest)
01236 {
01237 int x, y;
01238 int dlower_idx = width * (rows/2);
01239 int dupper_idx = dlower_idx - width;
01240 u_char *p = src;
01241
01242 for (y=0; y<rows; y+=2)
01243 {
01244 for (x=0; x<width; x++)
01245 dest[dupper_idx+x] = *p++;
01246 dupper_idx -= width;
01247
01248 for (x=0; x<width; x++)
01249 dest[dlower_idx+x] = *p++;
01250 dlower_idx += width;
01251 }
01252
01253 return(0);
01254 }
01255
01256
01257
01258
01259
01260 int
01261 deIntlv_TopMid_Line16(u_short *src, int width, int rows, u_short *dest)
01262 {
01263 int x, y;
01264 int sfront_idx = 0;
01265 int dfront_idx = 0;
01266 int dhalf_idx = (width * (rows / 2)) ;
01267
01268 for (y=0; y<rows; ++y)
01269 {
01270 for (x=0; x<width; ++x)
01271 {
01272 if (y % 2)
01273 {
01274 dest[dhalf_idx+x] = src[sfront_idx+x];
01275 }
01276 else
01277 {
01278 dest[dfront_idx+x] = src[sfront_idx+x];
01279 }
01280 }
01281 if (y % 2)
01282 dhalf_idx += width;
01283 else
01284 dfront_idx += width;
01285
01286 sfront_idx += width;
01287 }
01288
01289 return(0);
01290
01291 }
01292
01293
01294
01295
01296
01297 int
01298 deIntlv_HiLo_Line16(u_short *src, int width, int rows, u_short *dest)
01299 {
01300 int x, y;
01301 int sfront_idx = 0;
01302 int dfront_idx = 0;
01303 int dend_idx = (width * (rows - 1)) - 1;
01304
01305 for (y=0; y<rows; ++y)
01306 {
01307 for (x=0; x<width; ++x)
01308 {
01309 if (y % 2)
01310 {
01311 dest[dend_idx+x] = src[sfront_idx+x];
01312 }
01313 else
01314 {
01315 dest[dfront_idx+x] = src[sfront_idx+x];
01316 }
01317 }
01318 if(y % 2)
01319 dend_idx -= width;
01320 else
01321 dfront_idx += width;
01322
01323 sfront_idx += width;
01324 }
01325
01326 return(0);
01327
01328 }
01329
01330
01331
01332
01333 int
01334 deIntlv_XXband_16(u_short * src, int width, int rows, int bands, u_short * dest)
01335 {
01336 int b, x, y, lpb = rows/bands;
01337 u_short *sp = src;
01338 u_short *dp = dest;
01339
01340
01341
01342 for (y=0; y<lpb; y++)
01343 {
01344 for (x=0;x<width;x++)
01345 {
01346 for (b=0;b<bands;b++)
01347 {
01348 int idx = x + (b * width * lpb) + (y * width);
01349 dest[idx] = *sp++;
01350 }
01351 }
01352 }
01353
01354 return (0);
01355 }
01356
01357
01358
01359
01360 int
01361 deIntlv_merge_fields(
01362 u_char * evenptr,
01363 u_char * oddptr,
01364 int width,
01365 int rows,
01366 int depth,
01367 u_char * dest,
01368 int offset
01369 )
01370 {
01371 int depth_bytes = ((int) depth + 7) / 8;
01372 int partial = 0;
01373
01374 edt_msg(DBG2, "deIntlv_merge_fields() interlace %d offset %d\n",
01375 oddptr - evenptr, offset);
01376
01377 width *= depth_bytes;
01378
01379
01380 if (rows & 1)
01381 rows--;
01382
01383
01384 if (offset)
01385 {
01386 partial = 2;
01387 offset *= depth_bytes;
01388 memset(dest, 0, offset);
01389 memcpy(dest + offset, evenptr, width - offset);
01390 dest += width;
01391 evenptr += width - offset;
01392
01393 memcpy(dest, oddptr, width);
01394 dest += width;
01395 oddptr += width;
01396
01397 rows -= 2;
01398 }
01399
01400 for (; rows > partial; rows -= 2)
01401 {
01402
01403 memcpy(dest, evenptr, width);
01404 dest += width;
01405 evenptr += width;
01406
01407 memcpy(dest, oddptr, width);
01408 dest += width;
01409 oddptr += width;
01410 }
01411
01412
01413 if (partial)
01414 {
01415 memcpy(dest, evenptr, width);
01416 dest += width;
01417 oddptr += width;
01418
01419 memcpy(dest, evenptr, offset);
01420 memset(dest + offset, 0, width - offset);
01421 }
01422 return (0);
01423 }
01424
01425
01426
01427
01428
01429 pp_deintlv_midtop_line8(void *p_src,
01430 int width,
01431 int rows,
01432 void *p_dest,
01433 EdtPostProc *pCtrl)
01434 {
01435 u_char *src = (u_char *) p_src;
01436 u_char *dest = (u_char *) p_dest;
01437
01438 return deIntlv_MidTop_Line8(src, width, rows, dest);
01439 }
01440 pp_deintlv_midtop_line16(void *p_src,
01441 int width,
01442 int rows,
01443 void *p_dest,
01444 EdtPostProc *pCtrl)
01445 {
01446 u_short *src = (u_short *) p_src;
01447 u_short *dest = (u_short *) p_dest;
01448
01449 return deIntlv_MidTop_Line16(src, width, rows, dest);
01450 }
01451
01452 pp_deintlv_topmid_line16(void *p_src,
01453 int width,
01454 int rows,
01455 void *p_dest,
01456 EdtPostProc *pCtrl)
01457 {
01458 u_short *src = (u_short *) p_src;
01459 u_short *dest = (u_short *) p_dest;
01460
01461 return deIntlv_TopMid_Line16(src, width, rows, dest);
01462 }
01463
01464 pp_deintlv_hilo_line16(void *p_src,
01465 int width,
01466 int rows,
01467 void *p_dest,
01468 EdtPostProc *pCtrl)
01469 {
01470 u_short *src = (u_short *) p_src;
01471 u_short *dest = (u_short *) p_dest;
01472
01473 return deIntlv_HiLo_Line16(src, width, rows, dest);
01474 }
01475
01476 pp_deintlv_line_topbottom16(void * p_src,
01477 int width,
01478 int rows,
01479 void * p_dest,
01480 EdtPostProc *pCtrl)
01481
01482 {
01483 u_short *src = (u_short *) p_src;
01484 u_short *dest = (u_short *) p_dest;
01485
01486 return deIntlv_TopBottom16(src, width, rows, dest);
01487
01488 }
01489 pp_deintlv_line_topbottom8(void * p_src,
01490 int width,
01491 int rows,
01492 void * p_dest,
01493 EdtPostProc *pCtrl)
01494
01495 {
01496 u_char *src = (u_char *) p_src;
01497 u_char *dest = (u_char *) p_dest;
01498
01499 return deIntlv_TopBottom8(src, width, rows, dest);
01500
01501 }
01502 pp_deintlv_line_inout16(void * p_src,
01503 int width,
01504 int rows,
01505 void * p_dest,
01506 EdtPostProc *pCtrl)
01507
01508 {
01509 u_short *src = (u_short *) p_src;
01510 u_short *dest = (u_short *) p_dest;
01511
01512 return deIntlv_InOut16(src, width, rows, dest);
01513
01514 }
01515 pp_deintlv_line_inout8(void * p_src,
01516 int width,
01517 int rows,
01518 void * p_dest,
01519 EdtPostProc *pCtrl)
01520
01521 {
01522 u_char *src = (u_char *) p_src;
01523 u_char *dest = (u_char *) p_dest;
01524
01525 return deIntlv_InOut8(src, width, rows, dest);
01526
01527 }
01528
01529 int
01530 pp_deintlv_line_taps_8x4(void * p_src, int width, int rows,
01531 void * p_dest, EdtPostProc *pCtrl)
01532
01533
01534
01535 {
01536
01537 u_char *src = (u_char *) p_src;
01538 u_char *dest = (u_char *) p_dest;
01539
01540 return deintlv_line_taps_8x4(src, width, rows, dest,
01541 pCtrl->nTaps, pCtrl->taps);
01542
01543 }
01544
01545 int
01546 pp_deintlv_line_taps_8x4_inv_rt(void *p_src, int width, int rows, void *p_dest,
01547 EdtPostProc *pCtrl)
01548
01549 {
01550
01551 u_char *src = (u_char *) p_src;
01552 u_char *dest = (u_char *) p_dest;
01553
01554 return deIntlv_line_taps_8x4_inv_rt(src, width, rows, dest);
01555 }
01556
01557 int
01558 pp_convert_bayer_image_16_BGR(void * p_src, int width, int rows,
01559 void * p_dest, EdtPostProc *pCtrl)
01560
01561 {
01562
01563 u_short *src = (u_short *) p_src;
01564 u_char *dest = (u_char *) p_dest;
01565
01566 return convert_bayer_image_16_BGR(src, width, rows, width, dest,
01567 pCtrl->order, pCtrl->src_depth);
01568
01569 }
01570
01571 int
01572 pp_convert_bayer_image_8_BGR(void * p_src, int width, int rows,
01573 void * p_dest, EdtPostProc *pCtrl)
01574
01575 {
01576
01577 u_char *src = (u_char *) p_src;
01578 u_char *dest = (u_char *) p_dest;
01579
01580 return convert_bayer_image_8_BGR(src, width, rows, width, dest,
01581 pCtrl->order);
01582
01583 }
01584
01585 int
01586 pp_deIntlv_inv_rt_16_BGR(void * p_src, int width, int rows,
01587 void * p_dest, EdtPostProc *pCtrl)
01588
01589 {
01590
01591 u_short *src = (u_short *) p_src;
01592 u_char *dest = (u_char *) p_dest;
01593
01594 return deIntlv_inv_rt_16_BGR(src, width, rows, dest,
01595 pCtrl->order, pCtrl->src_depth);
01596
01597 }
01598
01599 int
01600 pp_deIntlv_inv_rt_8_BGR(void * p_src, int width, int rows,
01601 void * p_dest, EdtPostProc *pCtrl)
01602
01603 {
01604
01605 u_char *src = (u_char *) p_src;
01606 u_char *dest = (u_char *) p_dest;
01607
01608 return deIntlv_inv_rt_8_BGR(src, width, rows, dest,
01609 pCtrl->order);
01610
01611 }
01612
01613 int
01614 pp_deIntlv_quad_16(void *p_src,
01615 int width, int rows,
01616 void *p_dest,
01617 EdtPostProc *pCtrl)
01618
01619 {
01620
01621 u_short *src = (u_short *) p_src;
01622 u_short *dest = (u_short *) p_dest;
01623
01624 return deIntlv_quad_16(src, width, rows, dest);
01625
01626 }
01627
01628 int
01629 pp_deIntlv_quad_8(void *p_src,
01630 int width, int rows,
01631 void *p_dest,
01632 EdtPostProc *pCtrl)
01633
01634 {
01635
01636 u_char *src = (u_char *) p_src;
01637 u_char *dest = (u_char *) p_dest;
01638
01639 return deIntlv_quad_8(src, width, rows, dest);
01640
01641 }
01642
01643 int
01644 pp_deIntlv_quad2_16(void *p_src,
01645 int width, int rows,
01646 void *p_dest,
01647 EdtPostProc *pCtrl)
01648
01649 {
01650
01651 u_short *src = (u_short *) p_src;
01652 u_short *dest = (u_short *) p_dest;
01653
01654 return deIntlv_quad2_16(src, width, rows, dest);
01655
01656 }
01657
01658 int
01659 pp_deIntlv_quad2_8(void *p_src,
01660 int width, int rows,
01661 void *p_dest,
01662 EdtPostProc *pCtrl)
01663
01664 {
01665
01666 u_char *src = (u_char *) p_src;
01667 u_char *dest = (u_char *) p_dest;
01668
01669 return deIntlv_quad2_8(src, width, rows, dest);
01670
01671 }
01672
01673 int
01674 pp_deIntlv_quad3_16(void *p_src,
01675 int width, int rows,
01676 void *p_dest,
01677 EdtPostProc *pCtrl)
01678
01679 {
01680
01681 u_short *src = (u_short *) p_src;
01682 u_short *dest = (u_short *) p_dest;
01683
01684 return deIntlv_quad3_16(src, width, rows, dest);
01685
01686 }
01687
01688 int
01689 pp_deIntlv_quad3_8(void *p_src,
01690 int width, int rows,
01691 void *p_dest,
01692 EdtPostProc *pCtrl)
01693
01694 {
01695
01696 u_char *src = (u_char *) p_src;
01697 u_char *dest = (u_char *) p_dest;
01698
01699 return deIntlv_quad3_8(src, width, rows, dest);
01700
01701 }
01702 int
01703 pp_deIntlv_4ch_ill_16(void *p_src, int width, int rows, void * p_dest,
01704 EdtPostProc *pCtrl)
01705
01706 {
01707
01708 u_short *src = (u_short *) p_src;
01709 u_short *dest = (u_short *) p_dest;
01710
01711 return deIntlv_4ch_ill_16(src, width, rows, dest);
01712
01713 }
01714
01715
01716 int
01717 pp_deIntlv_4ch_ill_8(void *p_src, int width, int rows, void *p_dest,
01718 EdtPostProc *pCtrl)
01719
01720 {
01721
01722 u_char *src = (u_char *) p_src;
01723 u_char *dest = (u_char *) p_dest;
01724
01725 return deIntlv_4ch_ill_8(src, width, rows, dest);
01726
01727 }
01728
01729
01730 int
01731 pp_deIntlv_piranha_8(void *p_src, int width, int rows, void *p_dest,
01732 EdtPostProc *pCtrl)
01733
01734 {
01735
01736 u_char *src = (u_char *) p_src;
01737 u_char *dest = (u_char *) p_dest;
01738
01739 return deIntlv_piranha_8(src, width, rows, dest);
01740
01741 }
01742
01743 int
01744 pp_deIntlv_dalsa_4ch_8(void *p_src, int width, int rows, void *p_dest,
01745 EdtPostProc *pCtrl)
01746
01747 {
01748
01749 u_char *src = (u_char *) p_src;
01750 u_char *dest = (u_char *) p_dest;
01751
01752 return deIntlv_dalsa_4ch_8(src, width, rows, dest);
01753
01754 }
01755
01756 int
01757 pp_deIntlv_dalsa_ls_4ch_8(void *p_src, int width, int rows, void *p_dest,
01758 EdtPostProc *pCtrl)
01759
01760 {
01761
01762 u_char *src = (u_char *) p_src;
01763 u_char *dest = (u_char *) p_dest;
01764
01765 return deIntlv_dalsa_ls_4ch_8(src, width, rows, dest);
01766
01767 }
01768
01769
01770 int
01771 pp_deIntlv_inv_rt_16(void * p_src, int width, int rows, void * p_dest,
01772 EdtPostProc *pCtrl)
01773
01774 {
01775
01776 u_short *src = (u_short *) p_src;
01777 u_short *dest = (u_short *) p_dest;
01778
01779 return deIntlv_inv_rt_16(src, width, rows, dest);
01780
01781 }
01782
01783
01784 int
01785 pp_deIntlv_inv_rt_8(void * p_src, int width, int rows, void * p_dest,
01786 EdtPostProc *pCtrl)
01787
01788 {
01789
01790 u_char *src = (u_char *) p_src;
01791 u_char *dest = (u_char *) p_dest;
01792
01793 return deIntlv_inv_rt_8(src, width, rows, dest);
01794
01795 }
01796
01797
01798 int
01799 pp_deIntlv_2ch_even_rt_16(void * p_src, int width, int rows, void * p_dest,
01800 EdtPostProc *pCtrl)
01801
01802 {
01803
01804 u_short *src = (u_short *) p_src;
01805 u_short *dest = (u_short *) p_dest;
01806
01807 return deIntlv_2ch_even_rt_16(src, width, rows, dest);
01808
01809 }
01810
01811
01812 int
01813 pp_deIntlv_2ch_even_rt_8(void * p_src, int width, int rows, void * p_dest,
01814 EdtPostProc *pCtrl)
01815
01816 {
01817
01818 u_char *src = (u_char *) p_src;
01819 u_char *dest = (u_char *) p_dest;
01820
01821 return deIntlv_2ch_even_rt_8(src, width, rows, dest);
01822
01823 }
01824
01825
01826 int
01827 pp_deIntlv_2ch_inv_rt_24_12(void * p_src, int width, int rows,
01828 void * p_dest,
01829 EdtPostProc *pCtrl)
01830
01831 {
01832
01833 u_char *src = (u_char *) p_src;
01834 u_short *dest = (u_short *) p_dest;
01835
01836 return deIntlv_2ch_inv_rt_24_12(src, width, rows, dest);
01837
01838 }
01839
01840
01841 int
01842 pp_deIntlv_2ch_24_12(void * p_src, int width, int rows, void * p_dest,
01843 EdtPostProc *pCtrl)
01844
01845 {
01846
01847 u_char *src = (u_char *) p_src;
01848 u_short *dest = (u_short *) p_dest;
01849
01850 return deIntlv_2ch_24_12(src, width, rows, dest);
01851
01852 }
01853
01854
01855 int
01856 pp_deIntlv_1_8_msb7(void * p_src,
01857 int width,
01858 int rows,
01859 void * p_dest,
01860 EdtPostProc *pCtrl)
01861
01862 {
01863
01864 u_char *src = (u_char *) p_src;
01865 u_char *dest = (u_char *) p_dest;
01866
01867 return deIntlv_1_8_msb7(src, width, rows, dest);
01868
01869 }
01870
01871 int
01872 pp_deIntlv_1_8_msb0(void * p_src,
01873 int width,
01874 int rows,
01875 void * p_dest,
01876 EdtPostProc *pCtrl)
01877
01878 {
01879
01880 u_char *src = (u_char *) p_src;
01881 u_char *dest = (u_char *) p_dest;
01882
01883 return deIntlv_1_8_msb0(src, width, rows, dest);
01884
01885 }
01886
01887
01888 int
01889 pp_deIntlv_ES10_8(void * p_src,
01890 int width,
01891 int rows,
01892 void * p_dest,
01893 EdtPostProc *pCtrl)
01894
01895 {
01896 u_char *src = (u_char *) p_src;
01897 u_char *dest = (u_char *) p_dest;
01898
01899 return deIntlv_ES10_8(src, width, rows, dest);
01900
01901 }
01902
01903 int
01904 pp_ES10deIntlv_16(void * p_src,
01905 int width,
01906 int rows,
01907 void * p_dest,
01908 EdtPostProc *pCtrl)
01909
01910 {
01911 u_short *src = (u_short *) p_src;
01912 u_short *dest = (u_short *) p_dest;
01913
01914 return deIntlv_ES10_16(src, width, rows, dest);
01915
01916 }
01917
01918 int
01919 pp_ES10deIntlv_16_odd(void * p_src,
01920 int width,
01921 int rows,
01922 void * p_dest,
01923 EdtPostProc *pCtrl)
01924
01925 {
01926 u_short *src = (u_short *) p_src;
01927 u_short *dest = (u_short *) p_dest;
01928
01929 return deIntlv_ES10_16_odd(src, width, rows, dest);
01930
01931 }
01932
01933 int
01934 pp_ES10deIntlv_16_hilo(void * p_src,
01935 int width,
01936 int rows,
01937 void * p_dest,
01938 EdtPostProc *pCtrl)
01939
01940 {
01941 u_short *src = (u_short *) p_src;
01942 u_short *dest = (u_short *) p_dest;
01943
01944 return deIntlv_ES10_16_hilo(src, width, rows, dest);
01945
01946 }
01947
01948 int
01949 pp_deIntlv_ES10_8_BGGR(void * p_src,
01950 int width,
01951 int rows,
01952 void * p_dest,
01953 EdtPostProc *pCtrl)
01954
01955 {
01956 u_char *src = (u_char *) p_src;
01957 u_char *dest = (u_char *) p_dest;
01958
01959
01960
01961 deIntlv_ES10_8(src, width, rows, src);
01962
01963 return convert_bayer_image_8_BGR(src, width, rows, width, dest,
01964 pCtrl->order);
01965 }
01966
01967 int
01968 pp_deIntlv_specinst_4ch_16(void * p_src,
01969 int width,
01970 int rows,
01971 void * p_dest,
01972 EdtPostProc *pCtrl)
01973
01974 {
01975 u_short *src = (u_short *) p_src;
01976 u_short *dest = (u_short *) p_dest;
01977
01978 return deIntlv_specinst_4ch_16(src, width, rows, dest);
01979
01980 }
01981
01982 int
01983 pp_deIntlv_10bit_8tap_packed(void * p_src,
01984 int width,
01985 int rows,
01986 void * p_dest,
01987 EdtPostProc *pCtrl)
01988
01989 {
01990 u_char *src = (u_char *) p_src;
01991 u_short *dest = (u_short *) p_dest;
01992
01993 return deIntlv_10bit_8tap_packed(src, width, rows, dest);
01994
01995 }
01996
01997 int
01998 pp_deIntlv_10bit_8tap_to_8bit(void * p_src,
01999 int width,
02000 int rows,
02001 void * p_dest,
02002 EdtPostProc *pCtrl)
02003
02004 {
02005 u_char *src = (u_char *) p_src;
02006 u_char *dest = (u_char *) p_dest;
02007
02008 return deIntlv_10bit_8tap_to_8bit(src, width, rows, dest);
02009
02010 }
02011
02012
02013 int
02014 pp_merge_fields(void * p_src,
02015 int width,
02016 int rows,
02017 void * p_dest,
02018 EdtPostProc *pCtrl)
02019
02020 {
02021 u_char *src = (u_char *) p_src;
02022 u_char *dest = (u_char *) p_dest;
02023
02024 return deIntlv_merge_fields(src, src + pCtrl->interlace, width, rows, pCtrl->src_depth, dest,
02025 pCtrl->offset);
02026
02027 }
02028
02029
02030
02031
02032 int
02033 pp_bgr_2_rgb(void *p_src,
02034 int width,
02035 int rows,
02036 void * p_dest,
02037 EdtPostProc *pCtrl)
02038
02039 {
02040 u_char *src = (u_char *) p_src;
02041 u_char *dest = (u_char *) p_dest;
02042 int x, y;
02043 int w = width * 3;
02044
02045 for (y=0;y<rows;y++)
02046 {
02047 for (x = 0; x < w; x+=3)
02048 {
02049 u_char t = src[x];
02050 dest[x] = src[x+2];
02051 dest[x+2] = t;
02052 }
02053 src += w;
02054 dest += w;
02055 }
02056
02057 return 0;
02058 }
02059
02060 pp_deIntlv_20band_16(void * p_src,
02061 int width,
02062 int rows,
02063 void * p_dest,
02064 EdtPostProc *pCtrl)
02065 {
02066 u_short *src = (u_short *) p_src;
02067 u_short *dest = (u_short *) p_dest;
02068
02069 return deIntlv_XXband_16(src, width, rows, 20, dest);
02070 }
02071
02072 pp_deIntlv_21band_16(void * p_src,
02073 int width,
02074 int rows,
02075 void * p_dest,
02076 EdtPostProc *pCtrl)
02077 {
02078 u_short *src = (u_short *) p_src;
02079 u_short *dest = (u_short *) p_dest;
02080
02081 return deIntlv_XXband_16(src, width, rows, 21, dest);
02082 }
02083
02084
02085
02086 int
02087 pdv_deinterlace(PdvDev *pdv_p,
02088 PdvDependent *dd_p,
02089 u_char *dmabuf,
02090 u_char *output_buf)
02091
02092 {
02093
02094 EdtPostProc *pCtrl = NULL;
02095
02096
02097 int frame_height = dd_p->height;
02098
02099 if (pdv_p)
02100 pCtrl = (EdtPostProc *) pdv_p->pInterleaver;
02101
02102 if (pCtrl == NULL)
02103 {
02104 if (dd_p->swinterlace)
02105 pCtrl = pdv_setup_postproc(pdv_p, dd_p, NULL);
02106
02107 if (pCtrl == NULL)
02108 return 0;
02109 }
02110
02111 if (dd_p->frame_height != 0)
02112 {
02113 frame_height = dd_p->frame_height;
02114 }
02115
02116 if (pCtrl->process)
02117 {
02118 return pCtrl->process(dmabuf, dd_p->width, frame_height, output_buf, pCtrl);
02119 }
02120 else
02121 {
02122 return -1;
02123 }
02124
02125 }
02126
02127 int
02128 deIntlv_buffers(EdtPostProc *pCtrl, void *src_p, void *dest_p, int width, int height)
02129
02130 {
02131
02132 if (pCtrl->process)
02133 {
02134 return pCtrl->process(src_p, width, height, dest_p, pCtrl);
02135 }
02136 else
02137 {
02138 return -1;
02139 }
02140
02141 }
02142
02143
02144
02145
02146 static EdtPostProc built_in_postproc[] = {
02147 {PDV_BYTE_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02148 pp_deIntlv_ES10_8, 0},
02149 {PDV_ES10_BGGR, EDT_TYPE_BYTE, EDT_TYPE_BGR,
02150 pp_deIntlv_ES10_8_BGGR, 0},
02151 {PDV_WORD_INTLV, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02152 pp_ES10deIntlv_16, 0},
02153 {PDV_WORD_INTLV_ODD, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02154 pp_ES10deIntlv_16_odd, 0},
02155 {PDV_WORD_INTLV_HILO, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02156 pp_ES10deIntlv_16_hilo, 0},
02157 {PDV_FIELD_INTLC, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02158 pp_merge_fields, 0},
02159 {PDV_FIELD_INTLC, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02160 pp_merge_fields, 0},
02161 {PDV_FIELD_INTLC, EDT_TYPE_BGR, EDT_TYPE_BGR,
02162 pp_merge_fields, 0},
02163 {PDV_BGGR_WORD, EDT_TYPE_USHORT, EDT_TYPE_BGR,
02164 pp_convert_bayer_image_16_BGR, 0},
02165 {PDV_BGGR, EDT_TYPE_BYTE, EDT_TYPE_BGR,
02166 pp_convert_bayer_image_8_BGR, 0},
02167 {PDV_DALSA_4CH_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02168 pp_deIntlv_dalsa_4ch_8, 0},
02169 {PDV_DALSA_LS_4CH_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02170 pp_deIntlv_dalsa_ls_4ch_8, 0},
02171 {PDV_INVERT_RIGHT_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02172 pp_deIntlv_inv_rt_8, 0},
02173 {PDV_INVERT_RIGHT_INTLV, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02174 pp_deIntlv_inv_rt_16, 0},
02175 {PDV_INVERT_RIGHT_BGGR_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BGR,
02176 pp_deIntlv_inv_rt_8_BGR, 0},
02177 {PDV_INVERT_RIGHT_BGGR_INTLV, EDT_TYPE_USHORT, EDT_TYPE_BGR,
02178 pp_deIntlv_inv_rt_16_BGR, 0},
02179 {PDV_EVEN_RIGHT_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02180 pp_deIntlv_2ch_even_rt_8, 0},
02181 {PDV_EVEN_RIGHT_INTLV, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02182 pp_deIntlv_2ch_even_rt_16, 0},
02183 {PDV_PIRANHA_4CH_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02184 pp_deIntlv_piranha_8, 0},
02185 {PDV_PIRANHA_4CH_INTLV, EDT_TYPE_USHORT, EDT_TYPE_BYTE,
02186 pp_deIntlv_piranha_8, 0},
02187 {PDV_SPECINST_4PORT_INTLV, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02188 pp_deIntlv_specinst_4ch_16, 0},
02189 {PDV_QUADRANT_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02190 pp_deIntlv_quad_8, 0},
02191 {PDV_QUADRANT_INTLV, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02192 pp_deIntlv_quad_16, 0},
02193 {PDV_QUADRANT2_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02194 pp_deIntlv_quad2_8, 0},
02195 {PDV_QUADRANT3_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02196 pp_deIntlv_quad3_8, 0},
02197 {PDV_QUADRANT3_INTLV, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02198 pp_deIntlv_quad3_16, 0},
02199 {PDV_ILLUNIS_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02200 pp_deIntlv_4ch_ill_8, 0},
02201 {PDV_ILLUNIS_INTLV, EDT_TYPE_SHORT, EDT_TYPE_USHORT,
02202 pp_deIntlv_4ch_ill_16, 0},
02203 {PDV_INV_RT_INTLV_24_12, EDT_TYPE_BGR, EDT_TYPE_USHORT,
02204 pp_deIntlv_2ch_inv_rt_24_12, 0},
02205 {PDV_INTLV_24_12, EDT_TYPE_BGR, EDT_TYPE_USHORT,
02206 pp_deIntlv_2ch_24_12, 0},
02207 {PDV_INTLV_1_8_MSB7, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02208 pp_deIntlv_1_8_msb7, 0},
02209 {PDV_INTLV_1_8_MSB0, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02210 pp_deIntlv_1_8_msb0},
02211 {PDV_INTLV_BGR_2_RGB, EDT_TYPE_BGR, EDT_TYPE_BGR,
02212 pp_bgr_2_rgb},
02213 {PDV_LINE_INTLV, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02214 pp_deintlv_line_taps_8x4},
02215 {PDV_LINE_INTLV_P3_8X4, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02216 pp_deintlv_line_taps_8x4_inv_rt},
02217 {PDV_WORD_INTLV_HILO_LINE, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02218 pp_deintlv_hilo_line16},
02219 {PDV_WORD_INTLV_TOPMID_LINE, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02220 pp_deintlv_topmid_line16},
02221 {PDV_WORD_INTLV_MIDTOP_LINE, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02222 pp_deintlv_midtop_line16},
02223 {PDV_BYTE_INTLV_MIDTOP_LINE, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02224 pp_deintlv_midtop_line8},
02225 {PDV_WORD_INTLV_TOPBOTTOM, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02226 pp_deintlv_line_topbottom16},
02227 {PDV_BYTE_INTLV_TOPBOTTOM, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02228 pp_deintlv_line_topbottom8},
02229 {PDV_WORD_INTLV_INOUT, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02230 pp_deintlv_line_inout16},
02231 {PDV_BYTE_INTLV_INOUT, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02232 pp_deintlv_line_inout8},
02233 {PDV_INTLV_10BIT_8TAP_PACKED, EDT_TYPE_BYTE, EDT_TYPE_USHORT,
02234 pp_deIntlv_10bit_8tap_packed},
02235 {PDV_INTLV_10BIT_8TAP_TO_8BIT, EDT_TYPE_BYTE, EDT_TYPE_BYTE,
02236 pp_deIntlv_10bit_8tap_to_8bit},
02237 {PDV_INTLV_20BAND, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02238 pp_deIntlv_20band_16},
02239 {PDV_INTLV_21BAND, EDT_TYPE_USHORT, EDT_TYPE_USHORT,
02240 pp_deIntlv_21band_16},
02241 {0,0,0,0}
02242 };
02243
02244
02245
02246 int pdv_pixel_type_from_depth(int depth)
02247 {
02248 int type = EDT_TYPE_BYTE;
02249
02250 if (depth <= 8)
02251 type = EDT_TYPE_BYTE;
02252 else if (depth >8 && depth <= 16)
02253 type = EDT_TYPE_USHORT;
02254 else if (depth > 16 && depth <= 24)
02255 type = EDT_TYPE_BGR;
02256 else
02257 type = EDT_TYPE_BGRA;
02258
02259 return type;
02260 }
02261
02262
02263 EdtPostProc *
02264 pdv_lookup_postproc(int func_type, int src_depth, int depth)
02265
02266 {
02267 EdtPostProc *pCtrl;
02268
02269 int src_type = pdv_pixel_type_from_depth(src_depth);
02270 int dest_type = pdv_pixel_type_from_depth(depth);
02271
02272 pCtrl = &built_in_postproc[0];
02273
02274 while (pCtrl->func_type != 0 &&
02275 (pCtrl->func_type != func_type ||
02276 pCtrl->src_type != src_type ||
02277 pCtrl->dest_type != dest_type))
02278 {
02279 pCtrl ++;
02280 }
02281
02282 if (pCtrl->func_type == 0)
02283
02284 return NULL;
02285
02286 return pCtrl;
02287
02288 }
02289
02290
02291 int
02292 pdv_set_postproc(EdtPostProc *pCtrl,
02293 int depth,
02294 int extdepth,
02295 int frame_height,
02296 int interlace,
02297 int image_offset,
02298 int order,
02299 int n_intlv_taps,
02300 PdvInterleaveTap *taps
02301 )
02302
02303 {
02304
02305
02306 pCtrl->interlace = interlace;
02307 pCtrl->order = order;
02308
02309 pCtrl->frame_height = frame_height;
02310
02311 pCtrl->src_type = pdv_pixel_type_from_depth(extdepth);
02312 pCtrl->dest_type = pdv_pixel_type_from_depth(depth);
02313
02314 pCtrl->src_depth = extdepth;
02315 pCtrl->dest_depth = depth;
02316
02317 pCtrl->offset = image_offset;
02318
02319 pCtrl->nTaps = n_intlv_taps;
02320 if (n_intlv_taps)
02321 memcpy(pCtrl->taps, taps, n_intlv_taps * sizeof(PdvInterleaveTap));
02322
02323 return 0;
02324
02325
02326 }
02327
02328 int
02329 pdv_update_postproc(PdvDev *pdv_p, PdvDependent *dd_p, EdtPostProc *pCtrl)
02330
02331 {
02332
02333
02334 if (dd_p == NULL)
02335 {
02336 if (pdv_p)
02337 dd_p = pdv_p->dd_p;
02338 else
02339 return -1;
02340 }
02341
02342 pdv_set_postproc(pCtrl,
02343 dd_p->depth,
02344 dd_p->extdepth,
02345 dd_p->frame_height,
02346 dd_p->interlace,
02347 dd_p->image_offset,
02348 PDV_BAYER_ORDER(dd_p),
02349 dd_p->n_intlv_taps,
02350 dd_p->intlv_taps);
02351
02352
02353
02354 return 0;
02355
02356
02357 }
02358
02359
02360 EdtPostProc *
02361 pdv_setup_postproc(PdvDev *pdv_p, PdvDependent *dd_p, EdtPostProc *pInCtrl)
02362
02363 {
02364
02365 EdtPostProc *pCtrl = pInCtrl;
02366
02367
02368 if (dd_p == NULL)
02369 dd_p = pdv_p->dd_p;
02370
02371 if (dd_p->interlace_module[0])
02372 {
02373 if (!pInCtrl)
02374 {
02375 pCtrl = (EdtPostProc *) edt_alloc(sizeof(*pInCtrl));
02376
02377 memset(pCtrl,0,sizeof(*pCtrl));
02378
02379 if (pdv_load_postproc_module(pCtrl, dd_p->interlace_module,
02380 dd_p->extdepth, dd_p->depth) == 0)
02381 {
02382
02383
02384 if (pdv_p)
02385 pdv_p->pInterleaver = pCtrl;
02386
02387 pdv_update_postproc(pdv_p, dd_p, pCtrl);
02388
02389 if (pCtrl->defaultInit)
02390 pCtrl->defaultInit(pdv_p, pCtrl);
02391
02392 return pCtrl;
02393 }
02394
02395 }
02396
02397
02398 }
02399
02400 if (dd_p->swinterlace)
02401 {
02402
02403 if (pInCtrl == NULL)
02404 pInCtrl = pdv_lookup_postproc(dd_p->swinterlace,
02405 dd_p->extdepth, dd_p->depth);
02406
02407 }
02408
02409
02410
02411
02412 if (pInCtrl)
02413 {
02414
02415 pCtrl = (EdtPostProc *) edt_alloc(sizeof(*pCtrl));
02416
02417 memcpy(pCtrl, pInCtrl, sizeof(*pCtrl));
02418
02419 if (pdv_p)
02420 pdv_p->pInterleaver = pCtrl;
02421
02422 pdv_update_postproc(pdv_p, dd_p, pCtrl);
02423
02424 if (pCtrl->defaultInit)
02425 pCtrl->defaultInit(pdv_p, pCtrl);
02426
02427 }
02428
02429 return pCtrl;
02430 }
02431
02432 int
02433 pdv_unload_postproc_module(EdtPostProc *pCtrl)
02434
02435 {
02436 return 0;
02437 }
02438
02439 int
02440 pdv_load_postproc_module(EdtPostProc *pCtrl,
02441 char *name,
02442 int srcdepth,
02443 int destdepth)
02444
02445 {
02446
02447 #ifndef EDT_CAMLINK_EXPORTS
02448
02449 #ifdef WIN32
02450 char process_name[80];
02451 char filename[MAX_PATH];
02452
02453
02454 pCtrl->dll_handle = LoadLibrary(name);
02455
02456 if (!pCtrl->dll_handle)
02457 {
02458 sprintf(filename,"postproc/%s", name);
02459 pCtrl->dll_handle = LoadLibrary(filename);
02460 }
02461
02462 if (pCtrl->dll_handle)
02463 {
02464 strcpy(pCtrl->dll_name, name);
02465
02466 if (srcdepth > 8 && srcdepth < 16)
02467 srcdepth = 16;
02468
02469 if (destdepth > 8 && destdepth < 16)
02470 destdepth = 16;
02471
02472 sprintf(process_name, "post_process_%d_%d", srcdepth, destdepth);
02473
02474 pCtrl->process = (post_process_f) GetProcAddress(pCtrl->dll_handle,
02475 process_name);
02476
02477 pCtrl->doinplace = (int (*)()) GetProcAddress(pCtrl->dll_handle,
02478 "post_process_doinplace");
02479
02480 }
02481 else
02482 {
02483 return -1;
02484
02485 }
02486
02487 #elif defined(__linux__)
02488
02489 #include <dlfcn.h>
02490
02491 char process_name[80];
02492
02493 pCtrl->dll_handle = dlopen(name, RTLD_LAZY);
02494
02495 if (pCtrl->dll_handle)
02496 {
02497 strcpy(pCtrl->dll_name, name);
02498
02499 if (srcdepth > 8 && srcdepth < 16)
02500 srcdepth = 16;
02501
02502 if (destdepth > 8 && destdepth < 16)
02503 destdepth = 16;
02504
02505 sprintf(process_name, "post_process_%d_%d", srcdepth, destdepth);
02506
02507 pCtrl->process = (post_process_f) dlsym(pCtrl->dll_handle,
02508 process_name);
02509
02510 pCtrl->doinplace = (int (*)()) dlsym(pCtrl->dll_handle,
02511 "post_process_doinplace");
02512
02513 }
02514 else
02515 {
02516 return -1;
02517
02518 }
02519
02520
02521 #endif
02522
02523 #endif
02524
02525 return 0;
02526
02527 }
02528