From f241dafe5c55c02d81f153de2a59e0a83d12d1c9 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Thu, 4 Aug 2011 13:33:20 +0200 Subject: [PATCH] motioncells: turn two global vars into static variables Move 2 variable to motioncells_warpper and make them static. --- ext/opencv/gstmotioncells.c | 6 +----- ext/opencv/motioncells_wrapper.cpp | 8 +++++--- ext/opencv/motioncells_wrapper.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ext/opencv/gstmotioncells.c b/ext/opencv/gstmotioncells.c index a349bcac1d..71b41c350a 100644 --- a/ext/opencv/gstmotioncells.c +++ b/ext/opencv/gstmotioncells.c @@ -105,9 +105,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_motion_cells_debug); POINTER = NULL;\ } -int instanceCounter = 0; -gboolean element_id_was_max = false; - /* Filter signals and args */ enum { @@ -396,8 +393,7 @@ gst_motion_cells_init (GstMotioncells * filter, GstMotioncellsClass * gclass) filter->datafileidx = 0; g_mutex_lock (filter->propset_mutex); - filter->id = instanceCounter; - motion_cells_init (); + filter->id = motion_cells_init (); g_mutex_unlock (filter->propset_mutex); } diff --git a/ext/opencv/motioncells_wrapper.cpp b/ext/opencv/motioncells_wrapper.cpp index b768f9ece9..d509686774 100644 --- a/ext/opencv/motioncells_wrapper.cpp +++ b/ext/opencv/motioncells_wrapper.cpp @@ -46,12 +46,13 @@ #include #include "motioncells_wrapper.h" -extern int instanceCounter; -extern bool element_id_was_max; +static int instanceCounter = 0; +static gboolean element_id_was_max = false; + MotionCells *mc; char p_str[] = "idx failed"; -void +int motion_cells_init () { mc = new MotionCells (); @@ -67,6 +68,7 @@ motion_cells_init () instanceCounter = motioncellsfreeids.back (); motioncellsfreeids.pop_back (); } + return tmpmc.id; } int diff --git a/ext/opencv/motioncells_wrapper.h b/ext/opencv/motioncells_wrapper.h index 0feaafa8bd..470bcfbe42 100644 --- a/ext/opencv/motioncells_wrapper.h +++ b/ext/opencv/motioncells_wrapper.h @@ -62,7 +62,7 @@ extern "C" { #endif - void motion_cells_init (); + int motion_cells_init (); int perform_detection_motion_cells (IplImage * p_image, double p_sensitivity, double p_framerate, int p_gridx, int p_gridy, long int p_timestamp_millisec, bool p_isVisible, bool p_useAlpha,