summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-06-28 09:36:20 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-06-28 09:36:20 +0000
commit0c5153fbc977d988e675790b352bc504af94d57f (patch)
tree4ccea4250c6be31280b99ac4581abec84a496756
parentd66b7e9f26de94b3cff5fe361c62b88185f241ad (diff)
downloadgst-plugins-bad-0c5153fbc977d988e675790b352bc504af94d57f.tar.gz
gst-plugins-bad-0c5153fbc977d988e675790b352bc504af94d57f.tar.bz2
gst-plugins-bad-0c5153fbc977d988e675790b352bc504af94d57f.zip
gst/videosignal/gstvideodetect.*: Add property to adjust the center, sensitivity is now the distance from this center.
Original commit message from CVS: * gst/videosignal/gstvideodetect.c: (gst_video_detect_420), (gst_video_detect_set_property), (gst_video_detect_get_property): * gst/videosignal/gstvideodetect.h: Add property to adjust the center, sensitivity is now the distance from this center.
-rw-r--r--ChangeLog8
-rw-r--r--gst/videosignal/gstvideodetect.c26
-rw-r--r--gst/videosignal/gstvideodetect.h1
3 files changed, 28 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index bd31a338..083494b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-28 Wim Taymans <wim@fluendo.com>
+
+ * gst/videosignal/gstvideodetect.c: (gst_video_detect_420),
+ (gst_video_detect_set_property), (gst_video_detect_get_property):
+ * gst/videosignal/gstvideodetect.h:
+ Add property to adjust the center, sensitivity is now the distance from
+ this center.
+
2007-06-27 Wim Taymans <wim@fluendo.com>
* gst/videosignal/gstvideodetect.c: (gst_video_detect_420),
diff --git a/gst/videosignal/gstvideodetect.c b/gst/videosignal/gstvideodetect.c
index e26e1561..2e8b0d37 100644
--- a/gst/videosignal/gstvideodetect.c
+++ b/gst/videosignal/gstvideodetect.c
@@ -120,7 +120,8 @@
#define DEFAULT_PATTERN_HEIGHT 16
#define DEFAULT_PATTERN_COUNT 4
#define DEFAULT_PATTERN_DATA_COUNT 5
-#define DEFAULT_PATTERN_SENSITIVITY 0.2
+#define DEFAULT_PATTERN_CENTER 0.5
+#define DEFAULT_PATTERN_SENSITIVITY 0.3
#define DEFAULT_LEFT_OFFSET 0
#define DEFAULT_BOTTOM_OFFSET 0
@@ -132,6 +133,7 @@ enum
PROP_PATTERN_HEIGHT,
PROP_PATTERN_COUNT,
PROP_PATTERN_DATA_COUNT,
+ PROP_PATTERN_CENTER,
PROP_PATTERN_SENSITIVITY,
PROP_LEFT_OFFSET,
PROP_BOTTOM_OFFSET
@@ -273,12 +275,16 @@ gst_video_detect_420 (GstVideoDetect * videodetect, GstBuffer * buffer)
GST_DEBUG_OBJECT (videodetect, "brightness %f", brightness);
if (i & 1) {
- /* odd pixels must be white */
- if (brightness < (1.0 - videodetect->pattern_sensitivity))
+ /* odd pixels must be white, all pixels darker than the center +
+ * sensitivity are considered wrong. */
+ if (brightness <
+ (videodetect->pattern_center + videodetect->pattern_sensitivity))
goto no_pattern;
} else {
- /* even pixels must be black */
- if (brightness > videodetect->pattern_sensitivity)
+ /* even pixels must be black, pixels lighter than the center - sensitivity
+ * are considered wrong. */
+ if (brightness >
+ (videodetect->pattern_center - videodetect->pattern_sensitivity))
goto no_pattern;
}
}
@@ -300,9 +306,9 @@ gst_video_detect_420 (GstVideoDetect * videodetect, GstBuffer * buffer)
/* calc brightness of width * height box */
brightness =
gst_video_detect_calc_brightness (videodetect, d, pw, ph, stride);
- /* update pattern */
+ /* update pattern, we just use the center to decide between black and white. */
pattern_data <<= 1;
- if (brightness > 0.5)
+ if (brightness > videodetect->pattern_center)
pattern_data |= 1;
}
@@ -361,6 +367,9 @@ gst_video_detect_set_property (GObject * object, guint prop_id,
case PROP_PATTERN_DATA_COUNT:
videodetect->pattern_data_count = g_value_get_int (value);
break;
+ case PROP_PATTERN_CENTER:
+ videodetect->pattern_center = g_value_get_double (value);
+ break;
case PROP_PATTERN_SENSITIVITY:
videodetect->pattern_sensitivity = g_value_get_double (value);
break;
@@ -400,6 +409,9 @@ gst_video_detect_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_PATTERN_DATA_COUNT:
g_value_set_int (value, videodetect->pattern_data_count);
break;
+ case PROP_PATTERN_CENTER:
+ g_value_set_double (value, videodetect->pattern_center);
+ break;
case PROP_PATTERN_SENSITIVITY:
g_value_set_double (value, videodetect->pattern_sensitivity);
break;
diff --git a/gst/videosignal/gstvideodetect.h b/gst/videosignal/gstvideodetect.h
index 99912a28..0c39f328 100644
--- a/gst/videosignal/gstvideodetect.h
+++ b/gst/videosignal/gstvideodetect.h
@@ -54,6 +54,7 @@ struct _GstVideoDetect {
gint pattern_height;
gint pattern_count;
gint pattern_data_count;
+ gdouble pattern_center;
gdouble pattern_sensitivity;
gint left_offset;
gint bottom_offset;