ext/ffmpeg/gstffmpegcodecmap.c: Use AVPALETTE_SIZE macro instead of magic value for...
authorFabrizio <fabrizio.ge@tiscali.it>
Fri, 24 Feb 2006 16:31:49 +0000 (16:31 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 24 Feb 2006 16:31:49 +0000 (16:31 +0000)
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette):
Use AVPALETTE_SIZE macro instead of magic value for clarity.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_frame):
In GStreamer, the size of the palette is not part of
GST_BUFFER_SIZE, so adjust buffer size of outgoing buffers
accordingly if there's a palette (fixes #327028, based on
patch by: Fabrizio Gennari).

ChangeLog
ext/ffmpeg/gstffmpegcodecmap.c
ext/ffmpeg/gstffmpegdec.c

index fbc3a8b..930b691 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-02-24  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
+       (gst_ffmpeg_set_palette):
+         Use AVPALETTE_SIZE macro instead of magic value for clarity.
+
+       * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_frame):
+         In GStreamer, the size of the palette is not part of
+         GST_BUFFER_SIZE, so adjust buffer size of outgoing buffers
+         accordingly if there's a palette (fixes #327028, based on 
+         patch by: Fabrizio Gennari).
+
 2006-02-21  Edward Hervey  <edward@fluendo.com>
 
        * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
index c17a958..f772000 100644 (file)
@@ -48,7 +48,7 @@ gst_ffmpeg_get_palette (const GstCaps *caps, AVCodecContext *context)
   if ((palette_v = gst_structure_get_value (str,
           "palette_data")) && context) {
     palette = gst_value_get_buffer (palette_v);
-    if (GST_BUFFER_SIZE (palette) >= 256 * 4) {
+    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
       if (context->palctrl)
         av_free (context->palctrl);
       context->palctrl = av_malloc (sizeof (AVPaletteControl));
@@ -63,7 +63,7 @@ static void
 gst_ffmpeg_set_palette (GstCaps *caps, AVCodecContext *context)
 {
   if (context->palctrl) {
-    GstBuffer *palette = gst_buffer_new_and_alloc (256 * 4);
+    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
 
     memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
         AVPALETTE_SIZE);
index 01c0552..5c05c6d 100644 (file)
@@ -984,8 +984,12 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
           ffmpegdec->next_ts = GST_CLOCK_TIME_NONE;
         }
       }
+      /* palette is not part of raw video frame in gst and the size
+       * of the outgoing buffer needs to be adjusted accordingly */
+      if (ffmpegdec->context->palctrl != NULL)
+        GST_BUFFER_SIZE (outbuf) -= AVPALETTE_SIZE;
       break;
-  }
+    }
     case CODEC_TYPE_AUDIO:
       if (!ffmpegdec->last_buffer)
         outbuf = gst_buffer_new_and_alloc (AVCODEC_MAX_AUDIO_FRAME_SIZE);