timgfilterpostproc.cpp

来自「从FFMPEG转换而来的H264解码程序,VC下编译..」· C++ 代码 · 共 1,961 行 · 第 1/5 页

CPP
1,961
字号
        csimd::paddw(mm1, mm4                 );

        csimd::movq( DCTSIZE_S*3*2+REG_D, mm6 );
        csimd::paddw(mm3, mm5                 );

        csimd::movq( temps[3], mm0    );
        REG_S+=8;

        csimd::movq( mm7, DCTSIZE_S*1*2+REG_D );
        csimd::paddw(mm0, mm6           );

        csimd::movq( mm4, DCTSIZE_S*2*2+REG_D );
        csimd::psubw(mm2, mm0             );

        csimd::movq( DCTSIZE_S*4*2+REG_D, mm7);
        csimd::paddw(mm2, mm6            );

        csimd::movq( mm5, DCTSIZE_S*5*2+REG_D);
        csimd::paddw(mm0, mm7         );

        csimd::movq( mm6, DCTSIZE_S*3*2+REG_D);

        csimd::movq( mm7, DCTSIZE_S*4*2+REG_D);
        REG_D               +=8;
        goto label4;

       label2:
        //--- non DC2
        //csimd::psraw mm1, 2 w/o it -> offset. thr1, thr1, thr1  (actually thr1, thr1, thr1-1)
        //csimd::psraw mm5, 2
        //csimd::psraw mm0, 2
        //csimd::psraw mm6, 2
        csimd::movq( mm5, mm3 );
        csimd::psubw(mm1, mm5 );

        csimd::psllw(1, mm5   );            //'z10
        csimd::paddw(mm1, mm3 );            //'z13

        csimd::movq( mm0, mm2 );
        csimd::psubw(mm6, mm0 );

        csimd::movq( mm5, mm1  );
        csimd::psllw(1, mm0   );            //'z12

        csimd::pmulhw (MM_FIX_2_613125930, mm1);  //-
        csimd::paddw(mm0, mm5 );

        csimd::pmulhw (MM_FIX_1_847759065, mm5);  //'z5
        csimd::paddw(mm6, mm2   );          //'z11

        csimd::pmulhw (MM_FIX_1_082392200, mm0 );
        csimd::movq( mm2, mm7 );

        //---
        csimd::movq( temps[0], mm4 );
        csimd::psubw(mm3, mm2 );

        csimd::psllw(1, mm2  );
        csimd::paddw(mm3, mm7);             //'t7

        csimd::pmulhw (MM_FIX_1_414213562, mm2);  //'t11
        csimd::movq( mm4, mm6    );
        //csimd::paddw(mm7, MM_2
        csimd::psraw (2, mm7  );

        csimd::paddw(DCTSIZE_S*0*2+REG_D, mm4 );
        csimd::psubw(mm7, mm6 );

        csimd::movq( temps[1], mm3 );
        csimd::paddw(mm7, mm4   );

        csimd::movq( mm6, DCTSIZE_S*7*2+REG_D );
        csimd::paddw(mm5, mm1        );     //'t12

        csimd::movq( mm4, DCTSIZE_S*0*2+REG_D  );
        csimd::psubw(mm7, mm1    );         //'t6

        csimd::movq( temps[2], mm7);
        csimd::psubw(mm5, mm0      );       //'t10

        csimd::movq( temps[3], mm6 );
        csimd::movq( mm3, mm5     );

        csimd::paddw(DCTSIZE_S*1*2+REG_D, mm3);
        csimd::psubw(mm1, mm5 );

        csimd::psubw(mm1, mm2 );            //'t5
        csimd::paddw(mm1, mm3);

        csimd::movq( mm5, DCTSIZE_S*6*2+REG_D);
        csimd::movq( mm7, mm4  );

        csimd::paddw(DCTSIZE_S*2*2+REG_D, mm7);
        csimd::psubw(mm2, mm4  );

        csimd::paddw(DCTSIZE_S*5*2+REG_D, mm4 );
        csimd::paddw(mm2, mm7  );

        csimd::movq( mm3, DCTSIZE_S*1*2+REG_D);
        csimd::paddw(mm2, mm0 );            //'t4

        // 't4 't6 't5 - - - - 't7
        csimd::movq( mm7, DCTSIZE_S*2*2+REG_D );
        csimd::movq( mm6, mm1               );

        csimd::paddw(DCTSIZE_S*4*2+REG_D, mm6);
        csimd::psubw(mm0, mm1                );

        csimd::paddw(DCTSIZE_S*3*2+REG_D, mm1);
        csimd::paddw(mm0, mm6                );

        csimd::movq( mm4, DCTSIZE_S*5*2+REG_D);
        REG_S               +=8;

        csimd::movq( mm6, DCTSIZE_S*4*2+REG_D );

        csimd::movq( mm1, DCTSIZE_S*3*2+REG_D );
        REG_D               +=8;

       label4:
//=part 2 (the same)===========================================================
        csimd::movq( DCTSIZE_S*0*2+REG_S, mm1);
        //
        csimd::movq( DCTSIZE_S*3*2+REG_S, mm7 );
        csimd::movq( mm1, mm0 );

        csimd::paddw(DCTSIZE_S*7*2+REG_S, mm1 ); //t0
        csimd::movq( mm7, mm3 );

        csimd::paddw(DCTSIZE_S*4*2+REG_S, mm7);  //t3
        csimd::movq( mm1, mm5);

        csimd::movq( DCTSIZE_S*1*2+REG_S, mm6 );
        csimd::psubw(mm7, mm1);             //t13

        csimd::movq( DCTSIZE_S*2*2+REG_S, mm2);
        csimd::movq( mm6, mm4  );

        csimd::paddw(DCTSIZE_S*6*2+REG_S, mm6 ); //t1
        csimd::paddw(mm7, mm5  );           //t10

        csimd::paddw(DCTSIZE_S*5*2+REG_S, mm2);  //t2
        csimd::movq( mm6, mm7);

        csimd::paddw(mm2, mm6);             //t11
        csimd::psubw(mm2, mm7 );            //t12

        csimd::movq( mm5, mm2 );
        csimd::paddw(mm6, mm5 );            //d0
        // i0 t13 t12 i3 i1 d0 - d4
        csimd::psubw(mm6, mm2);             //d4
        csimd::paddw(mm1, mm7);

        csimd::movq(  1*8+4*16+REG_d, mm6);
        csimd::psllw(2, mm7 );

        csimd::psubw(1*8+0*16+REG_d, mm5 );
        csimd::psubw(mm6, mm2 );

        csimd::paddusw(1*8+0*16+REG_d, mm5 );
        csimd::paddusw(mm6, mm2);

        csimd::pmulhw (MM_FIX_0_707106781, mm7 );
        //
        csimd::paddw(1*8+0*16+REG_d, mm5 );
        csimd::paddw(mm6, mm2   );

        csimd::psubusw(1*8+0*16+REG_d, mm5);
        csimd::psubusw(mm6, mm2);

//This func is totally compute-bound,  operates at huge speed. So,  DC shortcut
// at this place isn't worthwhile due to BTB miss penalty (checked on Pent. 3).
//However,  typical numbers: nondc - 29,  dc - 46,  zero - 25. All <> 0 case is very rare.
        csimd::paddw((MM_2), mm5  );
        csimd::movq( mm2, mm6);

        csimd::paddw(mm5, mm2);
        csimd::psubw(mm6, mm5 );

        csimd::movq( mm1, mm6 );
        csimd::paddw(mm7, mm1 );            //d2

        csimd::psubw(1*8+2*16+REG_d, mm1);
        csimd::psubw(mm7, mm6);             //d6

        csimd::movq( 1*8+6*16+REG_d, mm7);
        csimd::psraw (2, mm5 );

        csimd::paddusw(1*8+2*16+REG_d, mm1);
        csimd::psubw(mm7, mm6);
        // t7 d2 /t11 t4 t6 - d6 /t10

        csimd::paddw(1*8+2*16+REG_d, mm1);
        csimd::paddusw(mm7, mm6 );

        csimd::psubusw(1*8+2*16+REG_d, mm1 );
        csimd::paddw(mm7, mm6  );

        csimd::psubw(DCTSIZE_S*4*2+REG_S, mm3);
        csimd::psubusw(mm7, mm6 );

        //csimd::movq( [edi+DCTSIZE_S*2*2], mm1
        //csimd::movq( [edi+DCTSIZE_S*6*2], mm6
        csimd::movq( mm1, mm7  );
        csimd::psraw (2, mm2 );

        csimd::psubw(DCTSIZE_S*6*2+REG_S, mm4 );
        csimd::psubw(mm6, mm1            );

        csimd::psubw(DCTSIZE_S*7*2+REG_S, mm0 );
        csimd::paddw(mm7, mm6  );           //'t13

        csimd::psraw (2, mm6 );              //csimd::paddw(mm6, MM_2 !!    ---
        csimd::movq( mm2, mm7);

        csimd::pmulhw (MM_FIX_1_414213562_A, mm1 );
        csimd::paddw(mm6, mm2 );            //'t0

        csimd::movq( mm2, temps[0] );       //!
        csimd::psubw(mm6, mm7     );        //'t3

        csimd::movq( DCTSIZE_S*2*2+REG_S, mm2);
        csimd::psubw(mm6, mm1 );            //'t12

        csimd::psubw(DCTSIZE_S*5*2+REG_S, mm2);  //t5
        csimd::movq( mm5, mm6   );

        csimd::movq( mm7, temps[3]  );
        csimd::paddw(mm2, mm3);             //t10

        csimd::paddw(mm4, mm2);             //t11
        csimd::paddw(mm0, mm4);             //t12

        csimd::movq( mm3, mm7);
        csimd::psubw(mm4, mm3);

        csimd::psllw(2, mm3);
        csimd::psllw(2, mm7);               //opt for P6

        csimd::pmulhw (MM_FIX_0_382683433, mm3 );
        csimd::psllw(2, mm4  );

        csimd::pmulhw (MM_FIX_0_541196100, mm7 );
        csimd::psllw(2, mm2);

        csimd::pmulhw (MM_FIX_1_306562965, mm4 );
        csimd::paddw(mm1, mm5);             //'t1

        csimd::pmulhw (MM_FIX_0_707106781, mm2 );
        csimd::psubw(mm1, mm6 );            //'t2
        // t7 't12 't11 t4 t6 - 't13 't10   ---

        csimd::paddw(mm3, mm7 );            //z2

        csimd::movq( mm5, temps[1]       );
        csimd::paddw(mm3, mm4 );            //z4

        csimd::movq( 1*8+3*16+REG_d, mm3 );
        csimd::movq( mm0, mm1 );

        csimd::movq( mm6, temps[2]);
        csimd::psubw(mm2, mm1  );           //z13

//===
        csimd::paddw(mm2, mm0 );            //z11
        csimd::movq( mm1, mm5);

        csimd::movq( 1*8+5*16+REG_d, mm2);
        csimd::psubw(mm7, mm1);             //d3

        csimd::paddw(mm7, mm5);             //d5
        csimd::psubw(mm3, mm1);

        csimd::movq( 1*8+1*16+REG_d, mm7);
        csimd::psubw(mm2, mm5);

        csimd::movq( mm0, mm6);
        csimd::paddw(mm4, mm0);             //d1

        csimd::paddusw(mm3, mm1 );
        csimd::psubw(mm4, mm6);             //d7

        // d1 d3 - - - d5 d7 -
        csimd::movq( 1*8+7*16+REG_d, mm4);
        csimd::psubw(mm7, mm0);

        csimd::psubw(mm4, mm6);
        csimd::paddusw(mm2, mm5 );

        csimd::paddusw(mm4, mm6 );
        csimd::paddw(mm3, mm1);

        csimd::paddw(mm2, mm5);
        csimd::paddw(mm4, mm6 );

        csimd::psubusw(mm3, mm1 );
        csimd::psubusw(mm2, mm5 );

        csimd::psubusw(mm4, mm6 );
        csimd::movq( mm1, mm4);

        csimd::por( mm5, mm4 );
        csimd::paddusw(mm7, mm0 );

        csimd::por( mm6, mm4 );
        csimd::paddw(mm7, mm0 );

        csimd::packssdw(mm4, mm4 );
        csimd::psubusw(mm7, mm0);

        csimd::movd (mm4, REG_a);
        if (REG_a) //or REG_a, REG_a
          goto label3;//jnz 3f
        //csimd::movq( [edi+DCTSIZE_S*3*2], mm1
        //csimd::movq( [edi+DCTSIZE_S*5*2], mm5
        //csimd::movq( [edi+DCTSIZE_S*1*2], mm0
        //csimd::movq( [edi+DCTSIZE_S*7*2], mm6
        // t4 t5 - - - t6 t7 -
        //--- t4 (mm0) may be <>0; mm1, mm5, mm6 == 0
//Typical numbers: nondc - 19,  dc - 26,  zero - 55. zero case alone isn't worthwhile
        csimd::movq( temps[0], mm4);
        csimd::movq( mm0, mm1   );

        csimd::pmulhw (MM_FIX_0_847759065, mm0);  //tmp6
        csimd::movq( mm1, mm2 );

        csimd::movq( DCTSIZE_S*0*2+REG_D, mm5);
        csimd::movq( mm2, mm3);

        csimd::pmulhw (MM_FIX_0_566454497, mm1);  //tmp5
        csimd::paddw(mm4, mm5);

        csimd::movq( temps[1], mm6);
        //csimd::paddw(mm3, MM_2
        csimd::psraw (2, mm3 );              //tmp7

        csimd::pmulhw (MM_FIX_0_198912367, mm2);  //-tmp4
        csimd::psubw(mm3, mm4  );

        csimd::movq( DCTSIZE_S*1*2+REG_D, mm7 );
        csimd::paddw(mm3, mm5       );

        csimd::movq( mm4, DCTSIZE_S*7*2+REG_D   );
        csimd::paddw(mm6, mm7             );

        csimd::movq( temps[2], mm3 );
        csimd::psubw(mm0, mm6    );

        csimd::movq( DCTSIZE_S*2*2+REG_D, mm4 );
        csimd::paddw(mm0, mm7   );

        csimd::movq( mm5, DCTSIZE_S*0*2+REG_D );
        csimd::paddw(mm3, mm4              );

        csimd::movq( mm6, DCTSIZE_S*6*2+REG_D );
        csimd::psubw(mm1, mm3                );

        csimd::movq( DCTSIZE_S*5*2+REG_D, mm5 );
        csimd::paddw(mm1, mm4              );

        csimd::movq( DCTSIZE_S*3*2+REG_D, mm6 );
        csimd::paddw(mm3, mm5          );

        csimd::movq( temps[3], mm0 );
        REG_S+=24;

        csimd::movq( mm7, DCTSIZE_S*1*2+REG_D  );
        csimd::paddw(mm0, mm6  );

        csimd::movq( mm4, DCTSIZE_S*2*2+REG_D  );
        csimd::psubw(mm2, mm0   );

        csimd::movq( DCTSIZE_S*4*2+REG_D, mm7);
        csimd::paddw(mm2, mm6            );

        csimd::movq( mm5, DCTSIZE_S*5*2+REG_D);
        csimd::paddw(mm0, mm7         );

        csimd::movq( mm6, DCTSIZE_S*3*2+REG_D );

        csimd::movq( mm7, DCTSIZE_S*4*2+REG_D);
        REG_D+=24;
        REG_c-=2;
        if (REG_c) goto label1;//jnz 1b
        goto label5;

       label3:
        //--- non DC2
        //csimd::psraw mm1, 2 w/o it -> offset. thr1, thr1, th

⌨️ 快捷键说明

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