/*****************************************************************************
* gaussianblur.c : gaussian blur video filter
*****************************************************************************
- * Copyright (C) 2000-2007 the VideoLAN team
+ * Copyright (C) 2000-2007 VLC authors and VideoLAN
* $Id$
*
* Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_memory.h>
-#include "vlc_filter.h"
+#include <vlc_filter.h>
#include "filter_picture.h"
#include <math.h> /* exp(), sqrt() */
#define SIGMA_TEXT N_("Gaussian's std deviation")
#define SIGMA_LONGTEXT N_( \
- "Gaussian's standard deviation. The bluring will take " \
+ "Gaussian's standard deviation. The blurring will take " \
"into account pixels up to 3*sigma away in any direction.")
+#define GAUSSIAN_HELP N_("Add a blurring effect")
+
#define FILTER_PREFIX "gaussianblur-"
vlc_module_begin ()
set_description( N_("Gaussian blur video filter") )
set_shortname( N_( "Gaussian Blur" ))
+ set_help(GAUSSIAN_HELP)
set_capability( "video filter2", 0 )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
- add_float( FILTER_PREFIX "sigma", 2., NULL, SIGMA_TEXT, SIGMA_LONGTEXT,
+ add_float( FILTER_PREFIX "sigma", 2., SIGMA_TEXT, SIGMA_LONGTEXT,
false )
set_callbacks( Create, Destroy )
{
double f_sigma = p_sys->f_sigma;
int i_dim = (int)(3.*f_sigma);
- type_t *pt_distribution = malloc( (2*i_dim+1) * sizeof( type_t ) );
+ type_t *pt_distribution = xmalloc( (2*i_dim+1) * sizeof( type_t ) );
int x;
for( x = -i_dim; x <= i_dim; x++ )
)
{
/* We only want planar YUV 4:2:0 or 4:2:2 */
- msg_Err( p_filter, "Unsupported input chroma (%4s)",
+ msg_Err( p_filter, "Unsupported input chroma (%4.4s)",
(char*)&(p_filter->fmt_in.video.i_chroma) );
return VLC_EGENERIC;
}
}
if( !p_sys->pt_buffer )
{
- p_sys->pt_buffer = realloc( p_sys->pt_buffer,
- p_pic->p[Y_PLANE].i_visible_lines *
- p_pic->p[Y_PLANE].i_pitch *
- sizeof( type_t ) );
+ p_sys->pt_buffer = realloc_or_free( p_sys->pt_buffer,
+ p_pic->p[Y_PLANE].i_visible_lines *
+ p_pic->p[Y_PLANE].i_pitch * sizeof( type_t ) );
}
pt_buffer = p_sys->pt_buffer;
const int i_pitch = p_pic->p[Y_PLANE].i_pitch;
int i_col, i_line;
- p_sys->pt_scale = malloc( i_visible_lines * i_pitch * sizeof( type_t ) );
+ p_sys->pt_scale = xmalloc( i_visible_lines * i_pitch * sizeof( type_t ) );
pt_scale = p_sys->pt_scale;
for( i_line = 0 ; i_line < i_visible_lines ; i_line++ )
const int i_visible_lines = p_pic->p[i_plane].i_visible_lines;
const int i_visible_pitch = p_pic->p[i_plane].i_visible_pitch;
- const int i_pitch = p_pic->p[i_plane].i_pitch;
+ const int i_in_pitch = p_pic->p[i_plane].i_pitch;
int i_line, i_col;
const int x_factor = p_pic->p[Y_PLANE].i_visible_pitch/i_visible_pitch-1;
{
type_t t_value = 0;
int x;
- const int c = i_line*i_pitch+i_col;
+ const int c = i_line*i_in_pitch+i_col;
for( x = __MAX( -i_dim, -i_col*(x_factor+1) );
x <= __MIN( i_dim, (i_visible_pitch - i_col)*(x_factor+1) + 1 );
x++ )
{
type_t t_value = 0;
int y;
- const int c = i_line*i_pitch+i_col;
+ const int c = i_line*i_in_pitch+i_col;
for( y = __MAX( -i_dim, (-i_line)*(y_factor+1) );
y <= __MIN( i_dim, (i_visible_lines - i_line)*(y_factor+1) - 1 );
y++ )
{
t_value += pt_distribution[y+i_dim] *
- pt_buffer[c+(y>>y_factor)*i_pitch];
+ pt_buffer[c+(y>>y_factor)*i_in_pitch];
}
- const type_t t_scale = pt_scale[(i_line<<y_factor)*(i_pitch<<x_factor)+(i_col<<x_factor)];
- p_out[c] = (uint8_t)(t_value / t_scale); // FIXME wouldn't it be better to round instead of trunc ?
+ const type_t t_scale = pt_scale[(i_line<<y_factor)*(i_in_pitch<<x_factor)+(i_col<<x_factor)];
+ p_out[i_line * p_outpic->p[i_plane].i_pitch + i_col] = (uint8_t)(t_value / t_scale); // FIXME wouldn't it be better to round instead of trunc ?
}
}
}