summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/misc/stars/star104726/global.h
blob: 3baed2740bf32da343924d908afd6d3c49ebb24f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*****************************************************************************

  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
  more contributor license agreements.  See the NOTICE file distributed
  with this work for additional information regarding copyright ownership.
  Accellera licenses this file to you under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with the
  License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  implied.  See the License for the specific language governing
  permissions and limitations under the License.

 *****************************************************************************/

/*****************************************************************************

  global.h -- 

  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15

 *****************************************************************************/

/*****************************************************************************

  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
  changes you are making here.

      Name, Affiliation, Date:
  Description of Modification:

 *****************************************************************************/

#ifndef GLOBALH
#define GLOBALH


// #include <iostream.h>
#include <stdio.h>

#define MAXBUFLEN 64

// cos constants, factor 512 
#define c1d4 362L
#define c1d8 473L
#define c3d8 196L
#define c1d16 502L
#define c3d16 426L
#define c5d16 284L
#define c7d16 100L

// correct digits 
#define MSCALE(expr)   (COEFF)((expr)>>9)

typedef unsigned char  BYTE;
typedef unsigned short WORD;
typedef unsigned long  DWORD;

typedef BYTE  BLOCK[8][8];
typedef BYTE  COMPRESSED[MAXBUFLEN];
typedef WORD  MATRIX64x12[64];

// type of the coefficient arrays 
typedef short COEFF;

// typedefs for huffman tables 
typedef struct {
	BYTE size;
	WORD code;
} HUFFMTBL_ENTRY;


struct Block {
  BYTE b[8][8];
  
  Block();
  Block(BLOCK *);
  Block(const Block&);
  void operator=(const Block&);
  int operator==(const Block&) const;

  BYTE   get(int x, int y) const;
  void   put(int x, int y, BYTE val);
  BLOCK* get_ptr() const;
};

struct Compressed {
  BYTE c[MAXBUFLEN];
  
  Compressed();
  Compressed(const Compressed&);
  void operator=(const Compressed&);
  int operator==(const Compressed&) const;

  void clear();
  BYTE get(int x) const;
  void put(int x, BYTE val);
};

struct  Matrix64x12 {
  WORD m[64];
  
  Matrix64x12();
  Matrix64x12(const Matrix64x12&);
  void operator=(const Matrix64x12&);
  int operator==(const Matrix64x12&) const;

  WORD get(int x) const;
  void put(int x, WORD val);
};

struct Coeff8 {
  COEFF c[8];
  
  Coeff8();
  Coeff8(const Coeff8&);
  void operator=(const Coeff8&);
  int operator==(const Coeff8&) const;

  COEFF get(int x) const;
  void put(int x, COEFF val);
};

struct Coeff8x8 {
  COEFF c[8][8];
  
  Coeff8x8();
  Coeff8x8(const Coeff8x8&);
  void operator=(const Coeff8x8&);
  int operator==(const Coeff8x8&) const;

  COEFF get(int x, int y) const;
  void  put(int x, int y, COEFF val);
};

inline
void
sc_trace( sc_trace_file*, const Coeff8x8&, const std::string& )
{
    // NOT IMPLEMENTED
}


// quantization table 8-bit unsigned integer
static const unsigned char coeff_quant[8][8] = {  // v is row 
    {   16,   11,   10,   16,   24,   40,   51,   61},
    {   12,   12,   14,   19,   26,   58,   60,   55},
    {   14,   13,   16,   24,   40,   57,   69,   56},
    {   14,   17,   22,   29,   51,   87,   80,   82},
    {   18,   22,   37,   56,   68,  109,  103,   77},
    {   24,   35,   55,   64,   81,  104,  113,   92},
    {   99,   64,   78,   87,  103,  121,  120,  101},
    {   72,   92,   95,   98,  112,  100,  103,   99}
};


// table of Huffman DC coefficients 
static const HUFFMTBL_ENTRY huffm_dc[12] = {
    {  2, 0X0000 }, {  3, 0X0002 }, {  3, 0X0003 }, {  3, 0X0004 },
    {  3, 0X0005 }, {  3, 0X0006 }, {  4, 0X000E }, {  5, 0X001E },
    {  6, 0X003E }, {  7, 0X007E }, {  8, 0X00FE }, {  9, 0X01FE } 
};


// table of Huffman AC coefficients 
static const HUFFMTBL_ENTRY huffm_ac[256] = {
    {  4, 0x000a }, {  2, 0x0000 }, {  2, 0x0001 }, {  3, 0x0004 }, 
    {  4, 0x000b }, {  5, 0x001a }, {  7, 0x0078 }, {  8, 0x00f8 }, 
    { 10, 0x03f6 }, { 16, 0xff82 }, { 16, 0xff83 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  4, 0x000c }, {  5, 0x001b }, {  7, 0x0079 }, 
    {  9, 0x01f6 }, { 11, 0x07f6 }, { 16, 0xff84 }, { 16, 0xff85 }, 
    { 16, 0xff86 }, { 16, 0xff87 }, { 16, 0xff88 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  5, 0x001c }, {  8, 0x00f9 }, { 10, 0x03f7 }, 
    { 12, 0x0ff4 }, { 16, 0xff89 }, { 16, 0xff8a }, { 16, 0xff8b }, 
    { 16, 0xff8c }, { 16, 0xff8d }, { 16, 0xff8e }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  6, 0x003a }, {  9, 0x01f7 }, { 12, 0x0ff5 }, 
    { 16, 0xff8f }, { 16, 0xff90 }, { 16, 0xff91 }, { 16, 0xff92 }, 
    { 16, 0xff93 }, { 16, 0xff94 }, { 16, 0xff95 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  6, 0x003b }, { 10, 0x03f8 }, { 16, 0xff96 }, 
    { 16, 0xff97 }, { 16, 0xff98 }, { 16, 0xff99 }, { 16, 0xff9a }, 
    { 16, 0xff9b }, { 16, 0xff9c }, { 16, 0xff9d }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  7, 0x007a }, { 11, 0x07f7 }, { 16, 0xff9e }, 
    { 16, 0xff9f }, { 16, 0xffa0 }, { 16, 0xffa1 }, { 16, 0xffa2 }, 
    { 16, 0xffa3 }, { 16, 0xffa4 }, { 16, 0xffa5 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  7, 0x007b }, { 12, 0x0ff6 }, { 16, 0xffa6 }, 
    { 16, 0xffa7 }, { 16, 0xffa8 }, { 16, 0xffa9 }, { 16, 0xffaa }, 
    { 16, 0xffab }, { 16, 0xffac }, { 16, 0xffad }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  8, 0x00fa }, { 12, 0x0ff7 }, { 16, 0xffae }, 
    { 16, 0xffaf }, { 16, 0xffb0 }, { 16, 0xffb1 }, { 16, 0xffb2 }, 
    { 16, 0xffb3 }, { 16, 0xffb4 }, { 16, 0xffb5 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  9, 0x01f8 }, { 15, 0x7fc0 }, { 16, 0xffb6 }, 
    { 16, 0xffb7 }, { 16, 0xffb8 }, { 16, 0xffb9 }, { 16, 0xffba }, 
    { 16, 0xffbb }, { 16, 0xffbc }, { 16, 0xffbd }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  9, 0x01f9 }, { 16, 0xffbe }, { 16, 0xffbf }, 
    { 16, 0xffc0 }, { 16, 0xffc1 }, { 16, 0xffc2 }, { 16, 0xffc3 }, 
    { 16, 0xffc4 }, { 16, 0xffc5 }, { 16, 0xffc6 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  9, 0x01fa }, { 16, 0xffc7 }, { 16, 0xffc8 }, 
    { 16, 0xffc9 }, { 16, 0xffca }, { 16, 0xffcb }, { 16, 0xffcc }, 
    { 16, 0xffcd }, { 16, 0xffce }, { 16, 0xffcf }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, { 10, 0x03f9 }, { 16, 0xffd0 }, { 16, 0xffd1 }, 
    { 16, 0xffd2 }, { 16, 0xffd3 }, { 16, 0xffd4 }, { 16, 0xffd5 }, 
    { 16, 0xffd6 }, { 16, 0xffd7 }, { 16, 0xffd8 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, { 10, 0x03fa }, { 16, 0xffd9 }, { 16, 0xffda }, 
    { 16, 0xffdb }, { 16, 0xffdc }, { 16, 0xffdd }, { 16, 0xffde }, 
    { 16, 0xffdf }, { 16, 0xffe0 }, { 16, 0xffe1 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, { 11, 0x07f8 }, { 16, 0xffe2 }, { 16, 0xffe3 }, 
    { 16, 0xffe4 }, { 16, 0xffe5 }, { 16, 0xffe6 }, { 16, 0xffe7 }, 
    { 16, 0xffe8 }, { 16, 0xffe9 }, { 16, 0xffea }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, { 16, 0xffeb }, { 16, 0xffec }, { 16, 0xffed }, 
    { 16, 0xffee }, { 16, 0xffef }, { 16, 0xfff0 }, { 16, 0xfff1 }, 
    { 16, 0xfff2 }, { 16, 0xfff3 }, { 16, 0xfff4 }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, 
    { 11, 0x07f9 }, { 16, 0xfff5 }, { 16, 0xfff6 }, { 16, 0xfff7 }, 
    { 16, 0xfff8 }, { 16, 0xfff9 }, { 16, 0xfffa }, { 16, 0xfffb }, 
    { 16, 0xfffc }, { 16, 0xfffd }, { 16, 0xfffe }, {  0, 0x0000 }, 
    {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 }, {  0, 0x0000 } 
  };


#endif