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

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

?? jquant2.c

?? 一款最完整的工業組態軟源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
/*
 * jquant2.c
 *
 * Copyright (C) 1991-1996, Thomas G. Lane.
 * This file is part of the Independent JPEG Group's software.
 * For conditions of distribution and use, see the accompanying README file.
 *
 * This file contains 2-pass color quantization (color mapping) routines.
 * These routines provide selection of a custom color map for an image,
 * followed by mapping of the image to that color map, with optional
 * Floyd-Steinberg dithering.
 * It is also possible to use just the second pass to map to an arbitrary
 * externally-given color map.
 *
 * Note: ordered dithering is not supported, since there isn't any fast
 * way to compute intercolor distances; it's unclear that ordered dither's
 * fundamental assumptions even hold with an irregularly spaced color map.
 */

#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"

#ifdef QUANT_2PASS_SUPPORTED


/*
 * This module implements the well-known Heckbert paradigm for color
 * quantization.  Most of the ideas used here can be traced back to
 * Heckbert's seminal paper
 *   Heckbert, Paul.  "Color Image Quantization for Frame Buffer Display",
 *   Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304.
 *
 * In the first pass over the image, we accumulate a histogram showing the
 * usage count of each possible color.  To keep the histogram to a reasonable
 * size, we reduce the precision of the input; typical practice is to retain
 * 5 or 6 bits per color, so that 8 or 4 different input values are counted
 * in the same histogram cell.
 *
 * Next, the color-selection step begins with a box representing the whole
 * color space, and repeatedly splits the "largest" remaining box until we
 * have as many boxes as desired colors.  Then the mean color in each
 * remaining box becomes one of the possible output colors.
 * 
 * The second pass over the image maps each input pixel to the closest output
 * color (optionally after applying a Floyd-Steinberg dithering correction).
 * This mapping is logically trivial, but making it go fast enough requires
 * considerable care.
 *
 * Heckbert-style quantizers vary a good deal in their policies for choosing
 * the "largest" box and deciding where to cut it.  The particular policies
 * used here have proved out well in experimental comparisons, but better ones
 * may yet be found.
 *
 * In earlier versions of the IJG code, this module quantized in YCbCr color
 * space, processing the raw upsampled data without a color conversion step.
 * This allowed the color conversion math to be done only once per colormap
 * entry, not once per pixel.  However, that optimization precluded other
 * useful optimizations (such as merging color conversion with upsampling)
 * and it also interfered with desired capabilities such as quantizing to an
 * externally-supplied colormap.  We have therefore abandoned that approach.
 * The present code works in the post-conversion color space, typically RGB.
 *
 * To improve the visual quality of the results, we actually work in scaled
 * RGB space, giving G distances more weight than R, and R in turn more than
 * B.  To do everything in integer math, we must use integer scale factors.
 * The 2/3/1 scale factors used here correspond loosely to the relative
 * weights of the colors in the NTSC grayscale equation.
 * If you want to use this code to quantize a non-RGB color space, you'll
 * probably need to change these scale factors.
 */

#define R_SCALE 2		/* scale R distances by this much */
#define G_SCALE 3		/* scale G distances by this much */
#define B_SCALE 1		/* and B by this much */

/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined
 * in jmorecfg.h.  As the code stands, it will do the right thing for R,G,B
 * and B,G,R orders.  If you define some other weird order in jmorecfg.h,
 * you'll get compile errors until you extend this logic.  In that case
 * you'll probably want to tweak the histogram sizes too.
 */

#if RGB_RED == 0
#define C0_SCALE R_SCALE
#endif
#if RGB_BLUE == 0
#define C0_SCALE B_SCALE
#endif
#if RGB_GREEN == 1
#define C1_SCALE G_SCALE
#endif
#if RGB_RED == 2
#define C2_SCALE R_SCALE
#endif
#if RGB_BLUE == 2
#define C2_SCALE B_SCALE
#endif


/*
 * First we have the histogram data structure and routines for creating it.
 *
 * The number of bits of precision can be adjusted by changing these symbols.
 * We recommend keeping 6 bits for G and 5 each for R and B.
 * If you have plenty of memory and cycles, 6 bits all around gives marginally
 * better results; if you are short of memory, 5 bits all around will save
 * some space but degrade the results.
 * To maintain a fully accurate histogram, we'd need to allocate a "long"
 * (preferably unsigned long) for each cell.  In practice this is overkill;
 * we can get by with 16 bits per cell.  Few of the cell counts will overflow,
 * and clamping those that do overflow to the maximum value will give close-
 * enough results.  This reduces the recommended histogram size from 256Kb
 * to 128Kb, which is a useful savings on PC-class machines.
 * (In the second pass the histogram space is re-used for pixel mapping data;
 * in that capacity, each cell must be able to store zero to the number of
 * desired colors.  16 bits/cell is plenty for that too.)
 * Since the JPEG code is intended to run in small memory model on 80x86
 * machines, we can't just allocate the histogram in one chunk.  Instead
 * of a true 3-D array, we use a row of pointers to 2-D arrays.  Each
 * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and
 * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.  Note that
 * on 80x86 machines, the pointer row is in near memory but the actual
 * arrays are in far memory (same arrangement as we use for image arrays).
 */

#define MAXNUMCOLORS  (MAXJSAMPLE+1) /* maximum size of colormap */

/* These will do the right thing for either R,G,B or B,G,R color order,
 * but you may not like the results for other color orders.
 */
#define HIST_C0_BITS  5		/* bits of precision in R/B histogram */
#define HIST_C1_BITS  6		/* bits of precision in G histogram */
#define HIST_C2_BITS  5		/* bits of precision in B/R histogram */

/* Number of elements along histogram axes. */
#define HIST_C0_ELEMS  (1<<HIST_C0_BITS)
#define HIST_C1_ELEMS  (1<<HIST_C1_BITS)
#define HIST_C2_ELEMS  (1<<HIST_C2_BITS)

/* These are the amounts to shift an input value to get a histogram index. */
#define C0_SHIFT  (BITS_IN_JSAMPLE-HIST_C0_BITS)
#define C1_SHIFT  (BITS_IN_JSAMPLE-HIST_C1_BITS)
#define C2_SHIFT  (BITS_IN_JSAMPLE-HIST_C2_BITS)


typedef UINT16 histcell;	/* histogram cell; prefer an unsigned type */

typedef histcell FAR * histptr;	/* for pointers to histogram cells */

typedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */
typedef hist1d FAR * hist2d;	/* type for the 2nd-level pointers */
typedef hist2d * hist3d;	/* type for top-level pointer */


/* Declarations for Floyd-Steinberg dithering.
 *
 * Errors are accumulated into the array fserrors[], at a resolution of
 * 1/16th of a pixel count.  The error at a given pixel is propagated
 * to its not-yet-processed neighbors using the standard F-S fractions,
 *		...	(here)	7/16
 *		3/16	5/16	1/16
 * We work left-to-right on even rows, right-to-left on odd rows.
 *
 * We can get away with a single array (holding one row's worth of errors)
 * by using it to store the current row's errors at pixel columns not yet
 * processed, but the next row's errors at columns already processed.  We
 * need only a few extra variables to hold the errors immediately around the
 * current column.  (If we are lucky, those variables are in registers, but
 * even if not, they're probably cheaper to access than array elements are.)
 *
 * The fserrors[] array has (#columns + 2) entries; the extra entry at
 * each end saves us from special-casing the first and last pixels.
 * Each entry is three values long, one value for each color component.
 *
 * Note: on a wide image, we might not have enough room in a PC's near data
 * segment to hold the error array; so it is allocated with alloc_large.
 */

#if BITS_IN_JSAMPLE == 8
typedef INT16 FSERROR;		/* 16 bits should be enough */
typedef int LOCFSERROR;		/* use 'int' for calculation temps */
#else
typedef INT32 FSERROR;		/* may need more than 16 bits */
typedef INT32 LOCFSERROR;	/* be sure calculation temps are big enough */
#endif

typedef FSERROR FAR *FSERRPTR;	/* pointer to error array (in FAR storage!) */


/* Private subobject */

typedef struct {
  struct jpeg_color_quantizer pub; /* public fields */

  /* Space for the eventually created colormap is stashed here */
  JSAMPARRAY sv_colormap;	/* colormap allocated at init time */
  int desired;			/* desired # of colors = size of colormap */

  /* Variables for accumulating image statistics */
  hist3d histogram;		/* pointer to the histogram */

  boolean needs_zeroed;		/* TRUE if next pass must zero histogram */

  /* Variables for Floyd-Steinberg dithering */
  FSERRPTR fserrors;		/* accumulated errors */
  boolean on_odd_row;		/* flag to remember which row we are on */
  int * error_limiter;		/* table for clamping the applied error */
} my_cquantizer;

typedef my_cquantizer * my_cquantize_ptr;


/*
 * Prescan some rows of pixels.
 * In this module the prescan simply updates the histogram, which has been
 * initialized to zeroes by start_pass.
 * An output_buf parameter is required by the method signature, but no data
 * is actually output (in fact the buffer controller is probably passing a
 * NULL pointer).
 */

METHODDEF(void)
prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
		  JSAMPARRAY output_buf, int num_rows)
{
  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
  register JSAMPROW ptr;
  register histptr histp;
  register hist3d histogram = cquantize->histogram;
  int row;
  JDIMENSION col;
  JDIMENSION width = cinfo->output_width;

  for (row = 0; row < num_rows; row++) {
    ptr = input_buf[row];
    for (col = width; col > 0; col--) {
      /* get pixel value and index into the histogram */
      histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]
			 [GETJSAMPLE(ptr[1]) >> C1_SHIFT]
			 [GETJSAMPLE(ptr[2]) >> C2_SHIFT];
      /* increment, check for overflow and undo increment if so. */
      if (++(*histp) <= 0)
	(*histp)--;
      ptr += 3;
    }
  }
}


/*
 * Next we have the really interesting routines: selection of a colormap
 * given the completed histogram.
 * These routines work with a list of "boxes", each representing a rectangular
 * subset of the input color space (to histogram precision).
 */

typedef struct {
  /* The bounds of the box (inclusive); expressed as histogram indexes */
  int c0min, c0max;
  int c1min, c1max;
  int c2min, c2max;
  /* The volume (actually 2-norm) of the box */
  INT32 volume;
  /* The number of nonzero histogram cells within this box */
  long colorcount;
} box;

typedef box * boxptr;


LOCAL(boxptr)
find_biggest_color_pop (boxptr boxlist, int numboxes)
/* Find the splittable box with the largest color population */
/* Returns NULL if no splittable boxes remain */
{
  register boxptr boxp;
  register int i;
  register long maxc = 0;
  boxptr which = NULL;
  
  for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
    if (boxp->colorcount > maxc && boxp->volume > 0) {
      which = boxp;
      maxc = boxp->colorcount;
    }
  }
  return which;
}


LOCAL(boxptr)
find_biggest_volume (boxptr boxlist, int numboxes)
/* Find the splittable box with the largest (scaled) volume */
/* Returns NULL if no splittable boxes remain */
{
  register boxptr boxp;
  register int i;
  register INT32 maxv = 0;
  boxptr which = NULL;
  
  for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
    if (boxp->volume > maxv) {
      which = boxp;
      maxv = boxp->volume;
    }
  }
  return which;
}


LOCAL(void)
update_box (j_decompress_ptr cinfo, boxptr boxp)
/* Shrink the min/max bounds of a box to enclose only nonzero elements, */
/* and recompute its volume and population */
{
  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
  hist3d histogram = cquantize->histogram;
  histptr histp;
  int c0,c1,c2;
  int c0min,c0max,c1min,c1max,c2min,c2max;
  INT32 dist0,dist1,dist2;
  long ccount;
  
  c0min = boxp->c0min;  c0max = boxp->c0max;
  c1min = boxp->c1min;  c1max = boxp->c1max;
  c2min = boxp->c2min;  c2max = boxp->c2max;
  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91丨porny丨首页| 日韩午夜激情电影| 成人在线综合网站| 欧美肥大bbwbbw高潮| 欧美精品一区男女天堂| 亚洲婷婷综合久久一本伊一区| 亚洲一本大道在线| 国产成人日日夜夜| 日韩丝袜美女视频| 亚洲美女免费在线| 久久精品久久久精品美女| 91传媒视频在线播放| 久久久国际精品| 日韩av中文字幕一区二区 | 精品成人在线观看| 最新热久久免费视频| 美腿丝袜亚洲综合| 色视频成人在线观看免| 亚洲欧洲成人av每日更新| 人妖欧美一区二区| 欧美日韩亚洲综合在线| 中文字幕制服丝袜一区二区三区| 蜜臀av在线播放一区二区三区| 色婷婷一区二区三区四区| 久久午夜羞羞影院免费观看| 亚洲黄一区二区三区| www.欧美色图| 国产丝袜欧美中文另类| 奇米色777欧美一区二区| 欧美精品欧美精品系列| 亚洲色图欧洲色图婷婷| 久草精品在线观看| 日韩欧美一级二级三级久久久| 亚洲永久免费av| 欧美视频一区二| 一区二区三区欧美视频| 99re在线精品| 精品免费国产二区三区| 日韩电影在线免费看| 欧洲激情一区二区| 亚洲bt欧美bt精品| 欧美性一区二区| 2020国产成人综合网| 激情综合色综合久久综合| 日韩欧美的一区| 图片区小说区国产精品视频| 欧美网站大全在线观看| 国产精品久久久久久久久免费相片| 久久9热精品视频| 制服.丝袜.亚洲.另类.中文| 亚洲一区在线观看网站| 欧美视频一二三区| 视频一区中文字幕国产| 欧美成人国产一区二区| 精品一区二区三区香蕉蜜桃| 欧美精品一区二区精品网| 国产精品一二一区| 国产欧美综合在线观看第十页| 成人精品国产福利| 亚洲精品国久久99热| 精品视频1区2区3区| 卡一卡二国产精品| 久久嫩草精品久久久久| www.久久精品| 最新热久久免费视频| 91传媒视频在线播放| 国产在线国偷精品免费看| 久久久噜噜噜久噜久久综合| 99re免费视频精品全部| 亚洲18色成人| 精品国精品国产| 色噜噜夜夜夜综合网| 日韩高清一区在线| 国产精品美女久久久久久久 | 日本sm残虐另类| 日韩欧美不卡在线观看视频| 播五月开心婷婷综合| 亚洲自拍偷拍麻豆| 久久久久久久精| 一本色道综合亚洲| 青草av.久久免费一区| 亚洲色图在线播放| 日韩免费观看高清完整版| 色婷婷av一区二区三区大白胸| 蜜桃视频在线一区| 成人欧美一区二区三区小说 | 色噜噜狠狠成人中文综合| 日本欧美一区二区三区| 亚洲男帅同性gay1069| 91精品婷婷国产综合久久竹菊| 日韩福利视频导航| 一区二区三区四区中文字幕| 精品入口麻豆88视频| 丁香桃色午夜亚洲一区二区三区| 亚洲尤物在线视频观看| 欧美激情一区不卡| 日韩女优毛片在线| 在线观看欧美日本| 东方aⅴ免费观看久久av| 久久国产三级精品| 亚洲国产日韩精品| 一区二区三区av电影| 久久精品男人的天堂| 色八戒一区二区三区| 成人高清免费在线播放| 日本中文在线一区| 欧美一级久久久久久久大片| 在线视频国内一区二区| 国产99久久精品| 激情欧美一区二区| 亚洲成人av电影在线| 亚洲丝袜美腿综合| 91精品中文字幕一区二区三区| 国产成人aaa| 国产曰批免费观看久久久| 午夜精品久久一牛影视| 亚洲视频在线一区二区| 精品国产凹凸成av人网站| 91污片在线观看| 99久久精品国产网站| 国产乱码字幕精品高清av | 欧美日韩在线播放三区四区| 日本道精品一区二区三区 | 亚洲成av人片一区二区三区| 亚洲亚洲人成综合网络| 一级日本不卡的影视| 亚洲一级片在线观看| 亚洲精品老司机| 国产精品毛片无遮挡高清| 国产欧美一区二区三区鸳鸯浴 | 日韩欧美国产成人一区二区| 精品福利视频一区二区三区| 日韩视频免费观看高清完整版在线观看| 成人精品视频一区| 99re8在线精品视频免费播放| 99久久精品费精品国产一区二区| 成人看片黄a免费看在线| eeuss鲁片一区二区三区在线观看| 成人精品小蝌蚪| 欧美日韩中文国产| 777久久久精品| 美日韩一区二区三区| 国产米奇在线777精品观看| 国产成人亚洲精品狼色在线| 91麻豆国产福利在线观看| 欧美色男人天堂| 久久久综合视频| 中文字幕在线不卡国产视频| 在线视频观看一区| 精品乱人伦小说| 久久精品免费在线观看| 亚洲国产日韩a在线播放| 免费看精品久久片| 不卡视频一二三| 欧美日韩三级一区| 成人做爰69片免费看网站| 欧美欧美午夜aⅴ在线观看| 日韩欧美一区二区在线视频| 国产精品青草综合久久久久99| 成人免费在线播放视频| 日韩激情视频网站| 国产suv一区二区三区88区| 不卡视频在线观看| 欧美成人免费网站| 国产精品久久精品日日| 青青草原综合久久大伊人精品优势 | 最新国产成人在线观看| 天天亚洲美女在线视频| 国产精品亚洲专一区二区三区| 欧美日韩一区三区| 国产日韩欧美精品一区| 国产精品不卡在线观看| 亚洲一卡二卡三卡四卡| 麻豆一区二区三区| 欧美色图第一页| 日韩一区在线播放| 蜜桃av噜噜一区二区三区小说| 国产精品影视天天线| 精品婷婷伊人一区三区三| 26uuu色噜噜精品一区二区| 偷拍与自拍一区| 99热99精品| 久久网站热最新地址| 亚洲综合视频在线观看| 91网站视频在线观看| 欧美性xxxxx极品少妇| 欧美mv和日韩mv的网站| 亚洲一区二区三区美女| 国产成人精品1024| 337p亚洲精品色噜噜| 欧美国产精品中文字幕| 蜜桃一区二区三区四区| 在线观看国产一区二区| 亚洲国产高清aⅴ视频| 久草在线在线精品观看| 日韩欧美一级二级三级| 一区二区三区四区五区视频在线观看 | 久久夜色精品国产噜噜av | 久久综合色婷婷| 蜜桃av一区二区在线观看|