GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
}
-static void
-gst_jpeg_dec_clear_error (GstJpegDec * dec)
-{
- g_free (dec->error_msg);
- dec->error_msg = NULL;
- dec->error_line = 0;
- dec->error_func = NULL;
-}
-
-static void
-gst_jpeg_dec_set_error_va (GstJpegDec * dec, const gchar * func, gint line,
- const gchar * debug_msg_format, va_list args)
-{
-#ifndef GST_DISABLE_GST_DEBUG
- gst_debug_log_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, __FILE__, func,
- line, (GObject *) dec, debug_msg_format, args);
-#endif
-
- g_free (dec->error_msg);
- if (debug_msg_format)
- dec->error_msg = g_strdup_vprintf (debug_msg_format, args);
- else
- dec->error_msg = NULL;
-
- dec->error_line = line;
- dec->error_func = func;
-}
-
-static void
-gst_jpeg_dec_set_error (GstJpegDec * dec, const gchar * func, gint line,
- const gchar * debug_msg_format, ...)
-{
- va_list va;
-
- va_start (va, debug_msg_format);
- gst_jpeg_dec_set_error_va (dec, func, line, debug_msg_format, va);
- va_end (va);
-}
-
-static GstFlowReturn
-gst_jpeg_dec_post_error_or_warning (GstJpegDec * dec)
-{
- GstFlowReturn ret;
- int max_errors;
-
- ++dec->error_count;
- max_errors = g_atomic_int_get (&dec->max_errors);
-
- if (max_errors < 0) {
- ret = GST_FLOW_OK;
- } else if (max_errors == 0) {
- /* FIXME: do something more clever in "automatic mode" */
- if (gst_video_decoder_get_packetized (GST_VIDEO_DECODER (dec))) {
- ret = (dec->error_count < 3) ? GST_FLOW_OK : GST_FLOW_ERROR;
- } else {
- ret = GST_FLOW_ERROR;
- }
- } else {
- ret = (dec->error_count < max_errors) ? GST_FLOW_OK : GST_FLOW_ERROR;
- }
-
- GST_INFO_OBJECT (dec, "decoding error %d/%d (%s)", dec->error_count,
- max_errors, (ret == GST_FLOW_OK) ? "ignoring error" : "erroring out");
-
- gst_element_message_full (GST_ELEMENT (dec),
- (ret == GST_FLOW_OK) ? GST_MESSAGE_WARNING : GST_MESSAGE_ERROR,
- GST_STREAM_ERROR, GST_STREAM_ERROR_DECODE,
- g_strdup (_("Failed to decode JPEG image")), dec->error_msg,
- __FILE__, dec->error_func, dec->error_line);
-
- dec->error_msg = NULL;
- gst_jpeg_dec_clear_error (dec);
- return ret;
-}
-
static boolean
gst_jpeg_dec_fill_input_buffer (j_decompress_ptr cinfo)
{
format_not_supported:
{
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "Unsupported subsampling schema: v_samp factors: %u %u %u",
- v_samp[0], v_samp[1], v_samp[2]);
- return GST_FLOW_ERROR;
+ gboolean ret = GST_FLOW_OK;
+
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")),
+ ("Unsupported subsampling schema: v_samp factors: %u %u %u", v_samp[0],
+ v_samp[1], v_samp[2]), ret);
+
+ return ret;
}
}
GST_LOG_OBJECT (dec, "decompressing finished");
jpeg_finish_decompress (&dec->cinfo);
- /* reset error count on successful decode */
- dec->error_count = 0;
-
gst_buffer_unmap (frame->input_buffer, &dec->current_frame_map);
ret = gst_video_decoder_finish_frame (bdec, frame);
need_unmap = FALSE;
exit:
- if (G_UNLIKELY (ret == GST_FLOW_ERROR)) {
- jpeg_abort_decompress (&dec->cinfo);
- ret = gst_jpeg_dec_post_error_or_warning (dec);
- }
-
if (need_unmap)
gst_buffer_unmap (frame->input_buffer, &dec->current_frame_map);
/* ERRORS */
wrong_size:
{
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "Picture is too small or too big (%ux%u)", width, height);
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")),
+ ("Picture is too small or too big (%ux%u)", width, height), ret);
ret = GST_FLOW_ERROR;
goto done;
}
dec->jerr.pub.format_message ((j_common_ptr) (&dec->cinfo), err_msg);
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "Decode error #%u: %s", code, err_msg);
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")), ("Decode error #%u: %s", code,
+ err_msg), ret);
gst_buffer_unmap (frame->input_buffer, &dec->current_frame_map);
gst_video_decoder_drop_frame (bdec, frame);
need_unmap = FALSE;
+ jpeg_abort_decompress (&dec->cinfo);
ret = GST_FLOW_ERROR;
goto done;
jpeg_abort_decompress (&dec->cinfo);
if (ret != GST_FLOW_EOS && ret != GST_FLOW_FLUSHING &&
ret != GST_FLOW_NOT_LINKED) {
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "Buffer allocation failed, reason: %s", reason);
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")),
+ ("Buffer allocation failed, reason: %s", reason), ret);
+ jpeg_abort_decompress (&dec->cinfo);
}
goto exit;
}
components_not_supported:
{
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "number of components not supported: %d (max 3)",
- dec->cinfo.num_components);
- ret = GST_FLOW_ERROR;
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")),
+ ("number of components not supported: %d (max 3)",
+ dec->cinfo.num_components), ret);
+ jpeg_abort_decompress (&dec->cinfo);
goto done;
}
unsupported_colorspace:
{
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "Picture has unknown or unsupported colourspace");
- ret = GST_FLOW_ERROR;
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")),
+ ("Picture has unknown or unsupported colourspace"), ret);
+ jpeg_abort_decompress (&dec->cinfo);
goto done;
}
invalid_yuvrgbgrayscale:
{
- gst_jpeg_dec_set_error (dec, GST_FUNCTION, __LINE__,
- "Picture is corrupt or unhandled YUV/RGB/grayscale layout");
- ret = GST_FLOW_ERROR;
+ GST_VIDEO_DECODER_ERROR (dec, 1, STREAM, DECODE,
+ (_("Failed to decode JPEG image")),
+ ("Picture is corrupt or unhandled YUV/RGB/grayscale layout"), ret);
+ jpeg_abort_decompress (&dec->cinfo);
goto done;
}
}