gst-libs/gst/tag/tags.c: Don't increase the size of non-string image buffers by one...
authorSebastian Dröge <slomo@circular-chaos.org>
Fri, 20 Jun 2008 08:47:14 +0000 (08:47 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Fri, 20 Jun 2008 08:47:14 +0000 (08:47 +0000)
Original commit message from CVS:
* gst-libs/gst/tag/tags.c: (gst_tag_image_data_to_image_buffer):
Don't increase the size of non-string image buffers by one as this
might in theory confuse decoders. Still increase it by one for string
image buffers to append '\0'.

ChangeLog
gst-libs/gst/tag/tags.c

index c6205aa..44292a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-06-20  Sebastian Dröge  <slomo@circular-chaos.org>
 
+       * gst-libs/gst/tag/tags.c: (gst_tag_image_data_to_image_buffer):
+       Don't increase the size of non-string image buffers by one as this
+       might in theory confuse decoders. Still increase it by one for string
+       image buffers to append '\0'.
+
+2008-06-20  Sebastian Dröge  <slomo@circular-chaos.org>
+
        Patch by: Antoine Tremblay <hexa00 at gmail dot com>
        
        * gst/gdp/gstgdppay.c: (gst_gdp_pay_reset):
index 78d382b..d145f6e 100644 (file)
@@ -155,6 +155,7 @@ GType
 gst_tag_image_type_get_type (void)
 {
   static GType id;
+
   static GOnce once = G_ONCE_INIT;
 
   g_once (&once, (GThreadFunc) register_tag_image_type_enum, &id);
@@ -165,6 +166,7 @@ static inline gboolean
 gst_tag_image_type_is_valid (GstTagImageType type)
 {
   GEnumClass *klass;
+
   gboolean res;
 
   klass = g_type_class_ref (gst_tag_image_type_get_type ());
@@ -262,7 +264,9 @@ gst_tag_freeform_string_to_utf8 (const gchar * data, gint size,
     const gchar ** env_vars)
 {
   const gchar *cur_loc = NULL;
+
   gsize bytes_read;
+
   gchar *utf8 = NULL;
 
   g_return_val_if_fail (data != NULL, NULL);
@@ -385,7 +389,9 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
     guint image_data_len, GstTagImageType image_type)
 {
   const gchar *name;
+
   GstBuffer *image;
+
   GstCaps *caps;
 
   g_return_val_if_fail (image_data != NULL, NULL);
@@ -423,6 +429,12 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
     goto error;
   }
 
+  /* Decrease size by 1 if we don't have an URI list
+   * to keep the original size of the image
+   */
+  if (!g_str_equal (name, "text/uri-list"))
+    GST_BUFFER_SIZE (image) = GST_BUFFER_SIZE (image) - 1;
+
   if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
     GST_LOG ("Setting image type: %d", image_type);
     caps = gst_caps_make_writable (caps);