【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:ac.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
/* $Id: ac.cpp,v 1.2 2001/04/19 18:32:09 wmay Exp $ */
/****************************************************************************/
/* MPEG4 Visual Texture Coding (VTC) Mode Software */
/* */
/* This software was jointly developed by the following participants: */
/* */
/* Single-quant, multi-quant and flow control */
/* are provided by Sarnoff Corporation */
/* Iraj Sodagar (iraj@sarnoff.com) */
/* Hung-Ju Lee (hjlee@sarnoff.com) */
/* Paul Hatrack (hatrack@sarnoff.com) */
/* Shipeng Li (shipeng@sarnoff.com) */
/* Bing-Bing Chai (bchai@sarnoff.com) */
/* B.S. Srinivas (bsrinivas@sarnoff.com) */
/* */
/* Bi-level is provided by Texas Instruments */
/* Jie Liang (liang@ti.com) */
/* */
/* Shape Coding is provided by OKI Electric Industry Co., Ltd. */
/* Zhixiong Wu (sgo@hlabs.oki.co.jp) */
/* Yoshihiro Ueda (yueda@hlabs.oki.co.jp) */
/* Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp) */
/* */
/* OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream */
/* exchange and bug fixing. */
/* */
/* */
/* In the course of development of the MPEG-4 standard, this software */
/* module is an implementation of a part of one or more MPEG-4 tools as */
/* specified by the MPEG-4 standard. */
/* */
/* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use */
/* of the MPEG-4 standard free license to use this software module or */
/* modifications thereof for hardware or software products claiming */
/* conformance to the MPEG-4 standard. */
/* */
/* Those intending to use this software module in hardware or software */
/* products are advised that use may infringe existing patents. The */
/* original developers of this software module and their companies, the */
/* subsequent editors and their companies, and ISO/IEC have no liability */
/* and ISO/IEC have no liability for use of this software module or */
/* modification thereof in an implementation. */
/* */
/* Permission is granted to MPEG members to use, copy, modify, */
/* and distribute the software modules ( or portions thereof ) */
/* for standardization activity within ISO/IEC JTC1/SC29/WG11. */
/* */
/* Copyright 1995, 1996, 1997, 1998 ISO/IEC */
/****************************************************************************/
/************************************************************/
/* Sarnoff Very Low Bit Rate Still Image Coder */
/* Copyright 1995, 1996, 1997, 1998 Sarnoff Corporation */
/************************************************************/
/************************************************************/
/* Filename: ac.c */
/* Author: B.S. Srinivas */
/* Date Modified: April 23, 1998 */
/* */
/* Descriptions: */
/* This file contains routines for Integer arithmetic */
/* coding, which is based on the ac.c file from the SOL */
/* package. */
/* */
/* The following routines are modified or created for */
/* the latest VTC package: */
/* static Void mzte_output_bit() */
/* Void mzte_ac_encoder_init() */
/* Int mzte_ac_encoder_done() */
/* static Int mzte_input_bit() */
/* Void mzte_ac_decoder_init() */
/* Void mzte_ac_decoder_done() */
/* */
/************************************************************/
//#include <stdio.h>
//#include <stdlib.h>
//#include <assert.h>
#include "dataStruct.hpp"
#include "ac.hpp"
#include "bitpack.hpp"
#include "errorHandler.hpp"
#include "msg.hpp"
#define codeValueBits 16
#define peakValue (((long)1<<codeValueBits)-1)
#define firstQtr (peakValue/4+1)
#define Half (2*firstQtr)
#define thirdQtr (3*firstQtr)
#define BYTETYPE UChar
#define SHORTTYPE UShort
#define MIN(a,b) (((a)<(b)) ? (a) : (b))
#define STUFFING_CNT 22
#define MIXED 2
/* static function prototypes */
//static Void mzte_output_bit(ac_encoder *,Int);
//static Void mzte_bit_plus_follow(ac_encoder *,Int);
//static Void mzte_update_model(ac_model *,ac_model *,Int);
//static Int mzte_input_bit(ac_decoder *);
static Int zeroStrLen=0;
/************************************************************************/
/* Error Checking and Handling Macros */
/************************************************************************/
#define error(m) \
do { \
fflush(stdout); \
fprIntf(stderr, "%s:%d: error: ", __File__, __LINE__); \
fprIntf(stderr, m); \
fprIntf(stderr, "\n"); \
exit(1); \
} while (0)
#define check(b,m) \
do { \
if (b) \
error(m); \
} while (0)
/************************************************************************/
/* Bit Output */
/************************************************************************/
/**************************************************/
/* Added bit stuffing to prevent start code */
/* emulation, i.e., add a "1" bit after every 22 */
/* consecutive "0" bits in the bit stream */
/* */
/* Modified to use a fixed buffer and write to */
/* file directly after the buffer is full. So the*/
/* ace->bitstreamLength now only has the # of */
/* bytes in current buffer. Total bits (bitCount)*/
/* will indicate the total # bits for arithmetic */
/* coding part. */
/**************************************************/
Void CVTCEncoder::mzte_output_bit(ac_encoder *ace,Int bit)
{
register int flag=0;
ace->buffer *= 2;
ace->buffer |= (bit)?0x01:0;
(ace->bitsLeft)--;
(ace->bitCount)++;
if (!(ace->bitsLeft)) {
if (!(ace->bitstream))
errorHandler("Failure to allocate space for array Bitstream " \
"in ac_encoder structure");
switch (flag=(ace->bitstreamLength>=MAX_BUFFER)) {
case 1:
write_to_bitstream(ace->bitstream,MAX_BUFFER<<3);
ace->bitstreamLength=0;
break;
default:
break;
}
ace->bitstream[(ace->bitstreamLength)
上一篇:
AbstractFactory.cpp
下一篇:
如何提高博士论文的构思能力