+void BoxBlur::init_packages()
+{
+ int u = 0;
+ for( int i=0,n=LoadServer::get_total_packages(); i<n; ) {
+ BoxBlurPackage *pkg = (BoxBlurPackage*)get_package(i);
+ pkg->u1 = u;
+ pkg->u2 = u = (++i * ulen) / n;
+ }
+}
+
+//dst can equal src, requires geom(dst)==geom(src)
+//uv: 0=hblur, 1=vblur; comp: -1=rgb,0=r,1=g,2=b
+void BoxBlur::process(VFrame *dst, VFrame *src, int uv,
+ int radius, int power, int comp)
+{
+ this->radius = radius;
+ this->power = power;
+ int src_w = src->get_w(), src_h = src->get_h();
+ ulen = !uv ? src_h : src_w;
+ vlen = !uv ? src_w : src_h;
+ c0 = comp<0 ? 0 : comp;
+ c1 = comp<0 ? 2 : comp;
+ src_data = src->get_data();
+ dst_data = dst->get_data();
+ int src_pixsz = BC_CModels::calculate_pixelsize(src->get_color_model());
+ int src_comps = BC_CModels::components(src->get_color_model());
+ int src_bpp = src_pixsz / src_comps;
+ int dst_pixsz = BC_CModels::calculate_pixelsize(dst->get_color_model());
+ int dst_comps = BC_CModels::components(dst->get_color_model());
+ int dst_bpp = dst_pixsz / dst_comps;
+ int dst_linsz = dst->get_bytes_per_line() / dst_bpp;
+ int src_linsz = src->get_bytes_per_line() / src_bpp;
+ src_ustep = !uv ? src_linsz : src_comps;
+ dst_ustep = !uv ? dst_linsz: dst_comps;
+ src_vstep = !uv ? src_comps : src_linsz;
+ dst_vstep = !uv ? dst_comps : dst_linsz;
+
+ process_packages();
+}
+
+void BoxBlur::hblur(VFrame *dst, VFrame *src, int radius, int power, int comp)
+{
+ process(dst, src, 0, radius, power, comp);
+}
+void BoxBlur::vblur(VFrame *dst, VFrame *src, int radius, int power, int comp)
+{
+ process(dst, src, 1, radius, power, comp);
+}
+void BoxBlur::blur(VFrame *dst, VFrame *src, int radius, int power, int comp)
+{
+ process(dst, src, 0, radius, power, comp);
+ process(dst, dst, 1, radius, power, comp);
+}