⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tif_getimage.c

📁 支持各种栅格图像和矢量图像读取的库
💻 C
📖 第 1 页 / 共 5 页
字号:
			*cp++ = PACK(r, g, b);			pp += 3;		}		cp += toskew;		pp += fromskew;	}}/* * YCbCr -> RGB conversion and packing routines. */#define	YCbCrtoRGB(dst, Y) {						\	uint32 r, g, b;							\	TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b);		\	dst = PACK(r, g, b);						\}/* * 8-bit packed YCbCr samples => RGB  * This function is generic for different sampling sizes,  * and can handle blocks sizes that aren't multiples of the * sampling size.  However, it is substantially less optimized * than the specific sampling cases.  It is used as a fallback * for difficult blocks. */#ifdef notdefstatic void putcontig8bitYCbCrGenericTile(     TIFFRGBAImage* img,     uint32* cp,     uint32 x, uint32 y,     uint32 w, uint32 h,     int32 fromskew, int32 toskew,     unsigned char* pp,    int h_group,     int v_group ){    uint32* cp1 = cp+w+toskew;    uint32* cp2 = cp1+w+toskew;    uint32* cp3 = cp2+w+toskew;    int32 incr = 3*w+4*toskew;    int32   Cb, Cr;    int     group_size = v_group * h_group + 2;    (void) y;    fromskew = (fromskew * group_size) / h_group;    for( yy = 0; yy < h; yy++ )    {        unsigned char *pp_line;        int     y_line_group = yy / v_group;        int     y_remainder = yy - y_line_group * v_group;        pp_line = pp + v_line_group *                 for( xx = 0; xx < w; xx++ )        {            Cb = pp        }    }    for (; h >= 4; h -= 4) {	x = w>>2;	do {	    Cb = pp[16];	    Cr = pp[17];	    YCbCrtoRGB(cp [0], pp[ 0]);	    YCbCrtoRGB(cp [1], pp[ 1]);	    YCbCrtoRGB(cp [2], pp[ 2]);	    YCbCrtoRGB(cp [3], pp[ 3]);	    YCbCrtoRGB(cp1[0], pp[ 4]);	    YCbCrtoRGB(cp1[1], pp[ 5]);	    YCbCrtoRGB(cp1[2], pp[ 6]);	    YCbCrtoRGB(cp1[3], pp[ 7]);	    YCbCrtoRGB(cp2[0], pp[ 8]);	    YCbCrtoRGB(cp2[1], pp[ 9]);	    YCbCrtoRGB(cp2[2], pp[10]);	    YCbCrtoRGB(cp2[3], pp[11]);	    YCbCrtoRGB(cp3[0], pp[12]);	    YCbCrtoRGB(cp3[1], pp[13]);	    YCbCrtoRGB(cp3[2], pp[14]);	    YCbCrtoRGB(cp3[3], pp[15]);	    cp += 4, cp1 += 4, cp2 += 4, cp3 += 4;	    pp += 18;	} while (--x);	cp += incr, cp1 += incr, cp2 += incr, cp3 += incr;	pp += fromskew;    }}#endif/* * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr44tile){    uint32* cp1 = cp+w+toskew;    uint32* cp2 = cp1+w+toskew;    uint32* cp3 = cp2+w+toskew;    int32 incr = 3*w+4*toskew;    (void) y;    /* adjust fromskew */    fromskew = (fromskew * 18) / 4;    if ((h & 3) == 0 && (w & 3) == 0) {				                for (; h >= 4; h -= 4) {            x = w>>2;            do {                int32 Cb = pp[16];                int32 Cr = pp[17];                YCbCrtoRGB(cp [0], pp[ 0]);                YCbCrtoRGB(cp [1], pp[ 1]);                YCbCrtoRGB(cp [2], pp[ 2]);                YCbCrtoRGB(cp [3], pp[ 3]);                YCbCrtoRGB(cp1[0], pp[ 4]);                YCbCrtoRGB(cp1[1], pp[ 5]);                YCbCrtoRGB(cp1[2], pp[ 6]);                YCbCrtoRGB(cp1[3], pp[ 7]);                YCbCrtoRGB(cp2[0], pp[ 8]);                YCbCrtoRGB(cp2[1], pp[ 9]);                YCbCrtoRGB(cp2[2], pp[10]);                YCbCrtoRGB(cp2[3], pp[11]);                YCbCrtoRGB(cp3[0], pp[12]);                YCbCrtoRGB(cp3[1], pp[13]);                YCbCrtoRGB(cp3[2], pp[14]);                YCbCrtoRGB(cp3[3], pp[15]);                cp += 4, cp1 += 4, cp2 += 4, cp3 += 4;                pp += 18;            } while (--x);            cp += incr, cp1 += incr, cp2 += incr, cp3 += incr;            pp += fromskew;        }    } else {        while (h > 0) {            for (x = w; x > 0;) {                int32 Cb = pp[16];                int32 Cr = pp[17];                switch (x) {                default:                    switch (h) {                    default: YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */                    case 3:  YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */                    case 2:  YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                case 3:                    switch (h) {                    default: YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */                    case 3:  YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */                    case 2:  YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                case 2:                    switch (h) {                    default: YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */                    case 3:  YCbCrtoRGB(cp2[1], pp[ 9]); /* FALLTHROUGH */                    case 2:  YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                case 1:                    switch (h) {                    default: YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */                    case 3:  YCbCrtoRGB(cp2[0], pp[ 8]); /* FALLTHROUGH */                    case 2:  YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                }                if (x < 4) {                    cp += x; cp1 += x; cp2 += x; cp3 += x;                    x = 0;                }                else {                    cp += 4; cp1 += 4; cp2 += 4; cp3 += 4;                    x -= 4;                }                pp += 18;            }            if (h <= 4)                break;            h -= 4;            cp += incr, cp1 += incr, cp2 += incr, cp3 += incr;            pp += fromskew;        }    }}/* * 8-bit packed YCbCr samples w/ 4,2 subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr42tile){    uint32* cp1 = cp+w+toskew;    int32 incr = 2*toskew+w;    (void) y;    fromskew = (fromskew * 10) / 4;    if ((h & 3) == 0 && (w & 1) == 0) {        for (; h >= 2; h -= 2) {            x = w>>2;            do {                int32 Cb = pp[8];                int32 Cr = pp[9];                                YCbCrtoRGB(cp [0], pp[0]);                YCbCrtoRGB(cp [1], pp[1]);                YCbCrtoRGB(cp [2], pp[2]);                YCbCrtoRGB(cp [3], pp[3]);                YCbCrtoRGB(cp1[0], pp[4]);                YCbCrtoRGB(cp1[1], pp[5]);                YCbCrtoRGB(cp1[2], pp[6]);                YCbCrtoRGB(cp1[3], pp[7]);                                cp += 4, cp1 += 4;                pp += 10;            } while (--x);            cp += incr, cp1 += incr;            pp += fromskew;        }    } else {        while (h > 0) {            for (x = w; x > 0;) {                int32 Cb = pp[8];                int32 Cr = pp[9];                switch (x) {                default:                    switch (h) {                    default: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                case 3:                    switch (h) {                    default: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                case 2:                    switch (h) {                    default: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                case 1:                    switch (h) {                    default: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */                    case 1:  YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */                    }                                    /* FALLTHROUGH */                }                if (x < 4) {                    cp += x; cp1 += x;                    x = 0;                }                else {                    cp += 4; cp1 += 4;                    x -= 4;                }                pp += 10;            }            if (h <= 2)                break;            h -= 2;            cp += incr, cp1 += incr;            pp += fromskew;        }    }}/* * 8-bit packed YCbCr samples w/ 4,1 subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr41tile){    (void) y;    /* XXX adjust fromskew */    do {	x = w>>2;	do {	    int32 Cb = pp[4];	    int32 Cr = pp[5];	    YCbCrtoRGB(cp [0], pp[0]);	    YCbCrtoRGB(cp [1], pp[1]);	    YCbCrtoRGB(cp [2], pp[2]);	    YCbCrtoRGB(cp [3], pp[3]);	    cp += 4;	    pp += 6;	} while (--x);        if( (w&3) != 0 )        {	    int32 Cb = pp[4];	    int32 Cr = pp[5];            switch( (w&3) ) {              case 3: YCbCrtoRGB(cp [2], pp[2]);              case 2: YCbCrtoRGB(cp [1], pp[1]);              case 1: YCbCrtoRGB(cp [0], pp[0]);              case 0: break;            }            cp += (w&3);            pp += 6;        }	cp += toskew;	pp += fromskew;    } while (--h);}/* * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr22tile){	uint32* cp2;	(void) y;	fromskew = (fromskew / 2) * 6;	cp2 = cp+w+toskew;	while (h>=2) {		x = w;		while (x>=2) {			uint32 Cb = pp[4];			uint32 Cr = pp[5];			YCbCrtoRGB(cp[0], pp[0]);			YCbCrtoRGB(cp[1], pp[1]);			YCbCrtoRGB(cp2[0], pp[2]);			YCbCrtoRGB(cp2[1], pp[3]);			cp += 2;			cp2 += 2;			pp += 6;			x -= 2;		}		if (x==1) {			uint32 Cb = pp[4];			uint32 Cr = pp[5];			YCbCrtoRGB(cp[0], pp[0]);			YCbCrtoRGB(cp2[0], pp[2]);			cp ++ ;			cp2 ++ ;			pp += 6;		}		cp += toskew*2+w;		cp2 += toskew*2+w;		pp += fromskew;		h-=2;	}	if (h==1) {		x = w;		while (x>=2) {			uint32 Cb = pp[4];			uint32 Cr = pp[5];			YCbCrtoRGB(cp[0], pp[0]);			YCbCrtoRGB(cp[1], pp[1]);			cp += 2;			cp2 += 2;			pp += 6;			x -= 2;		}		if (x==1) {			uint32 Cb = pp[4];			uint32 Cr = pp[5];			YCbCrtoRGB(cp[0], pp[0]);		}	}}/* * 8-bit packed YCbCr samples w/ 2,1 subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr21tile){	(void) y;	fromskew = (fromskew * 4) / 2;	do {		x = w>>1;		do {			int32 Cb = pp[2];			int32 Cr = pp[3];			YCbCrtoRGB(cp[0], pp[0]);			YCbCrtoRGB(cp[1], pp[1]);			cp += 2;			pp += 4;		} while (--x);		if( (w&1) != 0 )		{			int32 Cb = pp[2];			int32 Cr = pp[3];			YCbCrtoRGB(cp[0], pp[0]);			cp += 1;			pp += 4;		}		cp += toskew;		pp += fromskew;	} while (--h);}/* * 8-bit packed YCbCr samples w/ 1,2 subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr12tile){	uint32* cp2;	(void) y;	fromskew = (fromskew / 2) * 4;	cp2 = cp+w+toskew;	while (h>=2) {		x = w;		do {			uint32 Cb = pp[2];			uint32 Cr = pp[3];			YCbCrtoRGB(cp[0], pp[0]);			YCbCrtoRGB(cp2[0], pp[1]);			cp ++;			cp2 ++;			pp += 4;		} while (--x);		cp += toskew*2+w;		cp2 += toskew*2+w;		pp += fromskew;		h-=2;	}	if (h==1) {		x = w;		do {			uint32 Cb = pp[2];			uint32 Cr = pp[3];			YCbCrtoRGB(cp[0], pp[0]);			cp ++;			pp += 4;		} while (--x);	}}/* * 8-bit packed YCbCr samples w/ no subsampling => RGB */DECLAREContigPutFunc(putcontig8bitYCbCr11tile){	(void) y;	fromskew *= 3;	do {		x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */		do {			int32 Cb = pp[1];			int32 Cr = pp[2];			YCbCrtoRGB(*cp++, pp[0]);			pp += 3;		} while (--x);		cp += toskew;		pp += fromskew;	} while (--h);}/* * 8-bit packed YCbCr samples w/ no subsampling => RGB */DECLARESepPutFunc(putseparate8bitYCbCr11tile){	(void) y;	(void) a;	/* TODO: naming of input vars is still off, change obfuscating declaration inside define, or resolve obfuscation */	while (h-- > 0) {		x = w;		do {			uint32 dr, dg, db;			TIFFYCbCrtoRGB(img->ycbcr,*r++,*g++,*b++,&dr,&dg,&db);			*cp++ = PACK(dr,dg,db);		} while (--x);		SKEW(r, g, b, fromskew);		cp += toskew;	}}#undef YCbCrtoRGBstatic intinitYCbCrConversion(TIFFRGBAImage* img){	static char module[] = "initYCbCrConversion";	float *luma, *refBlackWhite;	if (img->ycbcr == NULL) {		img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc(		    TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))		    + 4*256*sizeof (TIFFRGBValue)		    + 2*256*sizeof (int)		    + 3*256*sizeof (int32)		    );		if (img->ycbcr == NULL) {			TIFFErrorExt(img->tif->tif_clientdata, module,			    "No space for YCbCr->RGB conversion state");			return (0);		}	}	TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma);	TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE,	    &refBlackWhite);	if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0)		return(0);	return (1);}static tileContigRoutineinitCIELabConversion(TIFFRGBAImage* img){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -