gem5  v22.1.0.0
global.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  global.h --
23 
24  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
25 
26  *****************************************************************************/
27 
28 /*****************************************************************************
29 
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32 
33  Name, Affiliation, Date:
34  Description of Modification:
35 
36  *****************************************************************************/
37 
38 #ifndef GLOBALH
39 #define GLOBALH
40 
41 
42 // #include <iostream.h>
43 #include <stdio.h>
44 
45 #define MAXBUFLEN 64
46 
47 // cos constants, factor 512
48 #define c1d4 362L
49 #define c1d8 473L
50 #define c3d8 196L
51 #define c1d16 502L
52 #define c3d16 426L
53 #define c5d16 284L
54 #define c7d16 100L
55 
56 // correct digits
57 #define MSCALE(expr) (COEFF)((expr)>>9)
58 
59 typedef unsigned char BYTE;
60 typedef unsigned short WORD;
61 typedef unsigned long DWORD;
62 
63 typedef BYTE BLOCK[8][8];
65 typedef WORD MATRIX64x12[64];
66 
67 // type of the coefficient arrays
68 typedef short COEFF;
69 
70 // typedefs for huffman tables
71 typedef struct {
75 
76 
77 struct Block {
78  BYTE b[8][8];
79 
80  Block();
82  Block(const Block&);
83  void operator=(const Block&);
84  int operator==(const Block&) const;
85 
86  BYTE get(int x, int y) const;
87  void put(int x, int y, BYTE val);
88  BLOCK* get_ptr() const;
89 };
90 
91 struct Compressed {
93 
96  void operator=(const Compressed&);
97  int operator==(const Compressed&) const;
98 
99  void clear();
100  BYTE get(int x) const;
101  void put(int x, BYTE val);
102 };
103 
104 struct Matrix64x12 {
105  WORD m[64];
106 
109  void operator=(const Matrix64x12&);
110  int operator==(const Matrix64x12&) const;
111 
112  WORD get(int x) const;
113  void put(int x, WORD val);
114 };
115 
116 struct Coeff8 {
117  COEFF c[8];
118 
120  Coeff8(const Coeff8&);
121  void operator=(const Coeff8&);
122  int operator==(const Coeff8&) const;
123 
124  COEFF get(int x) const;
125  void put(int x, COEFF val);
126 };
127 
128 struct Coeff8x8 {
129  COEFF c[8][8];
130 
133  void operator=(const Coeff8x8&);
134  int operator==(const Coeff8x8&) const;
135 
136  COEFF get(int x, int y) const;
137  void put(int x, int y, COEFF val);
138 };
139 
140 inline
141 void
142 sc_trace( sc_trace_file*, const Coeff8x8&, const std::string& )
143 {
144  // NOT IMPLEMENTED
145 }
146 
147 
148 // quantization table 8-bit unsigned integer
149 static const unsigned char coeff_quant[8][8] = { // v is row
150  { 16, 11, 10, 16, 24, 40, 51, 61},
151  { 12, 12, 14, 19, 26, 58, 60, 55},
152  { 14, 13, 16, 24, 40, 57, 69, 56},
153  { 14, 17, 22, 29, 51, 87, 80, 82},
154  { 18, 22, 37, 56, 68, 109, 103, 77},
155  { 24, 35, 55, 64, 81, 104, 113, 92},
156  { 99, 64, 78, 87, 103, 121, 120, 101},
157  { 72, 92, 95, 98, 112, 100, 103, 99}
158 };
159 
160 
161 // table of Huffman DC coefficients
162 static const HUFFMTBL_ENTRY huffm_dc[12] = {
163  { 2, 0X0000 }, { 3, 0X0002 }, { 3, 0X0003 }, { 3, 0X0004 },
164  { 3, 0X0005 }, { 3, 0X0006 }, { 4, 0X000E }, { 5, 0X001E },
165  { 6, 0X003E }, { 7, 0X007E }, { 8, 0X00FE }, { 9, 0X01FE }
166 };
167 
168 
169 // table of Huffman AC coefficients
170 static const HUFFMTBL_ENTRY huffm_ac[256] = {
171  { 4, 0x000a }, { 2, 0x0000 }, { 2, 0x0001 }, { 3, 0x0004 },
172  { 4, 0x000b }, { 5, 0x001a }, { 7, 0x0078 }, { 8, 0x00f8 },
173  { 10, 0x03f6 }, { 16, 0xff82 }, { 16, 0xff83 }, { 0, 0x0000 },
174  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
175  { 0, 0x0000 }, { 4, 0x000c }, { 5, 0x001b }, { 7, 0x0079 },
176  { 9, 0x01f6 }, { 11, 0x07f6 }, { 16, 0xff84 }, { 16, 0xff85 },
177  { 16, 0xff86 }, { 16, 0xff87 }, { 16, 0xff88 }, { 0, 0x0000 },
178  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
179  { 0, 0x0000 }, { 5, 0x001c }, { 8, 0x00f9 }, { 10, 0x03f7 },
180  { 12, 0x0ff4 }, { 16, 0xff89 }, { 16, 0xff8a }, { 16, 0xff8b },
181  { 16, 0xff8c }, { 16, 0xff8d }, { 16, 0xff8e }, { 0, 0x0000 },
182  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
183  { 0, 0x0000 }, { 6, 0x003a }, { 9, 0x01f7 }, { 12, 0x0ff5 },
184  { 16, 0xff8f }, { 16, 0xff90 }, { 16, 0xff91 }, { 16, 0xff92 },
185  { 16, 0xff93 }, { 16, 0xff94 }, { 16, 0xff95 }, { 0, 0x0000 },
186  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
187  { 0, 0x0000 }, { 6, 0x003b }, { 10, 0x03f8 }, { 16, 0xff96 },
188  { 16, 0xff97 }, { 16, 0xff98 }, { 16, 0xff99 }, { 16, 0xff9a },
189  { 16, 0xff9b }, { 16, 0xff9c }, { 16, 0xff9d }, { 0, 0x0000 },
190  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
191  { 0, 0x0000 }, { 7, 0x007a }, { 11, 0x07f7 }, { 16, 0xff9e },
192  { 16, 0xff9f }, { 16, 0xffa0 }, { 16, 0xffa1 }, { 16, 0xffa2 },
193  { 16, 0xffa3 }, { 16, 0xffa4 }, { 16, 0xffa5 }, { 0, 0x0000 },
194  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
195  { 0, 0x0000 }, { 7, 0x007b }, { 12, 0x0ff6 }, { 16, 0xffa6 },
196  { 16, 0xffa7 }, { 16, 0xffa8 }, { 16, 0xffa9 }, { 16, 0xffaa },
197  { 16, 0xffab }, { 16, 0xffac }, { 16, 0xffad }, { 0, 0x0000 },
198  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
199  { 0, 0x0000 }, { 8, 0x00fa }, { 12, 0x0ff7 }, { 16, 0xffae },
200  { 16, 0xffaf }, { 16, 0xffb0 }, { 16, 0xffb1 }, { 16, 0xffb2 },
201  { 16, 0xffb3 }, { 16, 0xffb4 }, { 16, 0xffb5 }, { 0, 0x0000 },
202  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
203  { 0, 0x0000 }, { 9, 0x01f8 }, { 15, 0x7fc0 }, { 16, 0xffb6 },
204  { 16, 0xffb7 }, { 16, 0xffb8 }, { 16, 0xffb9 }, { 16, 0xffba },
205  { 16, 0xffbb }, { 16, 0xffbc }, { 16, 0xffbd }, { 0, 0x0000 },
206  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
207  { 0, 0x0000 }, { 9, 0x01f9 }, { 16, 0xffbe }, { 16, 0xffbf },
208  { 16, 0xffc0 }, { 16, 0xffc1 }, { 16, 0xffc2 }, { 16, 0xffc3 },
209  { 16, 0xffc4 }, { 16, 0xffc5 }, { 16, 0xffc6 }, { 0, 0x0000 },
210  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
211  { 0, 0x0000 }, { 9, 0x01fa }, { 16, 0xffc7 }, { 16, 0xffc8 },
212  { 16, 0xffc9 }, { 16, 0xffca }, { 16, 0xffcb }, { 16, 0xffcc },
213  { 16, 0xffcd }, { 16, 0xffce }, { 16, 0xffcf }, { 0, 0x0000 },
214  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
215  { 0, 0x0000 }, { 10, 0x03f9 }, { 16, 0xffd0 }, { 16, 0xffd1 },
216  { 16, 0xffd2 }, { 16, 0xffd3 }, { 16, 0xffd4 }, { 16, 0xffd5 },
217  { 16, 0xffd6 }, { 16, 0xffd7 }, { 16, 0xffd8 }, { 0, 0x0000 },
218  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
219  { 0, 0x0000 }, { 10, 0x03fa }, { 16, 0xffd9 }, { 16, 0xffda },
220  { 16, 0xffdb }, { 16, 0xffdc }, { 16, 0xffdd }, { 16, 0xffde },
221  { 16, 0xffdf }, { 16, 0xffe0 }, { 16, 0xffe1 }, { 0, 0x0000 },
222  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
223  { 0, 0x0000 }, { 11, 0x07f8 }, { 16, 0xffe2 }, { 16, 0xffe3 },
224  { 16, 0xffe4 }, { 16, 0xffe5 }, { 16, 0xffe6 }, { 16, 0xffe7 },
225  { 16, 0xffe8 }, { 16, 0xffe9 }, { 16, 0xffea }, { 0, 0x0000 },
226  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
227  { 0, 0x0000 }, { 16, 0xffeb }, { 16, 0xffec }, { 16, 0xffed },
228  { 16, 0xffee }, { 16, 0xffef }, { 16, 0xfff0 }, { 16, 0xfff1 },
229  { 16, 0xfff2 }, { 16, 0xfff3 }, { 16, 0xfff4 }, { 0, 0x0000 },
230  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
231  { 11, 0x07f9 }, { 16, 0xfff5 }, { 16, 0xfff6 }, { 16, 0xfff7 },
232  { 16, 0xfff8 }, { 16, 0xfff9 }, { 16, 0xfffa }, { 16, 0xfffb },
233  { 16, 0xfffc }, { 16, 0xfffd }, { 16, 0xfffe }, { 0, 0x0000 },
234  { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }
235  };
236 
237 
238 #endif
239 
#define MAXBUFLEN
Definition: global.h:45
BYTE COMPRESSED[MAXBUFLEN]
Definition: global.h:64
unsigned short WORD
Definition: global.h:60
static const HUFFMTBL_ENTRY huffm_ac[256]
Definition: global.h:170
WORD MATRIX64x12[64]
Definition: global.h:65
unsigned char BYTE
Definition: global.h:59
static const HUFFMTBL_ENTRY huffm_dc[12]
Definition: global.h:162
void sc_trace(sc_trace_file *, const Coeff8x8 &, const std::string &)
Definition: global.h:142
short COEFF
Definition: global.h:68
unsigned long DWORD
Definition: global.h:61
BYTE BLOCK[8][8]
Definition: global.h:63
static const unsigned char coeff_quant[8][8]
Definition: global.h:149
Bitfield< 4 > x
Definition: pagetable.hh:61
Bitfield< 63 > val
Definition: misc.hh:776
Definition: global.h:77
BLOCK * get_ptr() const
BYTE b[8][8]
Definition: global.h:78
BYTE get(int x, int y) const
Block(const Block &)
void put(int x, int y, BYTE val)
int operator==(const Block &) const
Block(BLOCK *)
void operator=(const Block &)
Definition: global.h:116
void put(int x, COEFF val)
Coeff8(const Coeff8 &)
COEFF c[8]
Definition: global.h:117
void operator=(const Coeff8 &)
COEFF get(int x) const
int operator==(const Coeff8 &) const
void put(int x, int y, COEFF val)
int operator==(const Coeff8x8 &) const
void operator=(const Coeff8x8 &)
COEFF c[8][8]
Definition: global.h:129
COEFF get(int x, int y) const
Coeff8x8(const Coeff8x8 &)
void put(int x, BYTE val)
int operator==(const Compressed &) const
void operator=(const Compressed &)
BYTE get(int x) const
void clear()
BYTE c[MAXBUFLEN]
Definition: global.h:92
Compressed(const Compressed &)
Definition: global.h:71
BYTE size
Definition: global.h:72
WORD code
Definition: global.h:73
Matrix64x12(const Matrix64x12 &)
WORD get(int x) const
WORD m[64]
Definition: global.h:105
int operator==(const Matrix64x12 &) const
void operator=(const Matrix64x12 &)
void put(int x, WORD val)

Generated on Wed Dec 21 2022 10:22:48 for gem5 by doxygen 1.9.1