📄 datastruct.hpp
字号:
/*************************************************************************
This software module was originally developed by
in the course of development of the MPEG-4 Video (ISO/IEC 14496-2).
This software module is an implementation of a part of one or more MPEG-4 Video tools
as specified by the MPEG-4 Video.
ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications
thereof for use in hardware or software products claiming conformance to the MPEG-4 Video.
Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents.
The original developer of this software module and his/her company,
the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation.
Copyright is not released for non MPEG-4 Video conforming products.
Microsoft retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products.
This copyright notice must be included in all copies or derivative works.
Copyright (c) 1996, 1997, 1998.
Module Name:
vtcEnc.hpp
Abstract:
Encoder for one still image using wavelet VTC.
Revision History:
*************************************************************************/
#ifndef __VTCENC_HPP_
#define __VTCENC_HPP_
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include "basic.hpp"
#include "quant.hpp"
#include "ac.hpp"
//#include "context.hpp"
#include "dwt.h"
/* for bilevel mode */
#include "PEZW_ac.hpp"
#include "wvtPEZW.hpp"
#include "PEZW_zerotree.hpp"
#include "PEZW_mpeg4.hpp"
/* for shape coding added by SL@Sarnoff (03/03/99)*/
#include "ShapeBaseCommon.hpp"
#include "BinArCodec.hpp"
#ifdef DATA
#undef DATA
#endif
#define DATA Int
#define MAXLEV 12
#define NCOLOR 3
#define SINGLE_Q 1
#define MULTIPLE_Q 2
#define BILEVEL_Q 3
/* zero tree symbols - if changed please change MapTypeToText variable */
#define IZ 0 /* Isolated Zero */
#define VAL 1 /* Value */
#define ZTR 2 /* Zero-Tree Root */
#define VZTR 3 /* Valued Zero-Tree Root */
#define ZTR_D 4 /* Parent has type of ZTR, VZTR, or ZTR_D (not coded) */
#define VLEAF 5 /* Leaf coefficient with non-zero value (not coded) */
#define ZLEAF 6 /* Leaf coefficient with zero value (not coded) */
#define UNTYPED 7 /* so far only for clearing of ZTR_Ds */
#define MAXDECOMPLEV 10
#define INF_RES 1024
// FPDAM begin: added by Sharp
#define OPAQUE_TILE 1
#define BOUNDA_TILE 2
#define TRANSP_TILE 3
// FPDAM end: added by Sharp
#define MONO 1
#define FULLSIZE 0
#define PROGRESSIVE 0
#define MASK_VAL (0xff)
#define SKIP_NONE 0 /* Not in skip mode */
#define SKIP_TNYC 1 /* Skip mode - Type Not Yet Coded */
#define SKIP_ZTR 2 /* Skip mode - previous type coded was ZTR */
#define SKIP_IZ 3 /* Skip mode - previous type coded was IZ */
/* QValArithModel field types - if changed please change mapArithModelToText
variable */
#if 0 // hjlee 0901
#define ACM_NONE 0 /* When there's no value to code */
#define ACM_SKIP 1
#define ACM_ROOT 2
#define ACM_VALZ 3
#define ACM_VALNZ 4
#define ACM_RESID 5 /* should have one for each set of coeffs arising in
different initial spatial layers */
#define ACM_DC 6
#endif // hjlee 0901
// hjlee 0901
#define ACM_NONE 0 /* When there's no value to code */
#define ACM_ROOT 1
#define ACM_VALZ 2
#define ACM_VALNZ 3
#define ACM_RESID 4 /* should have one for each set of coeffs arising in
different initial spatial layers */
#define ACM_DC 5
typedef short SInt;
typedef U8 UChar;
typedef struct {
/* not updated */
SInt wvt_coeff; /* Original value in encoding.*/
SInt rec_coeff; /* Reconstructed value in decoding
Put here for comparing with originals
at decoder. Reconstructed values can
be put in original when memory is an
issue and we don't want stats to be
computed at decoder. */
/* updated by quantization */
SInt quantized_value; /* quantized value */
quantState qState; /* state of quantizer for coefficient */
/* updated by marking */
UChar state; /* state of coefficient */
UChar type; /* MZTE tree types: ZTR, IZ, VZTR, or VAL */
UChar skip; /* Skip coding of coefficient value (not type) */
/* updated by Shipeng */
UChar mask;
} COEFFINFO;
typedef struct {
Int num_ZTR;
Int num_VZTR;
Int num_VAL;
} STATINFO;
typedef struct {
Int height;
Int width;
UChar *mask;
Void *data;
} PICTURE;
typedef struct {
SInt quant;
UChar allzero;
Int root_max; /* three maximum values for AC magnitude coding */
Int valz_max;
Int valnz_max;
Int residual_max;
// hjlee 0901
Int wvtDecompNumBitPlanes[MAXDECOMPLEV];
Int wvtDecompResNumBitPlanes;
Int wvtDecompMax[MAXDECOMPLEV]; /* for _NEW_CONTEXT_ */
STATINFO stat;
} SNR_IMAGE;
typedef struct {
SNR_IMAGE snr_image;
} SNR_LAYER;
typedef struct {
SInt height;
SInt width;
SInt SNR_scalability_levels;
COEFFINFO **coeffinfo;
SNR_LAYER SNRlayer;
} SPATIAL_LAYER;
typedef struct snr_param {
Int SNR_scalability_levels;
Int *Quant;
} SNR_PARAM;
typedef struct wvt_codec
{
Int m_iBitDepth; /* number bits per pixel (spatial) */
Int m_iColors; /* number of color components: 0 = mono, 3=yuv */
Int m_iColorFormat; /* 4:4:4, 4:2:2, or 4:2:0 ???? */
PICTURE *m_Image; /* spatial source */
PICTURE *m_SegImage; /* spatial source */
PICTURE *m_ImageOrg; /* storage for original source */ // added by Sharp (99/2/16)
Int m_iWvtType; /* Type of filter */
Int m_iWvtDownload;
Int m_iWvtDecmpLev;
Int m_iWvtUniform; // hjlee 0901
Int *m_WvtFilters; /* Wavetfilter numbers: 0-9 */ // hjlee 0901
Int m_iMean[NCOLOR]; /* mean of wvt coeffs in DC band ???? */
Int m_iQDC[NCOLOR];
Int m_iOffsetDC;
Int m_iMaxDC; /* max quantized DC coeff - pre-shifting */
Int m_iDCWidth;
Int m_iDCHeight;
// hjlee 0901
Int m_lastWvtDecompInSpaLayer[MAXDECOMPLEV][NCOLOR];
Int m_spaLayerWidth[MAXDECOMPLEV][NCOLOR];
Int m_spaLayerHeight[MAXDECOMPLEV][NCOLOR];
UChar m_defaultSpatialScale;
Int m_iTextureTileType; // FPDAM added by Sharp
Int m_iWidth;
Int m_iHeight;
Int m_iSpatialLev;
Int m_iQuantType;
Int m_iScanDirection;
Int m_iScanOrder;
Bool m_bStartCodeEnable;
SPATIAL_LAYER m_SPlayer[NCOLOR];
SNR_PARAM *m_Qinfo[NCOLOR];
Int m_iTargetSpatialLev;
Int m_iTargetSNRLev;
//Int m_iDeringWinSize; //deleted by SL@Sarnoff (03/02/99)
//Int m_iDeringThreshold;
Int m_iTargetShapeLev; //target shape spatial level (added by SL@Sarnoff -- 03/02/99)
Int m_iFullSizeOut; //full size output of image (added by SL@Sarnoff -- 03/02/99)
Int m_iTargetBitrate; /* PEZW */
/* for shape coding */
Int m_iAlphaChannel;
Int m_iAlphaTh;
Int m_iChangeCRDisable;
Int m_iSTOConstAlpha;
Int m_iSTOConstAlphaValue;
Int m_iShapeScalable; // shape scalable? (added by SL@Sarnoff -- 03/02/99)
Int m_iSingleBitFile;
Char *m_cBitFile;
Char *m_cBitFileAC;
Int m_iOriginX;
Int m_iOriginY;
Int m_iRealWidth;
Int m_iRealHeight;
// FPDAM begin: added by Sharp
Int m_iObjectOriginX;
Int m_iObjectOriginY;
Int m_iObjectWidth;
Int m_iObjectHeight;
// FPDAM end: added by Sharp
// begin: added by Sharp (99/5/10)
Int m_iPictWidth;
Int m_iPictHeight;
// end: added by Sharp (99/5/10)
Int m_iCurSpatialLev;
Int m_iCurSNRLev;
Int m_iCurColor;
//Added by Sarnoff for error resilience, 3/5/99
UShort m_usSegmentThresh;
UShort m_usPacketThresh; //bbc, 2/19/99
UShort m_usErrResiDisable;
//End Added by Sarnoff for error resilience, 3/5/99
/* for arithmetic coder */
Int m_iAcmOrder; /* 0 - zoro order, 1 - mix order */
Int m_iAcmMaxFreqChg; /* 0 - default, 1 - used defined */
Int *m_iAcmMaxFreq; /* array of user defined maximum freqs */
// begin: added by Sharp (99/2/16)
Int m_display_width, m_display_height;
Int m_tiling_disable;
Int m_tile_width;
Int m_tile_height;
Int m_tiling_jump_table_enable;
Int m_extension_type;
Int m_target_tile_id_from;
Int m_target_tile_id_to;
Int m_iNumOfTile;
// end: added by Sharp (99/2/16)
Int m_visual_object_verid; // added by Sharp (99/4/7)
} WVT_CODEC;
class CVTCCommon
{
public:
WVT_CODEC mzte_codec;
//begin: added by SL 030399
Int ObjectWidth, ObjectHeight;
Int STO_const_alpha;
UChar STO_const_alpha_value;
//end: added by SL 030399
// Utils.cpp
Void setSpatialLevelAndDimensions(Int spLayer, Int c);
Void updateResidMaxAndAssignSkips(Int c);
Int xy2wvtDecompLev(Int x, Int y);
// vtcdec.cpp
Void setSpatialLayerDimsSQ(Int band); // hjlee 0901
Void getSpatialLayerDims(); //hjlee 0901
Int ceilLog2(Int x); // hjlee 0901
// QMInit.cpp
Int ztqQListInit();
Void ztqQListExit();
Int ztqInitDC(Int decode, Int c);
Int ztqInitAC(Int decode, Int c);
// quant.cpp
Void initQuantSingleStage(quantState *state,
Int *statePrevQ, Int initialVal);
Void initInvQuantSingleStage(quantState *state,
Int *statePrevQ);
Int quantRefLev(Int curQ, Int *lastQUsed, Int whichQ);
Int invQuantSingleStage(Int QIndex, Int Q,
quantState *state, Int *statePrevQ,Int updatePrevQ);
// QMUtils.cpp
Int findChild(Int x, Int y, Int xc[], Int yc[], Int c);
Int isIndexInRootBands(Int x, Int y, Int c);
Void spatialLayerChangeUpdate(Int c);
Int coordToSpatialLev(Int x, Int y, Int c);
Void updateCoeffAndDescState(Int x, Int y, Int c);
Void markCoeff(Int x, Int y, UChar valuedDes, Int c);
Void updateState(Int x, Int y, Int type, Int c);
// msg.cpp
Void errorHandler(Char *s, ...);
Void noteStat(Char *s, ...);
Void noteDebug(Char *s, ...);
Void noteDetail(Char *s, ...);
Void noteProgress(Char *s, ...);
Void noteProgressNoNL(Char *s, ...);
Void noteWarning(Char *s, ...);
Void noteError(Char *s, ...);
Void noteErrorNoPre(Char *s, ...);
//download_filter.cpp
Void check_marker(Int marker_bit);
Void check_symmetry(FILTER *filter);
Void upload_wavelet_filters(FILTER *filter);
Int download_wavelet_filters(FILTER **filter, Int type); // hjlee 0901 , Modified by Sharp (99/2/16)
// wavelet.cpp
Void choose_wavelet_filter(FILTER **anafilter,FILTER **synfilter,
Int type);
// bitpack.cpp
Void init_bit_packing_fp(FILE *fp, Int clearByte);
Void emit_bits(UShort code, Int size);
Int get_X_bits(Int nbits);
Void flush_bytes1();
Int nextinputbit();
// ztscanUtil.cpp
Void clear_ZTR_D(COEFFINFO **coeffinfo, Int width,
Int height);
Void probModelInitSQ(Int col); // hjlee 0901
Void probModelFreeSQ(Int col); // hjlee 0901
Void setProbModelsSQ(Int col); // hjlee 0901
Void probModelInitMQ(Int col); // hjlee 0901
Void probModelFreeMQ(Int col); // hjlee 0901
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -