📄 idct_mmx_xvid.c
字号:
"psrad $11,%%mm3 \n\t"/* y6=a1-b1 y7=a0-b0*/\ "paddd %%mm4,%%mm1 \n\t"/* 4 ; a1+b1 a0+b0*/\ "paddd %%mm2,%%mm0 \n\t"/* 2 ; a3=sum(even3) a2=sum(even2)*/\ "psrad $11,%%mm1 \n\t"/* y1=a1+b1 y0=a0+b0*/\ "paddd %%mm6,%%mm5 \n\t"/* 6 ; b3=sum(odd3) b2=sum(odd2)*/\ "movq %%mm0,%%mm4 \n\t"/* 4 ; a3 a2*/\ "paddd %%mm5,%%mm0 \n\t"/* a3+b3 a2+b2*/\ "psubd %%mm5,%%mm4 \n\t"/* 5 ; a3-b3 a2-b2*/\ "psrad $11,%%mm0 \n\t"/* y3=a3+b3 y2=a2+b2*/\ "psrad $11,%%mm4 \n\t"/* y4=a3-b3 y5=a2-b2*/\ "packssdw %%mm0,%%mm1 \n\t"/* 0 ; y3 y2 y1 y0*/\ "packssdw %%mm3,%%mm4 \n\t"/* 3 ; y6 y7 y4 y5*/\ "movq %%mm4,%%mm7 \n\t"/* 7 ; y6 y7 y4 y5*/\ "psrld $16,%%mm4 \n\t"/* 0 y6 0 y4*/\ "pslld $16,%%mm7 \n\t"/* y7 0 y5 0*/\ "movq %%mm1," #A2 " \n\t"/* 1 ; save y3 y2 y1 y0*/\ "por %%mm4,%%mm7 \n\t"/* 4 ; y7 y6 y5 y4*/\ "movq %%mm7,8 +" #A2 "\n\t"/* 7 ; save y7 y6 y5 y4*/\//-----------------------------------------------------------------------------// DCT_8_INV_ROW_XMM( INP, OUT, TABLE, ROUNDER//-----------------------------------------------------------------------------#define DCT_8_INV_ROW_XMM(A1,A2,A3,A4)\ "movq " #A1 ",%%mm0 \n\t"/* 0 ; x3 x2 x1 x0*/\ "movq 8+" #A1 ",%%mm1 \n\t"/* 1 ; x7 x6 x5 x4*/\ "movq %%mm0,%%mm2 \n\t"/* 2 ; x3 x2 x1 x0*/\ "movq " #A3 ",%%mm3 \n\t"/* 3 ; w05 w04 w01 w00*/\ "pshufw $0b10001000,%%mm0,%%mm0 \n\t"/* x2 x0 x2 x0*/\ "movq 8+" #A3 ",%%mm4 \n\t"/* 4 ; w07 w06 w03 w02*/\ "movq %%mm1,%%mm5 \n\t"/* 5 ; x7 x6 x5 x4*/\ "pmaddwd %%mm0,%%mm3 \n\t"/* x2*w05+x0*w04 x2*w01+x0*w00*/\ "movq 32+" #A3 ",%%mm6 \n\t"/* 6 ; w21 w20 w17 w16*/\ "pshufw $0b10001000,%%mm1,%%mm1 \n\t"/* x6 x4 x6 x4*/\ "pmaddwd %%mm1,%%mm4 \n\t"/* x6*w07+x4*w06 x6*w03+x4*w02*/\ "movq 40+" #A3 ",%%mm7 \n\t"/* 7 ; w23 w22 w19 w18*/\ "pshufw $0b11011101,%%mm2,%%mm2 \n\t"/* x3 x1 x3 x1*/\ "pmaddwd %%mm2,%%mm6 \n\t"/* x3*w21+x1*w20 x3*w17+x1*w16*/\ "pshufw $0b11011101,%%mm5,%%mm5 \n\t"/* x7 x5 x7 x5*/\ "pmaddwd %%mm5,%%mm7 \n\t"/* x7*w23+x5*w22 x7*w19+x5*w18*/\ "paddd " #A4 ",%%mm3 \n\t"/* +%4*/\ "pmaddwd 16+" #A3 ",%%mm0 \n\t"/* x2*w13+x0*w12 x2*w09+x0*w08*/\ "paddd %%mm4,%%mm3 \n\t"/* 4 ; a1=sum(even1) a0=sum(even0)*/\ "pmaddwd 24+" #A3 ",%%mm1 \n\t"/* x6*w15+x4*w14 x6*w11+x4*w10*/\ "movq %%mm3,%%mm4 \n\t"/* 4 ; a1 a0*/\ "pmaddwd 48+" #A3 ",%%mm2 \n\t"/* x3*w29+x1*w28 x3*w25+x1*w24*/\ "paddd %%mm7,%%mm6 \n\t"/* 7 ; b1=sum(odd1) b0=sum(odd0)*/\ "pmaddwd 56+" #A3 ",%%mm5 \n\t"/* x7*w31+x5*w30 x7*w27+x5*w26*/\ "paddd %%mm6,%%mm3 \n\t"/* a1+b1 a0+b0*/\ "paddd " #A4 ",%%mm0 \n\t"/* +%4*/\ "psrad $11,%%mm3 \n\t"/* y1=a1+b1 y0=a0+b0*/\ "paddd %%mm1,%%mm0 \n\t"/* 1 ; a3=sum(even3) a2=sum(even2)*/\ "psubd %%mm6,%%mm4 \n\t"/* 6 ; a1-b1 a0-b0*/\ "movq %%mm0,%%mm7 \n\t"/* 7 ; a3 a2*/\ "paddd %%mm5,%%mm2 \n\t"/* 5 ; b3=sum(odd3) b2=sum(odd2)*/\ "paddd %%mm2,%%mm0 \n\t"/* a3+b3 a2+b2*/\ "psrad $11,%%mm4 \n\t"/* y6=a1-b1 y7=a0-b0*/\ "psubd %%mm2,%%mm7 \n\t"/* 2 ; a3-b3 a2-b2*/\ "psrad $11,%%mm0 \n\t"/* y3=a3+b3 y2=a2+b2*/\ "psrad $11,%%mm7 \n\t"/* y4=a3-b3 y5=a2-b2*/\ "packssdw %%mm0,%%mm3 \n\t"/* 0 ; y3 y2 y1 y0*/\ "packssdw %%mm4,%%mm7 \n\t"/* 4 ; y6 y7 y4 y5*/\ "movq %%mm3, " #A2 " \n\t"/* 3 ; save y3 y2 y1 y0*/\ "pshufw $0b10110001,%%mm7,%%mm7 \n\t"/* y7 y6 y5 y4*/\ "movq %%mm7,8 +" #A2 "\n\t"/* 7 ; save y7 y6 y5 y4*/\//-----------------------------------------------------------------------------//// The first stage DCT 8x8 - forward DCTs of columns//// The %2puts are multiplied// for rows 0,4 - on cos_4_16,// for rows 1,7 - on cos_1_16,// for rows 2,6 - on cos_2_16,// for rows 3,5 - on cos_3_16// and are shifted to the left for rise of accuracy////-----------------------------------------------------------------------------//// The 8-point scaled forward DCT algorithm (26a8m)////-----------------------------------------------------------------------------//// #define DCT_8_FRW_COL(x, y)//{// short t0, t1, t2, t3, t4, t5, t6, t7;// short tp03, tm03, tp12, tm12, tp65, tm65;// short tp465, tm465, tp765, tm765;//// t0 = LEFT_SHIFT ( x[0] + x[7] );// t1 = LEFT_SHIFT ( x[1] + x[6] );// t2 = LEFT_SHIFT ( x[2] + x[5] );// t3 = LEFT_SHIFT ( x[3] + x[4] );// t4 = LEFT_SHIFT ( x[3] - x[4] );// t5 = LEFT_SHIFT ( x[2] - x[5] );// t6 = LEFT_SHIFT ( x[1] - x[6] );// t7 = LEFT_SHIFT ( x[0] - x[7] );//// tp03 = t0 + t3;// tm03 = t0 - t3;// tp12 = t1 + t2;// tm12 = t1 - t2;//// y[0] = tp03 + tp12;// y[4] = tp03 - tp12;//// y[2] = tm03 + tm12 * tg_2_16;// y[6] = tm03 * tg_2_16 - tm12;//// tp65 =(t6 +t5 )*cos_4_16;// tm65 =(t6 -t5 )*cos_4_16;//// tp765 = t7 + tp65;// tm765 = t7 - tp65;// tp465 = t4 + tm65;// tm465 = t4 - tm65;//// y[1] = tp765 + tp465 * tg_1_16;// y[7] = tp765 * tg_1_16 - tp465;// y[5] = tm765 * tg_3_16 + tm465;// y[3] = tm765 - tm465 * tg_3_16;//}////-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// DCT_8_INV_COL_4 INP,OUT//-----------------------------------------------------------------------------#define DCT_8_INV_COL(A1,A2)\ "movq 2*8(%3),%%mm0\n\t"\ "movq 16*3+" #A1 ",%%mm3\n\t"\ "movq %%mm0,%%mm1 \n\t"/* tg_3_16*/\ "movq 16*5+" #A1 ",%%mm5\n\t"\ "pmulhw %%mm3,%%mm0 \n\t"/* x3*(tg_3_16-1)*/\ "movq (%3),%%mm4\n\t"\ "pmulhw %%mm5,%%mm1 \n\t"/* x5*(tg_3_16-1)*/\ "movq 16*7+" #A1 ",%%mm7\n\t"\ "movq %%mm4,%%mm2 \n\t"/* tg_1_16*/\ "movq 16*1+" #A1 ",%%mm6\n\t"\ "pmulhw %%mm7,%%mm4 \n\t"/* x7*tg_1_16*/\ "paddsw %%mm3,%%mm0 \n\t"/* x3*tg_3_16*/\ "pmulhw %%mm6,%%mm2 \n\t"/* x1*tg_1_16*/\ "paddsw %%mm3,%%mm1 \n\t"/* x3+x5*(tg_3_16-1)*/\ "psubsw %%mm5,%%mm0 \n\t"/* x3*tg_3_16-x5 = tm35*/\ "movq 3*8(%3),%%mm3\n\t"\ "paddsw %%mm5,%%mm1 \n\t"/* x3+x5*tg_3_16 = tp35*/\ "paddsw %%mm6,%%mm4 \n\t"/* x1+tg_1_16*x7 = tp17*/\ "psubsw %%mm7,%%mm2 \n\t"/* x1*tg_1_16-x7 = tm17*/\ "movq %%mm4,%%mm5 \n\t"/* tp17*/\ "movq %%mm2,%%mm6 \n\t"/* tm17*/\ "paddsw %%mm1,%%mm5 \n\t"/* tp17+tp35 = b0*/\ "psubsw %%mm0,%%mm6 \n\t"/* tm17-tm35 = b3*/\ "psubsw %%mm1,%%mm4 \n\t"/* tp17-tp35 = t1*/\ "paddsw %%mm0,%%mm2 \n\t"/* tm17+tm35 = t2*/\ "movq 1*8(%3),%%mm7\n\t"\ "movq %%mm4,%%mm1 \n\t"/* t1*/\ "movq %%mm5,3*16 +" #A2 "\n\t"/* save b0*/\ "paddsw %%mm2,%%mm1 \n\t"/* t1+t2*/\ "movq %%mm6,5*16 +" #A2 "\n\t"/* save b3*/\ "psubsw %%mm2,%%mm4 \n\t"/* t1-t2*/\ "movq 2*16+" #A1 ",%%mm5\n\t"\ "movq %%mm7,%%mm0 \n\t"/* tg_2_16*/\ "movq 6*16+" #A1 ",%%mm6\n\t"\ "pmulhw %%mm5,%%mm0 \n\t"/* x2*tg_2_16*/\ "pmulhw %%mm6,%%mm7 \n\t"/* x6*tg_2_16*/\ "pmulhw %%mm3,%%mm1 \n\t"/* ocos_4_16*(t1+t2) = b1/2*/\ "movq 0*16+" #A1 ",%%mm2\n\t"\ "pmulhw %%mm3,%%mm4 \n\t"/* ocos_4_16*(t1-t2) = b2/2*/\ "psubsw %%mm6,%%mm0 \n\t"/* t2*tg_2_16-x6 = tm26*/\ "movq %%mm2,%%mm3 \n\t"/* x0*/\ "movq 4*16+" #A1 ",%%mm6\n\t"\ "paddsw %%mm5,%%mm7 \n\t"/* x2+x6*tg_2_16 = tp26*/\ "paddsw %%mm6,%%mm2 \n\t"/* x0+x4 = tp04*/\ "psubsw %%mm6,%%mm3 \n\t"/* x0-x4 = tm04*/\ "movq %%mm2,%%mm5 \n\t"/* tp04*/\ "movq %%mm3,%%mm6 \n\t"/* tm04*/\ "psubsw %%mm7,%%mm2 \n\t"/* tp04-tp26 = a3*/\ "paddsw %%mm0,%%mm3 \n\t"/* tm04+tm26 = a1*/\ "paddsw %%mm1,%%mm1 \n\t"/* b1*/\ "paddsw %%mm4,%%mm4 \n\t"/* b2*/\ "paddsw %%mm7,%%mm5 \n\t"/* tp04+tp26 = a0*/\ "psubsw %%mm0,%%mm6 \n\t"/* tm04-tm26 = a2*/\ "movq %%mm3,%%mm7 \n\t"/* a1*/\ "movq %%mm6,%%mm0 \n\t"/* a2*/\ "paddsw %%mm1,%%mm3 \n\t"/* a1+b1*/\ "paddsw %%mm4,%%mm6 \n\t"/* a2+b2*/\ "psraw $6,%%mm3 \n\t"/* dst1*/\ "psubsw %%mm1,%%mm7 \n\t"/* a1-b1*/\ "psraw $6,%%mm6 \n\t"/* dst2*/\ "psubsw %%mm4,%%mm0 \n\t"/* a2-b2*/\ "movq 3*16+" #A2 ",%%mm1 \n\t"/* load b0*/\ "psraw $6,%%mm7 \n\t"/* dst6*/\ "movq %%mm5,%%mm4 \n\t"/* a0*/\ "psraw $6,%%mm0 \n\t"/* dst5*/\ "movq %%mm3,1*16+" #A2 "\n\t"\ "paddsw %%mm1,%%mm5 \n\t"/* a0+b0*/\ "movq %%mm6,2*16+" #A2 "\n\t"\ "psubsw %%mm1,%%mm4 \n\t"/* a0-b0*/\ "movq 5*16+" #A2 ",%%mm3 \n\t"/* load b3*/\ "psraw $6,%%mm5 \n\t"/* dst0*/\ "movq %%mm2,%%mm6 \n\t"/* a3*/\ "psraw $6,%%mm4 \n\t"/* dst7*/\ "movq %%mm0,5*16+" #A2 "\n\t"\ "paddsw %%mm3,%%mm2 \n\t"/* a3+b3*/\ "movq %%mm7,6*16+" #A2 "\n\t"\ "psubsw %%mm3,%%mm6 \n\t"/* a3-b3*/\ "movq %%mm5,0*16+" #A2 "\n\t"\ "psraw $6,%%mm2 \n\t"/* dst3*/\ "movq %%mm4,7*16+" #A2 "\n\t"\ "psraw $6,%%mm6 \n\t"/* dst4*/\ "movq %%mm2,3*16+" #A2 "\n\t"\ "movq %%mm6,4*16+" #A2 "\n\t"//=============================================================================// Code//=============================================================================//-----------------------------------------------------------------------------// void idct_mmx(uint16_t block[64]);//-----------------------------------------------------------------------------void ff_idct_xvid_mmx(short *block){asm volatile( //# Process each row DCT_8_INV_ROW_MMX(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1)) DCT_8_INV_ROW_MMX(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1)) DCT_8_INV_ROW_MMX(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1)) DCT_8_INV_ROW_MMX(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1)) DCT_8_INV_ROW_MMX(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1)) DCT_8_INV_ROW_MMX(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1)) DCT_8_INV_ROW_MMX(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1)) DCT_8_INV_ROW_MMX(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1)) //# Process the columns (4 at a time) DCT_8_INV_COL(0(%0), 0(%0)) DCT_8_INV_COL(8(%0), 8(%0)) :: "r"(block), "r"(rounder_0), "r"(tab_i_04_mmx), "r"(tg_1_16));}//-----------------------------------------------------------------------------// void idct_xmm(uint16_t block[64]);//-----------------------------------------------------------------------------void ff_idct_xvid_mmx2(short *block){asm volatile( //# Process each row DCT_8_INV_ROW_XMM(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1)) DCT_8_INV_ROW_XMM(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1)) DCT_8_INV_ROW_XMM(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1)) DCT_8_INV_ROW_XMM(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1)) DCT_8_INV_ROW_XMM(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1)) DCT_8_INV_ROW_XMM(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1)) DCT_8_INV_ROW_XMM(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1)) DCT_8_INV_ROW_XMM(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1)) //# Process the columns (4 at a time) DCT_8_INV_COL(0(%0), 0(%0)) DCT_8_INV_COL(8(%0), 8(%0)) :: "r"(block), "r"(rounder_0), "r"(tab_i_04_xmm), "r"(tg_1_16));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -