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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? jquant2.c

?? 這是JPEG解碼、編碼的源代碼
?? C
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
/*
 * 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;
  

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久夜| 中文字幕一区免费在线观看| 成人激情校园春色| 婷婷国产在线综合| 国产精品少妇自拍| 欧美一区二区久久久| 成人av在线观| 韩日精品视频一区| 亚洲乱码精品一二三四区日韩在线| 日韩亚洲欧美在线| 欧美午夜电影在线播放| 国产91富婆露脸刺激对白| 日韩在线a电影| 国产精品高潮久久久久无| 日韩一区二区在线播放| 欧美一a一片一级一片| 高清国产一区二区| 久久精品国产在热久久| 亚洲国产日韩a在线播放性色| 中文字幕成人av| 日韩欧美色综合网站| 欧美午夜电影在线播放| 色婷婷狠狠综合| 成人美女视频在线观看| 国产在线日韩欧美| 琪琪一区二区三区| 午夜视频一区二区三区| 亚洲男人的天堂网| 国产精品高潮呻吟久久| 欧美经典三级视频一区二区三区| 欧美一区二区私人影院日本| 欧美视频中文一区二区三区在线观看| 成人教育av在线| 成人免费观看av| 国产成人亚洲精品狼色在线| 精品亚洲欧美一区| 国产在线精品免费| 国产九色精品成人porny| 久久电影网站中文字幕| 理论片日本一区| 精品中文字幕一区二区| 免费欧美在线视频| 日本在线播放一区二区三区| 午夜影院在线观看欧美| 午夜电影久久久| 午夜精品久久久久久久久久| 午夜影视日本亚洲欧洲精品| 亚洲午夜日本在线观看| 亚洲成人动漫一区| 视频一区在线视频| 久久精品国产99国产精品| 狠狠色丁香婷婷综合久久片| 国产乱码精品一区二区三区av| 国产成人夜色高潮福利影视| 成人白浆超碰人人人人| 99久久99久久免费精品蜜臀| 色婷婷久久一区二区三区麻豆| 欧美日韩在线播放三区| 69成人精品免费视频| 日韩欧美亚洲另类制服综合在线| www国产成人| 国产精品女主播在线观看| 亚洲另类在线制服丝袜| 首页国产欧美日韩丝袜| 久久av老司机精品网站导航| 国产麻豆一精品一av一免费| 丰满放荡岳乱妇91ww| 91玉足脚交白嫩脚丫在线播放| 欧美日韩一区在线| 日韩美女一区二区三区四区| 中文字幕精品综合| 亚洲一区在线观看视频| 男男视频亚洲欧美| 成人永久aaa| 欧洲av在线精品| 欧美成人a在线| 国产精品久久久久久久久搜平片| 亚洲一区二区三区不卡国产欧美| 免费观看久久久4p| 国产不卡视频一区| 欧美三级电影在线观看| 国产网红主播福利一区二区| 亚洲精品乱码久久久久久久久 | 日韩成人av影视| 国产乱一区二区| 欧美三区在线观看| 久久久99精品免费观看| 亚洲美女淫视频| 国产在线日韩欧美| 91福利在线观看| 337p日本欧洲亚洲大胆精品| 一区二区三区色| 国产一区999| 欧美日韩亚洲国产综合| 欧美国产97人人爽人人喊| 亚欧色一区w666天堂| 国产91在线|亚洲| 91精品国产综合久久精品图片 | 精品国产乱码久久久久久牛牛| 中文字幕av资源一区| 日韩和的一区二区| 91捆绑美女网站| 久久久噜噜噜久噜久久综合| 亚洲午夜在线观看视频在线| 成人视屏免费看| 精品国产一区二区国模嫣然| 亚洲一区免费在线观看| 高清不卡在线观看av| 欧美电影免费观看高清完整版| 亚洲免费av在线| 国产 欧美在线| 精品欧美一区二区在线观看| 亚洲一区二区三区四区中文字幕| 粉嫩嫩av羞羞动漫久久久| 制服丝袜激情欧洲亚洲| 亚洲一级电影视频| 91网站最新地址| 国产欧美日韩卡一| 国产在线乱码一区二区三区| 91精品国产综合久久久久| 亚洲一区二区三区美女| 91免费版pro下载短视频| 久久精品一区二区三区不卡牛牛| 蜜桃视频一区二区三区在线观看| 91国偷自产一区二区三区观看| 国产精品久久久久久久浪潮网站| 风间由美一区二区三区在线观看| 久久久久97国产精华液好用吗| 久热成人在线视频| 日韩精品一区二区三区视频播放| 午夜精品免费在线| 欧美久久久久免费| 亚洲国产精品自拍| 欧美性受xxxx黑人xyx| 亚洲精品综合在线| 91视频在线看| 一区二区三区在线视频播放| 一本久久精品一区二区| 亚洲欧美日韩在线播放| 91免费版在线| 亚洲综合在线电影| 欧洲精品视频在线观看| 午夜日韩在线观看| 欧美一区二区三区白人| 首页国产欧美久久| 日韩精品一区二区在线观看| 久久精品国产99久久6| 精品sm在线观看| 成人午夜精品一区二区三区| 国产精品视频一二三区| 色呦呦国产精品| 石原莉奈一区二区三区在线观看| 欧美高清视频不卡网| 裸体一区二区三区| 精品999久久久| 不卡的av电影| 夜夜亚洲天天久久| 91精品国产一区二区人妖| 久久不见久久见中文字幕免费| 久久婷婷国产综合精品青草| 成人国产一区二区三区精品| 亚洲免费av高清| 7777精品伊人久久久大香线蕉的| 久久成人久久爱| 国产婷婷色一区二区三区在线| k8久久久一区二区三区| 亚洲国产视频一区二区| 日韩一区二区免费高清| 国产成人综合视频| 有码一区二区三区| 欧美sm美女调教| 99r精品视频| 日韩电影免费在线观看网站| 久久久欧美精品sm网站| 色综合天天综合网天天看片 | yourporn久久国产精品| 亚洲精品欧美综合四区| 91精品久久久久久久99蜜桃| 国产精品一区久久久久| 亚洲精品成人少妇| 日韩欧美电影一区| 色婷婷av一区| 狠狠久久亚洲欧美| 一区二区三区不卡视频在线观看| 日韩女同互慰一区二区| 91欧美激情一区二区三区成人| 免费在线观看不卡| 中文字幕中文字幕一区| 欧美一区二区三区思思人| 99久精品国产| 久久国产夜色精品鲁鲁99| 一区二区在线观看不卡| 久久色在线视频| 欧美日韩一级二级| 大白屁股一区二区视频| 亚洲国产日韩综合久久精品| 中文无字幕一区二区三区| 欧美一区二区性放荡片| 91女厕偷拍女厕偷拍高清| 国内精品伊人久久久久影院对白|