📄 idct_ap922_int.c
字号:
/*******************************************************************
IDCT module used AP-922 algorithm
*******************************************************************/
#include "idct_clip_table.h"
/*------------------------------------------------------------------
IEEE test conditions: -L = -256, +H = 255, sign = 1, #iters = 10000, elapsed = 1262
Peak absolute values of errors:
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
Worst peak error = 1 (meets spec limit 1)
Mean square errors:
0.0064 0.0065 0.0060 0.0060 0.0059 0.0060 0.0058 0.0070
0.0070 0.0078 0.0073 0.0078 0.0057 0.0098 0.0069 0.0065
0.0092 0.0085 0.0073 0.0061 0.0077 0.0097 0.0092 0.0074
0.0060 0.0057 0.0058 0.0056 0.0064 0.0071 0.0068 0.0054
0.0045 0.0074 0.0061 0.0065 0.0054 0.0059 0.0073 0.0078
0.0076 0.0081 0.0063 0.0063 0.0072 0.0080 0.0087 0.0075
0.0082 0.0076 0.0065 0.0082 0.0071 0.0073 0.0083 0.0080
0.0059 0.0067 0.0056 0.0065 0.0064 0.0063 0.0063 0.0053
Worst pmse = 0.009800 (meets spec limit 0.06)
Overall mse = 0.006923 (meets spec limit 0.02)
Mean errors:
0.0016 -0.0007 0.0008 -0.0004 0.0005 0.0014 0.0016 0.0006
-0.0004 -0.0014 0.0007 -0.0008 0.0019 0.0010 0.0007 -0.0001
-0.0020 0.0001 -0.0003 -0.0007 -0.0011 -0.0007 0.0002 -0.0004
-0.0020 -0.0001 -0.0006 -0.0002 0.0008 -0.0003 -0.0008 0.0002
-0.0003 0.0012 -0.0001 0.0007 0.0002 -0.0001 -0.0005 0.0010
0.0008 0.0013 0.0011 -0.0015 -0.0002 -0.0006 0.0005 -0.0005
-0.0008 -0.0010 0.0001 0.0014 -0.0001 -0.0001 0.0003 0.0002
-0.0005 0.0001 0.0014 0.0019 -0.0008 0.0001 -0.0013 -0.0005
Worst mean error = 0.002000 (meets spec limit 0.015)
Overall mean error = 0.000039 (meets spec limit 0.0015)
0 elements of IDCT(0) were not zero
------------------------------------------------------------------*/
static const int table_row_04[] = {
16384,21407,16384,8867,16384,8867,-16384,-21407,
16384,-8867,-16384,21407,16384,-21407,16384,-8867,
22725,19266,12873,4520,19266,-4520,-22725,-12873,
12873,-22725,4520,19266,4520,-12873,19266,-22725,
};
static const int table_row_17[] = {
22725,29692,22725,12299,22725,12299,-22725,-29692,
22725,-12299,-22725,29692,22725,-29692,22725,-12299,
31521,26722,17855,6270,26722,-6270,-31521,-17855,
17855,-31521,6270,26722,6270,-17855,26722,-31521,
};
static const int table_row_26[] = {
21407,27969,21407,11585,21407,11585,-21407,-27969,
21407,-11585,-21407,27969,21407,-27969,21407,-11585,
29692,25172,16819,5906,25172,-5906,-29692,-16819,
16819,-29692,5906,25172,5906,-16819,25172,-29692,
};
static const int table_row_35[] = {
19266,25172,19266,10426,19266,10426,-19266,-25172,
19266,-10426,-19266,25172,19266,-25172,19266,-10426,
26722,22654,15137,5315,22654,-5315,-26722,-15137,
15137,-26722,5315,22654,5315,-15137,22654,-26722,
};
static const int tan_1_16 = 13036;
static const int tan_2_16 = 27146;
static const int tan_3_16 = 43790;
static const int cos_4_16 = 46341;
static __inline void idct_ap922_row(short *b, const int *w);
static __inline void idct_ap922_col(short *b);
void __stdcall idct_ap922_int(short *block)
{
int i;
/* row */
idct_ap922_row(block+ 0, table_row_04);
idct_ap922_row(block+ 8, table_row_17);
idct_ap922_row(block+16, table_row_26);
idct_ap922_row(block+24, table_row_35);
idct_ap922_row(block+32, table_row_04);
idct_ap922_row(block+40, table_row_35);
idct_ap922_row(block+48, table_row_26);
idct_ap922_row(block+56, table_row_17);
/* col */
for(i=0;i<8;i++){
idct_ap922_col(block+i);
}
}
static __inline void idct_ap922_row(short *b, const int *w)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
a0 = b[0]*w[ 0] + b[2]*w[ 1] + b[4]*w[ 2] + b[6]*w[ 3];
a1 = b[0]*w[ 4] + b[2]*w[ 5] + b[4]*w[ 6] + b[6]*w[ 7];
a2 = b[0]*w[ 8] + b[2]*w[ 9] + b[4]*w[10] + b[6]*w[11];
a3 = b[0]*w[12] + b[2]*w[13] + b[4]*w[14] + b[6]*w[15];
b0 = b[1]*w[16] + b[3]*w[17] + b[5]*w[18] + b[7]*w[19];
b1 = b[1]*w[20] + b[3]*w[21] + b[5]*w[22] + b[7]*w[23];
b2 = b[1]*w[24] + b[3]*w[25] + b[5]*w[26] + b[7]*w[27];
b3 = b[1]*w[28] + b[3]*w[29] + b[5]*w[30] + b[7]*w[31];
b[0] = (a0+b0+((1<<10)))>>11;
b[1] = (a1+b1+((1<<10)))>>11;
b[2] = (a2+b2+((1<<10)))>>11;
b[3] = (a3+b3+((1<<10)))>>11;
b[4] = (a3-b3+((1<<10)))>>11;
b[5] = (a2-b2+((1<<10)))>>11;
b[6] = (a1-b1+((1<<10)))>>11;
b[7] = (a0-b0+((1<<10)))>>11;
}
static __inline void idct_ap922_col(short *b)
{
int t0, t1, t2, t3, t4, t5, t6, t7;
int tp03, tm03, tp12, tm12, tp65, tm65;
int tp465, tm465, tp765, tm765;
tp765 = b[1*8] + ((b[7*8]*tan_1_16)>>16);
tp465 = ((b[1*8]*tan_1_16)>>16) - b[7*8];
tm765 = ((b[5*8]*tan_3_16)>>16) + b[3*8];
tm465 = b[5*8] - ((b[3*8]*tan_3_16)>>16);
t7 = tp765 + tm765 + 1;
tp65 = tp765 - tm765;
t4 = tp465 + tm465;
tm65 = tp465 - tm465 + 1;
t6 = ((tp65 + tm65) * cos_4_16)>>16;
t5 = ((tp65 - tm65) * cos_4_16)>>16;
t6 |= 1;
t5 |= 1;
tp03 = b[0*8] + b[4*8];
tp12 = b[0*8] - b[4*8];
tm03 = b[2*8] + ((b[6*8]*tan_2_16)>>16);
tm12 = ((b[2*8]*tan_2_16)>>16) - b[6*8];
t0 = tp03 + tm03;
t3 = tp03 - tm03;
t1 = tp12 + tm12;
t2 = tp12 - tm12;
b[0*8] = (t0+t7+((1<<5)))>>6;
b[1*8] = (t1+t6+((1<<5)))>>6;
b[2*8] = (t2+t5+((1<<5)-1))>>6;
b[3*8] = (t3+t4+((1<<5)-1))>>6;
b[4*8] = (t3-t4+((1<<5)-1))>>6;
b[5*8] = (t2-t5+((1<<5)-1))>>6;
b[6*8] = (t1-t6+((1<<5)))>>6;
b[7*8] = (t0-t7+((1<<5)))>>6;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -