[vlc-devel] [PATCH] Some Corrections
noxelia at gmail.com
noxelia at gmail.com
Tue Aug 19 16:32:55 CEST 2008
From: basOS G <noxelia 4t gmail . com>
---
modules/video_filter/beep.c | 2 +-
modules/video_filter/static_detect.c | 68 +++++++++++++++++++---------------
2 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/modules/video_filter/beep.c b/modules/video_filter/beep.c
index fd469a4..6d2d5bc 100644
--- a/modules/video_filter/beep.c
+++ b/modules/video_filter/beep.c
@@ -127,7 +127,7 @@ int play_beep( float freq, int length)
if ( !length ) length = DEFAULT_LENGTH;
if ( freqi > 32767 || freqi < 37 )
return -10;
- if ( Beep( freqi, length ) ) // error occured
+ if ( Beep( freqi, length ) ) /* error occured */
return -11;
return 0;
}
diff --git a/modules/video_filter/static_detect.c b/modules/video_filter/static_detect.c
index 30c0054..5815772 100644
--- a/modules/video_filter/static_detect.c
+++ b/modules/video_filter/static_detect.c
@@ -2,7 +2,6 @@
* motion_blur.c : static detect filter for VLC
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
- * $Id$
*
* Authors: basOS G <noxelia 4t gmai1 , c0m>
* based on the work of Antoine Cellerier for motion detect VLC VFilter
@@ -32,15 +31,14 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
-/*#include <vlc_sout.h>*/
#include <vlc_vout.h>
#include <vlc_filter.h>
#include "filter_picture.h"
#include "beep.h"
#include <assert.h>
-//#include <vlc/vlc.h>
-//#include <vlc/libvlc_internal.h>
-
+/*#include <vlc/vlc.h>
+#include <vlc/libvlc_internal.h>
+*/
/*****************************************************************************
* Help Data Types
@@ -51,7 +49,7 @@
typedef uint16_t diff_t;
typedef void ( *findDiffs_t )( diff_t*, picture_t*, picture_t*, filter_t * );
typedef void ( *motionMeter_t )( float , float , picture_t* , filter_t* );
-//typedef void ( *markPicture_t )( diff_t*, picture_t*, diff_t , filter_t * p_filter );
+/*typedef void ( *markPicture_t )( diff_t*, picture_t*, diff_t , filter_t * p_filter );*/
/*****************************************************************************
* Local protypes
@@ -59,6 +57,7 @@ typedef void ( *motionMeter_t )( float , float , picture_t* , filter_t* );
static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static picture_t *Filter ( filter_t *, picture_t * );
+
/*****************************************************************************
** Some Predefined Protos
*****************************************************************************/
@@ -73,9 +72,9 @@ void motionMeterPacked( float f_motion, float f_threshold, picture_t* p_out_pic,
/*void markPicture( diff_t* p_diff, picture_t* p_out_pic, diff_t , filter_t * p_filter );
void markPicturePacked( diff_t* p_diff, picture_t* p_out_pic, diff_t , filter_t * p_filter ); */
-//TODO :static int StaticDetectCallback( vlc_object_t *, char const *,
-// vlc_value_t, vlc_value_t, void * );
-
+/*TODO :static int StaticDetectCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+*/
/*****************************************************************************
* Module descriptor
@@ -89,6 +88,7 @@ void markPicturePacked( diff_t* p_diff, picture_t* p_out_pic, diff_t , filter_t
#define FREEZE_TEXT N_("Snapshot Freeze Time (mseconds)")
#define FREEZE_LONGTEXT N_("How long should the snapped image stay freezed on the video. Use 0 to disable")
#define MOTIONM_TEXT N_("Display Motion meter")
+#define BEEP_TEXT N_("Beep When Static Detected")
#define FILTER_PREFIX "staticdetect-"
#define PAR_MTHRESHOLD "tolerance"
@@ -96,6 +96,7 @@ void markPicturePacked( diff_t* p_diff, picture_t* p_out_pic, diff_t , filter_t
#define PAR_DTHRESHOLD "sensivity"
#define PAR_FREEZETIME "freezetime"
#define PAR_MMETER "motionmeter"
+#define PAR_BEEP "beep"
/* default difference threshold */
#define DEFAULT_DIFF_THRESHOLD 9
@@ -107,7 +108,8 @@ void markPicturePacked( diff_t* p_diff, picture_t* p_out_pic, diff_t , filter_t
#define DEFAULT_MMETER true
/* time the station mark should be presented (in msecs)*/
#define DEFAULT_FREEZE_TIME 1200
-
+/* default beep status */
+#define DEFAULT_BEEP true
vlc_module_begin();
set_shortname( N_("Static Image Detector") );
@@ -116,29 +118,31 @@ vlc_module_begin();
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
- //TOCHECK : WHAT IS advc (last parameter of add integer ) @ vlc_plugin.h
add_float_with_range( FILTER_PREFIX PAR_MTHRESHOLD, DEFAULT_PIX_COUNT_THRESHOLD, 1, 100, NULL,
MTHRESHOLD_TEXT, MTHRESHOLD_LONGTEXT, false );
add_integer ( FILTER_PREFIX PAR_TTHRESHOLD, DEFAULT_TIME_THRESHOLD, NULL,
TTHRESHOLD_TEXT, TTHRESHOLD_LONGTEXT, false );
add_integer ( FILTER_PREFIX PAR_FREEZETIME, DEFAULT_FREEZE_TIME, NULL,
- FREEZE_TEXT, FREEZE_LONGTEXT, false );
+ FREEZE_TEXT, FREEZE_LONGTEXT, true );
add_integer_with_range ( FILTER_PREFIX PAR_DTHRESHOLD, DEFAULT_DIFF_THRESHOLD, 0, 768, NULL,
DTHRESHOLD_TEXT, DTHRESHOLD_LONGTEXT, false );
add_bool ( FILTER_PREFIX PAR_MMETER, DEFAULT_MMETER, NULL,
MOTIONM_TEXT, NULL, false );
+ add_bool ( FILTER_PREFIX PAR_BEEP, DEFAULT_BEEP, NULL,
+ BEEP_TEXT, NULL, true );
add_shortcut( "static" );
set_callbacks( Create, Destroy );
vlc_module_end();
-//TOCHECK : WHAT is this for?? It parses command line args without it
+/*TOCHECK : WHAT is this for?? It parses command line args without it*/
static const char *const psz_filter_options[] = {
PAR_MTHRESHOLD,
PAR_TTHRESHOLD,
PAR_DTHRESHOLD,
PAR_FREEZETIME,
PAR_MMETER,
+ PAR_BEEP,
NULL
};
@@ -148,21 +152,26 @@ static const char *const psz_filter_options[] = {
*****************************************************************************/
struct filter_sys_t
{
+ findDiffs_t pf_findDiffs ; /* findPixelDiffs: are we on a packed YCbCr data format? see www.fourcc.org */
+ /*markPicture_t pf_markPicture;*/ /* mark Pixel Diffs */
+ motionMeter_t pf_motionMeter; /* Draw a nice motion meter */
+
float f_pix_count_thres_percent ; /* motion threshold % pixels of an image */
int i_frame_thres ; /* time threshold of stationary image at msecs */
diff_t i_pix_diff_thres ;/* Difference of 2 pixels to mark it as changed */
bool b_is_snaped ; /* Is the picture snaped */
int i_static_frames ; /* # of static frames */
- findDiffs_t pf_findDiffs ; /* findPixelDiffs: are we on a packed YCbCr data format? see www.fourcc.org */
- //markPicture_t pf_markPicture; /* mark Pixel Diffs */
- motionMeter_t pf_motionMeter; /* Draw a nice motion meter */
+ bool b_beep ; /* Should we beep ? */
+
picture_t* p_old_pic; /*previous frame */
bool b_has_old_pic;
diff_t* p_diff; /*difference frame */
+
picture_t* p_freeze_pic; /*difference frame for marking video output */
int i_freeze_frames; /* # of frames used for marking */
int i_freeze_counter; /* # of frames left to dispay the current differencies*/
+
/* various motion stats */
float f_motion_min;
float f_motion_max;
@@ -256,9 +265,9 @@ static int Create( vlc_object_t *p_this )
var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX PAR_DTHRESHOLD );
bool b_meter = var_CreateGetBoolCommand( p_filter, FILTER_PREFIX PAR_MMETER );
if ( !b_meter) pf_motionMeter = NULL;
+ p_sys->b_beep = var_CreateGetBoolCommand( p_filter, FILTER_PREFIX PAR_BEEP );
-
- //TODO : Check for callback meaning. Do we need it ?
+ /*TODO : Check for callback meaning. Do we need it ?*/
/*var_AddCallback( p_filter, FILTER_PREFIX "factor",
MotionBlurCallback, p_filter->p_sys );
*/
@@ -382,9 +391,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_in_pic )
if ( ( p_sys->i_freeze_counter = p_sys->i_freeze_frames ) )
picture_Copy( p_sys->p_freeze_pic, p_in_pic );
vout_Snapshot( (vout_thread_t*) p_filter->p_owner, p_in_pic );
- //vout_Control( (vout_thread_t*) p_filter->p_owner, VOUT_SNAPSHOT );
- if ( (ec = play_beep ( 0, 0)) ) //play a default beep sound on the speaker
- msg_Warn( p_filter, "Error [%d] while Beeping",ec );
+ /*vout_Control( (vout_thread_t*) p_filter->p_owner, VOUT_SNAPSHOT );*/
+ if ( p_sys->b_beep )
+ if ( (ec = play_beep ( 0, 0)) ) //play a default beep sound on the speaker
+ msg_Warn( p_filter, "Error [%d] while Beeping",ec );
p_sys->b_is_snaped = true;
}
#if 0
@@ -415,7 +425,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_in_pic )
if (p_sys->pf_motionMeter)
( p_sys->pf_motionMeter)( f_motion, p_sys->f_pix_count_thres_percent, p_out_pic, p_filter );
#endif
- /**
+ /*
* We're done. Lets keep a copy of the picture
* TODO we may just picture_Release with a latency of 1 if the filters/vout
* handle it correctly */
@@ -517,7 +527,7 @@ void motionMeterPacked( float f_motion, float f_threshold, picture_t* p_out_pic,
for( x = i_bar_x1; x <= i_bar_x2; x+=2 )
{
for( y = i_bar_y1; y < i_bar_y2; y++ )
- // 1 macropixel = 4 bytes = 2 image pixels. For we proccess 2 image pixels per itteration
+ /* 1 macropixel = 4 bytes = 2 image pixels. For we proccess 2 image pixels per itteration*/
{
int i;
for ( i = 0; i < 2; i++)
@@ -533,7 +543,7 @@ void motionMeterPacked( float f_motion, float f_threshold, picture_t* p_out_pic,
}
}
-/*
+#if 0
void markPicture( diff_t* p_diff, picture_t* p_out_pic, diff_t i_motion_thres, filter_t * p_filter )
{
const video_frame_format_t *p_fmt = &p_out_pic->format;
@@ -592,7 +602,7 @@ void markPicturePacked( diff_t* p_diff, picture_t* p_out_pic,diff_t i_motion_thr
}
}
-*/
+#endif
float countMovedPixelsPercent( diff_t* p_diff, picture_t* p_ref_pic, diff_t i_motion_threshold )
{
@@ -627,7 +637,7 @@ void findDiffs (diff_t* p_diff, picture_t* p_new_pic, picture_t* p_old_pic, filt
const uint8_t *p_old_pix = p_old_pic->p[Y_PLANE].p_pixels;
const int i_old_pitch = p_old_pic->p[Y_PLANE].i_pitch;
- //msg_Dbg( p_filter, "In findDiffs" );
+
/**
* Substract Y planes
*/
@@ -641,7 +651,7 @@ void findDiffs (diff_t* p_diff, picture_t* p_new_pic, picture_t* p_old_pic, filt
int i_chroma_dx;
int i_chroma_dy;
switch( p_new_pic->format.i_chroma )
- /* NOTE: We check here with picture->format.i_chrome and we initialized with p_filter->fmt_in.video.i_chroma */
+ /* NOTE: We check here with picture->format.i_chrome and we initialized with p_filter->fmt_in.video.i_chroma */
{
case VLC_FOURCC('I','4','2','0'):
case VLC_FOURCC('I','Y','U','V'):
@@ -711,13 +721,11 @@ void findDiffsPacked (diff_t* p_diff, picture_t* p_new_pic, picture_t* p_old_pic
const int i_old_pitch = p_old_pic->p[Y_PLANE].i_pitch;
int i_y_offset, i_u_offset, i_v_offset;
-
unsigned x, y;
- //msg_Dbg( p_filter, "In findDiffsPacked" );
+
if( GetPackedYuvOffsets( p_fmt->i_chroma,
&i_y_offset, &i_u_offset, &i_v_offset ) != VLC_SUCCESS )
{
- //FIX: Is it ok to hang to the p_new_pic ??
msg_Warn( p_filter, "Unsupported input chroma (%4s)",
(char*)&p_fmt->i_chroma );
return ;
--
1.5.4.3
More information about the vlc-devel
mailing list