summaryrefslogtreecommitdiff
path: root/gst/videomeasure/gstvideomeasure_collector.c
diff options
context:
space:
mode:
authorРуслан Ижбулатов <lrn1986@gmail.com>2009-09-25 12:20:50 +0400
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-30 18:51:55 +0200
commit05e059c6247a72cbb47069cc76b79979ccf22f89 (patch)
tree4ba27ff075f7673aba350513defdf2a53fa7aa97 /gst/videomeasure/gstvideomeasure_collector.c
parent1adfafbe2cd0af7a8b1e03da8f68a63d8c102b28 (diff)
downloadgstreamer-plugins-bad-05e059c6247a72cbb47069cc76b79979ccf22f89.tar.gz
Take offset gaps into account.
Prevents measurecollector from crashing when frame numbers are not consecutive. Fixes bug #596285.
Diffstat (limited to 'gst/videomeasure/gstvideomeasure_collector.c')
-rw-r--r--gst/videomeasure/gstvideomeasure_collector.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/gst/videomeasure/gstvideomeasure_collector.c b/gst/videomeasure/gstvideomeasure_collector.c
index 306b3c0bf..a7c6d2e85 100644
--- a/gst/videomeasure/gstvideomeasure_collector.c
+++ b/gst/videomeasure/gstvideomeasure_collector.c
@@ -135,17 +135,27 @@ gst_measure_collector_post_message (GstMeasureCollector * mc)
if (strcmp (mc->metric, "SSIM") == 0) {
gfloat dresult = 0;
+ guint64 mlen;
g_free (mc->result);
mc->result = g_new0 (GValue, 1);
g_value_init (mc->result, G_TYPE_FLOAT);
+ mlen = mc->measurements->len;
for (i = 0; i < mc->measurements->len; i++) {
const GValue *v;
GstStructure *str =
(GstStructure *) g_ptr_array_index (mc->measurements, i);
- v = gst_structure_get_value (str, "mean");
- dresult += g_value_get_float (v);
+ if (str)
+ {
+ v = gst_structure_get_value (str, "mean");
+ dresult += g_value_get_float (v);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (mc, "No measurement info for frame %" G_GUINT64_FORMAT, i);
+ mlen--;
+ }
}
- g_value_set_float (mc->result, dresult / mc->measurements->len);
+ g_value_set_float (mc->result, dresult / mlen);
}
m = gst_message_new_element (GST_OBJECT_CAST (mc),
@@ -269,16 +279,18 @@ gst_measure_collector_save_csv (GstMeasureCollector * mc)
for (i = 0; i < mc->measurements->len; i++) {
fprintf (file, "\n");
str = (GstStructure *) g_ptr_array_index (mc->measurements, i);
- for (j = 0; j < gst_structure_n_fields (str); j++) {
- const gchar *fieldname;
- fieldname = gst_structure_nth_field_name (str, j);
- if (G_LIKELY (j > 0))
- fprintf (file, ";");
- if (G_LIKELY (g_value_transform (gst_structure_get_value (str, fieldname),
- &tmp)))
- fprintf (file, "%s", g_value_get_string (&tmp));
- else
- fprintf (file, "<untranslatable>");
+ if (str != NULL) {
+ for (j = 0; j < gst_structure_n_fields (str); j++) {
+ const gchar *fieldname;
+ fieldname = gst_structure_nth_field_name (str, j);
+ if (G_LIKELY (j > 0))
+ fprintf (file, ";");
+ if (G_LIKELY (g_value_transform (gst_structure_get_value (str, fieldname),
+ &tmp)))
+ fprintf (file, "%s", g_value_get_string (&tmp));
+ else
+ fprintf (file, "<untranslatable>");
+ }
}
}
@@ -387,8 +399,9 @@ gst_measure_collector_finalize (GObject * object)
GstMeasureCollector *mc = GST_MEASURE_COLLECTOR (object);
for (i = 0; i < mc->measurements->len; i++) {
- gst_structure_free ((GstStructure *) g_ptr_array_index (mc->measurements,
- i));
+ if (g_ptr_array_index (mc->measurements,i) != NULL)
+ gst_structure_free ((GstStructure *) g_ptr_array_index (mc->measurements,
+ i));
}
g_ptr_array_free (mc->measurements, TRUE);