summaryrefslogtreecommitdiffstats
path: root/gst/videosignal/gstvideodetect.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/videosignal/gstvideodetect.c')
-rw-r--r--gst/videosignal/gstvideodetect.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/gst/videosignal/gstvideodetect.c b/gst/videosignal/gstvideodetect.c
index 54d0dd77..e26e1561 100644
--- a/gst/videosignal/gstvideodetect.c
+++ b/gst/videosignal/gstvideodetect.c
@@ -121,6 +121,8 @@
#define DEFAULT_PATTERN_COUNT 4
#define DEFAULT_PATTERN_DATA_COUNT 5
#define DEFAULT_PATTERN_SENSITIVITY 0.2
+#define DEFAULT_LEFT_OFFSET 0
+#define DEFAULT_BOTTOM_OFFSET 0
enum
{
@@ -130,7 +132,9 @@ enum
PROP_PATTERN_HEIGHT,
PROP_PATTERN_COUNT,
PROP_PATTERN_DATA_COUNT,
- PROP_PATTERN_SENSITIVITY
+ PROP_PATTERN_SENSITIVITY,
+ PROP_LEFT_OFFSET,
+ PROP_BOTTOM_OFFSET
};
GST_DEBUG_CATEGORY_STATIC (video_detect_debug);
@@ -256,8 +260,9 @@ gst_video_detect_420 (GstVideoDetect * videodetect, GstBuffer * buffer)
/* analyse the bottom left pixels */
for (i = 0; i < videodetect->pattern_count; i++) {
d = data;
- /* move to start of bottom left */
- d += stride * (height - ph);
+ /* move to start of bottom left, adjust for offsets */
+ d += stride * (height - ph - videodetect->bottom_offset) +
+ videodetect->left_offset;
/* move to i-th pattern */
d += pw * i;
@@ -284,8 +289,11 @@ gst_video_detect_420 (GstVideoDetect * videodetect, GstBuffer * buffer)
/* get the data of the pattern */
for (i = 0; i < videodetect->pattern_data_count; i++) {
d = data;
- /* move to start of bottom left, after the pattern */
- d += stride * (height - ph) + (videodetect->pattern_count * pw);
+ /* move to start of bottom left, adjust for offsets */
+ d += stride * (height - ph - videodetect->bottom_offset) +
+ videodetect->left_offset;
+ /* move after the fixed pattern */
+ d += (videodetect->pattern_count * pw);
/* move to i-th pattern data */
d += pw * i;
@@ -356,6 +364,12 @@ gst_video_detect_set_property (GObject * object, guint prop_id,
case PROP_PATTERN_SENSITIVITY:
videodetect->pattern_sensitivity = g_value_get_double (value);
break;
+ case PROP_LEFT_OFFSET:
+ videodetect->left_offset = g_value_get_int (value);
+ break;
+ case PROP_BOTTOM_OFFSET:
+ videodetect->bottom_offset = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -389,6 +403,12 @@ gst_video_detect_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_PATTERN_SENSITIVITY:
g_value_set_double (value, videodetect->pattern_sensitivity);
break;
+ case PROP_LEFT_OFFSET:
+ g_value_set_int (value, videodetect->left_offset);
+ break;
+ case PROP_BOTTOM_OFFSET:
+ g_value_set_int (value, videodetect->bottom_offset);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -447,6 +467,16 @@ gst_video_detect_class_init (gpointer klass, gpointer class_data)
"The sensitivity for detecting the markers (0.0 = highest, 0.5 lowest)",
0.0, 0.5, DEFAULT_PATTERN_SENSITIVITY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (gobject_class, PROP_LEFT_OFFSET,
+ g_param_spec_int ("left-offset", "Left Offset",
+ "The offset from the left border where the pattern starts", 0,
+ G_MAXINT, DEFAULT_LEFT_OFFSET,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (gobject_class, PROP_BOTTOM_OFFSET,
+ g_param_spec_int ("bottom-offset", "Bottom Offset",
+ "The offset from the bottom border where the pattern starts", 0,
+ G_MAXINT, DEFAULT_BOTTOM_OFFSET,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_detect_set_caps);
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_video_detect_transform_ip);