亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tif_jpeg.c

?? 一款最完整的工業組態軟源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:

			/* Reload downsampled-data buffer if needed */
			if (sp->scancount >= DCTSIZE) {
				int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE;

				if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n)
					!= n)
					return (0);
				sp->scancount = 0;
			}
			/*
			 * Fastest way to unseparate data is to make one pass
			 * over the scanline for each row of each component.
			 */
			clumpoffset = 0;	/* first sample in clump */
			for (ci = 0, compptr = sp->cinfo.d.comp_info;
			     ci < sp->cinfo.d.num_components;
			     ci++, compptr++) {
			    int hsamp = compptr->h_samp_factor;
			    int vsamp = compptr->v_samp_factor;
			    int ypos;

			    for (ypos = 0; ypos < vsamp; ypos++) {
				JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos];
				JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset;
				JDIMENSION nclump;

				if (hsamp == 1) {
				    /* fast path for at least Cb and Cr */
				    for (nclump = clumps_per_line; nclump-- > 0; ) {
					outptr[0] = *inptr++;
					outptr += samples_per_clump;
				    }
				} else {
					int xpos;

				    /* general case */
				    for (nclump = clumps_per_line; nclump-- > 0; ) {
					for (xpos = 0; xpos < hsamp; xpos++)
					    outptr[xpos] = *inptr++;
					outptr += samples_per_clump;
				    }
				}
				clumpoffset += hsamp;
			    }
			}
			++sp->scancount;
			++tif->tif_row;
			buf += sp->bytesperline;
			cc -= sp->bytesperline;
		} while (--nrows > 0);
	}

        /* Close down the decompressor if done. */
        return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
	    || TIFFjpeg_finish_decompress(sp);
}


/*
 * JPEG Encoding.
 */

static void
unsuppress_quant_table (JPEGState* sp, int tblno)
{
	JQUANT_TBL* qtbl;

	if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL)
		qtbl->sent_table = FALSE;
}

static void
unsuppress_huff_table (JPEGState* sp, int tblno)
{
	JHUFF_TBL* htbl;

	if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL)
		htbl->sent_table = FALSE;
	if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL)
		htbl->sent_table = FALSE;
}

static int
prepare_JPEGTables(TIFF* tif)
{
	JPEGState* sp = JState(tif);

        JPEGInitializeLibJPEG( tif );

	/* Initialize quant tables for current quality setting */
	if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
		return (0);
	/* Mark only the tables we want for output */
	/* NB: chrominance tables are currently used only with YCbCr */
	if (!TIFFjpeg_suppress_tables(sp, TRUE))
		return (0);
	if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) {
		unsuppress_quant_table(sp, 0);
		if (sp->photometric == PHOTOMETRIC_YCBCR)
			unsuppress_quant_table(sp, 1);
	}
	if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) {
		unsuppress_huff_table(sp, 0);
		if (sp->photometric == PHOTOMETRIC_YCBCR)
			unsuppress_huff_table(sp, 1);
	}
	/* Direct libjpeg output into jpegtables */
	if (!TIFFjpeg_tables_dest(sp, tif))
		return (0);
	/* Emit tables-only datastream */
	if (!TIFFjpeg_write_tables(sp))
		return (0);

	return (1);
}

static int
JPEGSetupEncode(TIFF* tif)
{
	JPEGState* sp = JState(tif);
	TIFFDirectory *td = &tif->tif_dir;
	static const char module[] = "JPEGSetupEncode";

        JPEGInitializeLibJPEG( tif );

	assert(sp != NULL);
	assert(!sp->cinfo.comm.is_decompressor);

	/*
	 * Initialize all JPEG parameters to default values.
	 * Note that jpeg_set_defaults needs legal values for
	 * in_color_space and input_components.
	 */
	sp->cinfo.c.in_color_space = JCS_UNKNOWN;
	sp->cinfo.c.input_components = 1;
	if (!TIFFjpeg_set_defaults(sp))
		return (0);
	/* Set per-file parameters */
	sp->photometric = td->td_photometric;
	switch (sp->photometric) {
	case PHOTOMETRIC_YCBCR:
		sp->h_sampling = td->td_ycbcrsubsampling[0];
		sp->v_sampling = td->td_ycbcrsubsampling[1];
		/*
		 * A ReferenceBlackWhite field *must* be present since the
		 * default value is inappropriate for YCbCr.  Fill in the
		 * proper value if application didn't set it.
		 */
		if (!TIFFFieldSet(tif, FIELD_REFBLACKWHITE)) {
			float refbw[6];
			long top = 1L << td->td_bitspersample;
			refbw[0] = 0;
			refbw[1] = (float)(top-1L);
			refbw[2] = (float)(top>>1);
			refbw[3] = refbw[1];
			refbw[4] = refbw[2];
			refbw[5] = refbw[1];
			TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw);
		}
		break;
	case PHOTOMETRIC_PALETTE:		/* disallowed by Tech Note */
	case PHOTOMETRIC_MASK:
		TIFFError(module,
			  "PhotometricInterpretation %d not allowed for JPEG",
			  (int) sp->photometric);
		return (0);
	default:
		/* TIFF 6.0 forbids subsampling of all other color spaces */
		sp->h_sampling = 1;
		sp->v_sampling = 1;
		break;
	}
	
	/* Verify miscellaneous parameters */

	/*
	 * This would need work if libtiff ever supports different
	 * depths for different components, or if libjpeg ever supports
	 * run-time selection of depth.  Neither is imminent.
	 */
	if (td->td_bitspersample != BITS_IN_JSAMPLE) {
		TIFFError(module, "BitsPerSample %d not allowed for JPEG",
			  (int) td->td_bitspersample);
		return (0);
	}
	sp->cinfo.c.data_precision = td->td_bitspersample;
	if (isTiled(tif)) {
		if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) {
			TIFFError(module,
				  "JPEG tile height must be multiple of %d",
				  sp->v_sampling * DCTSIZE);
			return (0);
		}
		if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) {
			TIFFError(module,
				  "JPEG tile width must be multiple of %d",
				  sp->h_sampling * DCTSIZE);
			return (0);
		}
	} else {
		if (td->td_rowsperstrip < td->td_imagelength &&
		    (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) {
			TIFFError(module,
				  "RowsPerStrip must be multiple of %d for JPEG",
				  sp->v_sampling * DCTSIZE);
			return (0);
		}
	}

	/* Create a JPEGTables field if appropriate */
	if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) {
		if (!prepare_JPEGTables(tif))
			return (0);
		/* Mark the field present */
		/* Can't use TIFFSetField since BEENWRITING is already set! */
		TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
		tif->tif_flags |= TIFF_DIRTYDIRECT;
	} else {
		/* We do not support application-supplied JPEGTables, */
		/* so mark the field not present */
		TIFFClrFieldBit(tif, FIELD_JPEGTABLES);
	}

	/* Direct libjpeg output to libtiff's output buffer */
	TIFFjpeg_data_dest(sp, tif);

	return (1);
}

/*
 * Set encoding state at the start of a strip or tile.
 */
static int
JPEGPreEncode(TIFF* tif, tsample_t s)
{
	JPEGState *sp = JState(tif);
	TIFFDirectory *td = &tif->tif_dir;
	static const char module[] = "JPEGPreEncode";
	uint32 segment_width, segment_height;
	int downsampled_input;

	assert(sp != NULL);
	assert(!sp->cinfo.comm.is_decompressor);
	/*
	 * Set encoding parameters for this strip/tile.
	 */
	if (isTiled(tif)) {
		segment_width = td->td_tilewidth;
		segment_height = td->td_tilelength;
		sp->bytesperline = TIFFTileRowSize(tif);
	} else {
		segment_width = td->td_imagewidth;
		segment_height = td->td_imagelength - tif->tif_row;
		if (segment_height > td->td_rowsperstrip)
			segment_height = td->td_rowsperstrip;
		sp->bytesperline = TIFFScanlineSize(tif);
	}
	if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) {
		/* for PC 2, scale down the strip/tile size
		 * to match a downsampled component
		 */
		segment_width = TIFFhowmany(segment_width, sp->h_sampling);
		segment_height = TIFFhowmany(segment_height, sp->v_sampling);
	}
	if (segment_width > 65535 || segment_height > 65535) {
		TIFFError(module, "Strip/tile too large for JPEG");
		return (0);
	}
	sp->cinfo.c.image_width = segment_width;
	sp->cinfo.c.image_height = segment_height;
	downsampled_input = FALSE;
	if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
		sp->cinfo.c.input_components = td->td_samplesperpixel;
		if (sp->photometric == PHOTOMETRIC_YCBCR) {
			if (sp->jpegcolormode == JPEGCOLORMODE_RGB) {
				sp->cinfo.c.in_color_space = JCS_RGB;
			} else {
				sp->cinfo.c.in_color_space = JCS_YCbCr;
				if (sp->h_sampling != 1 || sp->v_sampling != 1)
					downsampled_input = TRUE;
			}
			if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr))
				return (0);
			/*
			 * Set Y sampling factors;
			 * we assume jpeg_set_colorspace() set the rest to 1
			 */
			sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling;
			sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling;
		} else {
			sp->cinfo.c.in_color_space = JCS_UNKNOWN;
			if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN))
				return (0);
			/* jpeg_set_colorspace set all sampling factors to 1 */
		}
	} else {
		sp->cinfo.c.input_components = 1;
		sp->cinfo.c.in_color_space = JCS_UNKNOWN;
		if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN))
			return (0);
		sp->cinfo.c.comp_info[0].component_id = s;
		/* jpeg_set_colorspace() set sampling factors to 1 */
		if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) {
			sp->cinfo.c.comp_info[0].quant_tbl_no = 1;
			sp->cinfo.c.comp_info[0].dc_tbl_no = 1;
			sp->cinfo.c.comp_info[0].ac_tbl_no = 1;
		}
	}
	/* ensure libjpeg won't write any extraneous markers */
	sp->cinfo.c.write_JFIF_header = FALSE;
	sp->cinfo.c.write_Adobe_marker = FALSE;
	/* set up table handling correctly */
	if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) {
		if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
			return (0);
		unsuppress_quant_table(sp, 0);
		unsuppress_quant_table(sp, 1);
	}
	if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF)
		sp->cinfo.c.optimize_coding = FALSE;
	else
		sp->cinfo.c.optimize_coding = TRUE;
	if (downsampled_input) {
		/* Need to use raw-data interface to libjpeg */
		sp->cinfo.c.raw_data_in = TRUE;
		tif->tif_encoderow = JPEGEncodeRaw;
		tif->tif_encodestrip = JPEGEncodeRaw;
		tif->tif_encodetile = JPEGEncodeRaw;
	} else {
		/* Use normal interface to libjpeg */
		sp->cinfo.c.raw_data_in = FALSE;
		tif->tif_encoderow = JPEGEncode;
		tif->tif_encodestrip = JPEGEncode;
		tif->tif_encodetile = JPEGEncode;
	}
	/* Start JPEG compressor */
	if (!TIFFjpeg_start_compress(sp, FALSE))
		return (0);
	/* Allocate downsampled-data buffers if needed */
	if (downsampled_input) {
		if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info,
					       sp->cinfo.c.num_components))
			return (0);
	}
	sp->scancount = 0;

	return (1);
}

/*
 * Encode a chunk of pixels.
 * "Standard" case: incoming data is not downsampled.
 */
static int
JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
{
	JPEGState *sp = JState(tif);
	tsize_t nrows;
	JSAMPROW bufptr[1];

	(void) s;
	assert(sp != NULL);
	/* data is expected to be supplied in multiples of a scanline */
	nrows = cc / sp->bytesperline;
	if (cc % sp->bytesperline)
		TIFFWarning(tif->tif_name, "fractional scanline discarded");

	while (nrows-- > 0) {
		bufptr[0] = (JSAMPROW) buf;
		if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1)
			return (0);
		if (nrows > 0)
			tif->tif_row++;
		buf += sp->bytesperline;
	}
	return (1);
}

/*
 * Encode a chunk of pixels.
 * Incoming data is expected to be downsampled per sampling factors.
 */
static int
JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
{
	JPEGState *sp = JState(tif);
	JSAMPLE* inptr;
	JSAMPLE* outptr;
	tsize_t nrows;
	JDIMENSION clumps_per_line, nclump;
	int clumpoffset, ci, xpos, ypos;
	jpeg_component_info* compptr;
	int samples_per_clump = sp->samplesperclump;

	(void) s;
	assert(sp != NULL);
	/* data is expected to be supplied in multiples of a scanline */
	nrows = cc / sp->bytesperline;
	if (cc % sp->bytesperline)
		TIFFWarning(tif->tif_name, "fractional scanline discarded");

	/* Cb,Cr both have sampling factors 1, so this is correct */
	clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width;

	while (nrows-- > 0) {
		/*
		 * Fastest way to separate the data is to make one pass
		 * over the scanline for each row of each component.
		 */
		clumpoffset = 0;		/* first sample in clump */
		for (ci = 0, compptr = sp->cinfo.c.comp_info;
		     ci < sp->cinfo.c.num_components;
		     ci++, compptr++) {
		    int hsamp = compptr->h_samp_factor;
		    int vsamp = compptr->v_samp_factor;
		    int padding = (int) (compptr->width_in_blocks * DCTSIZE -
					 clumps_per_line * hsamp);
		    for (ypos = 0; ypos < vsamp; ypos++) {
			inptr = ((JSAMPLE*) buf) + clumpoffset;
			outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos];
			if (hsamp == 1) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品伦理一区二区| 久久夜色精品一区| 欧美午夜精品理论片a级按摩| 久久99精品一区二区三区| 亚洲午夜一二三区视频| 丝袜亚洲另类欧美| 日本免费新一区视频| 精品一区二区三区在线播放 | 蜜臀精品一区二区三区在线观看| 亚洲一区二区三区精品在线| 亚洲国产精品欧美一二99| 亚洲午夜激情网站| 国内精品久久久久影院薰衣草| 国产成人免费在线视频| 欧洲另类一二三四区| 日韩精品一区二区三区视频在线观看| 欧美一区二区啪啪| 自拍偷拍国产亚洲| 日本最新不卡在线| a4yy欧美一区二区三区| 亚洲欧洲日韩一区二区三区| 日韩欧美一区二区视频| 欧美电影在线免费观看| 久久综合色一综合色88| 亚洲黄色性网站| 成人综合婷婷国产精品久久蜜臀| 91国偷自产一区二区使用方法| 日韩欧美国产麻豆| 亚洲精品五月天| eeuss鲁一区二区三区| 欧美成人精品二区三区99精品| 一区二区视频在线看| 成人污视频在线观看| 久久伊人中文字幕| 午夜精品国产更新| 成人黄页毛片网站| 久久精品一区二区| 韩国精品在线观看| 日韩欧美亚洲国产另类| 久久精品免费看| 日韩一卡二卡三卡国产欧美| 日韩国产欧美三级| 欧美日韩国产天堂| 日本不卡123| 欧美老肥妇做.爰bbww| 日日夜夜免费精品| 日韩一区二区视频在线观看| 久久精品国产亚洲aⅴ| 精品福利在线导航| 丁香激情综合五月| 亚洲精品写真福利| 日韩欧美国产三级电影视频| 国产综合色精品一区二区三区| 久久久午夜精品| 色综合久久88色综合天天免费| 亚洲激情av在线| 56国语精品自产拍在线观看| 日本强好片久久久久久aaa| 精品少妇一区二区三区在线播放 | 在线成人高清不卡| 国产综合一区二区| 欧美极品少妇xxxxⅹ高跟鞋 | 国产精品一区二区久久不卡| 中国色在线观看另类| 欧美视频在线不卡| 国产a区久久久| 午夜精品福利久久久| 国产欧美一区二区精品久导航| 在线免费观看视频一区| 国产一区二区三区四区五区美女 | 色综合天天视频在线观看| 日本不卡在线视频| 亚洲图片自拍偷拍| 亚洲欧美中日韩| 国产欧美日本一区二区三区| 日韩欧美中文一区二区| 欧美日韩视频在线一区二区| 成人午夜电影网站| 狠狠色狠狠色综合| 亚洲小说欧美激情另类| 最新日韩在线视频| 亚洲婷婷在线视频| 成人欧美一区二区三区小说| 日本一区二区三区视频视频| 国产色产综合色产在线视频| 欧美一区二区三区四区高清| 99re这里都是精品| 99久久婷婷国产精品综合| 99久久久国产精品| eeuss鲁片一区二区三区在线看| 成人免费黄色大片| 成人美女视频在线观看| 不卡一区在线观看| 91女神在线视频| 欧美日韩精品专区| 日韩精品中午字幕| 国产日韩视频一区二区三区| 亚洲欧洲韩国日本视频| 中文字幕日韩精品一区| 亚洲一区二区三区三| 蜜臀国产一区二区三区在线播放 | 欧美日韩情趣电影| 日韩三级伦理片妻子的秘密按摩| 精品1区2区在线观看| 国产精品久久午夜| 亚洲免费观看高清完整| 久久精品免费在线观看| 日韩免费看的电影| 久久久91精品国产一区二区精品| 中文字幕的久久| 亚欧色一区w666天堂| 成人三级伦理片| 91精品国产欧美一区二区| 国产精品久久国产精麻豆99网站| 一区二区日韩av| 国产69精品久久99不卡| 日韩网站在线看片你懂的| 自拍偷拍亚洲欧美日韩| 国产呦精品一区二区三区网站| 色琪琪一区二区三区亚洲区| 精品欧美一区二区久久 | 成人高清免费观看| 亚洲精品一区二区三区精华液 | 日韩一区二区视频| 亚洲国产视频一区二区| 9久草视频在线视频精品| 久久午夜色播影院免费高清| 一级女性全黄久久生活片免费| 国产一区免费电影| 欧美v国产在线一区二区三区| 亚洲资源在线观看| 成人听书哪个软件好| 欧美不卡在线视频| 日本va欧美va欧美va精品| 欧美日韩久久久一区| 亚洲国产美国国产综合一区二区| 一本色道久久综合狠狠躁的推荐| 国产女主播在线一区二区| 国产精品91xxx| 欧美国产禁国产网站cc| 成人精品免费看| 亚洲日本在线天堂| 欧美日韩视频在线第一区 | 日韩一区二区中文字幕| 麻豆91免费看| 亚洲国产成人自拍| 欧美中文字幕一二三区视频| 午夜久久久久久久久| 久久久久久黄色| 色视频欧美一区二区三区| 人妖欧美一区二区| 欧美一区国产二区| 日本v片在线高清不卡在线观看| 国产亚洲精品超碰| 五月激情丁香一区二区三区| 精品免费国产二区三区| 94-欧美-setu| 精品在线观看免费| 亚洲夂夂婷婷色拍ww47| 制服丝袜一区二区三区| 国产一区二区三区免费看 | 一区二区三区四区在线免费观看| 在线精品国精品国产尤物884a| 亚洲素人一区二区| 在线观看区一区二| 成人av小说网| 欧美国产日韩一二三区| 91香蕉视频mp4| 国产一区二区在线影院| 亚洲欧美aⅴ...| 国产精品美女久久久久久2018| 6080国产精品一区二区| av电影在线观看不卡| 精品一区二区在线视频| 亚洲综合色丁香婷婷六月图片| 精品久久久久久久久久久久久久久久久 | 中文字幕日韩一区二区| 欧美久久免费观看| 成人午夜电影网站| 国产成人在线看| 韩国成人精品a∨在线观看| 蜜桃久久精品一区二区| 欧美在线免费视屏| 国产精品中文字幕日韩精品| 久久福利视频一区二区| 久久国产人妖系列| 丁香婷婷综合网| 不卡一二三区首页| 日本韩国欧美三级| 欧美日韩成人综合在线一区二区| 欧美日韩精品电影| 精品盗摄一区二区三区| 欧美激情艳妇裸体舞| 中文字幕第一区第二区| 亚洲国产美国国产综合一区二区| 首页国产欧美久久| 成人网男人的天堂| 欧美日韩精品一区二区| 久久久国产午夜精品| 一区二区久久久|