From c12d7735ac911a2d1f7b732baee6b3ad7c3932dd Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Wed, 8 Mar 2006 09:37:12 +0000 Subject: [PATCH] gst-libs/gst/riff/riff-media.c: Allow palettes with less than 256 colours in AVI files Original commit message from CVS: * gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps): Allow palettes with less than 256 colours in AVI files (#333488, patch by: Fabrizio Gennari). --- ChangeLog | 6 ++++++ gst-libs/gst/riff/riff-media.c | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d12b9dce75..798d267520 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-03-08 Tim-Philipp Müller + + * gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps): + Allow palettes with less than 256 colours in AVI files + (#333488, patch by: Fabrizio Gennari). + 2006-03-07 Julien MOUTTE * ext/pango/gsttextoverlay.c: (gst_text_overlay_text_event), diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c index ffba8cf6ba..01b6082db7 100644 --- a/gst-libs/gst/riff/riff-media.c +++ b/gst-libs/gst/riff/riff-media.c @@ -547,15 +547,26 @@ gst_riff_create_video_caps (guint32 codec_fcc, } /* palette */ - if (palette && GST_BUFFER_SIZE (palette) >= 256 * 4) { - GstBuffer *copy = gst_buffer_copy (palette); + if (palette) { + GstBuffer *copy; + guint num_colors; + + if (strf != NULL) + num_colors = strf->num_colors; + else + num_colors = 256; + + /* palette is always at least 256*4 bytes */ + copy = gst_buffer_new_and_alloc (MAX (num_colors * 4, 256 * 4)); + memcpy (GST_BUFFER_DATA (copy), GST_BUFFER_DATA (palette), + GST_BUFFER_SIZE (palette)); #if (G_BYTE_ORDER == G_BIG_ENDIAN) gint n; guint32 *data = (guint32 *) GST_BUFFER_DATA (copy); /* own endianness */ - for (n = 0; n < 256; n++) + for (n = 0; n < num_colors; n++) data[n] = GUINT32_FROM_LE (data[n]); #endif gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, copy, NULL);