mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-10 08:22:32 +00:00
zbar: Make scanner cache optional
This commit is contained in:
parent
5433fd062b
commit
18c3302608
2 changed files with 23 additions and 5 deletions
|
@ -102,6 +102,7 @@ enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_MESSAGE,
|
PROP_MESSAGE,
|
||||||
|
PROP_CACHE,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_PROP_ZBAR 1
|
#define DEFAULT_PROP_ZBAR 1
|
||||||
|
@ -170,6 +171,11 @@ gst_zbar_class_init (GstZBarClass * g_class)
|
||||||
"Post a barcode message for each detected code",
|
"Post a barcode message for each detected code",
|
||||||
TRUE, G_PARAM_READWRITE));
|
TRUE, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_CACHE,
|
||||||
|
g_param_spec_boolean ("cache", "cache",
|
||||||
|
"Enable or disable the inter-image result cache",
|
||||||
|
TRUE, G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY));
|
||||||
|
|
||||||
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_zbar_set_caps);
|
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_zbar_set_caps);
|
||||||
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_zbar_transform_ip);
|
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_zbar_transform_ip);
|
||||||
trans_class->start = GST_DEBUG_FUNCPTR (gst_zbar_start);
|
trans_class->start = GST_DEBUG_FUNCPTR (gst_zbar_start);
|
||||||
|
@ -179,6 +185,7 @@ gst_zbar_class_init (GstZBarClass * g_class)
|
||||||
static void
|
static void
|
||||||
gst_zbar_init (GstZBar * zbar, GstZBarClass * g_class)
|
gst_zbar_init (GstZBar * zbar, GstZBarClass * g_class)
|
||||||
{
|
{
|
||||||
|
zbar->cache = TRUE;
|
||||||
zbar->message = TRUE;
|
zbar->message = TRUE;
|
||||||
|
|
||||||
zbar->scanner = zbar_image_scanner_create ();
|
zbar->scanner = zbar_image_scanner_create ();
|
||||||
|
@ -204,6 +211,9 @@ gst_zbar_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
zbar = GST_ZBAR (object);
|
zbar = GST_ZBAR (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_CACHE:
|
||||||
|
zbar->cache = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
case PROP_MESSAGE:
|
case PROP_MESSAGE:
|
||||||
zbar->message = g_value_get_boolean (value);
|
zbar->message = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
@ -223,6 +233,9 @@ gst_zbar_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
zbar = GST_ZBAR (object);
|
zbar = GST_ZBAR (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_CACHE:
|
||||||
|
g_value_set_boolean (value, zbar->cache);
|
||||||
|
break;
|
||||||
case PROP_MESSAGE:
|
case PROP_MESSAGE:
|
||||||
g_value_set_boolean (value, zbar->message);
|
g_value_set_boolean (value, zbar->message);
|
||||||
break;
|
break;
|
||||||
|
@ -274,6 +287,8 @@ gst_zbar_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
||||||
|
|
||||||
/* scan the image for barcodes */
|
/* scan the image for barcodes */
|
||||||
n = zbar_scan_image (zbar->scanner, image);
|
n = zbar_scan_image (zbar->scanner, image);
|
||||||
|
if (n == 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
/* extract results */
|
/* extract results */
|
||||||
symbol = zbar_image_first_symbol (image);
|
symbol = zbar_image_first_symbol (image);
|
||||||
|
@ -285,7 +300,7 @@ gst_zbar_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
||||||
GST_DEBUG_OBJECT (zbar, "decoded %s symbol \"%s\" at quality %d",
|
GST_DEBUG_OBJECT (zbar, "decoded %s symbol \"%s\" at quality %d",
|
||||||
zbar_get_symbol_name (typ), data, quality);
|
zbar_get_symbol_name (typ), data, quality);
|
||||||
|
|
||||||
if (zbar_symbol_get_count (symbol) != 0)
|
if (zbar->cache && zbar_symbol_get_count (symbol) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (zbar->message) {
|
if (zbar->message) {
|
||||||
|
@ -302,7 +317,9 @@ gst_zbar_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
zbar_image_scanner_recycle_image (zbar->scanner, image);
|
||||||
zbar_image_destroy (image);
|
zbar_image_destroy (image);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -316,8 +333,8 @@ gst_zbar_start (GstBaseTransform * base)
|
||||||
{
|
{
|
||||||
GstZBar *zbar = GST_ZBAR (base);
|
GstZBar *zbar = GST_ZBAR (base);
|
||||||
|
|
||||||
/* start the cache (e.g. for filtering dupes) */
|
/* start the cache if enabled (e.g. for filtering dupes) */
|
||||||
zbar_image_scanner_enable_cache (zbar->scanner, TRUE);
|
zbar_image_scanner_enable_cache (zbar->scanner, zbar->cache);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -327,8 +344,8 @@ gst_zbar_stop (GstBaseTransform * base)
|
||||||
{
|
{
|
||||||
GstZBar *zbar = GST_ZBAR (base);
|
GstZBar *zbar = GST_ZBAR (base);
|
||||||
|
|
||||||
/* stop the cache (e.g. for filtering dupes) */
|
/* stop the cache if enabled (e.g. for filtering dupes) */
|
||||||
zbar_image_scanner_enable_cache (zbar->scanner, FALSE);
|
zbar_image_scanner_enable_cache (zbar->scanner, zbar->cache);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ struct _GstZBar
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
gboolean message;
|
gboolean message;
|
||||||
|
gboolean cache;
|
||||||
|
|
||||||
/* internals */
|
/* internals */
|
||||||
zbar_image_scanner_t *scanner;
|
zbar_image_scanner_t *scanner;
|
||||||
|
|
Loading…
Reference in a new issue