ext/ffmpeg/gstffmpegcodecmap.c: Initialize some more variables.
authorWim Taymans <wim.taymans@gmail.com>
Fri, 7 Nov 2008 11:43:42 +0000 (11:43 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Fri, 7 Nov 2008 11:43:42 +0000 (11:43 +0000)
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
Initialize some more variables.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_setcaps),
(alloc_output_buffer):
Disable direct rendering for h264, some functions just seem to read from
invalid memory.

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

index 71c0223..a0b258d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-11-07  Wim Taymans  <wim.taymans@collabora.co.uk>
+
+       * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
+       Initialize some more variables.
+
+       * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_setcaps),
+       (alloc_output_buffer):
+       Disable direct rendering for h264, some functions just seem to read from
+       invalid memory.
+
 2008-11-06  Wim Taymans  <wim.taymans@collabora.co.uk>
 
        * ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_cfg_init):
index 673548e..73a4a80 100644 (file)
@@ -3012,9 +3012,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = picture->data[0] + size;
       picture->data[2] = picture->data[1] + size2;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
       picture->linesize[1] = stride2;
       picture->linesize[2] = stride2;
+      picture->linesize[3] = 0;
       GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
       GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
       return size + 2 * size2;
@@ -3025,7 +3027,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = NULL;
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
+      picture->linesize[1] = 0;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size;
       /*case PIX_FMT_AYUV4444:
          case PIX_FMT_BGR32:
@@ -3037,7 +3043,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = NULL;
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
+      picture->linesize[1] = 0;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size;
     case PIX_FMT_RGB555:
     case PIX_FMT_RGB565:
@@ -3048,7 +3058,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = NULL;
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
+      picture->linesize[1] = 0;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size;
     case PIX_FMT_UYVY411:
       /* FIXME, probably not the right stride */
@@ -3057,7 +3071,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = NULL;
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = width + width / 2;
+      picture->linesize[1] = 0;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size + size / 2;
     case PIX_FMT_GRAY8:
       stride = ROUND_UP_4 (width);
@@ -3065,7 +3083,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = NULL;
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
+      picture->linesize[1] = 0;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size;
     case PIX_FMT_MONOWHITE:
     case PIX_FMT_MONOBLACK:
@@ -3074,7 +3096,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = NULL;
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
+      picture->linesize[1] = 0;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size;
     case PIX_FMT_PAL8:
       /* already forced to be with stride, so same result as other function */
@@ -3083,8 +3109,11 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
       picture->data[0] = ptr;
       picture->data[1] = ptr + size;    /* palette is stored here as 256 32 bit words */
       picture->data[2] = NULL;
+      picture->data[3] = NULL;
       picture->linesize[0] = stride;
       picture->linesize[1] = 4;
+      picture->linesize[2] = 0;
+      picture->linesize[3] = 0;
       return size + 256 * 4;
     default:
       picture->data[0] = NULL;
index 122415a..5488990 100644 (file)
@@ -694,21 +694,24 @@ gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
   ffmpegdec->extra_ref = FALSE;
   if (ffmpegdec->direct_rendering) {
     GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
-    if (!oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
-      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
+    if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
+      if (oclass->in_plugin->id == CODEC_ID_H264) {
+        GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
+        /* does not work, many stuff reads outside of the planes */
+        ffmpegdec->current_dr = FALSE;
+        ffmpegdec->extra_ref = TRUE;
+      } else {
+        GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
+        ffmpegdec->current_dr = TRUE;
+      }
     }
-    if (oclass->in_plugin->id == CODEC_ID_H264) {
-      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering setup for H264");
-      ffmpegdec->current_dr = TRUE;
-      ffmpegdec->extra_ref = TRUE;
-    } else {
-      GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
-      /* do *not* draw edges when in direct rendering, for some reason it draws
-       * outside of the memory. */
-      ffmpegdec->current_dr = TRUE;
+    else {
+      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
     }
   }
   if (ffmpegdec->current_dr) {
+    /* do *not* draw edges when in direct rendering, for some reason it draws
+     * outside of the memory. */
     ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
   }
 
@@ -784,6 +787,7 @@ alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
       width, height);
 
   if (!ffmpegdec->context->palctrl) {
+    GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
     /* no pallete, we can use the buffer size to alloc */
     ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
         GST_BUFFER_OFFSET_NONE, fsize,
@@ -791,6 +795,7 @@ alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
     if (G_UNLIKELY (ret != GST_FLOW_OK))
       goto alloc_failed;
   } else {
+    GST_LOG_OBJECT (ffmpegdec, "not calling pad_alloc, we have a pallete");
     /* for paletted data we can't use pad_alloc_buffer(), because
      * fsize contains the size of the palette, so the overall size
      * is bigger than ffmpegcolorspace's unit size, which will