mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
debugutils: port to 0.11
This commit is contained in:
parent
260e2e7427
commit
bc0dd274ee
7 changed files with 206 additions and 181 deletions
|
@ -315,7 +315,7 @@ dnl Non ported plugins (non-dependant, then dependant)
|
|||
dnl Make sure you have a space before and after all plugins
|
||||
GST_PLUGINS_NONPORTED=" aiff asfmux \
|
||||
camerabin cdxaparse coloreffects \
|
||||
dccp debugutils faceoverlay festival \
|
||||
dccp faceoverlay festival \
|
||||
fieldanalysis freeverb freeze frei0r gaudieffects geometrictransform h264parse \
|
||||
hdvparse hls id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
||||
kate liveadder legacyresample librfb mpegtsmux \
|
||||
|
|
|
@ -16,8 +16,8 @@ plugin_LTLIBRARIES = libgstdebugutilsbad.la
|
|||
|
||||
libgstdebugutilsbad_la_SOURCES = \
|
||||
gstdebugspy.c \
|
||||
fpsdisplaysink.c \
|
||||
debugutilsbad.c \
|
||||
fpsdisplaysink.c \
|
||||
gstchecksumsink.c \
|
||||
gstchecksumsink.h \
|
||||
gstchopmydata.c \
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
|
||||
#include "debugutils-marshal.h"
|
||||
#include "fpsdisplaysink.h"
|
||||
#include <gst/interfaces/xoverlay.h>
|
||||
|
||||
#define DEFAULT_SIGNAL_FPS_MEASUREMENTS FALSE
|
||||
#define DEFAULT_FPS_UPDATE_INTERVAL_MS 500 /* 500 ms */
|
||||
|
@ -214,10 +213,11 @@ fps_display_sink_class_init (GstFPSDisplaySinkClass * klass)
|
|||
"Zeeshan Ali <zeeshan.ali@nokia.com>, Stefan Kost <stefan.kost@nokia.com>");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
||||
static GstPadProbeReturn
|
||||
on_video_sink_data_flow (GstPad * pad, GstPadProbeInfo * info,
|
||||
gpointer user_data)
|
||||
{
|
||||
GstMiniObject *mini_obj = GST_PAD_PROBE_INFO_DATA (info);
|
||||
GstFPSDisplaySink *self = GST_FPS_DISPLAY_SINK (user_data);
|
||||
|
||||
#if 0
|
||||
|
@ -246,7 +246,7 @@ on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
|||
GstClockTimeDiff diff;
|
||||
GstClockTime ts;
|
||||
|
||||
gst_event_parse_qos (ev, NULL, &diff, &ts);
|
||||
gst_event_parse_qos (ev, NULL, NULL, &diff, &ts);
|
||||
if (diff <= 0.0) {
|
||||
g_atomic_int_inc (&self->frames_rendered);
|
||||
} else {
|
||||
|
@ -263,7 +263,7 @@ on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
|||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -278,6 +278,14 @@ update_sub_sync (GstElement * sink, gpointer data)
|
|||
GST_WARNING ("Internal sink doesn't have sync property");
|
||||
}
|
||||
|
||||
static void
|
||||
update_sub_sync_foreach (const GValue * item, gpointer data)
|
||||
{
|
||||
GstElement *sink = g_value_get_object (item);
|
||||
|
||||
update_sub_sync (sink, data);
|
||||
}
|
||||
|
||||
static void
|
||||
fps_display_sink_update_sink_sync (GstFPSDisplaySink * self)
|
||||
{
|
||||
|
@ -288,7 +296,8 @@ fps_display_sink_update_sink_sync (GstFPSDisplaySink * self)
|
|||
|
||||
if (GST_IS_BIN (self->video_sink)) {
|
||||
iterator = gst_bin_iterate_sinks (GST_BIN (self->video_sink));
|
||||
gst_iterator_foreach (iterator, (GFunc) update_sub_sync,
|
||||
gst_iterator_foreach (iterator,
|
||||
(GstIteratorForeachFunction) update_sub_sync_foreach,
|
||||
(void *) &self->sync);
|
||||
gst_iterator_free (iterator);
|
||||
} else
|
||||
|
@ -305,7 +314,7 @@ update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
|
|||
|
||||
/* remove pad probe */
|
||||
sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
|
||||
gst_pad_remove_data_probe (sink_pad, self->data_probe_id);
|
||||
gst_pad_remove_probe (sink_pad, self->data_probe_id);
|
||||
gst_object_unref (sink_pad);
|
||||
self->data_probe_id = -1;
|
||||
|
||||
|
@ -332,8 +341,9 @@ update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
|
|||
|
||||
/* attach or pad probe */
|
||||
sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
|
||||
self->data_probe_id = gst_pad_add_data_probe (sink_pad,
|
||||
G_CALLBACK (on_video_sink_data_flow), (gpointer) self);
|
||||
self->data_probe_id = gst_pad_add_probe (sink_pad,
|
||||
GST_PAD_PROBE_TYPE_DATA_BOTH, on_video_sink_data_flow,
|
||||
(gpointer) self, NULL);
|
||||
gst_object_unref (sink_pad);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,13 +47,21 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
|||
|
||||
/* class initialization */
|
||||
|
||||
GST_BOILERPLATE (GstChecksumSink, gst_checksum_sink, GstBaseSink,
|
||||
GST_TYPE_BASE_SINK);
|
||||
#define gst_checksum_sink_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstChecksumSink, gst_checksum_sink, GST_TYPE_BASE_SINK);
|
||||
|
||||
static void
|
||||
gst_checksum_sink_base_init (gpointer g_class)
|
||||
gst_checksum_sink_class_init (GstChecksumSinkClass * klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = gst_checksum_sink_dispose;
|
||||
gobject_class->finalize = gst_checksum_sink_finalize;
|
||||
base_sink_class->start = GST_DEBUG_FUNCPTR (gst_checksum_sink_start);
|
||||
base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_checksum_sink_stop);
|
||||
base_sink_class->render = GST_DEBUG_FUNCPTR (gst_checksum_sink_render);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_checksum_sink_src_template));
|
||||
|
@ -66,21 +74,7 @@ gst_checksum_sink_base_init (gpointer g_class)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_checksum_sink_class_init (GstChecksumSinkClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = gst_checksum_sink_dispose;
|
||||
gobject_class->finalize = gst_checksum_sink_finalize;
|
||||
base_sink_class->start = GST_DEBUG_FUNCPTR (gst_checksum_sink_start);
|
||||
base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_checksum_sink_stop);
|
||||
base_sink_class->render = GST_DEBUG_FUNCPTR (gst_checksum_sink_render);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_checksum_sink_init (GstChecksumSink * checksumsink,
|
||||
GstChecksumSinkClass * checksumsink_class)
|
||||
gst_checksum_sink_init (GstChecksumSink * checksumsink)
|
||||
{
|
||||
gst_base_sink_set_sync (GST_BASE_SINK (checksumsink), FALSE);
|
||||
}
|
||||
|
@ -113,9 +107,11 @@ static GstFlowReturn
|
|||
gst_checksum_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||
{
|
||||
gchar *s;
|
||||
GstMapInfo map;
|
||||
|
||||
s = g_compute_checksum_for_data (G_CHECKSUM_SHA1, GST_BUFFER_DATA (buffer),
|
||||
GST_BUFFER_SIZE (buffer));
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
s = g_compute_checksum_for_data (G_CHECKSUM_SHA1, map.data, map.size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
g_print ("%" GST_TIME_FORMAT " %s\n",
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), s);
|
||||
|
||||
|
|
|
@ -59,9 +59,12 @@ static void gst_chop_my_data_get_property (GObject * object,
|
|||
static GstStateChangeReturn
|
||||
gst_chop_my_data_change_state (GstElement * element, GstStateChange transition);
|
||||
|
||||
static GstFlowReturn gst_chop_my_data_chain (GstPad * pad, GstBuffer * buffer);
|
||||
static gboolean gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_chop_my_data_src_event (GstPad * pad, GstEvent * event);
|
||||
static GstFlowReturn gst_chop_my_data_chain (GstPad * pad, GstObject * parent,
|
||||
GstBuffer * buffer);
|
||||
static gboolean gst_chop_my_data_sink_event (GstPad * pad, GstObject * parent,
|
||||
GstEvent * event);
|
||||
static gboolean gst_chop_my_data_src_event (GstPad * pad, GstObject * parent,
|
||||
GstEvent * event);
|
||||
|
||||
#define DEFAULT_MAX_SIZE 4096
|
||||
#define DEFAULT_MIN_SIZE 1
|
||||
|
@ -91,21 +94,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
|||
|
||||
/* class initialization */
|
||||
|
||||
GST_BOILERPLATE (GstChopMyData, gst_chop_my_data, GstElement, GST_TYPE_ELEMENT);
|
||||
|
||||
static void
|
||||
gst_chop_my_data_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_chop_my_data_src_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_chop_my_data_sink_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "FIXME",
|
||||
"Generic", "FIXME", "David Schleef <ds@schleef.org>");
|
||||
}
|
||||
#define gst_chop_my_data_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstChopMyData, gst_chop_my_data, GST_TYPE_ELEMENT);
|
||||
|
||||
static void
|
||||
gst_chop_my_data_class_init (GstChopMyDataClass * klass)
|
||||
|
@ -130,11 +120,18 @@ gst_chop_my_data_class_init (GstChopMyDataClass * klass)
|
|||
g_param_spec_int ("step-size", "step-size",
|
||||
"Step increment for random buffer sizes", 1, G_MAXINT,
|
||||
DEFAULT_MAX_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_chop_my_data_src_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_chop_my_data_sink_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "FIXME",
|
||||
"Generic", "FIXME", "David Schleef <ds@schleef.org>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_chop_my_data_init (GstChopMyData * chopmydata,
|
||||
GstChopMyDataClass * chopmydata_class)
|
||||
gst_chop_my_data_init (GstChopMyData * chopmydata)
|
||||
{
|
||||
|
||||
chopmydata->sinkpad =
|
||||
|
@ -144,16 +141,14 @@ gst_chop_my_data_init (GstChopMyData * chopmydata,
|
|||
GST_DEBUG_FUNCPTR (gst_chop_my_data_sink_event));
|
||||
gst_pad_set_chain_function (chopmydata->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_chop_my_data_chain));
|
||||
gst_pad_set_getcaps_function (chopmydata->sinkpad, gst_pad_proxy_getcaps);
|
||||
gst_pad_set_setcaps_function (chopmydata->sinkpad, gst_pad_proxy_setcaps);
|
||||
GST_PAD_SET_PROXY_CAPS (chopmydata->sinkpad);
|
||||
gst_element_add_pad (GST_ELEMENT (chopmydata), chopmydata->sinkpad);
|
||||
|
||||
chopmydata->srcpad =
|
||||
gst_pad_new_from_static_template (&gst_chop_my_data_src_template, "src");
|
||||
gst_pad_set_event_function (chopmydata->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_chop_my_data_src_event));
|
||||
gst_pad_set_getcaps_function (chopmydata->srcpad, gst_pad_proxy_getcaps);
|
||||
gst_pad_set_setcaps_function (chopmydata->srcpad, gst_pad_proxy_setcaps);
|
||||
GST_PAD_SET_PROXY_CAPS (chopmydata->srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (chopmydata), chopmydata->srcpad);
|
||||
|
||||
chopmydata->step_size = DEFAULT_STEP_SIZE;
|
||||
|
@ -315,29 +310,28 @@ gst_chop_my_data_process (GstChopMyData * chopmydata, gboolean flush)
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_chop_my_data_chain (GstPad * pad, GstBuffer * buffer)
|
||||
gst_chop_my_data_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
GstChopMyData *chopmydata;
|
||||
GstFlowReturn ret;
|
||||
|
||||
chopmydata = GST_CHOP_MY_DATA (gst_pad_get_parent (pad));
|
||||
chopmydata = GST_CHOP_MY_DATA (parent);
|
||||
|
||||
GST_DEBUG_OBJECT (chopmydata, "chain");
|
||||
|
||||
gst_adapter_push (chopmydata->adapter, buffer);
|
||||
ret = gst_chop_my_data_process (chopmydata, FALSE);
|
||||
|
||||
gst_object_unref (chopmydata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event)
|
||||
gst_chop_my_data_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||
{
|
||||
gboolean res;
|
||||
GstChopMyData *chopmydata;
|
||||
|
||||
chopmydata = GST_CHOP_MY_DATA (gst_pad_get_parent (pad));
|
||||
chopmydata = GST_CHOP_MY_DATA (parent);
|
||||
|
||||
GST_DEBUG_OBJECT (chopmydata, "event");
|
||||
|
||||
|
@ -349,7 +343,7 @@ gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event)
|
|||
gst_adapter_clear (chopmydata->adapter);
|
||||
res = gst_pad_push_event (chopmydata->srcpad, event);
|
||||
break;
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
case GST_EVENT_SEGMENT:
|
||||
res = gst_pad_push_event (chopmydata->srcpad, event);
|
||||
break;
|
||||
case GST_EVENT_EOS:
|
||||
|
@ -361,17 +355,16 @@ gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event)
|
|||
break;
|
||||
}
|
||||
|
||||
gst_object_unref (chopmydata);
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_chop_my_data_src_event (GstPad * pad, GstEvent * event)
|
||||
gst_chop_my_data_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||
{
|
||||
gboolean res;
|
||||
GstChopMyData *chopmydata;
|
||||
|
||||
chopmydata = GST_CHOP_MY_DATA (gst_pad_get_parent (pad));
|
||||
chopmydata = GST_CHOP_MY_DATA (parent);
|
||||
|
||||
GST_DEBUG_OBJECT (chopmydata, "event");
|
||||
|
||||
|
@ -384,6 +377,5 @@ gst_chop_my_data_src_event (GstPad * pad, GstEvent * event)
|
|||
break;
|
||||
}
|
||||
|
||||
gst_object_unref (chopmydata);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -108,31 +108,16 @@ static void gst_compare_get_property (GObject * object,
|
|||
|
||||
static void gst_compare_reset (GstCompare * overlay);
|
||||
|
||||
static GstCaps *gst_compare_getcaps (GstPad * pad);
|
||||
static gboolean gst_compare_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query);
|
||||
static GstFlowReturn gst_compare_collect_pads (GstCollectPads2 * cpads,
|
||||
GstCompare * comp);
|
||||
|
||||
static GstStateChangeReturn gst_compare_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
GST_BOILERPLATE (GstCompare, gst_compare, GstElement, GST_TYPE_ELEMENT);
|
||||
|
||||
|
||||
static void
|
||||
gst_compare_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_factory));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&check_sink_factory));
|
||||
gst_element_class_set_details_simple (element_class, "Compare buffers",
|
||||
"Filter/Debug", "Compares incoming buffers",
|
||||
"Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
|
||||
}
|
||||
#define gst_compare_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstCompare, gst_compare, GST_TYPE_ELEMENT);
|
||||
|
||||
static void
|
||||
gst_compare_finalize (GObject * object)
|
||||
|
@ -184,10 +169,20 @@ gst_compare_class_init (GstCompareClass * klass)
|
|||
g_param_spec_boolean ("upper", "Threshold Upper Bound",
|
||||
"Whether threshold value is upper bound or lower bound for difference measure",
|
||||
DEFAULT_UPPER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&sink_factory));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&check_sink_factory));
|
||||
gst_element_class_set_details_simple (gstelement_class, "Compare buffers",
|
||||
"Filter/Debug", "Compares incoming buffers",
|
||||
"Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_compare_init (GstCompare * comp, GstCompareClass * klass)
|
||||
gst_compare_init (GstCompare * comp)
|
||||
{
|
||||
comp->cpads = gst_collect_pads2_new ();
|
||||
gst_collect_pads2_set_function (comp->cpads,
|
||||
|
@ -195,12 +190,12 @@ gst_compare_init (GstCompare * comp, GstCompareClass * klass)
|
|||
comp);
|
||||
|
||||
comp->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
|
||||
gst_pad_set_getcaps_function (comp->sinkpad, gst_compare_getcaps);
|
||||
GST_PAD_SET_PROXY_CAPS (comp->sinkpad);
|
||||
gst_element_add_pad (GST_ELEMENT (comp), comp->sinkpad);
|
||||
|
||||
comp->checkpad =
|
||||
gst_pad_new_from_static_template (&check_sink_factory, "check");
|
||||
gst_pad_set_getcaps_function (comp->checkpad, gst_compare_getcaps);
|
||||
gst_pad_set_query_function (comp->checkpad, gst_compare_query);
|
||||
gst_element_add_pad (GST_ELEMENT (comp), comp->checkpad);
|
||||
|
||||
gst_collect_pads2_add_pad_full (comp->cpads, comp->sinkpad,
|
||||
|
@ -209,7 +204,7 @@ gst_compare_init (GstCompare * comp, GstCompareClass * klass)
|
|||
sizeof (GstCollectData2), NULL, TRUE);
|
||||
|
||||
comp->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
|
||||
gst_pad_set_getcaps_function (comp->srcpad, gst_compare_getcaps);
|
||||
gst_pad_set_query_function (comp->srcpad, gst_compare_query);
|
||||
gst_element_add_pad (GST_ELEMENT (comp), comp->srcpad);
|
||||
|
||||
/* init properties */
|
||||
|
@ -227,29 +222,21 @@ gst_compare_reset (GstCompare * comp)
|
|||
{
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_compare_getcaps (GstPad * pad)
|
||||
static gboolean
|
||||
gst_compare_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
GstCompare *comp;
|
||||
GstPad *otherpad;
|
||||
GstCaps *result;
|
||||
|
||||
comp = GST_COMPARE (gst_pad_get_parent (pad));
|
||||
if (G_UNLIKELY (comp == NULL))
|
||||
return gst_caps_new_any ();
|
||||
|
||||
comp = GST_COMPARE (parent);
|
||||
otherpad = (pad == comp->srcpad ? comp->sinkpad : comp->srcpad);
|
||||
result = gst_pad_peer_get_caps (otherpad);
|
||||
if (result == NULL)
|
||||
result = gst_caps_new_any ();
|
||||
|
||||
gst_object_unref (comp);
|
||||
|
||||
return result;
|
||||
return gst_pad_peer_query (otherpad, query);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||
gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||
GstBuffer * buf2, GstCaps * caps2)
|
||||
{
|
||||
gint flags = 0;
|
||||
|
||||
|
@ -290,14 +277,16 @@ gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
|||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
/* FIXME ?? */
|
||||
if (comp->meta & GST_BUFFER_COPY_CAPS) {
|
||||
if (!gst_caps_is_equal (GST_BUFFER_CAPS (buf1), GST_BUFFER_CAPS (buf2))) {
|
||||
if (!gst_caps_is_equal (caps1, caps2)) {
|
||||
flags |= GST_BUFFER_COPY_CAPS;
|
||||
GST_DEBUG_OBJECT (comp,
|
||||
"caps %" GST_PTR_FORMAT " != caps %" GST_PTR_FORMAT,
|
||||
GST_BUFFER_CAPS (buf1), GST_BUFFER_CAPS (buf2));
|
||||
"caps %" GST_PTR_FORMAT " != caps %" GST_PTR_FORMAT, caps1, caps2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* signal mismatch by debug and message */
|
||||
if (flags) {
|
||||
|
@ -313,23 +302,39 @@ gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
|||
/* when comparing contents, it is already ensured sizes are equal */
|
||||
|
||||
static gint
|
||||
gst_compare_mem (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||
gst_compare_mem (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||
GstBuffer * buf2, GstCaps * caps2)
|
||||
{
|
||||
return memcmp (GST_BUFFER_DATA (buf1), GST_BUFFER_DATA (buf2),
|
||||
GST_BUFFER_SIZE (buf1)) ? 1 : 0;
|
||||
GstMapInfo map1, map2;
|
||||
gint c;
|
||||
|
||||
gst_buffer_map (buf1, &map1, GST_MAP_READ);
|
||||
gst_buffer_map (buf2, &map2, GST_MAP_READ);
|
||||
|
||||
c = memcmp (map1.data, map2.data, map1.size);
|
||||
|
||||
gst_buffer_unmap (buf1, &map1);
|
||||
gst_buffer_unmap (buf2, &map2);
|
||||
|
||||
return c ? 1 : 0;
|
||||
}
|
||||
|
||||
static gint
|
||||
gst_compare_max (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||
gst_compare_max (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||
GstBuffer * buf2, GstCaps * caps2)
|
||||
{
|
||||
gint i, delta = 0;
|
||||
gint8 *data1, *data2;
|
||||
GstMapInfo map1, map2;
|
||||
|
||||
data1 = (gint8 *) GST_BUFFER_DATA (buf1);
|
||||
data2 = (gint8 *) GST_BUFFER_DATA (buf2);
|
||||
gst_buffer_map (buf1, &map1, GST_MAP_READ);
|
||||
gst_buffer_map (buf2, &map2, GST_MAP_READ);
|
||||
|
||||
data1 = (gint8 *) map1.data;
|
||||
data2 = (gint8 *) map2.data;
|
||||
|
||||
/* primitive loop */
|
||||
for (i = 0; i < GST_BUFFER_SIZE (buf1); i++) {
|
||||
for (i = 0; i < map1.size; i++) {
|
||||
gint diff = ABS (*data1 - *data2);
|
||||
if (diff > 0)
|
||||
GST_LOG_OBJECT (comp, "diff at %d = %d", i, diff);
|
||||
|
@ -338,6 +343,9 @@ gst_compare_max (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
|||
data2++;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf1, &map1);
|
||||
gst_buffer_unmap (buf2, &map2);
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
|
@ -410,65 +418,66 @@ gst_compare_ssim_component (GstCompare * comp, guint8 * data1, guint8 * data2,
|
|||
}
|
||||
|
||||
static gdouble
|
||||
gst_compare_ssim (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||
gst_compare_ssim (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||
GstBuffer * buf2, GstCaps * caps2)
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstVideoFormat format, f;
|
||||
gint width, height, w, h, i, comps;
|
||||
GstVideoInfo info1, info2;
|
||||
GstVideoFrame frame1, frame2;
|
||||
gint i, comps;
|
||||
gdouble cssim[4], ssim, c[4] = { 1.0, 0.0, 0.0, 0.0 };
|
||||
guint8 *data1, *data2;
|
||||
|
||||
caps = GST_BUFFER_CAPS (buf1);
|
||||
if (!caps)
|
||||
if (!caps1)
|
||||
goto invalid_input;
|
||||
|
||||
if (!gst_video_format_parse_caps (caps, &format, &width, &height))
|
||||
if (!gst_video_info_from_caps (&info1, caps1))
|
||||
goto invalid_input;
|
||||
|
||||
caps = GST_BUFFER_CAPS (buf2);
|
||||
if (!caps)
|
||||
if (!caps2)
|
||||
goto invalid_input;
|
||||
|
||||
if (!gst_video_format_parse_caps (caps, &f, &w, &h))
|
||||
if (!gst_video_info_from_caps (&info2, caps1))
|
||||
goto invalid_input;
|
||||
|
||||
if (f != format || w != width || h != height)
|
||||
if (GST_VIDEO_INFO_FORMAT (&info1) != GST_VIDEO_INFO_FORMAT (&info2) ||
|
||||
GST_VIDEO_INFO_WIDTH (&info1) != GST_VIDEO_INFO_WIDTH (&info2) ||
|
||||
GST_VIDEO_INFO_HEIGHT (&info1) != GST_VIDEO_INFO_HEIGHT (&info2))
|
||||
return comp->threshold + 1;
|
||||
|
||||
comps = gst_video_format_is_gray (format) ? 1 : 3;
|
||||
if (gst_video_format_has_alpha (format))
|
||||
comps += 1;
|
||||
|
||||
comps = GST_VIDEO_INFO_N_COMPONENTS (&info1);
|
||||
/* note that some are reported both yuv and gray */
|
||||
for (i = 0; i < comps; ++i)
|
||||
c[i] = 1.0;
|
||||
/* increase luma weight if yuv */
|
||||
if (gst_video_format_is_yuv (format) && (comps > 1))
|
||||
if (GST_VIDEO_INFO_IS_YUV (&info1) && (comps > 1))
|
||||
c[0] = comps - 1;
|
||||
for (i = 0; i < comps; ++i)
|
||||
c[i] /= (gst_video_format_is_yuv (format) && (comps > 1)) ?
|
||||
c[i] /= (GST_VIDEO_INFO_IS_YUV (&info1) && (comps > 1)) ?
|
||||
2 * (comps - 1) : comps;
|
||||
|
||||
data1 = GST_BUFFER_DATA (buf1);
|
||||
data2 = GST_BUFFER_DATA (buf2);
|
||||
gst_video_frame_map (&frame1, &info1, buf1, GST_MAP_READ);
|
||||
gst_video_frame_map (&frame2, &info2, buf2, GST_MAP_READ);
|
||||
|
||||
for (i = 0; i < comps; i++) {
|
||||
gint offset, cw, ch, step, stride;
|
||||
gint cw, ch, step, stride;
|
||||
|
||||
/* only support most common formats */
|
||||
if (gst_video_format_get_component_depth (format, i) != 8)
|
||||
if (GST_VIDEO_INFO_COMP_DEPTH (&info1, i) != 8)
|
||||
goto unsupported_input;
|
||||
offset = gst_video_format_get_component_offset (format, i, width, height);
|
||||
cw = gst_video_format_get_component_width (format, i, width);
|
||||
ch = gst_video_format_get_component_height (format, i, height);
|
||||
step = gst_video_format_get_pixel_stride (format, i);
|
||||
stride = gst_video_format_get_row_stride (format, i, width);
|
||||
cw = GST_VIDEO_FRAME_COMP_WIDTH (&frame1, i);
|
||||
ch = GST_VIDEO_FRAME_COMP_HEIGHT (&frame1, i);
|
||||
step = GST_VIDEO_FRAME_COMP_PSTRIDE (&frame1, i);
|
||||
stride = GST_VIDEO_FRAME_COMP_STRIDE (&frame1, i);
|
||||
|
||||
GST_LOG_OBJECT (comp, "component %d", i);
|
||||
cssim[i] = gst_compare_ssim_component (comp, data1 + offset, data2 + offset,
|
||||
cw, ch, step, stride);
|
||||
cssim[i] = gst_compare_ssim_component (comp,
|
||||
GST_VIDEO_FRAME_COMP_DATA (&frame1, i),
|
||||
GST_VIDEO_FRAME_COMP_DATA (&frame2, i), cw, ch, step, stride);
|
||||
GST_LOG_OBJECT (comp, "ssim[%d] = %f", i, cssim[i]);
|
||||
}
|
||||
|
||||
gst_video_frame_unmap (&frame1);
|
||||
gst_video_frame_unmap (&frame2);
|
||||
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
for (i = 0; i < 4; i++) {
|
||||
GST_DEBUG_OBJECT (comp, "ssim[%d] = %f, c[%d] = %f", i, cssim[i], i, c[i]);
|
||||
|
@ -488,37 +497,46 @@ invalid_input:
|
|||
unsupported_input:
|
||||
{
|
||||
GST_ERROR_OBJECT (comp, "raw video format not supported %" GST_PTR_FORMAT,
|
||||
caps);
|
||||
caps1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_compare_buffers (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||
gst_compare_buffers (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||
GstBuffer * buf2, GstCaps * caps2)
|
||||
{
|
||||
gdouble delta = 0;
|
||||
gsize size1, size2;
|
||||
|
||||
/* first check metadata */
|
||||
gst_compare_meta (comp, buf1, buf2);
|
||||
gst_compare_meta (comp, buf1, caps1, buf2, caps2);
|
||||
|
||||
size1 = gst_buffer_get_size (buf1);
|
||||
size2 = gst_buffer_get_size (buf1);
|
||||
|
||||
/* check content according to method */
|
||||
/* but at least size should match */
|
||||
if (GST_BUFFER_SIZE (buf1) != GST_BUFFER_SIZE (buf2)) {
|
||||
if (size1 != size2) {
|
||||
delta = comp->threshold + 1;
|
||||
} else {
|
||||
GST_MEMDUMP_OBJECT (comp, "buffer 1", GST_BUFFER_DATA (buf1),
|
||||
GST_BUFFER_SIZE (buf1));
|
||||
GST_MEMDUMP_OBJECT (comp, "buffer 2", GST_BUFFER_DATA (buf2),
|
||||
GST_BUFFER_SIZE (buf2));
|
||||
GstMapInfo map1, map2;
|
||||
|
||||
gst_buffer_map (buf1, &map1, GST_MAP_READ);
|
||||
gst_buffer_map (buf2, &map2, GST_MAP_READ);
|
||||
GST_MEMDUMP_OBJECT (comp, "buffer 1", map1.data, map2.size);
|
||||
GST_MEMDUMP_OBJECT (comp, "buffer 2", map2.data, map2.size);
|
||||
gst_buffer_unmap (buf1, &map1);
|
||||
gst_buffer_unmap (buf2, &map2);
|
||||
switch (comp->method) {
|
||||
case GST_COMPARE_METHOD_MEM:
|
||||
delta = gst_compare_mem (comp, buf1, buf2);
|
||||
delta = gst_compare_mem (comp, buf1, caps1, buf2, caps2);
|
||||
break;
|
||||
case GST_COMPARE_METHOD_MAX:
|
||||
delta = gst_compare_max (comp, buf1, buf2);
|
||||
delta = gst_compare_max (comp, buf1, caps1, buf2, caps2);
|
||||
break;
|
||||
case GST_COMPARE_METHOD_SSIM:
|
||||
delta = gst_compare_ssim (comp, buf1, buf2);
|
||||
delta = gst_compare_ssim (comp, buf1, caps1, buf2, caps2);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -542,18 +560,21 @@ static GstFlowReturn
|
|||
gst_compare_collect_pads (GstCollectPads2 * cpads, GstCompare * comp)
|
||||
{
|
||||
GstBuffer *buf1, *buf2;
|
||||
GstCaps *caps1, *caps2;
|
||||
|
||||
buf1 = gst_collect_pads2_pop (comp->cpads,
|
||||
gst_pad_get_element_private (comp->sinkpad));
|
||||
caps1 = gst_pad_get_current_caps (comp->sinkpad);
|
||||
|
||||
buf2 = gst_collect_pads2_pop (comp->cpads,
|
||||
gst_pad_get_element_private (comp->checkpad));
|
||||
caps2 = gst_pad_get_current_caps (comp->checkpad);
|
||||
|
||||
if (!buf1 && !buf2) {
|
||||
gst_pad_push_event (comp->srcpad, gst_event_new_eos ());
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_EOS;
|
||||
} else if (buf1 && buf2) {
|
||||
gst_compare_buffers (comp, buf1, buf2);
|
||||
gst_compare_buffers (comp, buf1, caps1, buf2, caps2);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (comp, "buffer %p != NULL", buf1 ? buf1 : buf2);
|
||||
|
||||
|
@ -570,6 +591,12 @@ gst_compare_collect_pads (GstCollectPads2 * cpads, GstCompare * comp)
|
|||
if (buf2)
|
||||
gst_buffer_unref (buf2);
|
||||
|
||||
if (caps1)
|
||||
gst_caps_unref (caps1);
|
||||
|
||||
if (caps2)
|
||||
gst_caps_unref (caps2);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,8 +95,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_STATIC_CAPS ("ANY")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (GstDebugSpy, gst_debug_spy, GstBaseTransform,
|
||||
GST_TYPE_BASE_TRANSFORM);
|
||||
G_DEFINE_TYPE (GstDebugSpy, gst_debug_spy, GST_TYPE_BASE_TRANSFORM);
|
||||
|
||||
static void gst_debug_spy_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
|
@ -107,33 +106,16 @@ static GstFlowReturn gst_debug_spy_transform_ip (GstBaseTransform * transform,
|
|||
|
||||
/* GObject vmethod implementations */
|
||||
|
||||
static void
|
||||
gst_debug_spy_base_init (gpointer gclass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_debug_spy_debug, "debugspy", 0, "debugspy");
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"DebugSpy",
|
||||
"Filter/Analyzer/Debug",
|
||||
"DebugSpy provides information on buffers with bus messages",
|
||||
"Guillaume Emont <gemont@igalia.com>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_factory));
|
||||
}
|
||||
|
||||
/* initialize the debugspy's class */
|
||||
static void
|
||||
gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *element_class;
|
||||
GstBaseTransformClass *base_transform_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
element_class = (GstElementClass *) klass;
|
||||
base_transform_class = (GstBaseTransformClass *) klass;
|
||||
|
||||
gobject_class->set_property = gst_debug_spy_set_property;
|
||||
|
@ -151,6 +133,18 @@ gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
|||
"Checksum algorithm to use", GST_DEBUG_SPY_CHECKSUM_TYPE,
|
||||
G_CHECKSUM_SHA1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"DebugSpy",
|
||||
"Filter/Analyzer/Debug",
|
||||
"DebugSpy provides information on buffers with bus messages",
|
||||
"Guillaume Emont <gemont@igalia.com>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_factory));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_debug_spy_debug, "debugspy", 0, "debugspy");
|
||||
}
|
||||
|
||||
/* initialize the new element
|
||||
|
@ -159,7 +153,7 @@ gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
|||
* initialize instance structure
|
||||
*/
|
||||
static void
|
||||
gst_debug_spy_init (GstDebugSpy * debugspy, GstDebugSpyClass * gclass)
|
||||
gst_debug_spy_init (GstDebugSpy * debugspy)
|
||||
{
|
||||
debugspy->silent = FALSE;
|
||||
debugspy->checksum_type = G_CHECKSUM_SHA1;
|
||||
|
@ -214,20 +208,26 @@ gst_debug_spy_transform_ip (GstBaseTransform * transform, GstBuffer * buf)
|
|||
gchar *checksum;
|
||||
GstMessage *message;
|
||||
GstStructure *message_structure;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
checksum = g_compute_checksum_for_data (debugspy->checksum_type,
|
||||
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
map.data, map.size);
|
||||
|
||||
caps = gst_pad_get_current_caps (GST_BASE_TRANSFORM_SRC_PAD (transform));
|
||||
message_structure = gst_structure_new ("buffer",
|
||||
"checksum", G_TYPE_STRING, checksum,
|
||||
"timestamp", GST_TYPE_CLOCK_TIME, GST_BUFFER_TIMESTAMP (buf),
|
||||
"duration", GST_TYPE_CLOCK_TIME, GST_BUFFER_DURATION (buf),
|
||||
"offset", G_TYPE_UINT64, GST_BUFFER_OFFSET (buf),
|
||||
"offset_end", G_TYPE_UINT64, GST_BUFFER_OFFSET_END (buf),
|
||||
"size", G_TYPE_UINT, GST_BUFFER_SIZE (buf),
|
||||
"caps", GST_TYPE_CAPS, GST_BUFFER_CAPS (buf), NULL);
|
||||
"size", G_TYPE_UINT, map.size, "caps", GST_TYPE_CAPS, caps, NULL);
|
||||
if (caps)
|
||||
gst_caps_unref (caps);
|
||||
|
||||
g_free (checksum);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
message =
|
||||
gst_message_new_element (GST_OBJECT (transform), message_structure);
|
||||
|
|
Loading…
Reference in a new issue