From b2be3e2f1a79066518eda791ef45194beceddb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 25 Feb 2011 14:24:17 +0000 Subject: [PATCH] jp2kdec: post proper error when the image's colour space is not supported https://bugzilla.gnome.org/show_bug.cgi?id=643115 --- ext/jp2k/gstjasperdec.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ext/jp2k/gstjasperdec.c b/ext/jp2k/gstjasperdec.c index 595134c461..159eb95c8f 100644 --- a/ext/jp2k/gstjasperdec.c +++ b/ext/jp2k/gstjasperdec.c @@ -256,12 +256,13 @@ refuse_caps: } } -static gboolean +static GstFlowReturn gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image) { + GstFlowReturn flow_ret = GST_FLOW_OK; gint width, height, channels; gint i, j; - gboolean negotiate = FALSE, ret = TRUE; + gboolean negotiate = FALSE; jas_clrspc_t clrspc; GstCaps *allowed_caps, *caps; @@ -316,7 +317,7 @@ gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image) goto done; /* clear and refresh to new state */ - ret = FALSE; + flow_ret = GST_FLOW_NOT_NEGOTIATED; dec->format = GST_VIDEO_FORMAT_UNKNOWN; dec->width = width; dec->height = height; @@ -419,24 +420,30 @@ gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image) GST_DEBUG_OBJECT (dec, "Set format to %d, size to %dx%d", dec->format, dec->width, dec->height); - ret = gst_pad_set_caps (dec->srcpad, caps); + + if (!gst_pad_set_caps (dec->srcpad, caps)) + flow_ret = GST_FLOW_NOT_NEGOTIATED; + else + flow_ret = GST_FLOW_OK; + gst_caps_unref (caps); } done: - return ret; + return flow_ret; /* ERRORS */ fail_image: { GST_DEBUG_OBJECT (dec, "Failed to process decoded image."); - ret = FALSE; + flow_ret = GST_FLOW_NOT_NEGOTIATED; goto done; } not_supported: { GST_DEBUG_OBJECT (dec, "Decoded image has unsupported colour space."); - ret = FALSE; + GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("Unsupported colorspace")); + flow_ret = GST_FLOW_ERROR; goto done; } } @@ -460,7 +467,8 @@ gst_jasper_dec_get_picture (GstJasperDec * dec, guint8 * data, if (!(image = jas_image_decode (stream, dec->fmt, (char *) ""))) goto fail_decode; - if (!gst_jasper_dec_negotiate (dec, image)) + ret = gst_jasper_dec_negotiate (dec, image); + if (ret != GST_FLOW_OK) goto fail_negotiate; ret = gst_pad_alloc_buffer_and_set_caps (dec->srcpad, @@ -548,7 +556,6 @@ no_buffer: fail_negotiate: { GST_DEBUG_OBJECT (dec, "Failed to determine output caps."); - ret = GST_FLOW_NOT_NEGOTIATED; goto done; } }