qtdemux: for non-raw video, move palette in caps
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 19 Jul 2013 15:12:37 +0000 (17:12 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 19 Jul 2013 15:14:46 +0000 (17:14 +0200)
We only need to append the palette to raw video buffers, non-raw video has the
palette in the caps still.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=704292

gst/isomp4/qtdemux.c

index 9005bb5..88e9056 100644 (file)
@@ -7204,11 +7204,41 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
       }
     }
 
+    stream->caps =
+        qtdemux_video_caps (qtdemux, stream, fourcc, stsd_data, &codec);
+    if (codec) {
+      list = gst_tag_list_new_empty ();
+      gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+          GST_TAG_VIDEO_CODEC, codec, NULL);
+      g_free (codec);
+      codec = NULL;
+    }
+
+
     if (palette_data) {
+      GstStructure *s;
+
       if (stream->rgb8_palette)
         gst_memory_unref (stream->rgb8_palette);
       stream->rgb8_palette = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
           palette_data, palette_size, 0, palette_size, palette_data, g_free);
+
+      s = gst_caps_get_structure (stream->caps, 0);
+
+      /* non-raw video has a palette_data property. raw video has the palette as
+       * an extra plane that we append to the output buffers before we push
+       * them*/
+      if (!gst_structure_has_name (s, "video/x-raw")) {
+        GstBuffer *palette;
+
+        palette = gst_buffer_new ();
+        gst_buffer_append_memory (palette, stream->rgb8_palette);
+        stream->rgb8_palette = NULL;
+
+        gst_caps_set_simple (stream->caps, "palette_data",
+            GST_TYPE_BUFFER, palette, NULL);
+        gst_buffer_unref (palette);
+      }
     } else if (palette_count != 0) {
       GST_ELEMENT_WARNING (qtdemux, STREAM, NOT_IMPLEMENTED,
           (NULL), ("Unsupported palette depth %d", depth));
@@ -7217,16 +7247,6 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
     GST_LOG_OBJECT (qtdemux, "frame count:   %u",
         QT_UINT16 (stsd_data + offset + 48));
 
-    stream->caps =
-        qtdemux_video_caps (qtdemux, stream, fourcc, stsd_data, &codec);
-    if (codec) {
-      list = gst_tag_list_new_empty ();
-      gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
-          GST_TAG_VIDEO_CODEC, codec, NULL);
-      g_free (codec);
-      codec = NULL;
-    }
-
     esds = NULL;
     pasp = NULL;
     /* pick 'the' stsd child */