summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-08-20 11:09:19 -0300
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-08-21 21:08:13 +0200
commit407f6158871691f8442d903874e64873d43fdca6 (patch)
tree182874488a49febb1f86ff8874ae1da2713837c8
parente72574124f7470d8abd1fd221aab620593cad8b5 (diff)
jifmux: Avoid recombining RGB jpegs
JFIF only allows YUV as colorspace, when we receive an RGB jpeg, we should just push it forward without adding the JFIF marker. Fixes #627413
-rw-r--r--gst/jpegformat/gstjifmux.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gst/jpegformat/gstjifmux.c b/gst/jpegformat/gstjifmux.c
index bb66a1f51..1499366f6 100644
--- a/gst/jpegformat/gstjifmux.c
+++ b/gst/jpegformat/gstjifmux.c
@@ -298,6 +298,40 @@ gst_jif_mux_parse_image (GstJifMux * self, GstBuffer * buf)
goto error;
if (!gst_byte_reader_get_data (&reader, size - 2, &data))
goto error;
+
+ if (marker == APP14) {
+ gboolean valid = FALSE;
+
+ /* check if this contains RGB and reject it */
+ /*
+ * This marker should have:
+ * - 'Adobe\0'
+ * - 2 bytes DCTEncodeVersion
+ * - 2 bytes flags0
+ * - 2 bytes flags1
+ * - 1 byte ColorTransform
+ * - 0 means unknown (RGB or CMYK)
+ * - 1 YCbCr
+ * - 2 YCCK
+ */
+
+ if (size >= 14) {
+ if (strncmp ((gchar *) data, "Adobe\0", 6) == 0) {
+ valid = TRUE;
+
+ if (data[11] == 0) {
+ /* this is either RGB or CMYK, reject it */
+ goto not_yuv;
+ }
+
+ }
+ }
+ if (!valid) {
+ GST_WARNING_OBJECT (self, "Not checking suspicious APP14 "
+ "marker of size due to its size (%u) or name string", size);
+ }
+ }
+
m = gst_jif_mux_new_marker (marker, size - 2, data, FALSE);
self->priv->markers = g_list_prepend (self->priv->markers, m);
@@ -331,6 +365,10 @@ error:
"Error parsing image header (need more that %u bytes available)",
gst_byte_reader_get_remaining (&reader));
return FALSE;
+not_yuv:
+ GST_WARNING_OBJECT (self,
+ "This image is in RGB/CMYK format and JFIF only allows YCbCr");
+ return FALSE;
}
static gboolean