gst/ffmpegcolorspace/gstffmpegcolorspace.c: Return FALSE instead of returning a rando...
authorTim-Philipp Müller <tim@centricular.net>
Wed, 30 Aug 2006 17:22:27 +0000 (17:22 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 30 Aug 2006 17:22:27 +0000 (17:22 +0000)
Original commit message from CVS:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_get_unit_size):
Return FALSE instead of returning a random false unit
size when the format isn't known/supported (even if
this shouldn't happen under normal circumstances).

ChangeLog
gst/ffmpegcolorspace/gstffmpegcolorspace.c

index 0a7eb80..5383e03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-30  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/ffmpegcolorspace/gstffmpegcolorspace.c:
+       (gst_ffmpegcsp_get_unit_size):
+         Return FALSE instead of returning a random false unit
+         size when the format isn't known/supported (even if
+         this shouldn't happen under normal circumstances).
+
 2006-08-29  Wim Taymans  <wim@fluendo.com>
 
        Patch by: Tim-Philipp Müller  <tim at centricular dot net>
index b3a0b72..8ac9942 100644 (file)
@@ -382,6 +382,7 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
   GstFFMpegCsp *space = NULL;
   GstStructure *structure = NULL;
   AVCodecContext *ctx = NULL;
+  gboolean ret = TRUE;
   gint width, height;
 
   g_assert (size);
@@ -396,8 +397,15 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
 
   g_assert (ctx != NULL);
 
+  ctx->pix_fmt = PIX_FMT_NB;
+
   gst_ffmpegcsp_caps_with_codectype (CODEC_TYPE_VIDEO, caps, ctx);
 
+  if (G_UNLIKELY (ctx->pix_fmt == PIX_FMT_NB)) {
+    ret = FALSE;
+    goto beach;
+  }
+
   *size = avpicture_get_size (ctx->pix_fmt, width, height);
 
   /* ffmpeg frames have the palette after the frame data, whereas
@@ -408,11 +416,13 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
     *size -= 4 * 256;           /* = AVPALETTE_SIZE */
   }
 
+beach:
+
   if (ctx->palctrl)
     av_free (ctx->palctrl);
   av_free (ctx);
 
-  return TRUE;
+  return ret;
 }
 
 #if 0