[vlc-devel] [PATCH] Added some more error checking, fixed close function, and fixed some comments
Odd-Arild Kristensen
oddarildkristensen at gmail.com
Tue Feb 2 17:01:08 CET 2016
---
modules/video_filter/edgedetection.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/modules/video_filter/edgedetection.c b/modules/video_filter/edgedetection.c
index dce0064..c13070a 100644
--- a/modules/video_filter/edgedetection.c
+++ b/modules/video_filter/edgedetection.c
@@ -86,12 +86,14 @@ struct filter_sys_t
/*****************************************************************************
* Opens the filter.
- * Sets up the filer chain. The image needs to be black-and-white in order to
- * detect any edges. The Gaussian blur is needed so that the Sobel operator
- * does not give a high response for noise, or small changes in the image.
+ * Allocates and initializes data needed by the filter. The image needs to
+ * be black-and-white in order to detect any edges. The Gaussian blur is
+ * needed so that the Sobel operator does not give a high response for noise,
+ * or small changes in the image.
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
+ int ret;
es_format_t fmt;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
@@ -120,11 +122,21 @@ static int Open( vlc_object_t *p_this )
/* Clear filter chain */
filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &fmt);
/* Add adjust filter to turn frame black-and-white */
- filter_chain_AppendFromString( p_sys->p_chain, "adjust{saturation=0}" );
- /* Add gaussian blur to the frame so to remove some noise in the frame,
- which reduces the number 'random' of lines being enhanced. */
- filter_chain_AppendFromString( p_sys->p_chain, "gaussianblur{deviation=1}" );
- // fmt = *filter_chain_GetFmtOut( p_filter->p_sys->p_chain );
+ ret = filter_chain_AppendFromString( p_sys->p_chain, "adjust{saturation=0}" );
+ if ( ret == -1 )
+ {
+ msg_Err( p_filter, "Could not append filter to filter chain" );
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
+ /* Add gaussian blur to the frame so to remove noise from the frame */
+ ret = filter_chain_AppendFromString( p_sys->p_chain, "gaussianblur{deviation=1}" );
+ if ( ret == -1 )
+ {
+ msg_Err( p_filter, "Could not append filter to filter chain" );
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
/* Set callback function */
p_filter->pf_video_filter = Filter;
return VLC_SUCCESS;
@@ -136,6 +148,7 @@ static int Open( vlc_object_t *p_this )
static int Close( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
+ filter_chain_Delete( p_filter->p_sys->p_chain );
free( p_filter->p_sys );
return VLC_SUCCESS;
}
@@ -190,7 +203,7 @@ static int sobel( uint8_t const *p_pixels, const int i_pitch, const int i_lines,
{
int i_x_val = 0;
int i_y_val = 0;
- /* Check for frame boundry */
+ /* Check for frame boundary */
if ( i_line == 0 || i_line == i_lines )
{
i_y_val = 0;
--
2.2.0
More information about the vlc-devel
mailing list