void chameleon_apply( VJFrame *frame, int mode) { const int len = frame->len; VJFrame source; int strides[4] = { len, len, len, 0 }; vj_frame_copy( frame->data, tmpimage, strides ); source.data[0] = tmpimage[0]; source.data[1] = tmpimage[1]; source.data[2] = tmpimage[2]; source.len = len; uint32_t activity = 0; int auto_switch = 0; int tmp1,tmp2; if( motionmap_active() ) { motionmap_scale_to( 32,32,1,1, &tmp1,&tmp2, &n__, &N__ ); auto_switch = 1; activity = motionmap_activity(); } else { N__ = 0; n__ = 0; } if( n__ == N__ || n__ == 0 ) auto_switch = 0; if(auto_switch) { if( activity <= 40 ) { // into the wall drawDisappearing( &source, frame ); } else { // out of the wall drawAppearing( &source, frame ); } } if( mode == 0 ) drawDisappearing( &source, frame ); else drawAppearing( &source, frame ); }
void chameleonblend_apply( VJFrame *frame, VJFrame *source, int width, int height, int mode ) { uint32_t activity = 0; int auto_switch = 0; int tmp1,tmp2; if( motionmap_active() ) { motionmap_scale_to( 32,32,1,1, &tmp1,&tmp2, &n__, &N__ ); auto_switch = 1; activity = motionmap_activity(); } else { N__ = 0; n__ = 0; } if( n__ == N__ || n__ == 0 ) auto_switch = 0; if(auto_switch) { if( activity <= 40 ) { veejay_msg(2, "Activity > 40, draw disappearing" ); // into the wall drawDisappearing( source, frame ); } else { veejay_msg(2, "Activity > 40, draw appearing" ); // out of the wall drawAppearing( source, frame ); } } else { if( mode == 0 ) drawDisappearing( source, frame ); else drawAppearing( source, frame ); } }
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); }
void magicmirror_apply( VJFrame *frame, int w, int h, int vx, int vy, int d, int n ) { double c1 = (double)vx; double c2 = (double)vy; int motion = 0; if( motionmap_active()) { motionmap_scale_to( 100,100,0,0, &d, &n, &n__, &N__ ); motion = 1; } else { n__ = 0; N__ = 0; } double c3 = (double)d * 0.001; unsigned int dx,dy,x,y,p,q,len=w*h; double c4 = (double)n * 0.001; int changed = 0; uint8_t *Y = frame->data[0]; uint8_t *Cb= frame->data[1]; uint8_t *Cr= frame->data[2]; int interpolate = 1; if( n__ == N__ || n__ == 0) interpolate = 0; if( d != last[1] ) { changed = 1; last[1] =d; } if( n != last[0] ) { changed = 1; last[0] = n; } if(changed==1) { // degrees x or y changed, need new sin for(x=0; x < w ; x++) { double res; fast_sin(res,(double)(c3*x)); funhouse_x[x] = res; //funhouse_x[x] = sin(c3 * x); } for(y=0; y < h; y++) { double res; fast_sin(res,(double)(c4*y)); funhouse_y[y] = res; //funhouse_y[y] = sin(c4 * y); } } int strides[4] = { len,len,len, 0 }; vj_frame_copy( frame->data, magicmirrorbuf, strides ); for(x=0; x < w; x++) { dx = x + funhouse_x[x] * c1; if(dx < 0) dx += w; if(dx < 0) dx = 0; else if (dx >= w) dx = w-1; cache_x[x] = dx; } for(y=0; y < h; y++) { dy = y + funhouse_y[y] * c2; if(dy < 0) dy += h; if(dy < 0) dy = 0; else if (dy >= h) dy = h-1; cache_y[y] = dy; } for(y=1; y < h-1; y++) { for(x=1; x < w-1; x++) { p = cache_y[y] * w + cache_x[x]; q = y * w + x; Y[q] = magicmirrorbuf[0][p]; Cb[q] = magicmirrorbuf[1][p]; Cr[q] = magicmirrorbuf[2][p]; } } if( interpolate ) { motionmap_interpolate_frame( frame, N__, n__ ); } if( motion ) { motionmap_store_frame(frame); } }