View Single Post
Old 11-15-2018, 07:13 AM   #12
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Awesome!

Here's a simplified version that operates in YV12, and adjusts the blur/weight knob to give a nice feeling curve:
Code:
// simple blur, YV12
//@param1:weight_parm 'blur amount' .5 0 .99 0.5 0.001

in=0;

colorspace='YV12';
input_info(in,w,h);
gfx_img_resize(-1,w,h);

weight = weight_parm^.25;
uvweight= sqr(weight);
code="
(_1 -= 1) < 0 ? (
  _1=eval_w*.5-1;
  _2=y1; _3=y3; _4=u; _5=v;
);
y1+=weight*(_2-y1); _2=(y2+=weight*(y1-y2));
y3+=weight*(_3-y3); _3=(y4+=weight*(y3-y4));
_4=(u+=uvweight*(_4-u));
_5=(v+=uvweight*(_5-v));
";

weight>.00001 ? (
  extrasz=min((log(0.5)/log(weight) + 2),w/4)&0xfffc; // phase adjustment size
  
  // copy to expanded work buffer (to fix phase)
  gfx_dest = rotWs2 = gfx_img_resize(rotWs2,w+extrasz,h); 
  gfx_blit(in,0,0,0,w,h,0,0,w,h);
  gfx_fillrect(w,0,extrasz,h);
  
  // convolve in x
  eval_w = w+extrasz;
  gfx_evalrect(0,0,w+extrasz,h, code);
  
  // rotate to expanded vertical work buffer 
  gfx_dest = rotWs1 = gfx_img_resize(rotWs1,h+extrasz,w);
  gfx_deltablit(rotWs2,0,0,h,w, extrasz*.5,0, 0,1,1,0,0,0);
  gfx_fillrect(h,0,extrasz,w);
  
  // convolve in y (now x)
  eval_w = h+extrasz;
  gfx_evalrect(0,0,h+extrasz,w, code);
  
  // rotate back to output framebuffer
  gfx_dest = -1;
  gfx_deltablit(rotWs1,0,0,w,h,extrasz*.5,0, 0,1,1,0,0,0);
 
) : gfx_blit(in);
Mind if I add this as a preset?

(edit: bugfixed and simplified a little -- there are some artifacts on the left edge, though, hm).

Last edited by Justin; 11-15-2018 at 08:06 AM.
Justin is offline   Reply With Quote