Commit ce918b6d authored by Aolin's avatar Aolin
Browse files

init+yuv

parent 8d0ce53d
#include "TypeDef.h"
#include "BitStream.h"
#include <iostream>
Void writeBit(UInt value, UInt length)
Void BitStream:: writeBit(UInt value, UInt length)
{
// input value and length of current Huffman code
// write to data
UInt byteID = bitPos / 8;
UInt bitID = bitPos % 8;
if (length <= 8 - bitID)
{
data[byteID] += value << (8 - bitID - length);
bitPos += length;
}
else
{
UInt writein = value >> (length - (8 - bitID));
data[byteID] += writein;
bitPos += 8 - bitID;
writeBit(value - writein << (length - (8 - bitID)), length - (8 - bitID));
}
}
Void BitStream::init()
{
data = new unsigned char[MAXBYTENUM];
memset(data, 0, MAXBYTENUM);
bitPos = 0;
}
Void BitStream::destroy()
{
delete[] data;
data = NULL;
}
Void BitStream::saveBit(const char * filename)
{
FILE* fid;
fopen_s(&fid, filename, "wb");
fwrite(data, sizeof(unsigned char), ceil(bitPos / 8.0), fid);
fclose(fid);
}
\ No newline at end of file
......@@ -10,8 +10,10 @@ class BitStream
UChar* data;
UInt bitPos; //num of bits
public:
Void init();
Void destroy();
Void writeBit(UInt value, UInt length);
Void saveBit(const char* filename);
};
#endif
\ No newline at end of file
......@@ -4,59 +4,217 @@
Void CodingUnit::create() //allocate memory for YUV and coeff
{
m_puiCUYuvBuf = new Pel[CUSIZE*CUSIZE];
m_puiCuDctCoeff = new TCoeff[CUSIZE*CUSIZE];
m_puiCuQuanCoeff = new TCoeff[CUSIZE*CUSIZE];
}
Void CodingUnit::destroy() //free memory
{
delete[] m_puiCUYuvBuf;
delete[] m_puiCuDctCoeff;
delete[] m_puiCuQuanCoeff;
}
Void CodingUnit::initCu(ComponentID ch, UInt row, UInt col, CommonPic* pic)
Void CodingUnit::initCU(ComponentID ch, UInt row, UInt col, CommonPic* pPic)
{
m_ComponentId = ch;
m_uiChannal = ch;
m_uiRow = row;
m_uiCol = col;
m_pPic = pic;
m_pPic = pPic;
UInt uiPicWidth = m_pPic->getPicWidth();
Pel* puiOrgPicBuf = m_pPic->getBufAddr(ch);
for (int i = 0; i < CUSIZE; i++)
{
for (int j = 0; j < CUSIZE; j++)
{
m_puiCUYuvBuf[i*CUSIZE + j] = puiOrgPicBuf[row*uiPicWidth*CUSIZE + col*CUSIZE + i*uiPicWidth + j];
}
}
}
Void CodingUnit::compressCu()
//input: uiCuYuvBuf
//output: m_puiCuQuanCoeff
Void CodingUnit::compressCU()
{
//input: uiCuYuvBuf
//output: m_puiCuQuanCoeff
transform();
quantize();
}
Void CodingUnit::encodeCu()
Void CodingUnit::encodeCU()
{
//input: m_puiCuQuanCoeff
//output: bitstream
huffman();
}
//input: uiCuYuvBuf
//output: uiCuDctCoeff
//scan order, scale
Void CodingUnit::transform() //
{
//input: uiCuYuvBuf
//output: uiCuDctCoeff
//scan order, scale
}
//input: uiCuDctCoeff
//output: uiQuanDctCoeff
//copy quantized coeff to pic
Void CodingUnit::quantize() // quantize dct coeff and copy quantized coeff to pic
{
//input: uiCuDctCoeff
//output: uiQuanDctCoeff
//copy quantized coeff to pic
UInt uiComponentType = (m_uiChannal == COMPONENT_Y) ? 0 : 1;
UInt* uiQuanTable = m_pPic->getQpTable(uiComponentType);
UInt uiNumOfPixelInCU = CUSIZE * CUSIZE;
for (UInt n = 0; n < uiNumOfPixelInCU; n++)
{
*(m_puiCuQuanCoeff+n) = round( *(m_puiCuDctCoeff+n) / *(uiQuanTable+n) );
}
}
//input: cu information
//output: pic information
Void CodingUnit::copyPartToPic()
{
TCoeff* uiPicCoeff = m_pPic->getQuanCoeffAddr(m_uiChannal, m_uiRow, m_uiCol); //picCoeff address of (row, col) CU
UInt uiNumOfPixelInCU = CUSIZE * CUSIZE;
for (UInt n = 0; n < uiNumOfPixelInCU; n++)
{
*(uiPicCoeff + n) = *(m_puiCuQuanCoeff + n);
}
}
void CodingUnit::huffman() // quaDctCoeff>bitstream
Void CodingUnit::huffman() // quaDctCoeff>bitstream
{
//input:uiQuaDctCoeff
//output:pic.bitstream
huffmanDC();
huffmanAC();
}
Void CodingUnit::huffmanDC()
{
//compute DC difference
TCoeff iDC, iDCLast, iDCDiff;
UInt uiNumPixelInCU = CUSIZE * CUSIZE;
iDC = *(m_pPic->getQuanCoeffAddr(m_uiChannal, m_uiRow, m_uiCol));
iDCLast = (m_uiCUIdx == 0) ? 0 : *(m_pPic->getQuanCoeffAddr(m_uiChannal, m_uiRow, m_uiCol) - uiNumPixelInCU);
iDCDiff = iDC - iDCLast;
UInt uiDCLength = getBitLengthOfValue(iDCDiff);
//look up code and length of DC difference from huffman table
UInt uiCodeOfDCLength, uiLengthOfCode;
if (m_uiChannal == COMPONENT_Y)
{
uiCodeOfDCLength = *(m_pPic->getHuffmanTableLumaDC() + uiDCLength);
uiLengthOfCode = *(m_pPic->getHuffmanTableLumaDC() + DCLENGTH + uiDCLength);
}
else
{
uiCodeOfDCLength = *(m_pPic->getHuffmanTableChromaDC() + uiDCLength);
uiLengthOfCode = *(m_pPic->getHuffmanTableChromaDC() + DCLENGTH + uiDCLength);
}
//write DCDiffLength
m_pPic->getBitStream()->writeBit(uiCodeOfDCLength, uiLengthOfCode);
//write DCDiff value
UInt iDCComplement = getComplement(iDCDiff);
m_pPic->getBitStream()->writeBit(iDCComplement, uiDCLength);
}
Void CodingUnit::huffmanAC()
{
TCoeff* uiQuanCoeff = m_pPic->getQuanCoeffAddr(m_uiChannal, m_uiRow, m_uiCol);
UInt uiNumPixelInCU = CUSIZE * CUSIZE;
//derive EOB
UInt uiPosEOB = uiNumPixelInCU - 1;
while (*(uiQuanCoeff + g_uiZigZagTable[uiPosEOB]) != 0)
{
uiPosEOB--;
}
UInt uiZigZagEOB = g_uiZigZagTable[uiPosEOB];
//derive run and size
UInt uiRun = 0, uiMaxRun = 16;
for (UInt uiPos = 0; uiPos <= uiPosEOB; uiPos++)
{
if (*(uiQuanCoeff + g_uiZigZagTable[uiPos]) == 0)
{
uiRun++;
if (uiRun == uiMaxRun)
{
UInt uiRunSize = (uiRun - 1) << 4 + 0; //F0
UInt uiCode, uiLength;
if (m_uiChannal == COMPONENT_Y)
{
uiCode = *(m_pPic->getHuffmanTableLumaAC + uiRunSize);
uiLength = *(m_pPic->getHuffmanTableLumaAC + ACLENGTH + uiRunSize);
}
else
{
uiCode = *(m_pPic->getHuffmanTableChromaAC + uiRunSize);
uiLength = *(m_pPic->getHuffmanTableChromaAC + ACLENGTH + uiRunSize);
}
m_pPic->getBitStream()->writeBit(uiCode, uiLength);
}
uiRun = 0; //init uiRun
}
else
{
UInt uiNonZeroValue = *(uiQuanCoeff + g_uiZigZagTable[uiPos]);
UInt uiSize = getBitLengthOfValue(uiNonZeroValue);
UInt uiRunSize = (uiRun << 4) + uiSize;
uiRun = 0; //init uiRun
UInt uiCode, uiLength;
if (m_uiChannal == COMPONENT_Y)
{
uiCode = *(m_pPic->getHuffmanTableLumaAC + uiRunSize);
uiLength = *(m_pPic->getHuffmanTableLumaAC + ACLENGTH + uiRunSize);
}
else
{
uiCode = *(m_pPic->getHuffmanTableLumaAC + uiRunSize);
uiLength = *(m_pPic->getHuffmanTableLumaAC + ACLENGTH + uiRunSize);
}
//write run and size of nonzero value
m_pPic->getBitStream()->writeBit(uiCode, uiLength);
//write nonzero value
UInt iDCComplement = getComplement(uiNonZeroValue);
m_pPic->getBitStream()->writeBit(uiNonZeroValue, uiSize);
}
}
//write EOB
if (uiPosEOB != 63)
{
m_pPic->getBitStream()->writeBit(0, 8); //
}
}
Void CodingUnit::copyPartToPic()
{
//input: cu information
//output: pic information
}
UInt getBitLengthOfValue(Int value)
{
UInt uiAbsValue = abs(value);
UInt length = 0;
while (uiAbsValue != 0)
{
length++;
uiAbsValue = uiAbsValue >> 1;
}
return length;
}
UInt getComplement(Int value)
{
if (value >= 0) { return value; }
else { return ~abs(value); }
}
\ No newline at end of file
......@@ -7,10 +7,11 @@
class CodingUnit
{
private:
ComponentID m_ComponentId;
ComponentID m_uiChannal;
UInt m_uiCUIdx;
UInt m_uiRow;
UInt m_uiCol;
Pel* m_puiCuYuvBuf;
Pel* m_puiCUYuvBuf;
TCoeff* m_puiCuDctCoeff;
TCoeff* m_puiCuQuanCoeff;
CommonPic* m_pPic;
......@@ -18,20 +19,25 @@ class CodingUnit
public:
Void create(); //allocate memory for YUV and coeff
Void destroy(); //free memory
Void initCu(ComponentID ch, UInt row, UInt col, CommonPic* pic);
Void initCU(ComponentID ch, UInt row, UInt col, CommonPic* pPic);
Pel* getYuvAddr() { return m_puiCuYuvBuf; } //start address of yuv
Pel* getYuvAddr() { return m_puiCUYuvBuf; } //start address of yuv
TCoeff* getDctCoeffAddr() { return m_puiCuDctCoeff; } //start address of dct
TCoeff* getQuanCoeffAddr() { return m_puiCuQuanCoeff; } //start address of quan
TCoeff* getQuanCoeffAddr() { return m_puiCuQuanCoeff; }
Void compressCu();
Void encodeCu();
CommonPic* getCommonPic() { return m_pPic; }
ComponentID getComponentID() { return m_uiChannal; }
Void compressCU();
Void encodeCU();
Void transform();
Void quantize();
Void huffman();// quaDctCoeff>bitstream
Void huffmanDC();
Void huffmanAC();
Void copyPartToPic(); //copy cu to pic, including m_puiCuQuanCoeff
};
};
#endif
\ No newline at end of file
......@@ -5,18 +5,19 @@
Void CommonPic::compressPic()
{
computeQpTable();
for (UInt ch = COMPONENT_Y; ch < MAX_NUM_COMPONENT; ch++)
{
UInt uiScale = (ch == COMPONENT_Y) ? 1 : 2;
for (UInt row = 0; row < m_uiPicWidth / uiScale / CUSIZE; row++)
for (UInt uiRow = 0; uiRow < m_uiPicWidth / uiScale / CUSIZE; uiRow++)
{
for (UInt col = 0; col < m_uiPicHeight /uiScale / CUSIZE; col++)
for (UInt uiCol = 0; uiCol < m_uiPicHeight / uiScale / CUSIZE; uiCol++)
{
CodingUnit rcCu;
rcCu.create();
rcCu.initCu((ComponentID)ch, row, col, this);
rcCu.compressCu();
rcCu.destroy();
CodingUnit rcCU;
rcCU.create();
rcCU.initCU((ComponentID)ch, uiRow, uiCol, this);
rcCU.compressCU();
rcCU.destroy();
}
}
}
......@@ -27,15 +28,15 @@ Void CommonPic::encodePic()
for (UInt ch = COMPONENT_Y; ch < MAX_NUM_COMPONENT; ch++)
{
UInt uiScale = (ch == COMPONENT_Y) ? 1 : 2;
for (UInt row = 0; row < m_uiPicWidth / uiScale / CUSIZE; row++)
for (UInt uiRow = 0; uiRow < m_uiPicWidth / uiScale / CUSIZE; uiRow++)
{
for (UInt col = 0; col < m_uiPicHeight / uiScale / CUSIZE; col++)
for (UInt uiCol = 0; uiCol < m_uiPicHeight / uiScale / CUSIZE; uiCol++)
{
CodingUnit rcCu;
rcCu.create();
rcCu.initCu((ComponentID)ch, row, col, this);
rcCu.encodeCu();
rcCu.destroy();
CodingUnit rcCU;
rcCU.create();
rcCU.initCU((ComponentID)ch, uiRow, uiCol, this);
rcCU.encodeCU();
rcCU.destroy();
}
}
}
......@@ -43,7 +44,7 @@ Void CommonPic::encodePic()
Void CommonPic::create() //allocate memory for YUV, bitstream and coeff
{
}
Void CommonPic::destroy() //free memory
......@@ -51,33 +52,102 @@ Void CommonPic::destroy() //free memory
}
Void CommonPic::init(Cfg cfg)
{
m_uiOrgPicWidth = cfg.getPicWidth();
m_uiOrgPicHeight = cfg.getPicHeight();
ChromaFormat chromaFormat = cfg.getChromaFormat();
UInt uiEvenPicWidth = m_uiOrgPicWidth % 2 ? m_uiOrgPicWidth + 1 : m_uiOrgPicWidth;
UInt uiEvenPicHeight = m_uiOrgPicHeight % 2 ? m_uiOrgPicHeight + 1 : m_uiOrgPicHeight;
m_uiPicWidth = uiEvenPicWidth % CUSIZE ? (uiEvenPicWidth / CUSIZE + 1) * CUSIZE : uiEvenPicWidth;
m_uiPicHeight = uiEvenPicHeight % CUSIZE ? (uiEvenPicHeight / CUSIZE + 1) * CUSIZE : uiEvenPicHeight;
for (int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++)
{
UInt uiScale = (chromaFormat == CHROMA_420 && iComp != COMPONENT_Y) ? 4 : 1;
m_puiOrgPicRgb[iComp] = new Pel[m_uiOrgPicWidth * m_uiOrgPicWidth];
m_puiOrgPicYuv[iComp] = new Pel[uiEvenPicWidth * uiEvenPicHeight];
m_puiOrgPicBuf[iComp] = new Pel[m_uiPicWidth * m_uiPicHeight / uiScale];
m_uiPicDctCoeff[iComp] = new TCoeff[m_uiPicWidth * m_uiPicHeight / uiScale];
m_piPicQuanCoeff[iComp] = new TCoeff[m_uiPicWidth * m_uiPicHeight / uiScale];
// readRgb(string filename); //read yuv to uiOrgPicYuv
// colorSpaceConvert(); // color space convert, subsample
// preProcessing(); // padding,
// init bitstream:position,data
memset(m_puiOrgPicRgb[iComp], 0, m_uiOrgPicWidth * m_uiOrgPicWidth);
memset(m_puiOrgPicYuv[iComp], 0, uiEvenPicWidth * uiEvenPicHeight);
memset(m_puiOrgPicBuf[iComp], 0, m_uiPicWidth * m_uiPicHeight / uiScale);
memset(m_uiPicDctCoeff[iComp], 0, m_uiPicWidth * m_uiPicHeight / uiScale);
memset(m_piPicQuanCoeff[iComp], 0, m_uiPicWidth * m_uiPicHeight / uiScale);
}
readRgb(cfg.getInputFileName());
colorSpaceConvert(chromaFormat);
}
Bool CommonPic::readRgb() //read yuv to uiOrgPicYuv
Void CommonPic::readRgb(string sInputFileName) //read yuv to uiOrgPicYuv
{
//input: filename defined in cfg
//output: uiOrgPicRgb
FILE* file = fopen(sInputFileName.c_str(), "rb+");
fread(m_puiOrgPicRgb[COMPONENT_Y], sizeof(Pel), m_uiOrgPicHeight * m_uiOrgPicWidth, file);//R
fread(m_puiOrgPicRgb[COMPONENT_Cb], sizeof(Pel), m_uiOrgPicHeight * m_uiOrgPicWidth, file);//G
fread(m_puiOrgPicRgb[COMPONENT_Cr], sizeof(Pel), m_uiOrgPicHeight * m_uiOrgPicWidth, file);//B
fclose(file);
}
Bool CommonPic::colorSpaceConvert() // color space convert, subsample
Void CommonPic::colorSpaceConvert(ChromaFormat format) // color space convert, subsample
{
//input: uiOrgPicRgb
//output: uiOrgPicYuv
UInt uiEvenPicWidth = m_uiOrgPicWidth % 2 ? m_uiOrgPicWidth + 1 : m_uiOrgPicWidth;
UInt uiEvenPicHeight = m_uiOrgPicHeight % 2 ? m_uiOrgPicHeight + 1 : m_uiOrgPicHeight;
for (int i = 0; i < m_uiOrgPicHeight; i++)
{
for (int j = 0; j < m_uiOrgPicWidth; j++)
{
m_puiOrgPicYuv[COMPONENT_Y][i * uiEvenPicWidth + j] = 0.212600 * m_puiOrgPicRgb[COMPONENT_Y][i * m_uiOrgPicWidth + j] + 0.715200 * m_puiOrgPicRgb[COMPONENT_Cb][i * m_uiOrgPicWidth + j] + 0.072200 * m_puiOrgPicRgb[COMPONENT_Cr][i * m_uiOrgPicWidth + j]; //Y
m_puiOrgPicYuv[COMPONENT_Cb][i * uiEvenPicWidth + j] = -0.114572 * m_puiOrgPicRgb[COMPONENT_Y][i * m_uiOrgPicWidth + j] - 0.385428 * m_puiOrgPicRgb[COMPONENT_Cb][i * m_uiOrgPicWidth + j] + 0.5 * m_puiOrgPicRgb[COMPONENT_Cr][i * m_uiOrgPicWidth + j] + 128; //U
m_puiOrgPicYuv[COMPONENT_Cr][i * uiEvenPicWidth + j] = 0.5 * m_puiOrgPicRgb[COMPONENT_Y][i * m_uiOrgPicWidth + j] - 0.454153 * m_puiOrgPicRgb[COMPONENT_Cb][i * m_uiOrgPicWidth + j] - 0.045847 * m_puiOrgPicRgb[COMPONENT_Cr][i * m_uiOrgPicWidth + j] + 128; //V
}
}
if (format == CHROMA_420)
{
for (int i = 0; i < uiEvenPicHeight; i++)
{
for (int j = 0; j < uiEvenPicWidth; j++)
{
m_puiOrgPicBuf[COMPONENT_Y][i * m_uiPicWidth + j] = m_puiOrgPicYuv[COMPONENT_Y][i * uiEvenPicWidth + j];
}
}
for (int i = 0; i < uiEvenPicHeight >> 1; i++)
{
for (int j = 0; j < uiEvenPicWidth >> 1; j++)
{
m_puiOrgPicBuf[COMPONENT_Cb][i * (m_uiPicWidth >> 1) + j] = m_puiOrgPicYuv[COMPONENT_Cb][(i << 1)*uiEvenPicWidth + (j << 1)];
m_puiOrgPicBuf[COMPONENT_Cr][i * (m_uiPicWidth >> 1) + j] = m_puiOrgPicYuv[COMPONENT_Cr][(i << 1)*uiEvenPicWidth + (j << 1)];
}
}
}
else if (format == CHROMA_444)
{
for (int i = 0; i < uiEvenPicHeight; i++)
{
for (int j = 0; j < uiEvenPicWidth; j++)
{
m_puiOrgPicBuf[COMPONENT_Y][i * m_uiPicWidth + j] = m_puiOrgPicYuv[COMPONENT_Y][i * uiEvenPicWidth + j];
m_puiOrgPicBuf[COMPONENT_Cb][i * m_uiPicWidth + j] = m_puiOrgPicYuv[COMPONENT_Cb][i * uiEvenPicWidth + j];
m_puiOrgPicBuf[COMPONENT_Cr][i * m_uiPicWidth + j] = m_puiOrgPicYuv[COMPONENT_Cr][i * uiEvenPicWidth + j];
}
}
}
}
Bool CommonPic::preProcessing() // padding,
Void CommonPic::preProcessing() // padding,
{
//input: uiOrgPicYuv
//output: uiOrgPicYuvBuf
//output: uiOrgPicYuv
}
void CommonPic::writeHead()
{
......@@ -88,3 +158,54 @@ Void CommonPic::saveBitStream()
{
}
Void CommonPic::huffmanTableGeneration()
{
huffmanTableGenerationBase(g_uiDCLengthDHT[0], g_uiDCSymbolDHT[0], this->getHuffmanTableLumaDC(), this->getHuffmanTableLumaDC()+DCLENGTH); //LumaDC
huffmanTableGenerationBase(g_uiDCLengthDHT[1], g_uiDCSymbolDHT[1], this->getHuffmanTableChromaDC(), this->getHuffmanTableChromaDC()+DCLENGTH); //ChromaDC
huffmanTableGenerationBase(g_uiACLengthDHT[0], g_uiACSymbolDHT[0], this->getHuffmanTableLumaAC(), this->getHuffmanTableLumaAC() + ACLENGTH); //LumaDC
huffmanTableGenerationBase(g_uiACLengthDHT[1], g_uiACSymbolDHT[1], this->getHuffmanTableChromaAC(), this->getHuffmanTableChromaAC() + ACLENGTH); //ChromaDC
}
Void CommonPic::huffmanTableGenerationBase(UInt* uiDHTLength, UInt* uiDHTSymbol, UInt* uiHuffmanTableCode, UInt* uiHuffmanTableLength)
{
int code = 0;
for (int i = 0; i < ACLENGTH; i++)
{
int num = uiDHTLength[i];
int n_bits = i + 1;
for (int j = 0; j < num; j++)
{
int symbol = *uiDHTSymbol;
*(uiHuffmanTableCode+symbol) = code;
*(uiHuffmanTableLength+symbol) = n_bits;
//printf("0x%0.2x | %s\n", symbol, to_binary_str(code, n_bits, buf));
code++;
uiDHTSymbol++;
}
code <<= 1;
}
}
Void CommonPic::computeQpTable() //compute QpTable according g_uiQpTableBase
{
for (UInt ch = 0; ch < 2; ch++)
{
for (UInt i = 0; i < CUSIZE*CUSIZE; i++)
{
*(m_uiQpTable[ch] + i) = round(g_uiQpTableBase[ch][i] * m_uiQp);
}
}
}
//return address of (row, col) CU
TCoeff* CommonPic::getQuanCoeffAddr(const ComponentID ch, UInt uiRow, UInt uiCol)
{
UInt uiNumOfColInWidth = m_uiPicWidth / CUSIZE;
UInt uiNumPixelInCU = CUSIZE * CUSIZE;
return m_piPicQuanCoeff[ch] + (uiRow*uiNumOfColInWidth + uiCol) * uiNumPixelInCU;
}
......@@ -16,13 +16,18 @@ class CommonPic
UInt m_uiPicHeight;
Pel* m_puiOrgPicRgb[MAX_NUM_COMPONENT];
Pel* m_puiOrgPicYuv[MAX_NUM_COMPONENT];
Pel* m_puiOrgPicBuf[MAX_NUM_COMPONENT];
Pel* m_puiOrgPicYuv[MAX_NUM_COMPONENT]; // yuv444; even width and height
Pel* m_puiOrgPicBuf[MAX_NUM_COMPONENT]; // yuv444/420; 8 times width and height
TCoeff* m_uiPicDctCoeff[MAX_NUM_COMPONENT];
TCoeff* m_piPicQuanCoeff[MAX_NUM_COMPONENT];
UInt g_uiQpTable[CUSIZE][CUSIZE];
short* g_iHuffmanTable[2]; //value, length
UInt* m_uiQpTable[2];
UInt m_uiQp;
UInt m_uiHuffmanTableLumaDC[2][DCLENGTH]; //1st dim for value, 2nd dim for length
UInt m_uiHuffmanTableChromaDC[2][DCLENGTH];
UInt m_uiHuffmanTableLumaAC[2][ACLENGTH];
UInt m_uiHuffmanTableChromaAC[2][ACLENGTH];
BitStream* m_bitStream;
Cfg* m_cfg;
......@@ -46,15 +51,28 @@ class CommonPic
Pel* getBufAddr(const ComponentID ch) { return m_puiOrgPicBuf[ch]; } //start address of buf
TCoeff* getDctCoeffAddr(const ComponentID ch) { return m_uiPicDctCoeff[ch]; } //start address of dct
TCoeff* getQuanCoeffAddr(const ComponentID ch) { return m_piPicQuanCoeff[ch]; } //start address of quan
TCoeff* getQuanCoeffAddr(const ComponentID ch, UInt uiRow, UInt uiCol);
Void computeQpTable(); //compute QpTable according g_uiQpTableBase
UInt* getQpTable(UInt uiChannalType) { return m_uiQpTable[uiChannalType]; } //get QPTable address
UInt* getHuffmanTableLumaDC() { return *m_uiHuffmanTableLumaDC; }
UInt* getHuffmanTableChromaDC() { return *m_uiHuffmanTableChromaDC; }
UInt* getHuffmanTableLumaAC() { return *m_uiHuffmanTableLumaAC; }
UInt* getHuffmanTableChromaAC() { return *m_uiHuffmanTableChromaAC; }
Bool readRgb(); //read yuv to uiOrgPicYuv
Bool colorSpaceConvert(); // color space convert, subsample
Bool preProcessing(); // padding,
BitStream* getBitStream() { return m_bitStream; }
Void readRgb(string sInputFileName); //read yuv to uiOrgPicYuv
Void colorSpaceConvert(ChromaFormat format); // color space convert, subsample
Void preProcessing(); // padding,
Void compressPic();
Void encodePic();
Void writeHead(); // write header to bitstream