112855Sgabeblack@google.com/***************************************************************************** 212855Sgabeblack@google.com 312855Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412855Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512855Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612855Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712855Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812855Sgabeblack@google.com License. You may obtain a copy of the License at 912855Sgabeblack@google.com 1012855Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112855Sgabeblack@google.com 1212855Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312855Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412855Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512855Sgabeblack@google.com implied. See the License for the specific language governing 1612855Sgabeblack@google.com permissions and limitations under the License. 1712855Sgabeblack@google.com 1812855Sgabeblack@google.com *****************************************************************************/ 1912855Sgabeblack@google.com 2012855Sgabeblack@google.com/***************************************************************************** 2112855Sgabeblack@google.com 2212855Sgabeblack@google.com global.h -- 2312855Sgabeblack@google.com 2412855Sgabeblack@google.com Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 2512855Sgabeblack@google.com 2612855Sgabeblack@google.com *****************************************************************************/ 2712855Sgabeblack@google.com 2812855Sgabeblack@google.com/***************************************************************************** 2912855Sgabeblack@google.com 3012855Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112855Sgabeblack@google.com changes you are making here. 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com Name, Affiliation, Date: 3412855Sgabeblack@google.com Description of Modification: 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com *****************************************************************************/ 3712855Sgabeblack@google.com 3812855Sgabeblack@google.com#ifndef GLOBALH 3912855Sgabeblack@google.com#define GLOBALH 4012855Sgabeblack@google.com 4112855Sgabeblack@google.com 4212855Sgabeblack@google.com// #include <iostream.h> 4312855Sgabeblack@google.com#include <stdio.h> 4412855Sgabeblack@google.com 4512855Sgabeblack@google.com#define MAXBUFLEN 64 4612855Sgabeblack@google.com 4712855Sgabeblack@google.com// cos constants, factor 512 4812855Sgabeblack@google.com#define c1d4 362L 4912855Sgabeblack@google.com#define c1d8 473L 5012855Sgabeblack@google.com#define c3d8 196L 5112855Sgabeblack@google.com#define c1d16 502L 5212855Sgabeblack@google.com#define c3d16 426L 5312855Sgabeblack@google.com#define c5d16 284L 5412855Sgabeblack@google.com#define c7d16 100L 5512855Sgabeblack@google.com 5612855Sgabeblack@google.com// correct digits 5712855Sgabeblack@google.com#define MSCALE(expr) (COEFF)((expr)>>9) 5812855Sgabeblack@google.com 5912855Sgabeblack@google.comtypedef unsigned char BYTE; 6012855Sgabeblack@google.comtypedef unsigned short WORD; 6112855Sgabeblack@google.comtypedef unsigned long DWORD; 6212855Sgabeblack@google.com 6312855Sgabeblack@google.comtypedef BYTE BLOCK[8][8]; 6412855Sgabeblack@google.comtypedef BYTE COMPRESSED[MAXBUFLEN]; 6512855Sgabeblack@google.comtypedef WORD MATRIX64x12[64]; 6612855Sgabeblack@google.com 6712855Sgabeblack@google.com// type of the coefficient arrays 6812855Sgabeblack@google.comtypedef short COEFF; 6912855Sgabeblack@google.com 7012855Sgabeblack@google.com// typedefs for huffman tables 7112855Sgabeblack@google.comtypedef struct { 7212855Sgabeblack@google.com BYTE size; 7312855Sgabeblack@google.com WORD code; 7412855Sgabeblack@google.com} HUFFMTBL_ENTRY; 7512855Sgabeblack@google.com 7612855Sgabeblack@google.com 7712855Sgabeblack@google.comstruct Block { 7812855Sgabeblack@google.com BYTE b[8][8]; 7912855Sgabeblack@google.com 8012855Sgabeblack@google.com Block(); 8112855Sgabeblack@google.com Block(BLOCK *); 8212855Sgabeblack@google.com Block(const Block&); 8312855Sgabeblack@google.com void operator=(const Block&); 8412855Sgabeblack@google.com int operator==(const Block&) const; 8512855Sgabeblack@google.com 8612855Sgabeblack@google.com BYTE get(int x, int y) const; 8712855Sgabeblack@google.com void put(int x, int y, BYTE val); 8812855Sgabeblack@google.com BLOCK* get_ptr() const; 8912855Sgabeblack@google.com}; 9012855Sgabeblack@google.com 9112855Sgabeblack@google.comstruct Compressed { 9212855Sgabeblack@google.com BYTE c[MAXBUFLEN]; 9312855Sgabeblack@google.com 9412855Sgabeblack@google.com Compressed(); 9512855Sgabeblack@google.com Compressed(const Compressed&); 9612855Sgabeblack@google.com void operator=(const Compressed&); 9712855Sgabeblack@google.com int operator==(const Compressed&) const; 9812855Sgabeblack@google.com 9912855Sgabeblack@google.com void clear(); 10012855Sgabeblack@google.com BYTE get(int x) const; 10112855Sgabeblack@google.com void put(int x, BYTE val); 10212855Sgabeblack@google.com}; 10312855Sgabeblack@google.com 10412855Sgabeblack@google.comstruct Matrix64x12 { 10512855Sgabeblack@google.com WORD m[64]; 10612855Sgabeblack@google.com 10712855Sgabeblack@google.com Matrix64x12(); 10812855Sgabeblack@google.com Matrix64x12(const Matrix64x12&); 10912855Sgabeblack@google.com void operator=(const Matrix64x12&); 11012855Sgabeblack@google.com int operator==(const Matrix64x12&) const; 11112855Sgabeblack@google.com 11212855Sgabeblack@google.com WORD get(int x) const; 11312855Sgabeblack@google.com void put(int x, WORD val); 11412855Sgabeblack@google.com}; 11512855Sgabeblack@google.com 11612855Sgabeblack@google.comstruct Coeff8 { 11712855Sgabeblack@google.com COEFF c[8]; 11812855Sgabeblack@google.com 11912855Sgabeblack@google.com Coeff8(); 12012855Sgabeblack@google.com Coeff8(const Coeff8&); 12112855Sgabeblack@google.com void operator=(const Coeff8&); 12212855Sgabeblack@google.com int operator==(const Coeff8&) const; 12312855Sgabeblack@google.com 12412855Sgabeblack@google.com COEFF get(int x) const; 12512855Sgabeblack@google.com void put(int x, COEFF val); 12612855Sgabeblack@google.com}; 12712855Sgabeblack@google.com 12812855Sgabeblack@google.comstruct Coeff8x8 { 12912855Sgabeblack@google.com COEFF c[8][8]; 13012855Sgabeblack@google.com 13112855Sgabeblack@google.com Coeff8x8(); 13212855Sgabeblack@google.com Coeff8x8(const Coeff8x8&); 13312855Sgabeblack@google.com void operator=(const Coeff8x8&); 13412855Sgabeblack@google.com int operator==(const Coeff8x8&) const; 13512855Sgabeblack@google.com 13612855Sgabeblack@google.com COEFF get(int x, int y) const; 13712855Sgabeblack@google.com void put(int x, int y, COEFF val); 13812855Sgabeblack@google.com}; 13912855Sgabeblack@google.com 14012855Sgabeblack@google.cominline 14112855Sgabeblack@google.comvoid 14212855Sgabeblack@google.comsc_trace( sc_trace_file*, const Coeff8x8&, const std::string& ) 14312855Sgabeblack@google.com{ 14412855Sgabeblack@google.com // NOT IMPLEMENTED 14512855Sgabeblack@google.com} 14612855Sgabeblack@google.com 14712855Sgabeblack@google.com 14812855Sgabeblack@google.com// quantization table 8-bit unsigned integer 14912855Sgabeblack@google.comstatic const unsigned char coeff_quant[8][8] = { // v is row 15012855Sgabeblack@google.com { 16, 11, 10, 16, 24, 40, 51, 61}, 15112855Sgabeblack@google.com { 12, 12, 14, 19, 26, 58, 60, 55}, 15212855Sgabeblack@google.com { 14, 13, 16, 24, 40, 57, 69, 56}, 15312855Sgabeblack@google.com { 14, 17, 22, 29, 51, 87, 80, 82}, 15412855Sgabeblack@google.com { 18, 22, 37, 56, 68, 109, 103, 77}, 15512855Sgabeblack@google.com { 24, 35, 55, 64, 81, 104, 113, 92}, 15612855Sgabeblack@google.com { 99, 64, 78, 87, 103, 121, 120, 101}, 15712855Sgabeblack@google.com { 72, 92, 95, 98, 112, 100, 103, 99} 15812855Sgabeblack@google.com}; 15912855Sgabeblack@google.com 16012855Sgabeblack@google.com 16112855Sgabeblack@google.com// table of Huffman DC coefficients 16212855Sgabeblack@google.comstatic const HUFFMTBL_ENTRY huffm_dc[12] = { 16312855Sgabeblack@google.com { 2, 0X0000 }, { 3, 0X0002 }, { 3, 0X0003 }, { 3, 0X0004 }, 16412855Sgabeblack@google.com { 3, 0X0005 }, { 3, 0X0006 }, { 4, 0X000E }, { 5, 0X001E }, 16512855Sgabeblack@google.com { 6, 0X003E }, { 7, 0X007E }, { 8, 0X00FE }, { 9, 0X01FE } 16612855Sgabeblack@google.com}; 16712855Sgabeblack@google.com 16812855Sgabeblack@google.com 16912855Sgabeblack@google.com// table of Huffman AC coefficients 17012855Sgabeblack@google.comstatic const HUFFMTBL_ENTRY huffm_ac[256] = { 17112855Sgabeblack@google.com { 4, 0x000a }, { 2, 0x0000 }, { 2, 0x0001 }, { 3, 0x0004 }, 17212855Sgabeblack@google.com { 4, 0x000b }, { 5, 0x001a }, { 7, 0x0078 }, { 8, 0x00f8 }, 17312855Sgabeblack@google.com { 10, 0x03f6 }, { 16, 0xff82 }, { 16, 0xff83 }, { 0, 0x0000 }, 17412855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 17512855Sgabeblack@google.com { 0, 0x0000 }, { 4, 0x000c }, { 5, 0x001b }, { 7, 0x0079 }, 17612855Sgabeblack@google.com { 9, 0x01f6 }, { 11, 0x07f6 }, { 16, 0xff84 }, { 16, 0xff85 }, 17712855Sgabeblack@google.com { 16, 0xff86 }, { 16, 0xff87 }, { 16, 0xff88 }, { 0, 0x0000 }, 17812855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 17912855Sgabeblack@google.com { 0, 0x0000 }, { 5, 0x001c }, { 8, 0x00f9 }, { 10, 0x03f7 }, 18012855Sgabeblack@google.com { 12, 0x0ff4 }, { 16, 0xff89 }, { 16, 0xff8a }, { 16, 0xff8b }, 18112855Sgabeblack@google.com { 16, 0xff8c }, { 16, 0xff8d }, { 16, 0xff8e }, { 0, 0x0000 }, 18212855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 18312855Sgabeblack@google.com { 0, 0x0000 }, { 6, 0x003a }, { 9, 0x01f7 }, { 12, 0x0ff5 }, 18412855Sgabeblack@google.com { 16, 0xff8f }, { 16, 0xff90 }, { 16, 0xff91 }, { 16, 0xff92 }, 18512855Sgabeblack@google.com { 16, 0xff93 }, { 16, 0xff94 }, { 16, 0xff95 }, { 0, 0x0000 }, 18612855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 18712855Sgabeblack@google.com { 0, 0x0000 }, { 6, 0x003b }, { 10, 0x03f8 }, { 16, 0xff96 }, 18812855Sgabeblack@google.com { 16, 0xff97 }, { 16, 0xff98 }, { 16, 0xff99 }, { 16, 0xff9a }, 18912855Sgabeblack@google.com { 16, 0xff9b }, { 16, 0xff9c }, { 16, 0xff9d }, { 0, 0x0000 }, 19012855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 19112855Sgabeblack@google.com { 0, 0x0000 }, { 7, 0x007a }, { 11, 0x07f7 }, { 16, 0xff9e }, 19212855Sgabeblack@google.com { 16, 0xff9f }, { 16, 0xffa0 }, { 16, 0xffa1 }, { 16, 0xffa2 }, 19312855Sgabeblack@google.com { 16, 0xffa3 }, { 16, 0xffa4 }, { 16, 0xffa5 }, { 0, 0x0000 }, 19412855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 19512855Sgabeblack@google.com { 0, 0x0000 }, { 7, 0x007b }, { 12, 0x0ff6 }, { 16, 0xffa6 }, 19612855Sgabeblack@google.com { 16, 0xffa7 }, { 16, 0xffa8 }, { 16, 0xffa9 }, { 16, 0xffaa }, 19712855Sgabeblack@google.com { 16, 0xffab }, { 16, 0xffac }, { 16, 0xffad }, { 0, 0x0000 }, 19812855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 19912855Sgabeblack@google.com { 0, 0x0000 }, { 8, 0x00fa }, { 12, 0x0ff7 }, { 16, 0xffae }, 20012855Sgabeblack@google.com { 16, 0xffaf }, { 16, 0xffb0 }, { 16, 0xffb1 }, { 16, 0xffb2 }, 20112855Sgabeblack@google.com { 16, 0xffb3 }, { 16, 0xffb4 }, { 16, 0xffb5 }, { 0, 0x0000 }, 20212855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 20312855Sgabeblack@google.com { 0, 0x0000 }, { 9, 0x01f8 }, { 15, 0x7fc0 }, { 16, 0xffb6 }, 20412855Sgabeblack@google.com { 16, 0xffb7 }, { 16, 0xffb8 }, { 16, 0xffb9 }, { 16, 0xffba }, 20512855Sgabeblack@google.com { 16, 0xffbb }, { 16, 0xffbc }, { 16, 0xffbd }, { 0, 0x0000 }, 20612855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 20712855Sgabeblack@google.com { 0, 0x0000 }, { 9, 0x01f9 }, { 16, 0xffbe }, { 16, 0xffbf }, 20812855Sgabeblack@google.com { 16, 0xffc0 }, { 16, 0xffc1 }, { 16, 0xffc2 }, { 16, 0xffc3 }, 20912855Sgabeblack@google.com { 16, 0xffc4 }, { 16, 0xffc5 }, { 16, 0xffc6 }, { 0, 0x0000 }, 21012855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 21112855Sgabeblack@google.com { 0, 0x0000 }, { 9, 0x01fa }, { 16, 0xffc7 }, { 16, 0xffc8 }, 21212855Sgabeblack@google.com { 16, 0xffc9 }, { 16, 0xffca }, { 16, 0xffcb }, { 16, 0xffcc }, 21312855Sgabeblack@google.com { 16, 0xffcd }, { 16, 0xffce }, { 16, 0xffcf }, { 0, 0x0000 }, 21412855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 21512855Sgabeblack@google.com { 0, 0x0000 }, { 10, 0x03f9 }, { 16, 0xffd0 }, { 16, 0xffd1 }, 21612855Sgabeblack@google.com { 16, 0xffd2 }, { 16, 0xffd3 }, { 16, 0xffd4 }, { 16, 0xffd5 }, 21712855Sgabeblack@google.com { 16, 0xffd6 }, { 16, 0xffd7 }, { 16, 0xffd8 }, { 0, 0x0000 }, 21812855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 21912855Sgabeblack@google.com { 0, 0x0000 }, { 10, 0x03fa }, { 16, 0xffd9 }, { 16, 0xffda }, 22012855Sgabeblack@google.com { 16, 0xffdb }, { 16, 0xffdc }, { 16, 0xffdd }, { 16, 0xffde }, 22112855Sgabeblack@google.com { 16, 0xffdf }, { 16, 0xffe0 }, { 16, 0xffe1 }, { 0, 0x0000 }, 22212855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 22312855Sgabeblack@google.com { 0, 0x0000 }, { 11, 0x07f8 }, { 16, 0xffe2 }, { 16, 0xffe3 }, 22412855Sgabeblack@google.com { 16, 0xffe4 }, { 16, 0xffe5 }, { 16, 0xffe6 }, { 16, 0xffe7 }, 22512855Sgabeblack@google.com { 16, 0xffe8 }, { 16, 0xffe9 }, { 16, 0xffea }, { 0, 0x0000 }, 22612855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 22712855Sgabeblack@google.com { 0, 0x0000 }, { 16, 0xffeb }, { 16, 0xffec }, { 16, 0xffed }, 22812855Sgabeblack@google.com { 16, 0xffee }, { 16, 0xffef }, { 16, 0xfff0 }, { 16, 0xfff1 }, 22912855Sgabeblack@google.com { 16, 0xfff2 }, { 16, 0xfff3 }, { 16, 0xfff4 }, { 0, 0x0000 }, 23012855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, 23112855Sgabeblack@google.com { 11, 0x07f9 }, { 16, 0xfff5 }, { 16, 0xfff6 }, { 16, 0xfff7 }, 23212855Sgabeblack@google.com { 16, 0xfff8 }, { 16, 0xfff9 }, { 16, 0xfffa }, { 16, 0xfffb }, 23312855Sgabeblack@google.com { 16, 0xfffc }, { 16, 0xfffd }, { 16, 0xfffe }, { 0, 0x0000 }, 23412855Sgabeblack@google.com { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 } 23512855Sgabeblack@google.com }; 23612855Sgabeblack@google.com 23712855Sgabeblack@google.com 23812855Sgabeblack@google.com#endif 23912855Sgabeblack@google.com 240