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

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

?? tif_jpeg.c

?? 一款最完整的工業組態軟源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
			    /* fast path for at least Cb and Cr */
			    for (nclump = clumps_per_line; nclump-- > 0; ) {
				*outptr++ = inptr[0];
				inptr += samples_per_clump;
			    }
			} else {
			    /* general case */
			    for (nclump = clumps_per_line; nclump-- > 0; ) {
				for (xpos = 0; xpos < hsamp; xpos++)
				    *outptr++ = inptr[xpos];
				inptr += samples_per_clump;
			    }
			}
			/* pad each scanline as needed */
			for (xpos = 0; xpos < padding; xpos++) {
			    *outptr = outptr[-1];
			    outptr++;
			}
			clumpoffset += hsamp;
		    }
		}
		sp->scancount++;
		if (sp->scancount >= DCTSIZE) {
			int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE;
			if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n)
				return (0);
			sp->scancount = 0;
		}
		if (nrows > 0)
			tif->tif_row++;
		buf += sp->bytesperline;
	}
	return (1);
}

/*
 * Finish up at the end of a strip or tile.
 */
static int
JPEGPostEncode(TIFF* tif)
{
	JPEGState *sp = JState(tif);

	if (sp->scancount > 0) {
		/*
		 * Need to emit a partial bufferload of downsampled data.
		 * Pad the data vertically.
		 */
		int ci, ypos, n;
		jpeg_component_info* compptr;

		for (ci = 0, compptr = sp->cinfo.c.comp_info;
		     ci < sp->cinfo.c.num_components;
		     ci++, compptr++) {
			int vsamp = compptr->v_samp_factor;
			tsize_t row_width = compptr->width_in_blocks * DCTSIZE
				* sizeof(JSAMPLE);
			for (ypos = sp->scancount * vsamp;
			     ypos < DCTSIZE * vsamp; ypos++) {
				_TIFFmemcpy((tdata_t)sp->ds_buffer[ci][ypos],
					    (tdata_t)sp->ds_buffer[ci][ypos-1],
					    row_width);

			}
		}
		n = sp->cinfo.c.max_v_samp_factor * DCTSIZE;
		if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n)
			return (0);
	}

	return (TIFFjpeg_finish_compress(JState(tif)));
}

static void
JPEGCleanup(TIFF* tif)
{
	if (tif->tif_data) {
		JPEGState *sp = JState(tif);
                if( sp->cinfo_initialized )
                    TIFFjpeg_destroy(sp);	/* release libjpeg resources */
		if (sp->jpegtables)		/* tag value */
			_TIFFfree(sp->jpegtables);
		_TIFFfree(tif->tif_data);	/* release local state */
		tif->tif_data = NULL;
	}
}

static int
JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
	JPEGState* sp = JState(tif);
	TIFFDirectory* td = &tif->tif_dir;
	uint32 v32;

	switch (tag) {
	case TIFFTAG_JPEGTABLES:
		v32 = va_arg(ap, uint32);
		if (v32 == 0) {
			/* XXX */
			return (0);
		}
		_TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*),
		    (long) v32);
		sp->jpegtables_length = v32;
		TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
		break;
	case TIFFTAG_JPEGQUALITY:
		sp->jpegquality = va_arg(ap, int);
		return (1);			/* pseudo tag */
	case TIFFTAG_JPEGCOLORMODE:
		sp->jpegcolormode = va_arg(ap, int);
		/*
		 * Mark whether returned data is up-sampled or not
		 * so TIFFStripSize and TIFFTileSize return values
		 * that reflect the true amount of data.
		 */
		tif->tif_flags &= ~TIFF_UPSAMPLED;
		if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
		    if (td->td_photometric == PHOTOMETRIC_YCBCR &&
		      sp->jpegcolormode == JPEGCOLORMODE_RGB) {
			tif->tif_flags |= TIFF_UPSAMPLED;
		    } else {
			if (td->td_ycbcrsubsampling[0] != 1 ||
			    td->td_ycbcrsubsampling[1] != 1)
			    ; /* XXX what about up-sampling? */
		    }
		}
		/*
		 * Must recalculate cached tile size
		 * in case sampling state changed.
		 */
		tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
		return (1);			/* pseudo tag */
	case TIFFTAG_JPEGTABLESMODE:
		sp->jpegtablesmode = va_arg(ap, int);
		return (1);			/* pseudo tag */
	case TIFFTAG_YCBCRSUBSAMPLING:
                /* mark the fact that we have a real ycbcrsubsampling! */
		sp->ycbcrsampling_fetched = 1;
		return (*sp->vsetparent)(tif, tag, ap);
	default:
		return (*sp->vsetparent)(tif, tag, ap);
	}
	tif->tif_flags |= TIFF_DIRTYDIRECT;
	return (1);
}

/*
 * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in
 * the TIFF tags, but still use non-default (2,2) values within the jpeg
 * data stream itself.  In order for TIFF applications to work properly
 * - for instance to get the strip buffer size right - it is imperative
 * that the subsampling be available before we start reading the image
 * data normally.  This function will attempt to load the first strip in
 * order to get the sampling values from the jpeg data stream.  Various
 * hacks are various places are done to ensure this function gets called
 * before the td_ycbcrsubsampling values are used from the directory structure,
 * including calling TIFFGetField() for the YCBCRSUBSAMPLING field from 
 * TIFFStripSize(), and the printing code in tif_print.c. 
 *
 * Note that JPEGPreDeocode() will produce a fairly loud warning when the
 * discovered sampling does not match the default sampling (2,2) or whatever
 * was actually in the tiff tags. 
 *
 * Problems:
 *  o This code will cause one whole strip/tile of compressed data to be
 *    loaded just to get the tags right, even if the imagery is never read.
 *    It would be more efficient to just load a bit of the header, and
 *    initialize things from that. 
 *
 * See the bug in bugzilla for details:
 *
 * http://bugzilla.remotesensing.org/show_bug.cgi?id=168
 *
 * Frank Warmerdam, July 2002
 */

static void 
JPEGFixupTestSubsampling( TIFF * tif )
{
#ifdef CHECK_JPEG_YCBCR_SUBSAMPLING
    JPEGState *sp = JState(tif);
    TIFFDirectory *td = &tif->tif_dir;

    JPEGInitializeLibJPEG( tif );

    /*
     * Some JPEG-in-TIFF files don't provide the ycbcrsampling tags, 
     * and use a sampling schema other than the default 2,2.  To handle
     * this we actually have to scan the header of a strip or tile of
     * jpeg data to get the sampling.  
     */
    if( !sp->cinfo.comm.is_decompressor 
        || sp->ycbcrsampling_fetched  
        || td->td_photometric != PHOTOMETRIC_YCBCR )
        return;

    sp->ycbcrsampling_fetched = 1;
    if( TIFFIsTiled( tif ) )
    {
        if( !TIFFFillTile( tif, 0 ) )
            return;
    }
    else
    {
        if( !TIFFFillStrip( tif, 0 ) )
            return;
    }

    TIFFSetField( tif, TIFFTAG_YCBCRSUBSAMPLING, 
                  (uint16) sp->h_sampling, (uint16) sp->v_sampling );
#endif /* CHECK_JPEG_YCBCR_SUBSAMPLING */
}

static int
JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap)
{
	JPEGState* sp = JState(tif);

	switch (tag) {
	case TIFFTAG_JPEGTABLES:
		/* unsigned short is bogus --- should be uint32 ??? */
		/* TIFFWriteNormalTag needs fixed  XXX */
		*va_arg(ap, unsigned short*) =
                        (unsigned short) sp->jpegtables_length;
		*va_arg(ap, void**) = sp->jpegtables;
		break;
	case TIFFTAG_JPEGQUALITY:
		*va_arg(ap, int*) = sp->jpegquality;
		break;
	case TIFFTAG_JPEGCOLORMODE:
		*va_arg(ap, int*) = sp->jpegcolormode;
		break;
	case TIFFTAG_JPEGTABLESMODE:
		*va_arg(ap, int*) = sp->jpegtablesmode;
		break;
	case TIFFTAG_YCBCRSUBSAMPLING:
                JPEGFixupTestSubsampling( tif );
		return (*sp->vgetparent)(tif, tag, ap);
		break;
	default:
		return (*sp->vgetparent)(tif, tag, ap);
	}
	return (1);
}

static void
JPEGPrintDir(TIFF* tif, FILE* fd, long flags)
{
	JPEGState* sp = JState(tif);

	(void) flags;
	if (TIFFFieldSet(tif,FIELD_JPEGTABLES))
		fprintf(fd, "  JPEG Tables: (%lu bytes)\n",
			(unsigned long) sp->jpegtables_length);
}

static uint32
JPEGDefaultStripSize(TIFF* tif, uint32 s)
{
	JPEGState* sp = JState(tif);
	TIFFDirectory *td = &tif->tif_dir;

	s = (*sp->defsparent)(tif, s);
	if (s < td->td_imagelength)
		s = TIFFroundup(s, td->td_ycbcrsubsampling[1] * DCTSIZE);
	return (s);
}

static void
JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th)
{
	JPEGState* sp = JState(tif);
	TIFFDirectory *td = &tif->tif_dir;

	(*sp->deftparent)(tif, tw, th);
	*tw = TIFFroundup(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE);
	*th = TIFFroundup(*th, td->td_ycbcrsubsampling[1] * DCTSIZE);
}

/*
 * The JPEG library initialized used to be done in TIFFInitJPEG(), but
 * now that we allow a TIFF file to be opened in update mode it is necessary
 * to have some way of deciding whether compression or decompression is
 * desired other than looking at tif->tif_mode.  We accomplish this by 
 * examining {TILE/STRIP}BYTECOUNTS to see if there is a non-zero entry.
 * If so, we assume decompression is desired. 
 *
 * This is tricky, because TIFFInitJPEG() is called while the directory is
 * being read, and generally speaking the BYTECOUNTS tag won't have been read
 * at that point.  So we try to defer jpeg library initialization till we
 * do have that tag ... basically any access that might require the compressor
 * or decompressor that occurs after the reading of the directory. 
 *
 * In an ideal world compressors or decompressors would be setup
 * at the point where a single tile or strip was accessed (for read or write)
 * so that stuff like update of missing tiles, or replacement of tiles could
 * be done. However, we aren't trying to crack that nut just yet ...
 *
 * NFW, Feb 3rd, 2003.
 */

static int JPEGInitializeLibJPEG( TIFF * tif )
{
    JPEGState* sp = JState(tif);
    uint32 *byte_counts = NULL;
    int     data_is_empty = TRUE;

    if( sp->cinfo_initialized )
        return 1;

    /*
     * Do we have tile data already?  Make sure we initialize the
     * the state in decompressor mode if we have tile data, even if we
     * are not in read-only file access mode. 
     */
    if( TIFFIsTiled( tif ) 
        && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &byte_counts ) 
        && byte_counts != NULL )
    {
        data_is_empty = byte_counts[0] == 0;
    }
    if( !TIFFIsTiled( tif ) 
        && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &byte_counts) 
        && byte_counts != NULL )
    {
        data_is_empty = byte_counts[0] == 0;
    }

    /*
     * Initialize libjpeg.
     */
    if (tif->tif_mode == O_RDONLY || !data_is_empty ) {
        if (!TIFFjpeg_create_decompress(sp))
            return (0);

    } else {
        if (!TIFFjpeg_create_compress(sp))
            return (0);
    }

    sp->cinfo_initialized = TRUE;

    return 1;
}

int
TIFFInitJPEG(TIFF* tif, int scheme)
{
	JPEGState* sp;

	assert(scheme == COMPRESSION_JPEG);

	/*
	 * Allocate state block so tag methods have storage to record values.
	 */
	tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (JPEGState));

	if (tif->tif_data == NULL) {
		TIFFError("TIFFInitJPEG", "No space for JPEG state block");
		return (0);
	}
        _TIFFmemset( tif->tif_data, 0, sizeof(JPEGState));

	sp = JState(tif);
	sp->tif = tif;				/* back link */

	/*
	 * Merge codec-specific tag information and
	 * override parent get/set field methods.
	 */
	_TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo));
	sp->vgetparent = tif->tif_tagmethods.vgetfield;
	tif->tif_tagmethods.vgetfield = JPEGVGetField;	/* hook for codec tags */
	sp->vsetparent = tif->tif_tagmethods.vsetfield;
	tif->tif_tagmethods.vsetfield = JPEGVSetField;	/* hook for codec tags */
	tif->tif_tagmethods.printdir = JPEGPrintDir;	/* hook for codec tags */

	/* Default values for codec-specific fields */
	sp->jpegtables = NULL;
	sp->jpegtables_length = 0;
	sp->jpegquality = 75;			/* Default IJG quality */
	sp->jpegcolormode = JPEGCOLORMODE_RAW;
	sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF;

        sp->ycbcrsampling_fetched = 0;

	/*
	 * Install codec methods.
	 */
	tif->tif_setupdecode = JPEGSetupDecode;
	tif->tif_predecode = JPEGPreDecode;
	tif->tif_decoderow = JPEGDecode;
	tif->tif_decodestrip = JPEGDecode;
	tif->tif_decodetile = JPEGDecode;
	tif->tif_setupencode = JPEGSetupEncode;
	tif->tif_preencode = JPEGPreEncode;
	tif->tif_postencode = JPEGPostEncode;
	tif->tif_encoderow = JPEGEncode;
	tif->tif_encodestrip = JPEGEncode;
	tif->tif_encodetile = JPEGEncode;
	tif->tif_cleanup = JPEGCleanup;
	sp->defsparent = tif->tif_defstripsize;
	tif->tif_defstripsize = JPEGDefaultStripSize;
	sp->deftparent = tif->tif_deftilesize;
	tif->tif_deftilesize = JPEGDefaultTileSize;
	tif->tif_flags |= TIFF_NOBITREV;	/* no bit reversal, please */

        sp->cinfo_initialized = FALSE;

        /*
         * Mark the TIFFTAG_YCBCRSAMPLES as present even if it is not
         * see: JPEGFixupTestSubsampling().
         */
        TIFFSetFieldBit( tif, FIELD_YCBCRSUBSAMPLING );

	return (1);
}
#endif /* JPEG_SUPPORT */

/* vim: set ts=8 sts=8 sw=8 noet: */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
97精品国产露脸对白| 69堂精品视频| 全国精品久久少妇| 国产精品国产三级国产三级人妇| 加勒比av一区二区| 一区二区不卡在线播放| 精品国产一区二区三区久久久蜜月| 成人午夜精品一区二区三区| 蜜臀va亚洲va欧美va天堂| 亚洲欧美日韩成人高清在线一区| 欧美电影免费观看高清完整版在| 91免费版在线| 成人综合婷婷国产精品久久免费| 亚洲一区视频在线| 国产精品久久久久影院| 精品久久久久久亚洲综合网| 欧美日韩国产系列| 在线免费观看成人短视频| 成人免费看视频| 国产精品一区二区视频| 奇米888四色在线精品| 亚洲午夜久久久久久久久久久| 久久亚洲综合色| 日韩手机在线导航| 欧美喷水一区二区| 一本久道久久综合中文字幕 | 亚洲制服丝袜av| 国产拍欧美日韩视频二区| 日韩一区二区三区四区| 欧美日韩美女一区二区| 色94色欧美sute亚洲线路二| 99精品久久久久久| 91香蕉视频mp4| av午夜精品一区二区三区| 国产999精品久久久久久绿帽| 免费视频一区二区| 日本成人在线看| 日韩精品91亚洲二区在线观看| 亚洲欧洲日韩一区二区三区| 欧美激情一区二区三区蜜桃视频| 欧美一级欧美三级| 日韩欧美电影在线| 欧美成va人片在线观看| 欧美精品一区二区三区蜜桃视频| 日韩一二三区视频| 日韩午夜精品视频| 欧美一区二区在线不卡| 日韩一卡二卡三卡| 精品国产免费人成电影在线观看四季 | 欧美电视剧免费观看| 51久久夜色精品国产麻豆| 在线观看国产日韩| 6080亚洲精品一区二区| 日韩一区二区三区免费看 | 国产综合色在线| 国产不卡视频在线播放| 99在线精品视频| 色噜噜狠狠色综合欧洲selulu| 成人激情小说网站| 91在线小视频| 欧美精三区欧美精三区| 欧美电视剧在线观看完整版| 国产欧美日韩视频在线观看| 国产精品女人毛片| 亚洲高清三级视频| 青青国产91久久久久久| 国产一区二区三区免费观看| 成人动漫视频在线| 色狠狠色狠狠综合| 日韩一级成人av| 国产精品美女久久久久aⅴ | 欧美理论电影在线| 欧美精品一区二区三区蜜桃视频| 久久午夜色播影院免费高清| 亚洲精品视频一区| 蜜臀91精品一区二区三区| 国产麻豆精品一区二区| 色婷婷综合中文久久一本| 欧美一区二区国产| 国产精品护士白丝一区av| 爽爽淫人综合网网站| 国产精品自拍av| 欧美在线不卡视频| 精品国产乱码久久久久久浪潮| 欧美激情一区二区在线| 亚洲国产精品久久一线不卡| 国产精品一区二区在线播放 | 色婷婷国产精品| 精品国内二区三区| 亚洲精品国产a| 九色|91porny| 欧美日韩一区二区三区不卡| 久久精品一区二区三区四区| 一区二区三区在线高清| 国产激情精品久久久第一区二区| 91片黄在线观看| 精品国产百合女同互慰| 亚洲一区中文在线| 成人性生交大片免费看中文| 欧美一区三区二区| 一区二区三区在线播| 国产成人亚洲综合a∨婷婷图片| eeuss国产一区二区三区| 日韩欧美在线观看一区二区三区| 国产精品视频一二三区| 麻豆国产一区二区| 在线观看www91| 亚洲综合色在线| 91视视频在线观看入口直接观看www | 久久久久国色av免费看影院| 亚洲精品中文字幕在线观看| 国产在线观看一区二区| 91精品国产一区二区人妖| 伊人性伊人情综合网| 成人蜜臀av电影| 久久精品一区二区| 在线亚洲免费视频| 国产蜜臀97一区二区三区| 麻豆一区二区三| 欧美另类一区二区三区| 亚洲综合久久久| 色一情一伦一子一伦一区| 国产欧美日韩在线看| 激情五月激情综合网| 欧美一区二区精美| 日韩精品久久理论片| 欧美日韩另类一区| 亚洲一级二级在线| 欧美综合一区二区| 亚洲黄色免费网站| 91美女视频网站| 亚洲欧美综合另类在线卡通| 国产传媒久久文化传媒| 久久久不卡网国产精品一区| 久久99精品国产麻豆婷婷洗澡| 欧美在线影院一区二区| 亚洲综合一二区| 欧美性生交片4| 亚洲资源中文字幕| 欧美三级中文字幕| 亚洲成人一区二区在线观看| 在线一区二区三区四区五区| 亚洲精品乱码久久久久久黑人| 波多野结衣亚洲一区| 中文字幕亚洲欧美在线不卡| 99国产精品国产精品毛片| 亚洲免费观看高清在线观看| 在线观看视频一区| 亚洲成人综合视频| 日韩精品自拍偷拍| 国产美女主播视频一区| 中文乱码免费一区二区| 99久久亚洲一区二区三区青草| 国产精品伦理在线| 色哟哟精品一区| 日本女人一区二区三区| 久久亚洲精华国产精华液 | 久久综合精品国产一区二区三区| 激情久久五月天| 国产精品私人自拍| 欧美日韩一区二区在线观看| 午夜精品久久久久久久久久久| 欧美在线免费观看亚洲| 亚洲gay无套男同| 日韩精品一区二区三区视频播放| 奇米综合一区二区三区精品视频| 欧美伦理视频网站| 日本美女视频一区二区| 日韩精品在线一区| 国产精品亚洲第一| 国产精品国产三级国产普通话99 | 国产精品一二三区在线| 久久久久国产精品人| 成人h精品动漫一区二区三区| 国产精品嫩草影院av蜜臀| 色综合天天综合| 五月天欧美精品| 日韩精品中文字幕一区二区三区 | 午夜精品视频在线观看| 日韩一二在线观看| 97精品国产露脸对白| 午夜精品视频在线观看| 亚洲精品一区二区三区福利 | 91视频.com| 天天综合天天综合色| 欧美精品v国产精品v日韩精品 | 免费在线视频一区| 久久嫩草精品久久久精品 | 欧美三级欧美一级| 亚洲三级在线看| 欧美一级午夜免费电影| 成人免费视频视频在线观看免费| 亚洲欧洲99久久| 精品成a人在线观看| av成人老司机| 男女男精品视频网| 国产视频亚洲色图| 欧美成人一区二区三区| 一本大道久久a久久综合| 日韩精品电影一区亚洲|