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

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

?? jchuff.c

?? EVM板JPEG實現,Texas Instruments TMS320C54x EVM JPEG
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * jchuff.c
 *
 * Copyright (C) 1991, 1992, 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 Huffman entropy encoding routines.
 * These routines are invoked via the methods entropy_encode,
 * entropy_encode_init/term, and entropy_optimize.
 */

/* Changes were made to this program by eliminating the error messages,
   because the SWDS does not suppot direct file i/o.  Christopher Chang
   Summer 1993.
*/

#include "jinclude.h"


/* Static variables to avoid passing 'round extra parameters */

static compress_info_ptr cinfo;

static INT32 huff_put_buffer;   /* current bit-accumulation buffer */
static int huff_put_bits;   /* # of bits now in it */

static char * output_buffer;    /* output buffer */
static int bytes_in_buffer;



LOCAL void
fix_huff_tbl (HUFF_TBL * htbl)
/* Compute derived values for a Huffman table */
{
  int p, i, l, lastp, si;
  char huffsize[257];
  UINT16 huffcode[257];
  UINT16 code;
  
  /* Figure C.1: make table of Huffman code length for each symbol */
  /* Note that this is in code-length order. */

  p = 0;
  for (l = 1; l <= 16; l++) {
	for (i = 1; i <= (int) htbl->bits[l]; i++)
	  huffsize[p++] = (char) l;
  }
  huffsize[p] = 0;
  lastp = p;
  
  /* Figure C.2: generate the codes themselves */
  /* Note that this is in code-length order. */
  
  code = 0;
  si = huffsize[0];
  p = 0;
  while (huffsize[p]) {
	while (((int) huffsize[p]) == si) {
	  huffcode[p++] = code;
	  code++;
	}
	code <<= 1;
	si++;
  }
  
  /* Figure C.3: generate encoding tables */
  /* These are code and size indexed by symbol value */

  /* Set any codeless symbols to have code length 0;
   * this allows emit_bits to detect any attempt to emit such symbols.
   */
  MEMZERO(htbl->ehufsi, SIZEOF(htbl->ehufsi));

  for (p = 0; p < lastp; p++) {
	htbl->ehufco[htbl->huffval[p]] = huffcode[p];
	htbl->ehufsi[htbl->huffval[p]] = huffsize[p];
  }
  
  /* We don't bother to fill in the decoding tables mincode[], maxcode[], */
  /* and valptr[], since they are not used for encoding. */
}


/* Outputting bytes to the file */

LOCAL void
flush_bytes (void)
{
  if (bytes_in_buffer)
	(*cinfo->methods->entropy_output) (cinfo, output_buffer, bytes_in_buffer);
  bytes_in_buffer = 0;
}


#define emit_byte(val)  \
  MAKESTMT( if (bytes_in_buffer >= JPEG_BUF_SIZE) \
		  flush_bytes(); \
		output_buffer[bytes_in_buffer++] = (char) (val); )



/* Outputting bits to the file */

/* Only the right 24 bits of huff_put_buffer are used; the valid bits are
 * left-justified in this part.  At most 16 bits can be passed to emit_bits
 * in one call, and we never retain more than 7 bits in huff_put_buffer
 * between calls, so 24 bits are sufficient.
 */

INLINE
LOCAL void
emit_bits (UINT16 code, int size)
{
  /* This routine is heavily used, so it's worth coding tightly. */
  register INT32 put_buffer = code;
  register int put_bits = huff_put_bits;

  /* if size is 0, caller used an invalid Huffman table entry */

/*************************DID NOT SUPPORT THIS ERROR**********************  
  if (size == 0)                       
	ERREXIT(cinfo->emethods);
		(cinfo->emethods, "Missing Huffman code table entry");
**************************************************************************/
																		 
  put_buffer &= (((INT32) 1) << size) - 1; /* Mask off any excess bits in code */
  
  put_bits += size;     /* new number of bits in buffer */
  
  put_buffer <<= 24 - put_bits; /* align incoming bits */

  put_buffer |= huff_put_buffer; /* and merge with old buffer contents */
  
  while (put_bits >= 8) {
	int c = (int) ((put_buffer >> 16) & 0xFF);
	
	emit_byte(c);
	if (c == 0xFF) {        /* need to stuff a zero byte? */
	  emit_byte(0);
	}
	put_buffer <<= 8;
	put_bits -= 8;
  }

  huff_put_buffer = put_buffer; /* Update global variables */
  huff_put_bits = put_bits;
}


LOCAL void
flush_bits (void)
{
  emit_bits((UINT16) 0x7F, 7);  /* fill any partial byte with ones */
  huff_put_buffer = 0;      /* and reset bit-buffer to empty */
  huff_put_bits = 0;
}



/* Encode a single block's worth of coefficients */
/* Note that the DC coefficient has already been converted to a difference */

LOCAL void
encode_one_block (JBLOCK block, HUFF_TBL *dctbl, HUFF_TBL *actbl)
{
  register int temp, temp2;
  register int nbits;
  register int k, r, i;
  
  /* Encode the DC coefficient difference per section F.1.2.1 */
  
  temp = temp2 = block[0];

  if (temp < 0) {
	temp = -temp;       /* temp is abs value of input */
	/* For a negative input, want temp2 = bitwise complement of abs(input) */
	/* This code assumes we are on a two's complement machine */
	temp2--;
  }
  
  /* Find the number of bits needed for the magnitude of the coefficient */
  nbits = 0;
  while (temp) {
	nbits++;
	temp >>= 1;
  }
  
  /* Emit the Huffman-coded symbol for the number of bits */
  emit_bits(dctbl->ehufco[nbits], dctbl->ehufsi[nbits]);

  /* Emit that number of bits of the value, if positive, */
  /* or the complement of its magnitude, if negative. */
  if (nbits)            /* emit_bits rejects calls with size 0 */
	emit_bits((UINT16) temp2, nbits);
  
  /* Encode the AC coefficients per section F.1.2.2 */
  
  r = 0;            /* r = run length of zeros */
  
  for (k = 1; k < DCTSIZE2; k++) {
	if ((temp = block[k]) == 0) {
	  r++;
	} else {
	  /* if run length > 15, must emit special run-length-16 codes (0xF0) */
	  while (r > 15) {
	emit_bits(actbl->ehufco[0xF0], actbl->ehufsi[0xF0]);
	r -= 16;
	  }

	  temp2 = temp;
	  if (temp < 0) {
	temp = -temp;       /* temp is abs value of input */
	/* This code assumes we are on a two's complement machine */
	temp2--;
	  }
	  
	  /* Find the number of bits needed for the magnitude of the coefficient */
	  nbits = 1;        /* there must be at least one 1 bit */
	  while (temp >>= 1)
	nbits++;
	  
	  /* Emit Huffman symbol for run length / number of bits */
	  i = (r << 4) + nbits;
	  emit_bits(actbl->ehufco[i], actbl->ehufsi[i]);
	  
	  /* Emit that number of bits of the value, if positive, */
	  /* or the complement of its magnitude, if negative. */
	  emit_bits((UINT16) temp2, nbits);
	  
	  r = 0;
	}
  }

  /* If the last coef(s) were zero, emit an end-of-block code */
  if (r > 0)
	emit_bits(actbl->ehufco[0], actbl->ehufsi[0]);
}



/*
 * Initialize for a Huffman-compressed scan.
 * This is invoked after writing the SOS marker.
 * The pipeline controller must establish the entropy_output method pointer
 * before calling this routine.
 */

METHODDEF void
huff_init (compress_info_ptr xinfo)
{
  short ci;
  jpeg_component_info * compptr;

  /* Initialize static variables */
  cinfo = xinfo;
  huff_put_buffer = 0;
  huff_put_bits = 0;

  /* Initialize the output buffer */
  output_buffer = (char *) (*cinfo->emethods->alloc_small)
				((size_t) JPEG_BUF_SIZE);
  bytes_in_buffer = 0;

  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
	compptr = cinfo->cur_comp_info[ci];
	/* Make sure requested tables are present */

/*******************DID NOT SUPPORT THIS ERROR MESSAGE********************
if (cinfo->dc_huff_tbl_ptrs[compptr->dc_tbl_no] == NULL ||
	cinfo->ac_huff_tbl_ptrs[compptr->ac_tbl_no] == NULL)
	ERREXIT(cinfo->emethods);  
***************************************************************************/      

	  /*(cinfo->emethods, "Use of undefined Huffman table");*/
	/* Compute derived values for Huffman tables */
	/* We may do this more than once for same table, but it's not a big deal */
	fix_huff_tbl(cinfo->dc_huff_tbl_ptrs[compptr->dc_tbl_no]);
	fix_huff_tbl(cinfo->ac_huff_tbl_ptrs[compptr->ac_tbl_no]);
	/* Initialize DC predictions to 0 */
	cinfo->last_dc_val[ci] = 0;
  }

  /* Initialize restart stuff */
  cinfo->restarts_to_go = cinfo->restart_interval;
  cinfo->next_restart_num = 0;
}


/*
 * Emit a restart marker & resynchronize predictions.
 */

LOCAL void
emit_restart (compress_info_ptr cinfo)
{
  short ci;

  flush_bits();

  emit_byte(0xFF);
  emit_byte(RST0 + cinfo->next_restart_num);

  /* Re-initialize DC predictions to 0 */
  for (ci = 0; ci < cinfo->comps_in_scan; ci++)
	cinfo->last_dc_val[ci] = 0;

  /* Update restart state */
  cinfo->restarts_to_go = cinfo->restart_interval;
  cinfo->next_restart_num++;
  cinfo->next_restart_num &= 7;
}


/*
 * Encode and output one MCU's worth of Huffman-compressed coefficients.
 */

METHODDEF void
huff_encode (compress_info_ptr cinfo, JBLOCK *MCU_data)
{
  short blkn, ci;
  jpeg_component_info * compptr;
  JCOEF temp;

  /* Account for restart interval, emit restart marker if needed */
  if (cinfo->restart_interval) {
	if (cinfo->restarts_to_go == 0)
	  emit_restart(cinfo);
	cinfo->restarts_to_go--;
  }

  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
	ci = cinfo->MCU_membership[blkn];
	compptr = cinfo->cur_comp_info[ci];
	/* Convert DC value to difference, update last_dc_val */
	temp = MCU_data[blkn][0];
	MCU_data[blkn][0] -= cinfo->last_dc_val[ci];
	cinfo->last_dc_val[ci] = temp;
	encode_one_block(MCU_data[blkn],
			 cinfo->dc_huff_tbl_ptrs[compptr->dc_tbl_no],
			 cinfo->ac_huff_tbl_ptrs[compptr->ac_tbl_no]);
  }
}


/*
 * Finish up at the end of a Huffman-compressed scan.
 */

METHODDEF void
huff_term (compress_info_ptr cinfo)
{
  /* Flush out the last data */
  flush_bits();
  flush_bytes();
  /* Release the I/O buffer */
  (*cinfo->emethods->free_small) ((void *) output_buffer);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线三级电影| 亚洲乱码国产乱码精品精98午夜| 国产农村妇女毛片精品久久麻豆 | 中文字幕一区三区| 日韩专区中文字幕一区二区| jlzzjlzz国产精品久久| 欧美不卡123| 婷婷亚洲久悠悠色悠在线播放| 成人性生交大片免费看视频在线| 欧美人妖巨大在线| 日韩伦理电影网| 国产不卡高清在线观看视频| 日韩女优av电影在线观看| 一区二区三区精品| 97精品国产露脸对白| 国产日韩欧美精品一区| 久久精品国产精品亚洲精品| 欧美一a一片一级一片| 亚洲欧美一区二区久久| 成人av资源在线| 国产日韩高清在线| 国产精品一区二区久久不卡 | 国产在线不卡视频| 日韩一区二区电影| 狂野欧美性猛交blacked| 欧美日韩在线不卡| 午夜电影网一区| 欧美福利电影网| 无吗不卡中文字幕| 日韩一区二区三区电影| 久久精品国产在热久久| 日韩欧美国产三级| 精品亚洲欧美一区| 久久精品这里都是精品| 丁香亚洲综合激情啪啪综合| 久久精品亚洲乱码伦伦中文| 国产ts人妖一区二区| 国产欧美一区在线| 91香蕉视频mp4| 亚洲伦理在线精品| 欧美日韩视频一区二区| 日韩av高清在线观看| 欧美va日韩va| 成人国产精品免费观看动漫| 亚洲欧美自拍偷拍| 欧美亚洲高清一区二区三区不卡| 亚洲图片欧美综合| 欧美tickle裸体挠脚心vk| 国产精品一区久久久久| 亚洲丝袜另类动漫二区| 欧美美女直播网站| 韩国成人福利片在线播放| 国产精品丝袜一区| 欧美在线视频日韩| 精品在线播放午夜| 中文一区二区完整视频在线观看| 一本到高清视频免费精品| 午夜国产精品影院在线观看| 久久在线观看免费| 色爱区综合激月婷婷| 日韩成人dvd| 欧美激情在线一区二区三区| 欧美午夜电影网| 国产麻豆精品在线| 亚洲一区影音先锋| 久久综合色一综合色88| 99re亚洲国产精品| 久久99精品久久只有精品| 亚洲视频 欧洲视频| 日韩欧美成人激情| 日本韩国精品一区二区在线观看| 久久99精品国产麻豆不卡| 国产精品久久久久久久蜜臀| 欧美一区二区国产| 99在线精品免费| 国内精品伊人久久久久av影院 | 亚洲欧洲精品天堂一级| 91精品国产91综合久久蜜臀| 91在线国产福利| 九一九一国产精品| 午夜成人在线视频| 亚洲欧美日韩电影| 欧美激情在线一区二区三区| 日韩一区二区三区在线| 欧美亚洲尤物久久| 不卡的电视剧免费网站有什么| 日韩av二区在线播放| 一区二区三区四区在线| 国产亚洲短视频| 日韩你懂的电影在线观看| 日本高清不卡视频| 91在线国内视频| 成人精品高清在线| 国产成人在线观看免费网站| 青娱乐精品在线视频| 午夜精品一区二区三区电影天堂 | 一本高清dvd不卡在线观看| 国产精品18久久久久久久久久久久| 午夜精品视频在线观看| 亚洲美女在线国产| 亚洲日本乱码在线观看| 国产精品私房写真福利视频| 国产日韩欧美亚洲| 国产欧美一二三区| 久久亚洲二区三区| 久久亚洲精品国产精品紫薇| 精品国产髙清在线看国产毛片| 欧美一区日韩一区| 日韩一区和二区| 欧美va天堂va视频va在线| 日韩免费看的电影| 久久婷婷国产综合国色天香| 精品国产一区久久| 26uuu久久综合| 国产丝袜欧美中文另类| 国产午夜亚洲精品理论片色戒 | 国产精品欧美经典| 国产午夜三级一区二区三| 国产片一区二区| 中文字幕一区二区三区在线不卡 | 91精品国产色综合久久不卡蜜臀| 欧美自拍丝袜亚洲| 欧美日韩中文字幕一区二区| 欧美日韩一区二区在线观看| 欧美日韩国产中文| 欧美精品一区二区三区蜜桃| 久久久噜噜噜久久中文字幕色伊伊 | 国产欧美一区二区精品忘忧草| 欧美精彩视频一区二区三区| 亚洲欧洲99久久| 一区二区三区 在线观看视频| 亚洲国产视频一区二区| 日本午夜一区二区| 国产成人综合在线| 色综合一区二区| 欧美一区二区三级| 国产日本亚洲高清| 夜夜嗨av一区二区三区网页| 日本va欧美va精品| 国产成人综合在线观看| 一本色道a无线码一区v| 日韩一区二区三区精品视频| 欧美经典一区二区三区| 亚洲影视资源网| 激情综合色综合久久综合| hitomi一区二区三区精品| 91成人网在线| 久久免费午夜影院| 亚洲免费观看在线视频| 美国十次了思思久久精品导航| 风间由美一区二区三区在线观看| 色噜噜狠狠色综合中国| 日韩一区二区三区精品视频| 国产精品久久久久毛片软件| 五月天精品一区二区三区| 国产精品99久久久久久宅男| 欧美三级电影网| 中文字幕五月欧美| 精品一区二区三区影院在线午夜| 日本黄色一区二区| 日本一区二区三区四区| 热久久免费视频| 91在线观看一区二区| 精品国产1区二区| 亚洲国产精品久久久久婷婷884 | 国产成人欧美日韩在线电影| 精品视频一区二区三区免费| 国产精品国产自产拍高清av王其| 蜜臀99久久精品久久久久久软件| 99精品久久免费看蜜臀剧情介绍| 欧美v日韩v国产v| 五月天久久比比资源色| 色噜噜狠狠一区二区三区果冻| 欧美国产精品v| 国产在线精品一区二区夜色 | 亚洲国产经典视频| 蜜桃视频在线观看一区| 欧美日本在线播放| 亚洲综合在线五月| 99riav久久精品riav| 久久久精品黄色| 精油按摩中文字幕久久| 欧美性三三影院| 一区二区三区在线免费观看| 成人性生交大片免费看中文| 久久综合色播五月| 国内精品在线播放| 精品国产制服丝袜高跟| 久久精品国产亚洲高清剧情介绍 | 欧美日韩综合一区| 一区二区三区在线看| 色一情一乱一乱一91av| 国产精品区一区二区三区| 夫妻av一区二区| 中文字幕一区二区三区不卡在线 | 欧美tickling挠脚心丨vk| 老鸭窝一区二区久久精品| 日韩午夜小视频| 精品综合免费视频观看| 亚洲精品一区二区三区在线观看|