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

📄 jp5.txt

📁 这是一组JPEG解码的说明和源代码
💻 TXT
📖 第 1 页 / 共 3 页
字号:
 }

 /*
   * second 1-D IDCT row->col
  */
 p_col = work_maze;
 p_out = in;
 for ( i = 0; i < 8; ++i ) {
  tmp0 = COL(0);
  tmp1 = COL(2);
  tmp2 = COL(4);
  tmp3 = COL(6);
  tmp4 = COL(1);
  tmp5 = COL(3);
  tmp6 = COL(5);
  tmp7 = COL(7);

  tmp10 = tmp0 + tmp2; /* phase 3 */
  tmp11 = tmp0 - tmp2;

  tmp13 = tmp1 + tmp3; /* phases 5-3 */
  tmp12 = FIX_MULDIV(tmp1 - tmp3, FIX_1414) - tmp13; /* 2*c4 */

  tmp0 = tmp10 + tmp13; /* phase 2 */
  tmp3 = tmp10 - tmp13;
  tmp1 = tmp11 + tmp12;
  tmp2 = tmp11 - tmp12;

  /* Odd part */

  z13 = tmp6 + tmp5;  /* phase 6 */
  z10 = tmp6 - tmp5;
  z11 = tmp4 + tmp7;
  z12 = tmp4 - tmp7;

  tmp7 = z11 + z13;  /* phase 5 */
  tmp11 = FIX_MULDIV(z11 - z13, FIX_1414); /* 2*c4 */

  z5 = FIX_MULDIV(z10 + z12, FIX_1847); /* 2*c2 */
  tmp10 = FIX_MULDIV(z12, FIX_1082) - z5; /* 2*(c2-c6) */
  tmp12 = FIX_MULDIV(z10, -FIX_2613) + z5; /* -2*(c2+c6) */

  tmp6 = tmp12 - tmp7; /* phase 2 */
  tmp5 = tmp11 - tmp6;
  tmp4 = tmp10 + tmp5;

  p_out[0] = (tmp0 + tmp7) / 2048;
  p_out[0] += 128;
  if (p_out[0] < 0) p_out[0] = 0; else if (p_out[0] > 255) p_out[0] = 255;
  p_out[7] = (tmp0 - tmp7) / 2048;
  p_out[7] += 128;
  if (p_out[7] < 0) p_out[7] = 0; else if (p_out[7] > 255) p_out[7] = 255;
  p_out[1] = (tmp1 + tmp6) / 2048;
  p_out[1] += 128;
  if (p_out[1] < 0) p_out[1] = 0; else if (p_out[1] > 255) p_out[1] = 255;
  p_out[6] = (tmp1 - tmp6) / 2048;
  p_out[6] += 128;
  if (p_out[6] < 0) p_out[6] = 0; else if (p_out[6] > 255) p_out[6] = 255;
  p_out[2] = (tmp2 + tmp5) / 2048;
  p_out[2] += 128;
  if (p_out[2] < 0) p_out[2] = 0; else if (p_out[2] > 255) p_out[2] = 255;
  p_out[5] = (tmp2 - tmp5) / 2048;
  p_out[5] += 128;
  if (p_out[5] < 0) p_out[5] = 0; else if (p_out[5] > 255) p_out[5] = 255;
  p_out[4] = (tmp3 + tmp4) / 2048;
  p_out[4] += 128;
  if (p_out[4] < 0) p_out[4] = 0; else if (p_out[4] > 255) p_out[4] = 255;
  p_out[3] = (tmp3 - tmp4) / 2048;
  p_out[3] += 128;
  if (p_out[3] < 0) p_out[3] = 0; else if (p_out[3] > 255) p_out[3] = 255;

  /* next col */
  p_out += 8;
  p_col += 8;
 }

}

/* when we use AA&N method, we need the function to be implemented, otherwise, left it empty */
/* we shift the factor left 5 bits for our integer operations */
void jpeg_idct_prepare_qualitytable( p_jpeg_quality_table p_table )
{
 static INT32 aan_factors[8] = { 256, 355, 334, 301, 256, 201, 139, 71 };
 static BYTE _zig_zag[64] = {
  0, 1, 5, 6,14,15,27,28,
  2, 4, 7,13,16,26,29,42,
  3, 8,12,17,25,30,41,43,
  9,11,18,24,31,40,44,53,
  10,19,23,32,39,45,52,54,
  20,22,33,38,46,51,55,60,
  21,34,37,47,50,56,59,61,
  35,36,48,49,57,58,62,63
 };
 BYTE i, j;
 DWORD values[64];
 for ( j = 0; j < 8; ++j ) {
  for ( i = 0; i < 8; ++i ) {   
   values[i + j * 8] = p_table->values[_zig_zag[i + j * 8]] * aan_factors[i] * aan_factors[j] / 256;
  }
 }
 p_table->process_in_idct = 1;
 memcpy(p_table->values, values, sizeof(DWORD) * 64);
}

**************************************************************************************************************

sklidct.c(LLM算法,仅可供教学研究用,详情请访问网站http://skal.planet-d.net)

**************************************************************************************************************

#include "jpegdec2.h"

/********************************************************
* Some code. Copyright (C) 2003 by Pascal Massimino.   *
* All Rights Reserved.      (http://skal.planet-d.net) *
* For Educational/Academic use ONLY.                   *
********************************************************/
/*
*  skl_dct.cpp
*
*  "Fast and precise" LLM implementation of FDCT/IDCT, where 
*  rotations are decomposed using:
*    tmp = (x+y).cos t
*    x' = tmp + y.(sin t - cos t)
*    y' = tmp - x.(sin t + cos t)
*
*  See details at http://skl.planet-d.net/coding/dct.html
*  and at the end of this file...
*
* Reference (e.g.):
*  Loeffler C., Ligtenberg A., and Moschytz C.S.: 
*    Practical Fast 1D DCT Algorithm with Eleven Multiplications, 
*  Proc. ICASSP 1989, 988-991.
*
*  IEEE-1180-like error specs for FDCT:
* Peak error:   1.0000
* Peak MSE:     0.0340
* Overall MSE:  0.0200
* Peak ME:      0.0191
* Overall ME:   -0.0033
*
*  error specs for IDCT:
* Peak error:   1.0000
* Peak MSE:     0.0065
* Overall MSE:  0.0051
* Peak ME:      0.0015
* Overall ME:   0.0000
*
********************************************************/

#define LOAD_BUTF(m1, m2, a, b, tmp, S) \
 (m1) = (S)[(a)] + (S)[(b)]; \
 (m2) = (S)[(a)] - (S)[(b)]

#define BUTF(a, b, tmp) \
 (tmp) = (a)+(b); \
 (b) = (a)-(b);   \
 (a) = (tmp)

#define ROTATE(m1,m2,c,k1,k2,tmp,Fix,Rnd) \
 (tmp) = ( (m1) + (m2) )*(c); \
 (m1) *= k1; \
 (m2) *= k2; \
 (tmp) += (Rnd); \
 (m1) = ((m1)+(tmp))>>Fix; \
 (m2) = ((m2)+(tmp))>>Fix;

#define ROTATE2(m1,m2,c,k1,k2,tmp) \
 (tmp) = ( (m1) + (m2) )*(c); \
 (m1) *= k1; \
 (m2) *= k2; \
 (m1) = (m1)+(tmp); \
 (m2) = (m2)+(tmp);

#define ROTATE0(m1,m2,c,k1,k2,tmp) \
 (m1) = ( (m2) )*(c); \
 (m2) = (m2)*k2+(m1);

#define SHIFTL(x,n)   ((x)<<(n))
#define SHIFTR(x, n)  ((x)>>(n))
#define HALF(n)       (1<<((n)-1))

#define IPASS 3
#define FPASS 2
#define FIX  16

#if 1

#define ROT6_C     35468
#define ROT6_SmC   50159
#define ROT6_SpC  121095
#define ROT17_C    77062
#define ROT17_SmC  25571
#define ROT17_SpC 128553
#define ROT37_C    58981
#define ROT37_SmC  98391
#define ROT37_SpC  19571
#define ROT13_C   167963
#define ROT13_SmC 134553
#define ROT13_SpC 201373

#else

#define FX(x) ( (int)floor((x)*(1<<FIX) + .5 ) )

static const double c1 = cos(1.*M_PI/16);
static const double c2 = cos(2.*M_PI/16);
static const double c3 = cos(3.*M_PI/16);
static const double c4 = cos(4.*M_PI/16);
static const double c5 = cos(5.*M_PI/16);
static const double c6 = cos(6.*M_PI/16);
static const double c7 = cos(7.*M_PI/16);

static const int ROT6_C   = FX(c2-c6);  // 0.541
static const int ROT6_SmC = FX(2*c6);   // 0.765
static const int ROT6_SpC = FX(2*c2);   // 1.847

static const int ROT17_C   = FX(c1+c7);  // 1.175
static const int ROT17_SmC = FX(2*c7);   // 0.390
static const int ROT17_SpC = FX(2*c1);   // 1.961

static const int ROT37_C   = FX((c3-c7)/c4);  // 0.899
static const int ROT37_SmC = FX(2*(c5+c7));   // 1.501
static const int ROT37_SpC = FX(2*(c1-c3));   // 0.298

static const int ROT13_C   = FX((c1+c3)/c4);  // 2.562
static const int ROT13_SmC = FX(2*(c3+c7));   // 2.053
static const int ROT13_SpC = FX(2*(c1+c5));   // 3.072

#endif


#define TYPE SHORT

void jpeg_idct( p_jpeg_quality_table p_table, SHORT* In )
{
 register TYPE *pIn;
 register int i;
 int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill;
 pIn = In;
 for (i=8; i>0; --i)
 {
  // odd    

  mm4 = (int)pIn[7];
  mm5 = (int)pIn[5];
  mm6 = (int)pIn[3];
  mm7 = (int)pIn[1];

  mm2 = mm4 + mm6;
  mm3 = mm5 + mm7;
  ROTATE2(mm2, mm3,  ROT17_C, -ROT17_SpC, -ROT17_SmC, mm1);
  ROTATE2(mm4, mm7, -ROT37_C,  ROT37_SpC,  ROT37_SmC, mm1);
  ROTATE2(mm5, mm6, -ROT13_C,  ROT13_SmC,  ROT13_SpC, mm1);

  mm4 += mm2;
  mm5 += mm3;
  mm6 += mm2;
  mm7 += mm3;

  // even

  mm3 = (int)pIn[2];
  mm2 = (int)pIn[6];

  ROTATE2(mm3, mm2, ROT6_C, ROT6_SmC, -ROT6_SpC, mm1);

  LOAD_BUTF(mm0, mm1, 0, 4, Spill, pIn);
  mm0 = SHIFTL(mm0, FIX) + HALF(FIX-IPASS);
  mm1 = SHIFTL(mm1, FIX) + HALF(FIX-IPASS);
  BUTF(mm0, mm3, Spill);
  BUTF(mm1, mm2, Spill);


  BUTF(mm0, mm7, Spill);
  pIn[0] = SHIFTR(mm0, FIX-IPASS);
  pIn[7] = SHIFTR(mm7, FIX-IPASS);
  BUTF(mm1, mm6, mm0);
  pIn[1] = SHIFTR(mm1, FIX-IPASS);
  pIn[6] = SHIFTR(mm6, FIX-IPASS);
  BUTF(mm2, mm5, mm0);
  pIn[2] = SHIFTR(mm2, FIX-IPASS);
  pIn[5] = SHIFTR(mm5, FIX-IPASS);
  BUTF(mm3, mm4, mm0);
  pIn[3] = SHIFTR(mm3, FIX-IPASS);
  pIn[4] = SHIFTR(mm4, FIX-IPASS);

  pIn += 8;
 }

 pIn = In;
 for (i=8; i>0; --i)
 {
  // odd    

  mm4 = (int)pIn[7*8];
  mm5 = (int)pIn[5*8];
  mm6 = (int)pIn[3*8];
  mm7 = (int)pIn[1*8];


  mm2 = mm4 + mm6;
  mm3 = mm5 + mm7;
  ROTATE2(mm2, mm3,  ROT17_C, -ROT17_SpC, -ROT17_SmC, mm1);
  ROTATE2(mm4, mm7, -ROT37_C,  ROT37_SpC,  ROT37_SmC, mm1);
  ROTATE2(mm5, mm6, -ROT13_C,  ROT13_SmC,  ROT13_SpC, mm1);

  mm4 += mm2;
  mm5 += mm3;
  mm6 += mm2;
  mm7 += mm3;

  // even

  mm3 = (int)pIn[2*8];
  mm2 = (int)pIn[6*8];

  ROTATE2(mm3, mm2, ROT6_C, ROT6_SmC, -ROT6_SpC, mm1);

  LOAD_BUTF(mm0, mm1, 0*8, 4*8, Spill, pIn);
  mm0 = SHIFTL(mm0, FIX) + HALF(FIX+IPASS+3);
  mm1 = SHIFTL(mm1, FIX) + HALF(FIX+IPASS+3);
  BUTF(mm0, mm3, Spill);
  BUTF(mm1, mm2, Spill);

  BUTF(mm0, mm7, Spill);
  pIn[8*0] = (TYPE) SHIFTR(mm0, FIX+IPASS+3) + 128;

  if (pIn[8 * 0] < 0) pIn[8 * 0] = 0;
  else if (pIn[8 * 0] > 255) pIn[8 * 0] = 255;

  pIn[8*7] = (TYPE) SHIFTR(mm7, FIX+IPASS+3) + 128;

  if (pIn[8 * 7] < 0) pIn[8 * 7] = 0;
  else if (pIn[8 * 7] > 255) pIn[8 * 7] = 255;

  BUTF(mm1, mm6, mm0);
  pIn[8*1] = (TYPE) SHIFTR(mm1, FIX+IPASS+3) + 128;
  if (pIn[8 * 1] < 0) pIn[8 * 1] = 0;
  else if (pIn[8 * 1] > 255) pIn[8 * 1] = 255;

  pIn[8*6] = (TYPE) SHIFTR(mm6, FIX+IPASS+3) + 128;
  if (pIn[8 * 6] < 0) pIn[8 * 6] = 0;
  else if (pIn[8 * 6] > 255) pIn[8 * 6] = 255;

  BUTF(mm2, mm5, mm0);
  pIn[8*2] = (TYPE) SHIFTR(mm2, FIX+IPASS+3) + 128;

  if (pIn[8 * 2] < 0) pIn[8 * 2] = 0;
  else if (pIn[8 * 2] > 255) pIn[8 * 2] = 255;

  pIn[8*5] = (TYPE) SHIFTR(mm5, FIX+IPASS+3) + 128;
  if (pIn[8 * 5] < 0) pIn[8 * 5] = 0;
  else if (pIn[8 * 5] > 255) pIn[8 * 5] = 255;
  BUTF(mm3, mm4, mm0);
  pIn[8*3] = (TYPE) SHIFTR(mm3, FIX+IPASS+3) + 128;
  if (pIn[8 * 3] < 0) pIn[8 * 3] = 0;
  else if (pIn[8 * 3] > 255) pIn[8 * 3] = 255;
  pIn[8*4] = (TYPE) SHIFTR(mm4, FIX+IPASS+3) + 128;
  if (pIn[8 * 4] < 0) pIn[8 * 4] = 0;
  else if (pIn[8 * 4] > 255) pIn[8 * 4] = 255;

  pIn++;
 }
}

void jpeg_idct_prepare_qualitytable( p_jpeg_quality_table p_table )
{
}

发表于 @ 2006年10月21日 02:25:00|评论(0)|编辑

⌨️ 快捷键说明

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