void bgsubtract_apply(VJFrame *frame,int threshold, int method, int enabled, int alpha ) { const int len = frame->len; const int uv_len = (frame->ssm ? len : frame->uv_len ); if( auto_hist ) vje_histogram_auto_eq( frame ); if( enabled == 0 ) { switch( method ) { case 0: bgsubtract_show_bg( frame ); break; case 1: bgsubtract_cma_frame( len, frame->data[0], bg_frame__[0] ); bgsubtract_show_bg( frame ); bg_n ++; break; case 2: bgsubtract_avg_frame( len, frame->data[0], bg_frame__[0] ); bgsubtract_show_bg( frame ); break; default: break; } } else { if( alpha == 0 ) { veejay_memset( frame->data[1], 128, uv_len ); veejay_memset( frame->data[2], 128, uv_len ); vje_diff_plane( bg_frame__[0], frame->data[0], frame->data[0], threshold, len ); } else { vje_diff_plane( bg_frame__[0], frame->data[0], frame->data[3], threshold, len ); } } }
void timedistort_apply( VJFrame *frame, int width, int height, int val) { unsigned int i; const int len = (width * height); uint8_t *Y = frame->data[0]; uint8_t *Cb = frame->data[1]; uint8_t *Cr = frame->data[2]; uint8_t *diff = nonmap; uint8_t *prev = nonmap + len; int interpolate = 1; int motion = 0; int tmp1,tmp2; if(motionmap_active()) //@ use motion mapping frame { motionmap_scale_to( 255,255,1,1,&tmp1,&tmp2, &n__,&N__ ); motion = 1; diff = motionmap_bgmap(); } else { n__ = 0; N__ = 0; if(!have_bg) { vj_frame_copy1( Y, prev, len ); VJFrame smooth; veejay_memcpy(&smooth,frame, sizeof(VJFrame)); smooth.data[0] = prev; softblur_apply(&smooth, width, height, 0 ); veejay_memset( diff, 0, len ); have_bg = 1; return; } else { /*for( i = 0; i < len ; i ++ ) { diff[i] = (abs(prev[i] - Y[i])> val ? 0xff: 0 ); }*/ vje_diff_plane( prev, Y, diff, val, len ); vj_frame_copy1( Y, prev, len ); VJFrame smooth; veejay_memcpy(&smooth,frame, sizeof(VJFrame)); smooth.data[0] = prev; softblur_apply(&smooth, width, height, 0 ); } } if( n__ == N__ || n__ == 0 ) interpolate = 0; //@ process uint8_t *planeTables[4] = { planetableY[plane], planetableU[plane], planetableV[plane], NULL }; int strides[4] = { len, len, len, 0 }; vj_frame_copy( frame->data, planeTables, strides ); uint8_t *p = warptime[ warptimeFrame ] + width + 1; uint8_t *q = warptime[ warptimeFrame ^ 1] + width + 1; unsigned int x,y; for( y = height - 2; y > 0 ; y -- ) { for( x = width - 2; x > 0; x -- ) { i = *(p - width) + *(p-1) + *(p+1) + *(p + width); if( i > 3 ) i-= 3; p++; *q++ = i >> 2; } p += 2; q += 2; } q = warptime[ warptimeFrame ^ 1 ] + width + 1; int n_plane = 0; for( i = 0; i < len; i ++ ) { if( diff[i] ) { q[i] = PLANES - 1; } n_plane = ( plane - q[i] + PLANES ) & (PLANES-1); Y[i] = planetableY[ n_plane ][i]; Cb[i] = planetableU[ n_plane ][i]; Cr[i] = planetableV[ n_plane ][i]; } plane ++; plane = plane & (PLANES-1); warptimeFrame ^= 1; if(interpolate) motionmap_interpolate_frame( frame, N__,n__ ); if(motion) motionmap_store_frame(frame); }