当前位置: 首页>>代码示例>>C++>>正文


C++ MAXCODE函数代码示例

本文整理汇总了C++中MAXCODE函数的典型用法代码示例。如果您正苦于以下问题:C++ MAXCODE函数的具体用法?C++ MAXCODE怎么用?C++ MAXCODE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MAXCODE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: output

static void
output(int code)
{
    cur_accum &= masks[cur_bits];

    if (cur_bits > 0)
        cur_accum |= ((long)code << cur_bits);
    else
        cur_accum = code;

    cur_bits += n_bits;

    while( cur_bits >= 8 ) {
        char_out( (int)((unsigned int) cur_accum & 0xff) );
        cur_accum >>= 8;
        cur_bits -= 8;
    }

    /*
     * If the next entry is going to be too big for the code size, then
     * increase it, if possible.
     */
    if (free_ent > maxcode || clear_flg) {
        if (clear_flg) {
            maxcode = MAXCODE (n_bits = g_init_bits);
            clear_flg = 0;
        } else {
            n_bits++;

            if ( n_bits == maxbits )
                maxcode = maxmaxcode;
            else
                maxcode = MAXCODE(n_bits);
        }
    }

    if (code == EOFCode) {
        /* At EOF, write the rest of the buffer */
        while( cur_bits > 0 ) {
            char_out( (int)((unsigned int)cur_accum & 0xff) );
            cur_accum >>= 8;
            cur_bits -= 8;
        }

        flush_char();
        fflush( g_outfile );

#ifdef FOO
        if(ferror( g_outfile))
            FatalError("unable to write GIF file");
#endif
    }
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:53,代码来源:hdfgifwr.c

示例2: output

static void output(int code, struct aap *a)
{
  a->cur_accum &= masks[a->cur_bits];

  if (a->cur_bits > 0)
    a->cur_accum |= ((long)code << a->cur_bits);
  else
    a->cur_accum = code;
	
  a->cur_bits += a->n_bits;

  while( a->cur_bits >= 8 ) {
    char_out( (int) (a->cur_accum & 0xff), a );
    a->cur_accum >>= 8;
    a->cur_bits -= 8;
  }

  /*
   * If the next entry is going to be too big for the code size,
   * then increase it, if possible.
   */

  if (a->free_ent > a->maxcode || a->clear_flg) {

    if( a->clear_flg ) {
      a->maxcode = MAXCODE (a->n_bits = a->g_init_bits);
      a->clear_flg = 0;
    }
    else {
      a->n_bits++;
      if ( a->n_bits == XV_BITS )
	a->maxcode = (1<<XV_BITS);
      else
	a->maxcode = MAXCODE(a->n_bits);
    }
  }
	
  if( code == a->EOFCode ) {
    /* At EOF, write the rest of the buffer */
    while( a->cur_bits > 0 ) {
      char_out( (int)(a->cur_accum & 0xff), a );
      a->cur_accum >>= 8;
      a->cur_bits -= 8;
    }

    flush_char(a);
	
    fflush( a->g_outfile );

  }
}
开发者ID:msabhijith,项目名称:dgate,代码行数:51,代码来源:xvgifwr.cpp

示例3: output

LOCAL void
output (gif_dest_ptr dinfo, code_int code)
/* Emit a code of n_bits bits */
/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */
{
  dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits;
  dinfo->cur_bits += dinfo->n_bits;

  while (dinfo->cur_bits >= 8) {
    CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF);
    dinfo->cur_accum >>= 8;
    dinfo->cur_bits -= 8;
  }

  /*
   * If the next entry is going to be too big for the code size,
   * then increase it, if possible.  We do this here to ensure
   * that it's done in sync with the decoder's codesize increases.
   */
  if (dinfo->free_code > dinfo->maxcode) {
    dinfo->n_bits++;
    if (dinfo->n_bits == MAX_LZW_BITS)
      dinfo->maxcode = LZW_TABLE_SIZE; /* free_code will never exceed this */
    else
      dinfo->maxcode = MAXCODE(dinfo->n_bits);
  }
}
开发者ID:F5000,项目名称:spree,代码行数:27,代码来源:wrgif.cpp

示例4: MAXCODE

int CsObjectInt::InitComp (BYTE_TYP * outbuf,
                     SAP_INT    outlen,
                     SAP_INT    sumlen)
/*--------------------------------------------------------------------*/
/* Setup header info                                                  */
/* Clear hash table                                                   */
/* Initialize static variables for compression                        */
/*--------------------------------------------------------------------*/
{
  if (outlen < CS_HEAD_SIZE)       /* too small ......................*/
    return CS_E_OUT_BUFFER_LEN;

  if (sumlen <= 0L)
    return CS_E_INVALID_SUMLEN;

  csc.clear_flg      = 0;              /* init compression states ........*/
  csc.ratio          = 0;

  csc.block_compress = BLOCK_MASK;
  csc.maxbits        = CS_BITS;

  csc.checkpoint     = CHECK_GAP;
  csc.maxcode        = MAXCODE (csc.n_bits = INIT_CS_BITS);
  csc.maxmaxcode     = (CODE_INT)1 << CS_BITS;
  csc.free_ent       = ((csc.block_compress) ? FIRST : 256);
  csc.hsize          = HSIZE;
  CL_HASH (csc.hsize);         /* clear hash table .......................*/
                           /* fill in header informations ............*/
  CsSetHead (outbuf, sumlen,
             (BYTE_TYP) ((CS_VERSION << 4) | CS_ALGORITHM),
             (BYTE_TYP) (csc.maxbits | csc.block_compress));

  return 0;
}
开发者ID:jcmuniz,项目名称:pysap,代码行数:34,代码来源:vpa106cslzc.cpp

示例5: while

//-----------------------------------------------------------------
// write an LZW code 
void mgLZWEncode::writeCode(
  mgLZWCode nCode)
{
  // Uses nCurAccum and nCurBits to reblock into 8-bit bytes
  m_curAccum |= ((long) nCode) << m_curBits;
  m_curBits += m_bits;

  while (m_curBits >= 8) 
  {
    writeLZWByte(m_curAccum & 0xFF);
    m_curAccum >>= 8;
    m_curBits -= 8;
  }

  // If the next entry is going to be too big for the code size,
  // then increase it, if possible.  We do this here to ensure
  // that it's done in sync with the decoder's codesize increases.

  if (m_freeCode > m_maxCode) 
  {
    m_bits++;
    if (m_bits == MAX_LZW_BITS)
      m_maxCode = LZW_TABLE_SIZE; // free_code will never exceed this
    else m_maxCode = MAXCODE(m_bits);
  }
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:28,代码来源:mgLZW.cpp

示例6: LZWPreEncode

/*
 * Reset encoding state at the start of a strip.
 */
static int
LZWPreEncode(TIFF* tif, uint16 s)
{
	LZWCodecState *sp = EncoderState(tif);

	(void) s;
	assert(sp != NULL);

	if( sp->enc_hashtab == NULL )
        {
            tif->tif_setupencode( tif );
        }

	sp->lzw_nbits = BITS_MIN;
	sp->lzw_maxcode = MAXCODE(BITS_MIN);
	sp->lzw_free_ent = CODE_FIRST;
	sp->lzw_nextbits = 0;
	sp->lzw_nextdata = 0;
	sp->enc_checkpoint = CHECK_GAP;
	sp->enc_ratio = 0;
	sp->enc_incount = 0;
	sp->enc_outcount = 0;
	/*
	 * The 4 here insures there is space for 2 max-sized
	 * codes in LZWEncode and LZWPostDecode.
	 */
	sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4;
	cl_hash(sp);		/* clear hash table */
	sp->enc_oldcode = (hcode_t) -1;	/* generates CODE_CLEAR in LZWEncode */
	return (1);
}
开发者ID:cyberCBM,项目名称:DetectO,代码行数:34,代码来源:tif_lzw.c

示例7: clearHash

//-----------------------------------------------------------------
// reset compressor and issue a clear code
void mgLZWEncode::clearBlock()
{
  clearHash();			// delete all the symbols 

  m_freeCode = m_clearCode + 2;
  writeCode(m_clearCode);	// inform decoder 
  m_bits = m_initBits;	// reset code size 
  m_maxCode = MAXCODE(m_bits);
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:11,代码来源:mgLZW.cpp

示例8: clear_block

clear_block (gif_dest_ptr dinfo)
/* Reset compressor and issue a Clear code */
{
  clear_hash(dinfo);			/* delete all the symbols */
  dinfo->free_code = dinfo->ClearCode + 2;
  output(dinfo, dinfo->ClearCode);	/* inform decoder */
  dinfo->n_bits = dinfo->init_bits;	/* reset code size */
  dinfo->maxcode = MAXCODE(dinfo->n_bits);
}
开发者ID:deepmatrix,项目名称:blaxxun-cc3d,代码行数:9,代码来源:wrgif.c

示例9: compress_init

compress_init (gif_dest_ptr dinfo, int i_bits)
{
  
  dinfo->n_bits = i_bits;
  dinfo->maxcode = MAXCODE(dinfo->n_bits);
  dinfo->ClearCode = (1 << (i_bits - 1));
  dinfo->EOFCode = dinfo->ClearCode + 1;
  dinfo->code_counter = dinfo->ClearCode + 2;
  
  dinfo->bytesinpkt = 0;
  dinfo->cur_accum = 0;
  dinfo->cur_bits = 0;
  
  output(dinfo, dinfo->ClearCode);
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:15,代码来源:wrgif.c

示例10: compress_init

compress_init (gif_dest_ptr dinfo, int i_bits)
/* Initialize pseudo-compressor */
{
  /* init all the state variables */
  dinfo->n_bits = i_bits;
  dinfo->maxcode = MAXCODE(dinfo->n_bits);
  dinfo->ClearCode = (1 << (i_bits - 1));
  dinfo->EOFCode = dinfo->ClearCode + 1;
  dinfo->code_counter = dinfo->ClearCode + 2;
  /* init output buffering vars */
  dinfo->bytesinpkt = 0;
  dinfo->cur_accum = 0;
  dinfo->cur_bits = 0;
  /* GIF specifies an initial Clear code */
  output(dinfo, dinfo->ClearCode);
}
开发者ID:DankRank,项目名称:rom-properties,代码行数:16,代码来源:wrgif.c

示例11: MAXCODE

//-----------------------------------------------------------------
// constructor
mgLZWEncode::mgLZWEncode()
{
  m_hashCode = new mgLZWCode[HASH_SIZE];
  m_hashValue = new mgLZWHash[HASH_SIZE];

  // init all the state variables
  m_bits = m_initBits = 9;  // data size + 1
  m_maxCode = MAXCODE(m_bits);
  m_clearCode = ((mgLZWCode) 1 << (m_initBits - 1));
  m_EOFCode = m_clearCode + 1;
  m_freeCode = m_clearCode + 2;
  m_firstByte = TRUE;	// no waiting symbol yet

  // init output buffering vars
  m_curAccum = 0;
  m_curBits = 0;

  clearHash();        // clear hash table
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:21,代码来源:mgLZW.cpp

示例12: compress_init

compress_init (gif_dest_ptr dinfo, int i_bits)
/* Initialize LZW compressor */
{
  /* init all the state variables */
  dinfo->n_bits = dinfo->init_bits = i_bits;
  dinfo->maxcode = MAXCODE(dinfo->n_bits);
  dinfo->ClearCode = ((code_int) 1 << (i_bits - 1));
  dinfo->EOFCode = dinfo->ClearCode + 1;
  dinfo->free_code = dinfo->ClearCode + 2;
  dinfo->first_byte = TRUE;	/* no waiting symbol yet */
  /* init output buffering vars */
  dinfo->bytesinpkt = 0;
  dinfo->cur_accum = 0;
  dinfo->cur_bits = 0;
  /* clear hash table */
  clear_hash(dinfo);
  /* GIF specifies an initial Clear code */
  output(dinfo, dinfo->ClearCode);
}
开发者ID:deepmatrix,项目名称:blaxxun-cc3d,代码行数:19,代码来源:wrgif.c

示例13: lzwInit

int lzwInit(lzw_streamp strm)
{
    struct lzw_internal_state *state;
    hcode_t code;

    state = cli_malloc(sizeof(struct lzw_internal_state));
    if (state == NULL) {
        strm->msg = "failed to allocate state";
        return LZW_MEM_ERROR;
    }

    /* general state setup */
    state->nbits = BITS_MIN;
    state->nextdata = 0;
    state->nextbits = 0;

    /* dictionary setup */
    state->dec_codetab = cli_calloc(CSIZE, sizeof(code_t));
    if (state->dec_codetab == NULL) {
        free(state);
        strm->msg = "failed to allocate code table";
        return LZW_MEM_ERROR;
    }

    for (code = 0; code < CODE_BASIC; code++) {
        state->dec_codetab[code].next = NULL;
        state->dec_codetab[code].length = 1;
        state->dec_codetab[code].value = code;
        state->dec_codetab[code].firstchar = code;
    }

    state->dec_restart = 0;
    state->dec_nbitsmask = MAXCODE(BITS_MIN);
    state->dec_free_entp = state->dec_codetab + CODE_FIRST;
    state->dec_oldcodep = &state->dec_codetab[CODE_CLEAR];
    state->dec_maxcodep = &state->dec_codetab[state->dec_nbitsmask-1];

    strm->state = state;
    return LZW_OK;
}
开发者ID:chushuai,项目名称:clamav-devel,代码行数:40,代码来源:lzwdec.c

示例14: compress

static void compress(int init_bits, FILE *outfile, byte *data, int len)
{
    register long fcode;
    register int i = 0;
    register int c;
    register int ent;
    register int disp;
    register int hsize_reg;
    register int hshift;

    /*
     * Set up the globals:  g_init_bits - initial number of bits g_outfile -
     * pointer to output file
     */
    g_init_bits = init_bits;
    g_outfile   = outfile;

    /* initialize 'compress' globals */
    maxbits = XV_BITS;
    maxmaxcode = 1<<XV_BITS;
    memset(htab, 0, sizeof(htab));
    memset(codetab, 0, sizeof(codetab));
    hsize = HSIZE;
    free_ent = 0;
    clear_flg = 0;
    in_count = 1;
    out_count = 0;
    cur_accum = 0;
    cur_bits = 0;

    /* Set up the necessary values */
    out_count = 0;
    clear_flg = 0;
    in_count = 1;
    maxcode = MAXCODE(n_bits = g_init_bits);

    ClearCode = (1 << (init_bits - 1));
    EOFCode = ClearCode + 1;
    free_ent = ClearCode + 2;

    char_init();
    ent = pc2nc[*data++];
    len--;

    hshift = 0;
    for (fcode = (long)hsize; fcode < 65536L; fcode *= 2L )
        hshift++;

    hshift = 8 - hshift; /* set hash code range bound */

    hsize_reg = hsize;
    cl_hash( (count_int) hsize_reg); /* clear hash table */

    output(ClearCode);

    while (len) {
        c = pc2nc[*data++];
        len--;
        in_count++;

        fcode = (long)(((long) c << maxbits) + ent);
        i = (((int) c << hshift) ^ ent);    /* xor hashing */

        if ( HashTabOf (i) == fcode ) {
            ent = CodeTabOf (i);
            continue;
        } else if ( (long)HashTabOf (i) < 0) {
            /* empty slot */
            goto nomatch;
        }

        disp = hsize_reg - i;   /* secondary hash (after G. Knott) */

        if ( i == 0 )
            disp = 1;

probe:
        if ((i -= disp) < 0)
            i += hsize_reg;

        if (HashTabOf (i) == fcode) {
            ent = CodeTabOf (i);
            continue;
        }

        if ((long)HashTabOf (i) >= 0)
            goto probe;

nomatch:
        output(ent);
        out_count++;
        ent = c;

        if (free_ent < maxmaxcode) {
            CodeTabOf (i) = free_ent++; /* code -> hashtable */
            HashTabOf (i) = fcode;
        } else {
            cl_block();
        }
    }
//.........这里部分代码省略.........
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,代码来源:hdfgifwr.c

示例15: LZWDecodeCompat

static int
LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
{
	LZWCodecState *sp = DecoderState(tif);
	char *op = (char*) op0;
	long occ = (long) occ0;
	char *tp;
	u_char *bp;
	int code, nbits;
	long nextbits, nextdata, nbitsmask;
	code_t *codep, *free_entp, *maxcodep, *oldcodep;

	(void) s;
	assert(sp != NULL);
	/*
	 * Restart interrupted output operation.
	 */
	if (sp->dec_restart) {
		long residue;

		codep = sp->dec_codep;
		residue = codep->length - sp->dec_restart;
		if (residue > occ) {
			/*
			 * Residue from previous decode is sufficient
			 * to satisfy decode request.  Skip to the
			 * start of the decoded string, place decoded
			 * values in the output buffer, and return.
			 */
			sp->dec_restart += occ;
			do {
				codep = codep->next;
			} while (--residue > occ);
			tp = op + occ;
			do {
				*--tp = codep->value;
				codep = codep->next;
			} while (--occ);
			return (1);
		}
		/*
		 * Residue satisfies only part of the decode request.
		 */
		op += residue, occ -= residue;
		tp = op;
		do {
			*--tp = codep->value;
			codep = codep->next;
		} while (--residue);
		sp->dec_restart = 0;
	}

	bp = (u_char *)tif->tif_rawcp;
	nbits = sp->lzw_nbits;
	nextdata = sp->lzw_nextdata;
	nextbits = sp->lzw_nextbits;
	nbitsmask = sp->dec_nbitsmask;
	oldcodep = sp->dec_oldcodep;
	free_entp = sp->dec_free_entp;
	maxcodep = sp->dec_maxcodep;

	while (occ > 0) {
		NextCode(tif, sp, bp, code, GetNextCodeCompat);
		if (code == CODE_EOI)
			break;
		if (code == CODE_CLEAR) {
			free_entp = sp->dec_codetab + CODE_FIRST;
			nbits = BITS_MIN;
			nbitsmask = MAXCODE(BITS_MIN);
			maxcodep = sp->dec_codetab + nbitsmask;
			NextCode(tif, sp, bp, code, GetNextCodeCompat);
			if (code == CODE_EOI)
				break;
			*op++ = (char) code, occ--;
			oldcodep = sp->dec_codetab + code;
			continue;
		}
		codep = sp->dec_codetab + code;

		/*
	 	 * Add the new entry to the code table.
	 	 */
		if (free_entp < &sp->dec_codetab[0] ||
			free_entp >= &sp->dec_codetab[CSIZE]) {
			TIFFError(tif->tif_name,
			"LZWDecodeCompat: Corrupted LZW table at scanline %d",
			tif->tif_row);
			return (0);
		}

		free_entp->next = oldcodep;
		if (free_entp->next < &sp->dec_codetab[0] ||
			free_entp->next >= &sp->dec_codetab[CSIZE]) {
			TIFFError(tif->tif_name,
			"LZWDecodeCompat: Corrupted LZW table at scanline %d",
			tif->tif_row);
			return (0);
		}
		free_entp->firstchar = free_entp->next->firstchar;
		free_entp->length = free_entp->next->length+1;
//.........这里部分代码省略.........
开发者ID:AlexHayton,项目名称:decoda,代码行数:101,代码来源:tif_lzw.c


注:本文中的MAXCODE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。