From 0d637e4f092dabad1043b7f9033104176bbf2cc0 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 7 May 2010 10:13:54 -0300 Subject: [PATCH] jifmux: Avoid adding 2 xmp packets jifmux was only appending a new xmp packet to the stream, it should replace if there is already one. --- gst/jpegformat/gstjifmux.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/gst/jpegformat/gstjifmux.c b/gst/jpegformat/gstjifmux.c index 17c1df78af..8b8c7f0f6a 100644 --- a/gst/jpegformat/gstjifmux.c +++ b/gst/jpegformat/gstjifmux.c @@ -216,6 +216,15 @@ gst_jif_mux_sink_event (GstPad * pad, GstEvent * event) return ret; } +static void +gst_jif_mux_marker_free (GstJifMuxMarker * m) +{ + if (m->owned) + g_free ((gpointer) m->data); + + g_slice_free (GstJifMuxMarker, m); +} + static void gst_jif_mux_reset (GstJifMux * self) { @@ -224,11 +233,7 @@ gst_jif_mux_reset (GstJifMux * self) for (node = self->priv->markers; node; node = g_list_next (node)) { m = (GstJifMuxMarker *) node->data; - - if (m->owned) - g_free ((gpointer) m->data); - - g_slice_free (GstJifMuxMarker, m); + gst_jif_mux_marker_free (m); } g_list_free (self->priv->markers); self->priv->markers = NULL; @@ -459,15 +464,22 @@ gst_jif_mux_mangle_markers (GstJifMux * self) memcpy (&data[29], xmp, size); m = gst_jif_mux_new_marker (APP1, size + 29, data, TRUE); - pos = file_hdr; - if (app1_exif) - pos = app1_exif; - else if (app0_jfif) - pos = app0_jfif; - pos = g_list_next (pos); + /* replace the old xmp marker and not add a new one */ + if (app1_xmp) { + gst_jif_mux_marker_free ((GstJifMuxMarker *) app1_xmp->data); + app1_xmp->data = m; + } else { - self->priv->markers = g_list_insert_before (self->priv->markers, pos, m); + pos = file_hdr; + if (app1_exif) + pos = app1_exif; + else if (app0_jfif) + pos = app0_jfif; + pos = g_list_next (pos); + self->priv->markers = g_list_insert_before (self->priv->markers, pos, m); + + } gst_buffer_unref (xmp_data); modified = TRUE; }