Commit 48a73ee6 authored by v-xihuasheng's avatar v-xihuasheng
Browse files

update project

parent c40b6d8c
#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
#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
File added

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JPEG", "JPEG.vcxproj", "{AE771B59-71F4-4534-8949-8698E3BD9306}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE771B59-71F4-4534-8949-8698E3BD9306}.Debug|Win32.ActiveCfg = Debug|Win32
{AE771B59-71F4-4534-8949-8698E3BD9306}.Debug|Win32.Build.0 = Debug|Win32
{AE771B59-71F4-4534-8949-8698E3BD9306}.Debug|x64.ActiveCfg = Debug|x64
{AE771B59-71F4-4534-8949-8698E3BD9306}.Debug|x64.Build.0 = Debug|x64
{AE771B59-71F4-4534-8949-8698E3BD9306}.Release|Win32.ActiveCfg = Release|Win32
{AE771B59-71F4-4534-8949-8698E3BD9306}.Release|Win32.Build.0 = Release|Win32
{AE771B59-71F4-4534-8949-8698E3BD9306}.Release|x64.ActiveCfg = Release|x64
{AE771B59-71F4-4534-8949-8698E3BD9306}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\BitStream.h" />
<ClInclude Include="source\Cfg.h" />
<ClInclude Include="source\CodingUnit.h" />
<ClInclude Include="source\CommonPic.h" />
<ClInclude Include="source\TypeDef.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\BitStream.cpp" />
<ClCompile Include="source\Cfg.cpp" />
<ClCompile Include="source\CodingUnit.cpp" />
<ClCompile Include="source\CommonPic.cpp" />
<ClCompile Include="source\JPEGEncoder.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{AE771B59-71F4-4534-8949-8698E3BD9306}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>JPEG</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\BitStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\Cfg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\CodingUnit.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\CommonPic.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\TypeDef.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\BitStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Cfg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\CodingUnit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\CommonPic.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\JPEGEncoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
#include "TypeDef.h"
#include "BitStream.h"
Void writeBit(UInt value, UInt length)
{
// input value and length of current Huffman code
// write to data
}
\ No newline at end of file
#ifndef __BITSTREAM__
#define __BITSTREAM__
#include "TypeDef.h"
class BitStream
{
private:
UChar* data;
UInt bitPos; //num of bits
public:
Void writeBit(UInt value, UInt length);
};
#endif
\ No newline at end of file
#include "Cfg.h"
Void parseCfg()
Void Cfg::parseCfg()
{
//set header and configs
}
\ No newline at end of file
#ifndef __CFG__
#define __CFG__
#include <iostream>
#include "TypeDef.h"
#include <string>
using namespace std;
class Cfg
{
private:
UInt m_uiPicWidth;
UInt m_uiPicHeight;
string m_sInputFileName; //picture name, png
string m_sOutputFileName; //bitstream name, jpg
ChromaFormat m_chromaFormat; //internal chroma format
public:
Void parseCfg();
UInt getPicWidth() { return m_uiPicWidth; }
UInt getPicHeight() { return m_uiPicHeight; }
string getInputFileName() { return m_sInputFileName; }
string getOutputFileName() { return m_sOutputFileName; }
ChromaFormat getChromaFormat() { return m_chromaFormat; }
Void setPicWidth(UInt width) { m_uiPicWidth = width; }
Void setPicHeight(UInt height) { m_uiPicHeight = height; }
Void setInputFileName(string fileName) { m_sInputFileName = fileName; }
Void setOutputFileName(string fileName) { m_sOutputFileName = fileName; }
Void setChromaFormat(ChromaFormat chromaFormat) { m_chromaFormat = chromaFormat; }
};
#endif
\ No newline at end of file
#include "TypeDef.h"
#include "CodingUnit.h"
Void CodingUnit::create() //allocate memory for YUV and coeff
{
}
Void CodingUnit::destroy() //free memory
{
}
Void CodingUnit::initCu(ComponentID componentId, UInt row, UInt col, CommonPic* pic)
{
m_ComponentId = componentId;
m_uiRow = row;
m_uiCol = col;
m_pPic = pic;
}
Void CodingUnit::encodeCu()
{
//input: uiCuYuvBuf
//output: bitstream
transform();
quantize();
huffman();
}
Void CodingUnit::transform() //
{
//input: uiCuYuvBuf
//output: uiCuDctCoeff
//scan order, scale
}
Void CodingUnit::quantize() //
{
//input: uiCuDctCoeff
//output: uiQuanDctCoeff
}
void CodingUnit::huffman() // quaDctCoeff>bitstream
{
//input:uiQuaDctCoeff
//output:pic.bitstream
}
\ No newline at end of file
#ifndef __CODINGUNIT__
#define __CODINGUNIT__
#include "TypeDef.h"
#include "CommonPic.h"
class CodingUnit
{
private:
ComponentID m_ComponentId;
UInt m_uiRow;
UInt m_uiCol;
Pel* m_puiCuYuvBuf;
TCoeff* m_puiCuDctCoeff;
TCoeff* m_puiCuQuanCoeff;
CommonPic* m_pPic;
public:
Void create(); //allocate memory for YUV and coeff
Void destroy(); //free memory
Void initCu(ComponentID ch, UInt row, UInt col, CommonPic* pic);
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
Void encodeCu();
Void transform();
Void quantize();
Void huffman();// quaDctCoeff>bitstream
};
#endif
\ No newline at end of file