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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? jcphuff.c

?? MPEG4解碼程序源代碼(能夠?qū)Ω鞣NMPEG4文件進行解碼)
?? C
?? 第 1 頁 / 共 2 頁
字號:
////////////////////////////////////////////////////////////////////////
//
//	Note : this file is included as part of the Smaller Animals Software
//	JpegFile package. Though this file has not been modified from it's 
//	original IJG 6a form, it is not the responsibility on the Independent
//	JPEG Group to answer questions regarding this code.
//	
//	Any questions you have about this code should be addressed to :
//
//	CHRISDL@PAGESZ.NET	- the distributor of this package.
//
//	Remember, by including this code in the JpegFile package, Smaller 
//	Animals Software assumes all responsibilities for answering questions
//	about it. If we (SA Software) can't answer your questions ourselves, we 
//	will direct you to people who can.
//
//	Thanks, CDL.
//
////////////////////////////////////////////////////////////////////////

/*
 * jcphuff.c
 *
 * Copyright (C) 1995-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 Huffman entropy encoding routines for progressive JPEG.
 *
 * We do not support output suspension in this module, since the library
 * currently does not allow multiple-scan files to be written with output
 * suspension.
 */

#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jchuff.h"		/* Declarations shared with jchuff.c */

#ifdef C_PROGRESSIVE_SUPPORTED

/* Expanded entropy encoder object for progressive Huffman encoding. */

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

  /* Mode flag: TRUE for optimization, FALSE for actual data output */
  boolean gather_statistics;

  /* Bit-level coding status.
   * next_output_byte/free_in_buffer are local copies of cinfo->dest fields.
   */
  JOCTET * next_output_byte;	/* => next byte to write in buffer */
  size_t free_in_buffer;	/* # of byte spaces remaining in buffer */
  long put_buffer;		/* current bit-accumulation buffer */
  int put_bits;			/* # of bits now in it */
  j_compress_ptr cinfo;		/* link to cinfo (needed for dump_buffer) */

  /* Coding status for DC components */
  int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */

  /* Coding status for AC components */
  int ac_tbl_no;		/* the table number of the single component */
  unsigned int EOBRUN;		/* run length of EOBs */
  unsigned int BE;		/* # of buffered correction bits before MCU */
  char * bit_buffer;		/* buffer for correction bits (1 per char) */
  /* packing correction bits tightly would save some space but cost time... */

  unsigned int restarts_to_go;	/* MCUs left in this restart interval */
  int next_restart_num;		/* next restart number to write (0-7) */

  /* Pointers to derived tables (these workspaces have image lifespan).
   * Since any one scan codes only DC or only AC, we only need one set
   * of tables, not one for DC and one for AC.
   */
  c_derived_tbl * derived_tbls[NUM_HUFF_TBLS];

  /* Statistics tables for optimization; again, one set is enough */
  long * count_ptrs[NUM_HUFF_TBLS];
} phuff_entropy_encoder;

typedef phuff_entropy_encoder * phuff_entropy_ptr;

/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit
 * buffer can hold.  Larger sizes may slightly improve compression, but
 * 1000 is already well into the realm of overkill.
 * The minimum safe size is 64 bits.
 */

#define MAX_CORR_BITS  1000	/* Max # of correction bits I can buffer */

/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than long.
 * We assume that int right shift is unsigned if long right shift is,
 * which should be safe.
 */

#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define ISHIFT_TEMPS	int ishift_temp;
#define IRIGHT_SHIFT(x,shft)  \
	((ishift_temp = (x)) < 0 ? \
	 (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
	 (ishift_temp >> (shft)))
#else
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT(x,shft)	((x) >> (shft))
#endif

/* Forward declarations */
METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo,
					    JBLOCKROW *MCU_data));
METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo,
					    JBLOCKROW *MCU_data));
METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo,
					     JBLOCKROW *MCU_data));
METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo,
					     JBLOCKROW *MCU_data));
METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo));
METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo));


/*
 * Initialize for a Huffman-compressed scan using progressive JPEG.
 */

METHODDEF(void)
start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
{  
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
  boolean is_DC_band;
  int ci, tbl;
  jpeg_component_info * compptr;

  entropy->cinfo = cinfo;
  entropy->gather_statistics = gather_statistics;

  is_DC_band = (cinfo->Ss == 0);

  /* We assume jcmaster.c already validated the scan parameters. */

  /* Select execution routines */
  if (cinfo->Ah == 0) {
    if (is_DC_band)
      entropy->pub.encode_mcu = encode_mcu_DC_first;
    else
      entropy->pub.encode_mcu = encode_mcu_AC_first;
  } else {
    if (is_DC_band)
      entropy->pub.encode_mcu = encode_mcu_DC_refine;
    else {
      entropy->pub.encode_mcu = encode_mcu_AC_refine;
      /* AC refinement needs a correction bit buffer */
      if (entropy->bit_buffer == NULL)
	entropy->bit_buffer = (char *)
	  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				      MAX_CORR_BITS * SIZEOF(char));
    }
  }
  if (gather_statistics)
    entropy->pub.finish_pass = finish_pass_gather_phuff;
  else
    entropy->pub.finish_pass = finish_pass_phuff;

  /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1
   * for AC coefficients.
   */
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
    compptr = cinfo->cur_comp_info[ci];
    /* Initialize DC predictions to 0 */
    entropy->last_dc_val[ci] = 0;
    /* Make sure requested tables are present */
    /* (In gather mode, tables need not be allocated yet) */
    if (is_DC_band) {
      if (cinfo->Ah != 0)	/* DC refinement needs no table */
	continue;
      tbl = compptr->dc_tbl_no;
      if (tbl < 0 || tbl >= NUM_HUFF_TBLS ||
	  (cinfo->dc_huff_tbl_ptrs[tbl] == NULL && !gather_statistics))
	ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl);
    } else {
      entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;
      if (tbl < 0 || tbl >= NUM_HUFF_TBLS ||
          (cinfo->ac_huff_tbl_ptrs[tbl] == NULL && !gather_statistics))
        ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl);
    }
    if (gather_statistics) {
      /* Allocate and zero the statistics tables */
      /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
      if (entropy->count_ptrs[tbl] == NULL)
	entropy->count_ptrs[tbl] = (long *)
	  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
				      257 * SIZEOF(long));
      MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long));
    } else {
      /* Compute derived values for Huffman tables */
      /* We may do this more than once for a table, but it's not expensive */
      if (is_DC_band)
        jpeg_make_c_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[tbl],
				& entropy->derived_tbls[tbl]);
      else
        jpeg_make_c_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[tbl],
				& entropy->derived_tbls[tbl]);
    }
  }

  /* Initialize AC stuff */
  entropy->EOBRUN = 0;
  entropy->BE = 0;

  /* Initialize bit buffer to empty */
  entropy->put_buffer = 0;
  entropy->put_bits = 0;

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


/* Outputting bytes to the file.
 * NB: these must be called only when actually outputting,
 * that is, entropy->gather_statistics == FALSE.
 */

/* Emit a byte */
#define emit_byte(entropy,val)  \
	{ *(entropy)->next_output_byte++ = (JOCTET) (val);  \
	  if (--(entropy)->free_in_buffer == 0)  \
	    dump_buffer(entropy); }


LOCAL(void)
dump_buffer (phuff_entropy_ptr entropy)
/* Empty the output buffer; we do not support suspension in this module. */
{
  struct jpeg_destination_mgr * dest = entropy->cinfo->dest;

  if (! (*dest->empty_output_buffer) (entropy->cinfo))
    ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
  /* After a successful buffer dump, must reset buffer pointers */
  entropy->next_output_byte = dest->next_output_byte;
  entropy->free_in_buffer = dest->free_in_buffer;
}


/* Outputting bits to the file */

/* Only the right 24 bits of 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 put_buffer
 * between calls, so 24 bits are sufficient.
 */

INLINE
LOCAL(void)
emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
/* Emit some bits, unless we are in gather mode */
{
  /* This routine is heavily used, so it's worth coding tightly. */
  register long put_buffer = (long) code;
  register int put_bits = entropy->put_bits;

  /* if size is 0, caller used an invalid Huffman table entry */
  if (size == 0)
    ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);

  if (entropy->gather_statistics)
    return;			/* do nothing if we're only getting stats */

  put_buffer &= (((long) 1)<<size) - 1; /* mask off any extra bits in code */
  
  put_bits += size;		/* new number of bits in buffer */
  
  put_buffer <<= 24 - put_bits; /* align incoming bits */

  put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */

  while (put_bits >= 8) {
    int c = (int) ((put_buffer >> 16) & 0xFF);
    
    emit_byte(entropy, c);
    if (c == 0xFF) {		/* need to stuff a zero byte? */
      emit_byte(entropy, 0);
    }
    put_buffer <<= 8;
    put_bits -= 8;
  }

  entropy->put_buffer = put_buffer; /* update variables */
  entropy->put_bits = put_bits;
}


LOCAL(void)
flush_bits (phuff_entropy_ptr entropy)
{
  emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
  entropy->put_buffer = 0;     /* and reset bit-buffer to empty */
  entropy->put_bits = 0;
}


/*
 * Emit (or just count) a Huffman symbol.
 */

INLINE
LOCAL(void)
emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
{
  if (entropy->gather_statistics)
    entropy->count_ptrs[tbl_no][symbol]++;
  else {
    c_derived_tbl * tbl = entropy->derived_tbls[tbl_no];
    emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
  }
}


/*
 * Emit bits from a correction bit buffer.
 */

LOCAL(void)
emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart,
		    unsigned int nbits)
{
  if (entropy->gather_statistics)
    return;			/* no real work */

  while (nbits > 0) {
    emit_bits(entropy, (unsigned int) (*bufstart), 1);
    bufstart++;
    nbits--;
  }
}


/*
 * Emit any pending EOBRUN symbol.
 */

LOCAL(void)
emit_eobrun (phuff_entropy_ptr entropy)
{
  register int temp, nbits;

  if (entropy->EOBRUN > 0) {	/* if there is any pending EOBRUN */
    temp = entropy->EOBRUN;
    nbits = 0;
    while ((temp >>= 1))
      nbits++;

    emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
    if (nbits)
      emit_bits(entropy, entropy->EOBRUN, nbits);

    entropy->EOBRUN = 0;

    /* Emit any buffered correction bits */
    emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
    entropy->BE = 0;
  }
}


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

LOCAL(void)
emit_restart (phuff_entropy_ptr entropy, int restart_num)
{
  int ci;

  emit_eobrun(entropy);

  if (! entropy->gather_statistics) {
    flush_bits(entropy);
    emit_byte(entropy, 0xFF);
    emit_byte(entropy, JPEG_RST0 + restart_num);
  }

  if (entropy->cinfo->Ss == 0) {
    /* Re-initialize DC predictions to 0 */
    for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
      entropy->last_dc_val[ci] = 0;
  } else {
    /* Re-initialize all AC-related fields to 0 */
    entropy->EOBRUN = 0;
    entropy->BE = 0;
  }
}


/*
 * MCU encoding for DC initial scan (either spectral selection,
 * or first pass of successive approximation).
 */

METHODDEF(boolean)
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
  register int temp, temp2;
  register int nbits;
  int blkn, ci;
  int Al = cinfo->Al;
  JBLOCKROW block;
  jpeg_component_info * compptr;
  ISHIFT_TEMPS

  entropy->next_output_byte = cinfo->dest->next_output_byte;
  entropy->free_in_buffer = cinfo->dest->free_in_buffer;

  /* Emit restart marker if needed */
  if (cinfo->restart_interval)
    if (entropy->restarts_to_go == 0)
      emit_restart(entropy, entropy->next_restart_num);

  /* Encode the MCU data blocks */
  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
    block = MCU_data[blkn];
    ci = cinfo->MCU_membership[blkn];
    compptr = cinfo->cur_comp_info[ci];

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
2020日本不卡一区二区视频| 中文字幕第一页久久| 国产露脸91国语对白| 国产精品国产三级国产有无不卡| 欧美天堂一区二区三区| 国产一区欧美一区| 亚洲一区二区三区四区在线观看 | 欧美激情在线看| 欧美性猛交xxxxxx富婆| 国产精一区二区三区| 伊人色综合久久天天人手人婷| 精品国产乱码久久久久久蜜臀| 色婷婷久久久综合中文字幕 | 亚洲精品视频在线观看免费| 久久一区二区三区国产精品| 欧洲人成人精品| www.亚洲人| 国产乱码一区二区三区| 日韩和欧美一区二区| 一区二区三区精品久久久| 国产欧美精品区一区二区三区| 91精品欧美一区二区三区综合在| 一本久道久久综合中文字幕| 福利一区福利二区| 久久草av在线| 日韩不卡一区二区| 亚洲国产另类av| 一区在线观看视频| 日本一区二区三区免费乱视频| 久久午夜国产精品| 日韩欧美久久久| 欧美一区二区三区四区视频| 欧美日韩黄色一区二区| 欧美影视一区在线| 色悠久久久久综合欧美99| 成人免费观看男女羞羞视频| 国产一二精品视频| 国产在线精品一区二区夜色| 精品在线你懂的| 蜜桃av一区二区在线观看| 男女男精品视频网| 美女一区二区久久| 国产在线视频精品一区| 韩国视频一区二区| 国产精品香蕉一区二区三区| 国产精品中文字幕日韩精品| 国产精品自在欧美一区| 国产91丝袜在线播放| 国产jizzjizz一区二区| 丁香啪啪综合成人亚洲小说 | 国产一区二区调教| 国产乱子轮精品视频| 国产成人精品一区二区三区四区| 高清久久久久久| 99精品视频在线免费观看| 99国产精品久久久久久久久久| eeuss鲁片一区二区三区| 成人妖精视频yjsp地址| 国产 欧美在线| 国产精品 欧美精品| 蜜臀久久久久久久| 国产成人精品午夜视频免费| 国产一区中文字幕| 国内精品嫩模私拍在线| 久久99精品久久久久久| 激情小说欧美图片| 国内精品免费**视频| 国产在线精品一区在线观看麻豆| 精品写真视频在线观看| 国产乱人伦偷精品视频不卡| 麻豆精品在线视频| 大陆成人av片| 成人伦理片在线| 91亚洲精品一区二区乱码| 94色蜜桃网一区二区三区| 91麻豆精品一区二区三区| 91小视频免费观看| 欧美日韩中文国产| 91精品视频网| 精品国产区一区| 亚洲视频资源在线| 亚洲成人在线网站| 蜜桃视频在线一区| 国产99久久久久久免费看农村| 国产一区二区毛片| 99久久精品国产网站| 91激情五月电影| 日韩一级大片在线| 国产欧美日韩视频一区二区| 亚洲日韩欧美一区二区在线| 亚洲国产成人91porn| 免费的国产精品| 国产精品一区二区你懂的| 91小视频免费观看| 欧美一区二区三区四区视频| 欧美激情一区二区| 亚洲黄网站在线观看| 美日韩黄色大片| 成人开心网精品视频| 99精品欧美一区二区蜜桃免费| 欧美性xxxxxxxx| 久久综合五月天婷婷伊人| 中文无字幕一区二区三区 | 国模套图日韩精品一区二区 | 欧美日韩不卡一区二区| 精品国一区二区三区| 亚洲欧洲在线观看av| 日本欧美大码aⅴ在线播放| 国产aⅴ综合色| 精品国产一区二区三区四区四 | 欧美日韩黄色一区二区| 久久久久久久综合色一本| 亚洲精品国产高清久久伦理二区| 蜜桃久久精品一区二区| 91在线播放网址| 日韩精品一区二区三区视频| 久久久久高清精品| 久久99国产精品成人| 色综合久久久久| 久久亚洲免费视频| 亚洲动漫第一页| 欧美一区二区私人影院日本| 欧美国产精品久久| 日韩精品三区四区| caoporen国产精品视频| 日韩一级片在线观看| 亚洲一区二区三区四区不卡| 成人一区二区三区| 日韩欧美国产一区在线观看| 一区二区三区在线视频免费| 国产精品12区| 久久综合九色欧美综合狠狠| 亚洲va天堂va国产va久| eeuss鲁片一区二区三区| 久久精品在线观看| 免费观看在线综合| 欧美手机在线视频| 亚洲人亚洲人成电影网站色| 国产寡妇亲子伦一区二区| 日韩一区二区三区电影在线观看| 亚洲嫩草精品久久| 色婷婷综合久久久中文字幕| 国产精品美女一区二区三区| 国产在线国偷精品免费看| 日韩精品综合一本久道在线视频| 亚洲国产美女搞黄色| 91国产精品成人| 亚洲欧美日韩国产手机在线| 日本乱人伦aⅴ精品| 亚洲免费看黄网站| 91在线国产福利| 国产精品国产三级国产普通话99 | 色呦呦国产精品| 国产精品视频观看| 91小视频免费看| 亚洲人成伊人成综合网小说| 91在线无精精品入口| 亚洲视频资源在线| 91免费国产视频网站| 亚洲免费在线视频一区 二区| 高清成人在线观看| 国产日韩精品一区二区三区在线| 国模套图日韩精品一区二区| 久久久亚洲综合| 国产成都精品91一区二区三| 欧美激情一区二区三区不卡| 成人免费三级在线| 亚洲欧美另类图片小说| 94色蜜桃网一区二区三区| 亚洲成av人在线观看| 欧美人牲a欧美精品| 蜜臀av在线播放一区二区三区| 欧美成人精品二区三区99精品| 加勒比av一区二区| 久久久不卡影院| 成人激情动漫在线观看| 日韩美女啊v在线免费观看| 91麻豆蜜桃一区二区三区| 亚洲高清视频在线| 日韩欧美综合一区| 国产精品一区一区| 中文字幕中文在线不卡住| 99re这里都是精品| 亚洲成av人片在www色猫咪| 91精品国产综合久久精品app| 久久国产精品一区二区| 欧美国产在线观看| 在线日韩国产精品| 蜜臀久久99精品久久久久宅男 | 蜜桃免费网站一区二区三区| 日本一区二区三区dvd视频在线| 91麻豆国产福利在线观看| 亚洲成人一区二区在线观看| 日韩欧美成人一区二区| 成人性生交大片免费| 一个色综合av| 欧美精品一区二区三区视频| 972aa.com艺术欧美| 日韩国产精品久久| 国产欧美日韩综合精品一区二区 |