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

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

?? tif_jpeg.c

?? 一款最完整的工業組態軟源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
	if (newbuf == NULL)
		ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100);
	sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length;
	sp->dest.free_in_buffer = (size_t) 1000;
	sp->jpegtables = newbuf;
	sp->jpegtables_length += 1000;
	return (TRUE);
}

static void
tables_term_destination(j_compress_ptr cinfo)
{
	JPEGState* sp = (JPEGState*) cinfo;

	/* set tables length to number of bytes actually emitted */
	sp->jpegtables_length -= sp->dest.free_in_buffer;
}

static int
TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif)
{
	(void) tif;
	/*
	 * Allocate a working buffer for building tables.
	 * Initial size is 1000 bytes, which is usually adequate.
	 */
	if (sp->jpegtables)
		_TIFFfree(sp->jpegtables);
	sp->jpegtables_length = 1000;
	sp->jpegtables = (void*) _TIFFmalloc((tsize_t) sp->jpegtables_length);
	if (sp->jpegtables == NULL) {
		sp->jpegtables_length = 0;
		TIFFError("TIFFjpeg_tables_dest", "No space for JPEGTables");
		return (0);
	}
	sp->cinfo.c.dest = &sp->dest;
	sp->dest.init_destination = tables_init_destination;
	sp->dest.empty_output_buffer = tables_empty_output_buffer;
	sp->dest.term_destination = tables_term_destination;
	return (1);
}

/*
 * JPEG library source data manager.
 * These routines supply compressed data to libjpeg.
 */

static void
std_init_source(j_decompress_ptr cinfo)
{
	JPEGState* sp = (JPEGState*) cinfo;
	TIFF* tif = sp->tif;

	sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata;
	sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc;
}

static boolean
std_fill_input_buffer(j_decompress_ptr cinfo)
{
	JPEGState* sp = (JPEGState* ) cinfo;
	static const JOCTET dummy_EOI[2] = { 0xFF, JPEG_EOI };

	/*
	 * Should never get here since entire strip/tile is
	 * read into memory before the decompressor is called,
	 * and thus was supplied by init_source.
	 */
	WARNMS(cinfo, JWRN_JPEG_EOF);
	/* insert a fake EOI marker */
	sp->src.next_input_byte = dummy_EOI;
	sp->src.bytes_in_buffer = 2;
	return (TRUE);
}

static void
std_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{
	JPEGState* sp = (JPEGState*) cinfo;

	if (num_bytes > 0) {
		if (num_bytes > (long) sp->src.bytes_in_buffer) {
			/* oops, buffer overrun */
			(void) std_fill_input_buffer(cinfo);
		} else {
			sp->src.next_input_byte += (size_t) num_bytes;
			sp->src.bytes_in_buffer -= (size_t) num_bytes;
		}
	}
}

static void
std_term_source(j_decompress_ptr cinfo)
{
	/* No work necessary here */
	/* Or must we update tif->tif_rawcp, tif->tif_rawcc ??? */
	/* (if so, need empty tables_term_source!) */
	(void) cinfo;
}

static void
TIFFjpeg_data_src(JPEGState* sp, TIFF* tif)
{
	(void) tif;
	sp->cinfo.d.src = &sp->src;
	sp->src.init_source = std_init_source;
	sp->src.fill_input_buffer = std_fill_input_buffer;
	sp->src.skip_input_data = std_skip_input_data;
	sp->src.resync_to_restart = jpeg_resync_to_restart;
	sp->src.term_source = std_term_source;
	sp->src.bytes_in_buffer = 0;		/* for safety */
	sp->src.next_input_byte = NULL;
}

/*
 * Alternate source manager for reading from JPEGTables.
 * We can share all the code except for the init routine.
 */

static void
tables_init_source(j_decompress_ptr cinfo)
{
	JPEGState* sp = (JPEGState*) cinfo;

	sp->src.next_input_byte = (const JOCTET*) sp->jpegtables;
	sp->src.bytes_in_buffer = (size_t) sp->jpegtables_length;
}

static void
TIFFjpeg_tables_src(JPEGState* sp, TIFF* tif)
{
	TIFFjpeg_data_src(sp, tif);
	sp->src.init_source = tables_init_source;
}

/*
 * Allocate downsampled-data buffers needed for downsampled I/O.
 * We use values computed in jpeg_start_compress or jpeg_start_decompress.
 * We use libjpeg's allocator so that buffers will be released automatically
 * when done with strip/tile.
 * This is also a handy place to compute samplesperclump, bytesperline.
 */
static int
alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info,
			  int num_components)
{
	JPEGState* sp = JState(tif);
	int ci;
	jpeg_component_info* compptr;
	JSAMPARRAY buf;
	int samples_per_clump = 0;

	for (ci = 0, compptr = comp_info; ci < num_components;
	     ci++, compptr++) {
		samples_per_clump += compptr->h_samp_factor *
			compptr->v_samp_factor;
		buf = TIFFjpeg_alloc_sarray(sp, JPOOL_IMAGE,
				compptr->width_in_blocks * DCTSIZE,
				(JDIMENSION) (compptr->v_samp_factor*DCTSIZE));
		if (buf == NULL)
			return (0);
		sp->ds_buffer[ci] = buf;
	}
	sp->samplesperclump = samples_per_clump;
	return (1);
}


/*
 * JPEG Decoding.
 */

static int
JPEGSetupDecode(TIFF* tif)
{
	JPEGState* sp = JState(tif);
	TIFFDirectory *td = &tif->tif_dir;

        JPEGInitializeLibJPEG( tif );

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

	/* Read JPEGTables if it is present */
	if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) {
		TIFFjpeg_tables_src(sp, tif);
		if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) {
			TIFFError("JPEGSetupDecode", "Bogus JPEGTables field");
			return (0);
		}
	}

	/* Grab parameters that are same for all strips/tiles */
	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];
		break;
	default:
		/* TIFF 6.0 forbids subsampling of all other color spaces */
		sp->h_sampling = 1;
		sp->v_sampling = 1;
		break;
	}

	/* Set up for reading normal data */
	TIFFjpeg_data_src(sp, tif);
	tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */
	return (1);
}

/*
 * Set up for decoding a strip or tile.
 */
static int
JPEGPreDecode(TIFF* tif, tsample_t s)
{
	JPEGState *sp = JState(tif);
	TIFFDirectory *td = &tif->tif_dir;
	static const char module[] = "JPEGPreDecode";
	uint32 segment_width, segment_height;
	int downsampled_output;
	int ci;

	assert(sp != NULL);
	assert(sp->cinfo.comm.is_decompressor);
	/*
	 * Reset decoder state from any previous strip/tile,
	 * in case application didn't read the whole strip.
	 */
	if (!TIFFjpeg_abort(sp))
		return (0);
	/*
	 * Read the header for this strip/tile.
	 */
	if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK)
		return (0);
	/*
	 * Check image parameters and set decompression parameters.
	 */
	segment_width = td->td_imagewidth;
	segment_height = td->td_imagelength - tif->tif_row;
	if (isTiled(tif)) {
                segment_width = td->td_tilewidth;
                segment_height = td->td_tilelength;
		sp->bytesperline = TIFFTileRowSize(tif);
	} else {
		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 expected 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 (sp->cinfo.d.image_width != segment_width ||
	    sp->cinfo.d.image_height != segment_height) {
		TIFFWarning(module, 
                 "Improper JPEG strip/tile size, expected %dx%d, got %dx%d",
                          segment_width, 
                          segment_height,
                          sp->cinfo.d.image_width, 
                          sp->cinfo.d.image_height);
	}
	if (sp->cinfo.d.num_components !=
	    (td->td_planarconfig == PLANARCONFIG_CONTIG ?
	     td->td_samplesperpixel : 1)) {
		TIFFError(module, "Improper JPEG component count");
		return (0);
	}
	if (sp->cinfo.d.data_precision != td->td_bitspersample) {
		TIFFError(module, "Improper JPEG data precision");
		return (0);
	}
	if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
		/* Component 0 should have expected sampling factors */
		if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
		    sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) {
			    TIFFWarning(module, 
                                    "Improper JPEG sampling factors %d,%d\n"
                                    "Apparently should be %d,%d.",
                                    sp->cinfo.d.comp_info[0].h_samp_factor,
                                    sp->cinfo.d.comp_info[0].v_samp_factor,
                                    sp->h_sampling, sp->v_sampling);

			    /*
			     * XXX: Files written by the Intergraph software
			     * has different sampling factors stored in the
			     * TIFF tags and in the JPEG structures. We will
			     * try to deduce Intergraph files by the presense
			     * of the tag 33918.
			     */
			    if (!_TIFFFindFieldInfo(tif, 33918, TIFF_ANY)) {
				    TIFFWarning(module, 
					"Decompressor will try reading with "
					"sampling %d,%d.",
					sp->cinfo.d.comp_info[0].h_samp_factor,
					sp->cinfo.d.comp_info[0].v_samp_factor);

				    sp->h_sampling = (uint16)
					sp->cinfo.d.comp_info[0].h_samp_factor;
				    sp->v_sampling = (uint16)
					sp->cinfo.d.comp_info[0].v_samp_factor;
			    }
		}
		/* Rest should have sampling factors 1,1 */
		for (ci = 1; ci < sp->cinfo.d.num_components; ci++) {
			if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 ||
			    sp->cinfo.d.comp_info[ci].v_samp_factor != 1) {
				TIFFError(module, "Improper JPEG sampling factors");
				return (0);
			}
		}
	} else {
		/* PC 2's single component should have sampling factors 1,1 */
		if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 ||
		    sp->cinfo.d.comp_info[0].v_samp_factor != 1) {
			TIFFError(module, "Improper JPEG sampling factors");
			return (0);
		}
	}
	downsampled_output = FALSE;
	if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
	    sp->photometric == PHOTOMETRIC_YCBCR &&
	    sp->jpegcolormode == JPEGCOLORMODE_RGB) {
	/* Convert YCbCr to RGB */
		sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
		sp->cinfo.d.out_color_space = JCS_RGB;
	} else {
			/* Suppress colorspace handling */
		sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
		sp->cinfo.d.out_color_space = JCS_UNKNOWN;
		if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
		    (sp->h_sampling != 1 || sp->v_sampling != 1))
			downsampled_output = TRUE;
		/* XXX what about up-sampling? */
	}
	if (downsampled_output) {
		/* Need to use raw-data interface to libjpeg */
		sp->cinfo.d.raw_data_out = TRUE;
		tif->tif_decoderow = JPEGDecodeRaw;
		tif->tif_decodestrip = JPEGDecodeRaw;
		tif->tif_decodetile = JPEGDecodeRaw;
	} else {
		/* Use normal interface to libjpeg */
		sp->cinfo.d.raw_data_out = FALSE;
		tif->tif_decoderow = JPEGDecode;
		tif->tif_decodestrip = JPEGDecode;
		tif->tif_decodetile = JPEGDecode;
	}
	/* Start JPEG decompressor */
	if (!TIFFjpeg_start_decompress(sp))
		return (0);
	/* Allocate downsampled-data buffers if needed */
	if (downsampled_output) {
		if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info,
					       sp->cinfo.d.num_components))
			return (0);
		sp->scancount = DCTSIZE;	/* mark buffer empty */
	}
	return (1);
}

/*
 * Decode a chunk of pixels.
 * "Standard" case: returned data is not downsampled.
 */
/*ARGSUSED*/ static int
JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
{
    JPEGState *sp = JState(tif);
    tsize_t nrows;

    nrows = cc / sp->bytesperline;
    if (cc % sp->bytesperline)
        TIFFWarning(tif->tif_name, "fractional scanline not read");

    if( nrows > (int) sp->cinfo.d.image_height )
        nrows = sp->cinfo.d.image_height;

    /* data is expected to be read in multiples of a scanline */
    if (nrows)
    {
        do {
            JSAMPROW bufptr = (JSAMPROW)buf;

            if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1)
                return (0);
            ++tif->tif_row;
            buf += sp->bytesperline;
            cc -= sp->bytesperline;
        } while (--nrows > 0);
    }
    /* Close down the decompressor if we've finished the strip or tile. */
    return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
        || TIFFjpeg_finish_decompress(sp);
}

/*
 * Decode a chunk of pixels.
 * Returned data is downsampled per sampling factors.
 */
/*ARGSUSED*/ static int
JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
{
	JPEGState *sp = JState(tif);
	tsize_t nrows;

	/* data is expected to be read in multiples of a scanline */
	if ( (nrows = sp->cinfo.d.image_height) ) {
		/* Cb,Cr both have sampling factors 1, so this is correct */
		JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;
		int samples_per_clump = sp->samplesperclump;
	
		do {
			jpeg_component_info *compptr;
			int ci, clumpoffset;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲人亚洲人成电影网站色| jlzzjlzz亚洲日本少妇| 日本丶国产丶欧美色综合| 亚洲国产高清在线观看视频| 蜜臀av性久久久久av蜜臀妖精| 在线日韩国产精品| 综合久久给合久久狠狠狠97色 | 亚洲午夜久久久久中文字幕久| 成人精品在线视频观看| 久久久久久**毛片大全| 国产宾馆实践打屁股91| 国产欧美日韩激情| 99精品欧美一区二区三区综合在线| 国产精品国产精品国产专区不蜜 | 56国语精品自产拍在线观看| 一区二区欧美在线观看| 一本大道综合伊人精品热热 | 日韩色视频在线观看| 国产一区二区0| 中文字幕永久在线不卡| 色综合 综合色| 性感美女久久精品| 日韩一级完整毛片| 成人免费看片app下载| 亚洲啪啪综合av一区二区三区| 91网站视频在线观看| 亚洲第一二三四区| 久久久久久毛片| 欧美色区777第一页| 国产99久久久久| 亚洲午夜精品在线| 欧美成人猛片aaaaaaa| 欧美亚洲综合色| 久久精品999| 亚洲福利一二三区| 亚洲国产精品成人久久综合一区| 欧美美女黄视频| 在线精品视频一区二区三四 | 日韩精品电影在线| 国产精品三级av| 欧美精品一区二区高清在线观看| 成人视屏免费看| 国产在线不卡一区| 亚洲一区二区三区自拍| 亚洲黄色免费电影| 国产欧美日韩不卡免费| 精品国产伦一区二区三区免费| 在线亚洲免费视频| 99久久婷婷国产| 北条麻妃国产九九精品视频| 国产一区二区按摩在线观看| 久久精品72免费观看| 蜜桃视频一区二区| 日本vs亚洲vs韩国一区三区 | 毛片av一区二区| 久久成人精品无人区| 蜜臀av一区二区在线免费观看| 午夜免费久久看| 蜜桃视频在线观看一区二区| 久久福利资源站| 国产高清一区日本| gogogo免费视频观看亚洲一| 99九九99九九九视频精品| 91在线视频免费观看| 欧美日韩国产精品成人| 久久亚洲欧美国产精品乐播| 亚洲视频在线观看三级| 亚洲成av人片| 狠狠狠色丁香婷婷综合久久五月| 成人av电影免费在线播放| 99久久精品国产一区二区三区| 欧美日韩大陆一区二区| 日韩三级在线观看| 亚洲免费在线电影| 日本不卡一区二区三区高清视频| 国产麻豆精品视频| 色女孩综合影院| 2017欧美狠狠色| 夜夜爽夜夜爽精品视频| 极品少妇xxxx精品少妇偷拍| 欧美日韩精品欧美日韩精品一| 国产精品视频一二| 久久99久久99| 欧美一区二区二区| 亚洲欧美国产77777| 国产suv精品一区二区883| 91精品国产综合久久精品app | 91色.com| 一区二区三区鲁丝不卡| 成人一区二区三区在线观看 | 亚洲精品一区二区在线观看| 亚洲人精品午夜| caoporm超碰国产精品| 精品国产一区二区三区忘忧草| 天天色天天爱天天射综合| 欧美手机在线视频| 亚洲黄色在线视频| 91福利社在线观看| 亚洲午夜精品网| 91成人免费网站| 亚洲国产美国国产综合一区二区| 91麻豆国产精品久久| 天天影视色香欲综合网老头| 欧美日韩国产欧美日美国产精品| 成人免费在线视频观看| 成人v精品蜜桃久久一区| 国产精品精品国产色婷婷| 在线中文字幕一区| 韩日欧美一区二区三区| 国产日韩欧美电影| 91麻豆精品在线观看| 午夜亚洲福利老司机| 久久久久99精品国产片| 成人网在线免费视频| 最近中文字幕一区二区三区| 在线日韩一区二区| 国产在线麻豆精品观看| 一区二区免费在线| 久久影音资源网| 337p亚洲精品色噜噜狠狠| 国产精品影视在线| 亚洲精品免费在线| 欧美精品乱码久久久久久按摩| 秋霞电影一区二区| 国产精品青草久久| 欧美精品一区二区久久久| 色婷婷精品大视频在线蜜桃视频| 亚洲成人一区二区| 国产精品人妖ts系列视频| 3d动漫精品啪啪| 成人丝袜视频网| 国产精品白丝jk白祙喷水网站| 亚洲色欲色欲www| 国产亚洲欧美一级| 国产亚洲人成网站| 久久精品亚洲精品国产欧美kt∨| 欧美卡1卡2卡| 91麻豆精品在线观看| 国产99久久久精品| 裸体健美xxxx欧美裸体表演| 亚洲第一激情av| 亚洲一区二区不卡免费| 亚洲欧美日韩国产综合在线| 成人免费视频在线观看| 国产精品毛片a∨一区二区三区| 欧美一区二区网站| 欧美亚洲日本国产| 欧美日韩成人综合在线一区二区| 91麻豆福利精品推荐| 欧美日韩激情一区二区| 在线不卡一区二区| 欧美mv日韩mv国产网站| 久久久久久综合| 中国av一区二区三区| 亚洲欧美激情视频在线观看一区二区三区| 国产欧美日韩精品a在线观看| 亚洲国产激情av| 亚洲免费观看高清完整版在线观看 | 亚洲二区在线观看| 老司机精品视频线观看86| 国产高清不卡一区| 成人av电影在线网| 欧美日韩激情一区| 69av一区二区三区| 国产欧美1区2区3区| 一区二区三区色| 精品午夜久久福利影院| 欧美综合亚洲图片综合区| 制服.丝袜.亚洲.中文.综合| 日本一区二区三区四区 | 亚洲精品中文在线影院| 日韩影院免费视频| 成人精品电影在线观看| 欧美一区二区三区白人| 亚洲欧洲成人自拍| 久久99精品国产麻豆婷婷| 欧美性猛片xxxx免费看久爱| bt7086福利一区国产| 精品久久久久久久久久久久久久久 | 精品久久久久久亚洲综合网| 一区二区三区不卡在线观看| 国模套图日韩精品一区二区| 8x8x8国产精品| 亚洲一区二区三区四区五区中文| 成人性生交大片免费看在线播放| 制服丝袜成人动漫| 亚洲精品国产a| av电影在线观看完整版一区二区| 精品成a人在线观看| 日本午夜精品视频在线观看 | 久久亚洲春色中文字幕久久久| 午夜视频在线观看一区二区| 在线中文字幕不卡| 一区二区三国产精华液| 91年精品国产| 一区二区三区欧美视频| 国内精品国产成人国产三级粉色 | 99久久99久久综合| √…a在线天堂一区| 色哟哟国产精品免费观看|