//*@@@+++@@@@******************************************************************1//2// Copyright © Microsoft Corp.3// All rights reserved.4//5// Redistribution and use in source and binary forms, with or without6// modification, are permitted provided that the following conditions are met:7//8// • Redistributions of source code must retain the above copyright notice,9// this list of conditions and the following disclaimer.10// • Redistributions in binary form must reproduce the above copyright notice,11// this list of conditions and the following disclaimer in the documentation12// and/or other materials provided with the distribution.13//14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"15// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE18// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR19// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF20// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS21// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN22// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)23// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE24// POSSIBILITY OF SUCH DAMAGE.25//26//*@@@---@@@@******************************************************************2728#ifndef WMI_COMMON_H29#define WMI_COMMON_H3031/*************************************************************************32// Common typedef's33*************************************************************************/34typedef enum { ENCODER = 0, DECODER = 1 } CODINGMODE;3536typedef enum tagBand37{38BAND_HEADER = 0,39BAND_DC = 1,40BAND_LP = 2,41BAND_AC = 3,42BAND_FL = 443} BAND;4445/*************************************************************************46struct / class definitions47*************************************************************************/48//#define SIGNATURE_BYTES 8 // Bytes for GDI+ signature49#define CODEC_VERSION 150#define CODEC_SUBVERSION 051#define CODEC_SUBVERSION_NEWSCALING_SOFT_TILES 152#define CODEC_SUBVERSION_NEWSCALING_HARD_TILES 95354#define CONTEXTX 855#define CTDC 556#define NUMVLCTABLES 21 // CONTEXTX * 2 + CTDC57#define AVG_NDIFF 35859#define MAXTOTAL 32767 // 511 should be enough6061/** Quantization related defines **/62#define SHIFTZERO 1 /* >= 0 */63#define QPFRACBITS 2 /* or 0 only supported */6465/** adaptive huffman encoding / decoding struct **/66typedef struct CAdaptiveHuffman67{68Int m_iNSymbols;69const Int *m_pTable;70const Int *m_pDelta, *m_pDelta1;71Int m_iTableIndex;72const short *m_hufDecTable;73Bool m_bInitialize;74//Char m_pLabel[8]; // for debugging - label attached to constructor7576Int m_iDiscriminant, m_iDiscriminant1;77Int m_iUpperBound;78Int m_iLowerBound;79} CAdaptiveHuffman;808182/************************************************************************************83Context structures84************************************************************************************/85typedef struct CAdaptiveModel {86Int m_iFlcState[2];87Int m_iFlcBits[2];88BAND m_band;89} CAdaptiveModel;9091typedef struct CCBPModel {92Int m_iCount0[2];93Int m_iCount1[2];94Int m_iState[2];95} CCBPModel;9697/*************************************************************************98globals99*************************************************************************/100extern Int grgiZigzagInv4x4_lowpass[];101extern Int grgiZigzagInv4x4H[];102extern Int grgiZigzagInv4x4V[];103extern const Int gSignificantRunBin[];104extern const Int gSignificantRunFixedLength[];105static const Int cblkChromas[] = {0,4,8,16, 16,16,16, 0,0};106/*************************************************************************107function declarations108*************************************************************************/109// common utilities110Void Clean (CAdaptiveHuffman *pAdHuff);111CAdaptiveHuffman *Allocate (Int iNSymbols, CODINGMODE cm);112113/* Timing functions */114void reset_timing(double *time);115void report_timing(const char *s, double time);116// static double timeperclock;117118/** adaptive model functions **/119Void UpdateModelMB (COLORFORMAT cf, Int iChannels, Int iLaplacianMean[], CAdaptiveModel *m_pModel);120121/** adaptive huffman encoder / decoder functions **/122Void Adapt (CAdaptiveHuffman *pAdHuff, Bool bFixedTables);123Void AdaptFixed (CAdaptiveHuffman *pAdHuff);124Void AdaptDiscriminant (CAdaptiveHuffman *pAdHuff);125126#ifndef _PREFAST_127#pragma warning(disable:4068)128#endif129130#endif // WMI_COMMON_H131132133