⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reconstruct.c

📁 jpeg快速算法,用于TI和philips的DSP开发
💻 C
字号:
/*
 *********************************************************************
 * File name: reconstruct.c
 * Version: 5.0(release v1.0)    Date: Jan 12, 2006
 * Author:  xiezm                Email: xiezm@wxintech.cn
 * Company: Wuxi Intech co., ltd.
 *
 * Project: Jpeg Decoder for Trio
 *********************************************************************
 */
#define  RECONSTRUCT_GLOBALS

#include "cf6_chess.h"

#include "djpg.h"

const int chess_storage(YMEM) reconstruct_idx_2x2[128] = {
	 0, 1, 2, 3, 0, 1, 2, 3, 8, 9,10,11, 8, 9,10,11,
	16,17,18,19,16,17,18,19,24,25,26,27,24,25,26,27,
	 4, 5, 6, 7, 4, 5, 6, 7,12,13,14,15,12,13,14,15,
	20,21,22,23,20,21,22,23,28,29,30,31,28,29,30,31,
	32,33,34,35,32,33,34,35,40,41,42,43,40,41,42,43,
	48,49,50,51,48,49,50,51,56,57,58,59,56,57,58,59,
	36,37,38,39,36,37,38,39,44,45,46,47,44,45,46,47,
	52,53,54,55,52,53,54,55,60,61,62,63,60,61,62,63
};
const int chess_storage(YMEM) reconstruct_idx_2x1[64] = {
	 0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27,
	32,33,34,35,40,41,42,43,48,49,50,51,56,57,58,59,
	 4, 5, 6, 7,12,13,14,15,20,21,22,23,28,29,30,31,
	36,37,38,39,44,45,46,47,52,53,54,55,60,61,62,63
};


int chess_storage(YMEM) CCbB[128] = {
 -57, -57, -57, -57, -57, -57, -57, -57,
 -57, -57, -57, -57, -57, -57, -57, -57,
 -57, -57, -57, -57, -57, -57, -57, -57,
 -57, -57, -57, -57, -57, -57, -57, -57,
 -57, -55, -54, -52, -50, -48, -47, -45,
 -43, -41, -40, -38, -36, -34, -32, -31,
 -29, -27, -25, -24, -22, -20, -18, -16,
 -15, -13, -11,  -9,  -8,  -6,  -4,  -2,
   0,   1,   3,   5,   7,   8,  10,  12,
  14,  15,  17,  19,  21,  23,  24,  26,
  28,  30,  31,  33,  35,  37,  39,  40,
  42,  44,  46,  47,  49,  51,  53,  54,
  54,  54,  54,  54,  54,  54,  54,  54,
  54,  54,  54,  54,  54,  54,  54,  54,
  54,  54,  54,  54,  54,  54,  54,  54,
  54,  54,  54,  54,  54,  54,  54,  54};

int chess_storage(YMEM) CCbG[128] = {
  11,  11,  11,  11,  11,  11,  11,  11,
  11,  11,  11,  11,  11,  11,  11,  11,
  11,  11,  11,  11,  11,  11,  11,  11,
  11,  11,  11,  11,  11,  11,  11,  11,
  11,  10,  10,   9,   9,   9,   8,   8,
   8,   7,   7,   7,   6,   6,   6,   5,
   5,   5,   4,   4,   4,   3,   3,   3,
   2,   2,   2,   1,   1,   1,   0,   0,
   0,  -1,  -1,  -2,  -2,  -2,  -3,  -3,
  -3,  -4,  -4,  -4,  -5,  -5,  -5,  -6,
  -6,  -6,  -7,  -7,  -7,  -8,  -8,  -8,
  -9,  -9,  -9, -10, -10, -10, -11, -11,
 -11, -11, -11, -11, -11, -11, -11, -11,
 -11, -11, -11, -11, -11, -11, -11, -11,
 -11, -11, -11, -11, -11, -11, -11, -11,
 -11, -11, -11, -11, -11, -11, -11, -11};

int chess_storage(YMEM) CCrG[128] = {
  22,  22,  22,  22,  22,  22,  22,  22,
  22,  22,  22,  22,  22,  22,  22,  22,
  22,  22,  22,  22,  22,  22,  22,  22,
  22,  22,  22,  22,  22,  22,  22,  22,
  22,  22,  21,  20,  20,  19,  18,  17,
  17,  16,  15,  15,  14,  13,  12,  12,
  11,  10,  10,   9,   8,   7,   7,   6,
   5,   5,   4,   3,   2,   2,   1,   0,
   0,  -1,  -2,  -3,  -3,  -4,  -5,  -6,
  -6,  -7,  -8,  -8,  -9, -10, -11, -11,
 -12, -13, -13, -14, -15, -16, -16, -17,
 -18, -18, -19, -20, -21, -21, -22, -23,
 -23, -23, -23, -23, -23, -23, -23, -23, 
 -23, -23, -23, -23, -23, -23, -23, -23, 
 -23, -23, -23, -23, -23, -23, -23, -23, 
 -23, -23, -23, -23, -23, -23, -23, -23};

int chess_storage(YMEM) CCrR[128] = {
 -45, -45, -45, -45, -45, -45, -45, -45,
 -45, -45, -45, -45, -45, -45, -45, -45,
 -45, -45, -45, -45, -45, -45, -45, -45,
 -45, -45, -45, -45, -45, -45, -45, -45,
 -45, -44, -43, -41, -40, -38, -37, -36,
 -34, -33, -31, -30, -29, -27, -26, -24,
 -23, -22, -20, -19, -17, -16, -15, -13,
 -12, -10,  -9,  -8,  -6,  -5,  -3,  -2,
   0,   1,   2,   4,   5,   7,   8,   9,
  11,  12,  14,  15,  16,  18,  19,  21,
  22,  23,  25,  26,  28,  29,  30,  32,
  33,  35,  36,  37,  39,  40,  42,  43,
  43,  43,  43,  43,  43,  43,  43,  43,
  43,  43,  43,  43,  43,  43,  43,  43,
  43,  43,  43,  43,  43,  43,  43,  43,
  43,  43,  43,  43,  43,  43,  43,  43};

int chess_storage(YMEM) YYYC[128] = {
   0,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,   0,   0,   0,   0,
   0,   1,   2,   3,   4,   5,   6,   7,
   8,   9,  10,  11,  12,  13,  14,  15,  
  16,  17,  18,  19,  20,  21,  22,  23,
  24,  25,  26,  27,  28,  29,  30,  31,
  32,  33,  34,  35,  36,  37,  38,  39, 
  40,  41,  42,  43,  44,  45,  46,  47,
  48,  49,  50,  51,  52,  53,  54,  55,
  56,  57,  58,  59,  60,  61,  62,  63,
  63,  63,  63,  63,  63,  63,  63,  63,
  63,  63,  63,  63,  63,  63,  63,  63,
  63,  63,  63,  63,  63,  63,  63,  63,
  63,  63,  63,  63,  63,  63,  63,  63};

void decode_mcu_2x1(void)
{
	int i;
	int R, G, B;
	
	//Y
	decode_data_unit(0, 0);
	decode_data_unit(0, 1);

	//Cb
	decode_data_unit(1, 4);
	//Cr
	decode_data_unit(2, 5);

	reconstruct_prt = reconstruc_buffer[0];

	for(i=0;i<64;i++)
	{
		R = G = B = *reconstruct_prt + 32;
		R += ((reconstruc_buffer[5][reconstruct_idx_2x1[i]]*INT_P359)>>8);
		B += ((reconstruc_buffer[4][reconstruct_idx_2x1[i]]*INT_P454)>>8);
		G += ((reconstruc_buffer[5][reconstruct_idx_2x1[i]]*INT_M183)>>8);
		G += ((reconstruc_buffer[4][reconstruct_idx_2x1[i]]*INT_M88)>>8);
		B=cellingB[B];
		R=cellingR[R];
		G=cellingG[G];
		*reconstruct_prt++ = R|G|B;
		R = G = B = *reconstruct_prt + 32;
		R += ((reconstruc_buffer[5][reconstruct_idx_2x1[i]]*INT_P359)>>8);
		B += ((reconstruc_buffer[4][reconstruct_idx_2x1[i]]*INT_P454)>>8);
		G += ((reconstruc_buffer[5][reconstruct_idx_2x1[i]]*INT_M183)>>8);
		G += ((reconstruc_buffer[4][reconstruct_idx_2x1[i]]*INT_M88)>>8);
		B=cellingB[B];
		R=cellingR[R];
		G=cellingG[G];
		*reconstruct_prt++ = R|G|B;	
	}
	//output
	reconstruct_prt = reconstruc_buffer[0];
	for(i=0;i<128;i++)
	{
#ifdef WIN32
		fprintf(OUTPUT, "%6x\n", *reconstruct_prt++);
#else
		OUTPUT = *reconstruct_prt++;
#endif
	}
}

void decode_mcu_1x2(void)
{
	int i, j;
	int R, G, B;
	
	//Y
	decode_data_unit(0, 0);
	decode_data_unit(0, 1);

	//Cb
	decode_data_unit(1, 4);
	//Cr
	decode_data_unit(2, 5);

	reconstruct_prt = reconstruc_buffer[0];
	for(j=0;j<64;)
	{
		for(i=0;i<8;i++)
		{
			R = G = B = *reconstruct_prt + 32;
			R += ((reconstruc_buffer[5][j]*INT_P359)>>8);
			B += ((reconstruc_buffer[4][j]*INT_P454)>>8);
			G += ((reconstruc_buffer[5][j]*INT_M183)>>8);
			G += ((reconstruc_buffer[4][j++]*INT_M88)>>8);
			B=cellingB[B];
			R=cellingR[R];
			G=cellingG[G];
			*reconstruct_prt++ = R|G|B;
		}
		j -= 8;
		for(i=0;i<8;i++)
		{
			R = G = B = *reconstruct_prt + 32;
			R += ((reconstruc_buffer[5][j]*INT_P359)>>8);
			B += ((reconstruc_buffer[4][j]*INT_P454)>>8);
			G += ((reconstruc_buffer[5][j]*INT_M183)>>8);
			G += ((reconstruc_buffer[4][j++]*INT_M88)>>8);
			B=cellingB[B];
			R=cellingR[R];
			G=cellingG[G];
			*reconstruct_prt++ = R|G|B;
		}
	}
	//output
	reconstruct_prt = reconstruc_buffer[0];
	for(i=0;i<128;i++)
	{
#ifdef WIN32
		fprintf(OUTPUT, "%6x\n", *reconstruct_prt++);
#else
		OUTPUT = *reconstruct_prt++;
#endif
	}
}

void decode_mcu_1x1(void)
{
	int R, G, B;
	int i;

	//Y
	decode_data_unit(0, 0);
	
	//Cb
	decode_data_unit(1, 4);
	//Cr
	decode_data_unit(2, 5);

	reconstruct_prt = reconstruc_buffer[0];

	for(i=0;i<64;i++)
	{
		R = G = B = *reconstruct_prt + 32;
		R += ((reconstruc_buffer[5][i]*INT_P359)>>8);
		B += ((reconstruc_buffer[4][i]*INT_P454)>>8);
		G += ((reconstruc_buffer[5][i]*INT_M183)>>8);
		G += ((reconstruc_buffer[4][i]*INT_M88)>>8);
		R=cellingR[R];
		G=cellingG[G];
		B=cellingB[B];
		*reconstruct_prt++ = R|G|B;
	}
	//output
	reconstruct_prt = reconstruc_buffer[0];
	for(i=0;i<64;i++)
	{
#ifdef WIN32
		fprintf(OUTPUT, "%6x\n", *reconstruct_prt++);
#else
		OUTPUT = *reconstruct_prt++;
#endif
	}
}


int decode_mcu_2x2(void)
{
	int i,j;
	int iRet;
	int YYY, CCb, CCr;
	unsigned int pix;

	//Y
	iRet = decode_data_unit(0, 0);
	if(iRet != 0)
	{
		return 1;
	}
	iRet = decode_data_unit(0, 1);
	if(iRet != 0)
	{
		return 1;
	}
	iRet = decode_data_unit(0, 2);
	if(iRet != 0)
	{
		return 1;
	}
	iRet = decode_data_unit(0, 3);
	if(iRet != 0)
	{
		return 1;
	}
	//Cb
	iRet = decode_data_unit(1, 4);
	if(iRet != 0)
	{
		return 1;
	}
	//Cr
	iRet = decode_data_unit(2, 5);
	if(iRet != 0)
	{
		return 1;
	}


	
#if 1
	reconstruct_prt = reconstruc_buffer[0];

	for(i=0;i<128;i++)
	{
		CCb = reconstruc_buffer[4][reconstruct_idx_2x2[i]];
		CCr = reconstruc_buffer[5][reconstruct_idx_2x2[i]];
		YYY = *reconstruct_prt + 128;
		pix = cellingB[YYY + ((CCb*INT_P454)>>8)];
		pix |= cellingG[YYY + ((CCb*INT_M88)>>8) + ((CCr*INT_M183)>>8)];
		pix |= cellingR[YYY + ((CCr*INT_P359)>>8)];	

		*reconstruct_prt++ = pix;
		YYY = *reconstruct_prt + 128;
		pix = cellingB[YYY + ((CCb*INT_P454)>>8)];
		pix |= cellingG[YYY + ((CCb*INT_M88)>>8) + ((CCr*INT_M183)>>8)];
		pix |= cellingR[YYY + ((CCr*INT_P359)>>8)];		
		*reconstruct_prt++ = pix;
	}	
#endif

	//output
	for(i=0;i<256;i++)
	{
#ifdef WIN32
		fprintf(OUTPUT, "%d\n", *reconstruct_prt++);
#else
		OUTPUT = *reconstruct_prt++;
#endif
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -