static void 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, 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 (size1 != size2) { delta = comp->threshold + 1; } else { 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, caps1, buf2, caps2); break; case GST_COMPARE_METHOD_MAX: delta = gst_compare_max (comp, buf1, caps1, buf2, caps2); break; case GST_COMPARE_METHOD_SSIM: delta = gst_compare_ssim (comp, buf1, caps1, buf2, caps2); break; default: g_assert_not_reached (); break; } } if ((comp->upper && delta > comp->threshold) || (!comp->upper && delta < comp->threshold)) { GST_WARNING_OBJECT (comp, "buffers %p and %p failed content match %f", buf1, buf2, delta); gst_element_post_message (GST_ELEMENT (comp), gst_message_new_element (GST_OBJECT (comp), gst_structure_new ("delta", "content", G_TYPE_DOUBLE, delta, NULL))); } }
static void gst_compare_buffers (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2) { gdouble delta = 0; /* first check metadata */ gst_compare_meta (comp, buf1, buf2); /* check content according to method */ /* but at least size should match */ if (GST_BUFFER_SIZE (buf1) != GST_BUFFER_SIZE (buf2)) { 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)); switch (comp->method) { case GST_COMPARE_METHOD_MEM: delta = gst_compare_mem (comp, buf1, buf2); break; case GST_COMPARE_METHOD_MAX: delta = gst_compare_max (comp, buf1, buf2); break; case GST_COMPARE_METHOD_SSIM: delta = gst_compare_ssim (comp, buf1, buf2); break; default: g_assert_not_reached (); break; } } if ((comp->upper && delta > comp->threshold) || (!comp->upper && delta < comp->threshold)) { GST_WARNING_OBJECT (comp, "buffers %p and %p failed content match %f", buf1, buf2, delta); gst_element_post_message (GST_ELEMENT (comp), gst_message_new_element (GST_OBJECT (comp), gst_structure_new ("delta", "content", G_TYPE_DOUBLE, delta, NULL))); } }