From 4834e11da071a9cb32a45705bc80aaf5630ae7d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 16 Oct 2012 11:48:32 +0100 Subject: [PATCH] riff-media: fix palette extraction some more We still need to make sure the palette is always at least 1024 bytes. --- gst-libs/gst/riff/riff-media.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c index 12ff927..41749ac 100644 --- a/gst-libs/gst/riff/riff-media.c +++ b/gst-libs/gst/riff/riff-media.c @@ -905,27 +905,24 @@ gst_riff_create_video_caps (guint32 codec_fcc, size = gst_buffer_get_size (palette); if (size >= (num_colors * 4)) { + guint8 *pdata; + /* palette is always at least 256*4 bytes */ - copy = gst_buffer_new (); - gst_buffer_copy_into (copy, palette, GST_BUFFER_COPY_MEMORY, 0, size); + pdata = g_malloc0 (MAX (size, 256 * 4)); + gst_buffer_extract (palette, 0, pdata, size); -#if (G_BYTE_ORDER == G_BIG_ENDIAN) - { - GstMapInfo palette_mapinfo; - guint8 *p; + if (G_BYTE_ORDER == G_BIG_ENDIAN) { + guint8 *p = pdata; gint n; - gst_buffer_map (copy, &palette_mapinfo, GST_MAP_READWRITE); - /* own endianness */ - p = palette_mapinfo.data; for (n = 0; n < num_colors; n++) { GST_WRITE_UINT32_BE (p, GST_READ_UINT32_LE (p)); p += sizeof (guint32); } - gst_buffer_unmap (copy, &palette_mapinfo); } -#endif + + copy = gst_buffer_new_wrapped (pdata, size); gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, copy, NULL); gst_buffer_unref (copy); } else { -- 2.7.4