Commit 4834e11d authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

riff-media: fix palette extraction some more

We still need to make sure the palette is always at least 1024
bytes.
parent b0d581ea
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment