jp2kdec: post proper error when the image's colour space is not supported

https://bugzilla.gnome.org/show_bug.cgi?id=643115
This commit is contained in:
Tim-Philipp Müller 2011-02-25 14:24:17 +00:00
parent e4331322f2
commit b2be3e2f1a

View file

@ -256,12 +256,13 @@ refuse_caps:
} }
} }
static gboolean static GstFlowReturn
gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image) gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image)
{ {
GstFlowReturn flow_ret = GST_FLOW_OK;
gint width, height, channels; gint width, height, channels;
gint i, j; gint i, j;
gboolean negotiate = FALSE, ret = TRUE; gboolean negotiate = FALSE;
jas_clrspc_t clrspc; jas_clrspc_t clrspc;
GstCaps *allowed_caps, *caps; GstCaps *allowed_caps, *caps;
@ -316,7 +317,7 @@ gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image)
goto done; goto done;
/* clear and refresh to new state */ /* clear and refresh to new state */
ret = FALSE; flow_ret = GST_FLOW_NOT_NEGOTIATED;
dec->format = GST_VIDEO_FORMAT_UNKNOWN; dec->format = GST_VIDEO_FORMAT_UNKNOWN;
dec->width = width; dec->width = width;
dec->height = height; 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, GST_DEBUG_OBJECT (dec, "Set format to %d, size to %dx%d", dec->format,
dec->width, dec->height); 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); gst_caps_unref (caps);
} }
done: done:
return ret; return flow_ret;
/* ERRORS */ /* ERRORS */
fail_image: fail_image:
{ {
GST_DEBUG_OBJECT (dec, "Failed to process decoded image."); GST_DEBUG_OBJECT (dec, "Failed to process decoded image.");
ret = FALSE; flow_ret = GST_FLOW_NOT_NEGOTIATED;
goto done; goto done;
} }
not_supported: not_supported:
{ {
GST_DEBUG_OBJECT (dec, "Decoded image has unsupported colour space."); 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; goto done;
} }
} }
@ -460,7 +467,8 @@ gst_jasper_dec_get_picture (GstJasperDec * dec, guint8 * data,
if (!(image = jas_image_decode (stream, dec->fmt, (char *) ""))) if (!(image = jas_image_decode (stream, dec->fmt, (char *) "")))
goto fail_decode; 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; goto fail_negotiate;
ret = gst_pad_alloc_buffer_and_set_caps (dec->srcpad, ret = gst_pad_alloc_buffer_and_set_caps (dec->srcpad,
@ -548,7 +556,6 @@ no_buffer:
fail_negotiate: fail_negotiate:
{ {
GST_DEBUG_OBJECT (dec, "Failed to determine output caps."); GST_DEBUG_OBJECT (dec, "Failed to determine output caps.");
ret = GST_FLOW_NOT_NEGOTIATED;
goto done; goto done;
} }
} }