Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/jxr/image/sys/common.h
4393 views
1
//*@@@+++@@@@******************************************************************
2
//
3
// Copyright © Microsoft Corp.
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
//
9
// • Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// • Redistributions in binary form must reproduce the above copyright notice,
12
// this list of conditions and the following disclaimer in the documentation
13
// and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
// POSSIBILITY OF SUCH DAMAGE.
26
//
27
//*@@@---@@@@******************************************************************
28
29
#ifndef WMI_COMMON_H
30
#define WMI_COMMON_H
31
32
/*************************************************************************
33
// Common typedef's
34
*************************************************************************/
35
typedef enum { ENCODER = 0, DECODER = 1 } CODINGMODE;
36
37
typedef enum tagBand
38
{
39
BAND_HEADER = 0,
40
BAND_DC = 1,
41
BAND_LP = 2,
42
BAND_AC = 3,
43
BAND_FL = 4
44
} BAND;
45
46
/*************************************************************************
47
struct / class definitions
48
*************************************************************************/
49
//#define SIGNATURE_BYTES 8 // Bytes for GDI+ signature
50
#define CODEC_VERSION 1
51
#define CODEC_SUBVERSION 0
52
#define CODEC_SUBVERSION_NEWSCALING_SOFT_TILES 1
53
#define CODEC_SUBVERSION_NEWSCALING_HARD_TILES 9
54
55
#define CONTEXTX 8
56
#define CTDC 5
57
#define NUMVLCTABLES 21 // CONTEXTX * 2 + CTDC
58
#define AVG_NDIFF 3
59
60
#define MAXTOTAL 32767 // 511 should be enough
61
62
/** Quantization related defines **/
63
#define SHIFTZERO 1 /* >= 0 */
64
#define QPFRACBITS 2 /* or 0 only supported */
65
66
/** adaptive huffman encoding / decoding struct **/
67
typedef struct CAdaptiveHuffman
68
{
69
Int m_iNSymbols;
70
const Int *m_pTable;
71
const Int *m_pDelta, *m_pDelta1;
72
Int m_iTableIndex;
73
const short *m_hufDecTable;
74
Bool m_bInitialize;
75
//Char m_pLabel[8]; // for debugging - label attached to constructor
76
77
Int m_iDiscriminant, m_iDiscriminant1;
78
Int m_iUpperBound;
79
Int m_iLowerBound;
80
} CAdaptiveHuffman;
81
82
83
/************************************************************************************
84
Context structures
85
************************************************************************************/
86
typedef struct CAdaptiveModel {
87
Int m_iFlcState[2];
88
Int m_iFlcBits[2];
89
BAND m_band;
90
} CAdaptiveModel;
91
92
typedef struct CCBPModel {
93
Int m_iCount0[2];
94
Int m_iCount1[2];
95
Int m_iState[2];
96
} CCBPModel;
97
98
/*************************************************************************
99
globals
100
*************************************************************************/
101
extern Int grgiZigzagInv4x4_lowpass[];
102
extern Int grgiZigzagInv4x4H[];
103
extern Int grgiZigzagInv4x4V[];
104
extern const Int gSignificantRunBin[];
105
extern const Int gSignificantRunFixedLength[];
106
static const Int cblkChromas[] = {0,4,8,16, 16,16,16, 0,0};
107
/*************************************************************************
108
function declarations
109
*************************************************************************/
110
// common utilities
111
Void Clean (CAdaptiveHuffman *pAdHuff);
112
CAdaptiveHuffman *Allocate (Int iNSymbols, CODINGMODE cm);
113
114
/* Timing functions */
115
void reset_timing(double *time);
116
void report_timing(const char *s, double time);
117
// static double timeperclock;
118
119
/** adaptive model functions **/
120
Void UpdateModelMB (COLORFORMAT cf, Int iChannels, Int iLaplacianMean[], CAdaptiveModel *m_pModel);
121
122
/** adaptive huffman encoder / decoder functions **/
123
Void Adapt (CAdaptiveHuffman *pAdHuff, Bool bFixedTables);
124
Void AdaptFixed (CAdaptiveHuffman *pAdHuff);
125
Void AdaptDiscriminant (CAdaptiveHuffman *pAdHuff);
126
127
#ifndef _PREFAST_
128
#pragma warning(disable:4068)
129
#endif
130
131
#endif // WMI_COMMON_H
132
133