Commit 20bbead5 authored by v-xihuasheng's avatar v-xihuasheng
Browse files

init

parent fdd9f711
#include "BitStream.h"
write(value, length)
{
}
\ No newline at end of file
#ifndef __TYPEDEF__
#define __TYPEDEF__
#include <TypeDef.h>
class BitStream
{
private:
Char* data;
UInt bitPos;
public:
write(value, length);
}
#endif
\ No newline at end of file
#include "Cfg.h"
Void parseCfg()
{
//set header and configs
}
\ No newline at end of file
#ifndef __TYPEDEF__
#define __TYPEDEF__
#include <iostream>
#include "TypeDef.h"
#include <string>
class Cfg
{
private:
UInt uiPicWidth;
UInt uiPicHeight;
string sInputFileName;
string sOutputFileName;
public:
Void parseCfg();
UInt getPicWidth() {return uiPicWidth;}
UInt getPicHeight() {return uiPicHeight;}
String getInputFileName() {return sInputFileName;}
String getOutputFileName() {return sOutputFileName;}
UInt setPicWidth(UInt width) {uiPicWidth = width;}
UInt setPicHeight(UInt height) {uiPicHeight = height;}
String setInputFileName(string fileName) {sInputFileName = fileName;}
String setOutputFileName(string fileName) {sOutputFileName = fileName;}
}
#endif
\ No newline at end of file
void initCu(componentId, row, col,*pic)
{
//set ID
//set row
//set col
}
Void compressCu()
{
//input: uiCuYuvBuf (from Pic)
//output:
transform();
quantize();
cuHuffman();
}
Void transform() //
{
//input: uiCuYuvBuf
//output: uiCuDctCoeff
}
Void quantize() //
{
//input: uiCuDctCoeff
//output: uiQuaDctCoeff
}
Void copyFromCu()
{
//copy Cu data to Pic data
}
void cuHuffman()
{
//input:uiQuaDctCoeff
//output:pic.bitstream
}// quaDctCoeff>bitstream
\ No newline at end of file
#ifndef __TYPEDEF__
#define __TYPEDEF__
#include "TypeDef.h"
#include "CommonPic.h"
class CodingUnit
{
private:
UInt ComponentId;
UInt row;
UInt col;
UInt* uiCuYuvBuf;
Float* uiCuDctCoeff;
Int* uiQuaDctCoeff;
CommonPic ppic;
public:
void initCu(ComponentID componentId, UInt row, UInt col, CommonPic pic);
void compressCu();
void transform();
void quantize();
void cuHuffman(&bitstream);// quaDctCoeff>bitstream
}
#endif
\ No newline at end of file
Void encodePic()
{
for (int componentId=0, componentId<MAX_NUM_COMPONENT, componentId++)
{
for (int row = 0; row < uiPicWidth/CUSIZE; row++)
{
for (int col = 0; col < uiPicWidth/CUSIZE; col++)
{
CodingUnit cu;
cu.initCu(componentId, row, col, this);
// setCuBuff(cu);
cu.compressCu();//yuv
// copyFromCu(cu);
// cu.cuHuffman(bitstream);
}
}
}
}
Void init()
{
//allocate memory
// readRgb(string filename); //read yuv to uiOrgPicYuv
// colorSpaceConvert(); // color space convert, subsample
// preProcessing(); // padding,
// init bitstream:position,data……
}
Bool readRgb(string filename) //read yuv to uiOrgPicYuv
{
//input png
//output uiOrgPicRgb, set picOrgWidth picOrgHeight
}
Bool colorSpaceConvert() // color space convert, subsample
{
//input uiOrgPicRgb
//output uiOrgPicYuv
}
Bool preProcessing() // padding,
{
//input uiOrgPicYuv
//output uiOrgPicYuvBuf
}
void writeHead(){
bitstream.write(width, byteNum, bitstream.bitPos);
bitstream.write(height, byteNum, bitstream.bitPos);
}
#ifndef __TYPEDEF__
#define __TYPEDEF__
#include "TypeDef.h"
#include "Cfg.h"
using namespace std;
class CommonPic
{
private:
//CodingUnit* Cus;
// String inputFilename;
// String streamName;
UInt uiOrgPicWidth;
UInt uiOrgPicHeight;
UInt uiPicWidth;
UInt uiPicHeight;
UInt uiStride;
UInt* uiOrgPicRgb[MAX_NUM_COMPONENT];
UInt* uiOrgPicYuv[MAX_NUM_COMPONENT];
UInt* uiOrgPicYuvBuf[MAX_NUM_COMPONENT];
Float* uiPicDctCoeff[MAX_NUM_COMPONENT];
Int* uiPicQuaDctCoeff[MAX_NUM_COMPONENT];
UInt uiQpTable[8][8];
short* iHuffmanTable[2]; //value, length
BitStream bitstream;
Cfg cfg;
public:
// Void creat();
Void init(Cfg cfg);
Bool readRgb(); //read yuv to uiOrgPicYuv
Bool colorSpaceConvert(); // color space convert, subsample
Bool preProcessing(); // padding,
Void compressPic();
Void copyCuData(cu);
Void encodePic();
Void writeHeader(); // write header to bitstream
Void saveStream(); // save bitstream to file
}
#endif
\ No newline at end of file
#include "CommonPic.h"
#include "TypeDef.h"
#include "Cfg.h"
int main ()
{
Cfg cfg;
cfg.parseCfg()
CommonPic pic;
pic.init(cfg);
pic.writeHeader();
pic.encodePic();
pic.saveBitstream();
}
#ifndef __TYPEDEF__
#define __TYPEDEF__
#define CUSIZE 8
typedef void Void;
typedef bool Bool;
typedef char TChar; // Used for text/characters
typedef signed char SChar; // Signed 8-bit values
typedef unsigned char UChar; // Unsigned 8-bit values
typedef short Short;
typedef unsigned short UShort;
typedef int Int;
typedef unsigned int UInt;
typedef double Double;
typedef float Float;
enum ComponentID
{
COMPONENT_Y = 0,
COMPONENT_Cb = 1,
COMPONENT_Cr = 2,
MAX_NUM_COMPONENT = 3
};
#endif
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment