[vlc-devel] [RFA] sharpen filter improvement
Jérémy DEMEULE
DJ_Mulder at djduron.no-ip.org
Tue May 29 00:10:55 CEST 2007
Hi,
First, thanks to the vlc team for their work. The recent nightly seems to
be more and more stable.
Now I can test the sharpen filter I've coded more intensively :-).
So, I've found some simple but really efficient improvement (about 20-25%).
The idea is to avoid maximum computation with a pre calculus table and
don't use os/x86 features.
Index: modules/video_filter/sharpen.c
===================================================================
--- modules/video_filter/sharpen.c (revision 20107)
+++ modules/video_filter/sharpen.c (working copy)
@@ -84,6 +84,7 @@
struct filter_sys_t
{
float f_sigma;
+ int tab_precalc[512];
};
/*****************************************************************************
@@ -94,6 +95,16 @@
return (a > 255) ? 255 : (a < 0) ? 0 : a;
}
+static void init_precalc_table(filter_sys_t *p_filter)
+{
+ float sigma = p_filter->f_sigma;
+
+ for(int i = 0; i < 512; ++i)
+ {
+ p_filter->tab_precalc[i] = (i - 256) * sigma;
+ }
+}
+
/*****************************************************************************
* Create: allocates Sharpen video thread output method
*****************************************************************************
@@ -121,6 +132,8 @@
var_AddCallback( p_filter, FILTER_PREFIX "sigma",
SharpenCallback, p_filter->p_sys );
+ init_precalc_table(p_filter->p_sys);
+
return VLC_SUCCESS;
}
@@ -207,8 +220,9 @@
(p_src[(i + 1) * i_src_pitch + j ] * v1) +
(p_src[(i + 1) * i_src_pitch + j + 1] * v1);
- p_out[i * i_src_pitch + j] = clip( p_src[i * i_src_pitch + j] +
- (p_filter->p_sys->f_sigma * pix) );
+ pix = pix >= 0 ? clip(pix) : -clip(pix * -1);
+ p_out[i * i_src_pitch + j] = clip( p_src[i * i_src_pitch + j] +
+ p_filter->p_sys->tab_precalc[pix + 256] );
}
}
@@ -241,5 +255,6 @@
filter_sys_t *p_sys = (filter_sys_t *)p_data;
if( !strcmp( psz_var, FILTER_PREFIX "sigma" ) )
p_sys->f_sigma = __MIN( 2., __MAX( 0., newval.f_float ) );
+ init_precalc_table(p_sys);
return VLC_SUCCESS;
}
--
Jérémy DEMEULE - EPITA SIGL Promotion 2005
Mail: dj_mulder at djduron.no-ip.org
--
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
More information about the vlc-devel
mailing list