static inline void mean8(unsigned char *refpix,unsigned char *pixel,int radius_count,int row_stride,int threshold,int8_t *diff,unsigned char *count) { int a,b; pxor_r2r(mm6,mm6); // mm6 (aka count) = 0 pxor_r2r(mm7,mm7); // mm7 (aka diff) = 0 movq_m2r(*refpix,mm3); // mm3 = refpix[0] movd_g2r(0x80808080,mm4); // mm4 = 128 punpcklbw_r2r(mm4,mm4); pxor_r2r(mm4,mm3); // mm3 = refpix[0]-128 movd_g2r(threshold,mm5); // mm5 = threshold punpcklbw_r2r(mm5,mm5); punpcklbw_r2r(mm5,mm5); punpcklbw_r2r(mm5,mm5); for( b=0; b<radius_count; b++ ) { for( a=0; a<radius_count; a++ ) { movq_m2r(*pixel,mm0); // mm0 = pixel[0] pxor_r2r(mm4,mm0); // mm0 = pixel[0]-128 movq_r2r(mm3,mm2); // mm2 = refpix[0]-128 psubsb_r2r(mm0,mm2); // mm2 = refpix[0]-pixel[0] psubsb_r2r(mm3,mm0); // mm0 = pixel[0]-refpix[0] pminub_r2r(mm0,mm2); // mm2 = abs(pixel[0]-refpix[0]) movq_r2r(mm5,mm1); // mm1 = threshold pcmpgtb_r2r(mm2,mm1); // mm1 = (threshold > abs(pixel[0]-refpix[0])) ? -1 : 0 psubb_r2r(mm1,mm6); // mm6 += (threshold > abs(pixel[0]-refpix[0])) pand_r2r(mm1,mm0); // mm0 = (threshold > abs(pixel[0]-refpix[0])) ? pixel[0]-refpix[0] : 0 paddb_r2r(mm0,mm7); // mm7 += (threshold > abs(pixel[0]-refpix[0])) ? pixel[0]-refpix[0] : 0 ++pixel; } pixel += row_stride - radius_count; } movq_r2m(mm6,*count); movq_r2m(mm7,*diff); emms(); }
static void frame_f2i_sse(float *src,u_char *dst,int l) { int i; // put 128 in all 4 words of mm7 movd_g2r(128,mm7); punpcklwd_r2r(mm7,mm7); punpckldq_r2r(mm7,mm7); // put 128 in all 8 bytes of mm6 movd_g2r(128,mm6); punpcklbw_r2r(mm6,mm6); punpcklwd_r2r(mm6,mm6); punpckldq_r2r(mm6,mm6); for( i=0; i<l; i+=8 ) { movaps_m2r(src[0],xmm0); movaps_m2r(src[4],xmm2); movhlps_r2r(xmm0,xmm1); cvtps2pi_r2r(xmm0,mm0); cvtps2pi_r2r(xmm1,mm1); movhlps_r2r(xmm2,xmm3); cvtps2pi_r2r(xmm2,mm2); cvtps2pi_r2r(xmm3,mm3); packssdw_r2r(mm1,mm0); packssdw_r2r(mm3,mm2); psubw_r2r(mm7,mm0); psubw_r2r(mm7,mm2); packsswb_r2r(mm2, mm0); paddb_r2r(mm6, mm0); movq_r2m(mm0,dst[0]); src+=8; dst+=8; } emms(); }
static void deinterlace_scanline_linear_mmx (GstDeinterlaceSimpleMethod * self, guint8 * out, const guint8 * bot, const guint8 * top, gint size) { const mmx_t shiftmask = { 0xfefffefffefffeffULL }; /* To avoid shifting chroma to luma. */ int i; for (i = size / 32; i; --i) { movq_m2r (*bot, mm0); movq_m2r (*top, mm1); movq_m2r (*(bot + 8), mm2); movq_m2r (*(top + 8), mm3); movq_m2r (*(bot + 16), mm4); movq_m2r (*(top + 16), mm5); movq_m2r (*(bot + 24), mm6); movq_m2r (*(top + 24), mm7); pand_m2r (shiftmask, mm0); pand_m2r (shiftmask, mm1); pand_m2r (shiftmask, mm2); pand_m2r (shiftmask, mm3); pand_m2r (shiftmask, mm4); pand_m2r (shiftmask, mm5); pand_m2r (shiftmask, mm6); pand_m2r (shiftmask, mm7); psrlw_i2r (1, mm0); psrlw_i2r (1, mm1); psrlw_i2r (1, mm2); psrlw_i2r (1, mm3); psrlw_i2r (1, mm4); psrlw_i2r (1, mm5); psrlw_i2r (1, mm6); psrlw_i2r (1, mm7); paddb_r2r (mm1, mm0); paddb_r2r (mm3, mm2); paddb_r2r (mm5, mm4); paddb_r2r (mm7, mm6); movq_r2m (mm0, *out); movq_r2m (mm2, *(out + 8)); movq_r2m (mm4, *(out + 16)); movq_r2m (mm6, *(out + 24)); out += 32; top += 32; bot += 32; } size = (size & 0x1f); for (i = size / 8; i; --i) { movq_m2r (*bot, mm0); movq_m2r (*top, mm1); pand_m2r (shiftmask, mm0); pand_m2r (shiftmask, mm1); psrlw_i2r (1, mm0); psrlw_i2r (1, mm1); paddb_r2r (mm1, mm0); movq_r2m (mm0, *out); out += 8; top += 8; bot += 8; } emms (); size = size & 0xf; /* Handle last few pixels. */ for (i = size; i; --i) { *out++ = ((*top++) + (*bot++)) >> 1; } }
static void deinterlace_scanline_linear_mmx (GstDeinterlaceMethod * self, GstDeinterlace * parent, guint8 * out, GstDeinterlaceScanlineData * scanlines, gint width) { const mmx_t shiftmask = { 0xfefffefffefffeffULL }; /* To avoid shifting chroma to luma. */ int i; guint8 *bot = scanlines->b0, *top = scanlines->t0; for (i = width / 16; i; --i) { movq_m2r (*bot, mm0); movq_m2r (*top, mm1); movq_m2r (*(bot + 8), mm2); movq_m2r (*(top + 8), mm3); movq_m2r (*(bot + 16), mm4); movq_m2r (*(top + 16), mm5); movq_m2r (*(bot + 24), mm6); movq_m2r (*(top + 24), mm7); pand_m2r (shiftmask, mm0); pand_m2r (shiftmask, mm1); pand_m2r (shiftmask, mm2); pand_m2r (shiftmask, mm3); pand_m2r (shiftmask, mm4); pand_m2r (shiftmask, mm5); pand_m2r (shiftmask, mm6); pand_m2r (shiftmask, mm7); psrlw_i2r (1, mm0); psrlw_i2r (1, mm1); psrlw_i2r (1, mm2); psrlw_i2r (1, mm3); psrlw_i2r (1, mm4); psrlw_i2r (1, mm5); psrlw_i2r (1, mm6); psrlw_i2r (1, mm7); paddb_r2r (mm1, mm0); paddb_r2r (mm3, mm2); paddb_r2r (mm5, mm4); paddb_r2r (mm7, mm6); movq_r2m (mm0, *out); movq_r2m (mm2, *(out + 8)); movq_r2m (mm4, *(out + 16)); movq_r2m (mm6, *(out + 24)); out += 32; top += 32; bot += 32; } width = (width & 0xf); for (i = width / 4; i; --i) { movq_m2r (*bot, mm0); movq_m2r (*top, mm1); pand_m2r (shiftmask, mm0); pand_m2r (shiftmask, mm1); psrlw_i2r (1, mm0); psrlw_i2r (1, mm1); paddb_r2r (mm1, mm0); movq_r2m (mm0, *out); out += 8; top += 8; bot += 8; } width = width & 0x7; /* Handle last few pixels. */ for (i = width * 2; i; --i) { *out++ = ((*top++) + (*bot++)) >> 1; } emms (); }
static void interpolate_packed422_scanline_mmx( uint8_t *output, uint8_t *top, uint8_t *bot, int width ) { const mmx_t shiftmask = { 0xfefffefffefffeffULL }; /* To avoid shifting chroma to luma. */ int i; for( i = width/16; i; --i ) { movq_m2r( *bot, mm0 ); movq_m2r( *top, mm1 ); movq_m2r( *(bot + 8), mm2 ); movq_m2r( *(top + 8), mm3 ); movq_m2r( *(bot + 16), mm4 ); movq_m2r( *(top + 16), mm5 ); movq_m2r( *(bot + 24), mm6 ); movq_m2r( *(top + 24), mm7 ); pand_m2r( shiftmask, mm0 ); pand_m2r( shiftmask, mm1 ); pand_m2r( shiftmask, mm2 ); pand_m2r( shiftmask, mm3 ); pand_m2r( shiftmask, mm4 ); pand_m2r( shiftmask, mm5 ); pand_m2r( shiftmask, mm6 ); pand_m2r( shiftmask, mm7 ); psrlw_i2r( 1, mm0 ); psrlw_i2r( 1, mm1 ); psrlw_i2r( 1, mm2 ); psrlw_i2r( 1, mm3 ); psrlw_i2r( 1, mm4 ); psrlw_i2r( 1, mm5 ); psrlw_i2r( 1, mm6 ); psrlw_i2r( 1, mm7 ); paddb_r2r( mm1, mm0 ); paddb_r2r( mm3, mm2 ); paddb_r2r( mm5, mm4 ); paddb_r2r( mm7, mm6 ); movq_r2m( mm0, *output ); movq_r2m( mm2, *(output + 8) ); movq_r2m( mm4, *(output + 16) ); movq_r2m( mm6, *(output + 24) ); output += 32; top += 32; bot += 32; } width = (width & 0xf); for( i = width/4; i; --i ) { movq_m2r( *bot, mm0 ); movq_m2r( *top, mm1 ); pand_m2r( shiftmask, mm0 ); pand_m2r( shiftmask, mm1 ); psrlw_i2r( 1, mm0 ); psrlw_i2r( 1, mm1 ); paddb_r2r( mm1, mm0 ); movq_r2m( mm0, *output ); output += 8; top += 8; bot += 8; } width = width & 0x7; /* Handle last few pixels. */ for( i = width * 2; i; --i ) { *output++ = ((*top++) + (*bot++)) >> 1; } emms(); }