資源簡(jiǎn)介
用C++實(shí)現(xiàn)的壓縮、解壓縮算法,只有幾個(gè)cpp、h文件,非常小巧,方便學(xué)習(xí)算法用。
代碼片段和文件信息
//?jpgd.cpp?-?C++?class?for?JPEG?decompression.
//?Public?domain?Rich?Geldreich?
//?Last?updated?Apr.?16?2011
//?Alex?Evans:?Linear?memory?allocator?(taken?from?jpge.h).
//
//?Supports?progressive?and?baseline?sequential?JPEG?image?files?and?the?most?common?chroma?subsampling?factors:?Y?H1V1?H2V1?H1V2?and?H2V2.
//
//?Chroma?upsampling?quality:?H2V2?is?upsampled?in?the?frequency?domain?H2V1?and?H1V2?are?upsampled?using?point?sampling.
//?Chroma?upsampling?reference:?“Fast?Scheme?for?Image?Size?Change?in?the?Compressed?Domain“
//?http://vision.ai.uiuc.edu/~dugad/research/dct/index.html
#include?“jpgd.h“
#include?
#include?
#define?JPGD_ASSERT(x)?assert(x)
#ifdef?_MSC_VER
#pragma?warning?(disable?:?4611)?//?warning?C4611:?interaction?between?‘_setjmp‘?and?C++?object?destruction?is?non-portable
#endif
//?Set?to?1?to?enable?freq.?domain?chroma?upsampling?on?images?using?H2V2?subsampling?(0=faster?nearest?neighbor?sampling).
//?This?is?slower?but?results?in?higher?quality?on?images?with?highly?saturated?colors.
#define?JPGD_SUPPORT_FREQ_DOMAIN_UPSAMPLING?1
#define?JPGD_TRUE?(1)
#define?JPGD_FALSE?(0)
#define?JPGD_MAX(ab)?(((a)>(b))???(a)?:?(b))
#define?JPGD_MIN(ab)?(((a)<(b))???(a)?:?(b))
namespace?jpgd?{
static?inline?void?*jpgd_malloc(size_t?nSize)?{?return?malloc(nSize);?}
static?inline?void?jpgd_free(void?*p)?{?free(p);?}
//?DCT?coefficients?are?stored?in?this?sequence.
static?int?g_ZAG[64]?=?{??0181692310172432251811451219263340484134272013671421283542495657504336292215233037445158595245383139465360615447556263?};
enum?JPEG_MARKER
{
??M_SOF0??=?0xC0?M_SOF1??=?0xC1?M_SOF2??=?0xC2?M_SOF3??=?0xC3?M_SOF5??=?0xC5?M_SOF6??=?0xC6?M_SOF7??=?0xC7?M_JPG???=?0xC8
??M_SOF9??=?0xC9?M_SOF10?=?0xCA?M_SOF11?=?0xCB?M_SOF13?=?0xCD?M_SOF14?=?0xCE?M_SOF15?=?0xCF?M_DHT???=?0xC4?M_DAC???=?0xCC
??M_RST0??=?0xD0?M_RST1??=?0xD1?M_RST2??=?0xD2?M_RST3??=?0xD3?M_RST4??=?0xD4?M_RST5??=?0xD5?M_RST6??=?0xD6?M_RST7??=?0xD7
??M_SOI???=?0xD8?M_EOI???=?0xD9?M_SOS???=?0xDA?M_DQT???=?0xDB?M_DNL???=?0xDC?M_DRI???=?0xDD?M_DHP???=?0xDE?M_EXP???=?0xDF
??M_APP0??=?0xE0?M_APP15?=?0xEF?M_JPG0??=?0xF0?M_JPG13?=?0xFD?M_COM???=?0xFE?M_TEM???=?0x01?M_ERROR?=?0x100?RST0???=?0xD0
};
enum?JPEG_SUBSAMPLING?{?JPGD_GRAYSCALE?=?0?JPGD_YH1V1?JPGD_YH2V1?JPGD_YH1V2?JPGD_YH2V2?};
#define?CONST_BITS??13
#define?PASS1_BITS??2
#define?SCALEDONE?((int32)1)
#define?FIX_0_298631336??((int32)2446)????????/*?FIX(0.298631336)?*/
#define?FIX_0_390180644??((int32)3196)????????/*?FIX(0.390180644)?*/
#define?FIX_0_541196100??((int32)4433)????????/*?FIX(0.541196100)?*/
#define?FIX_0_765366865??((int32)6270)????????/*?FIX(0.765366865)?*/
#define?FIX_0_899976223??((int32)7373)????????/*?FIX(0.899976223)?*/
#define?FIX_1_175875602??((int32)9633)????????/*?FIX(1.175875602)?*/
#define?FIX_1_501321
- 上一篇:MFC 聊天功能源代碼
- 下一篇:交叉25碼ITF25編碼程序代碼
評(píng)論
共有 條評(píng)論