From eb7cae8033ec6a9b1d873bb9ddb0181facadad3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 23 Nov 2013 11:25:28 +0100 Subject: [PATCH] typefind: Add typefinder for OpenEXR --- gst/typefind/gsttypefindfunctions.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 14c679a9c5..a5f6ca1c7f 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -3806,6 +3806,33 @@ tiff_type_find (GstTypeFind * tf, gpointer ununsed) } } +/*** image/x-exr ***/ +static GstStaticCaps exr_caps = GST_STATIC_CAPS ("image/x-exr"); +#define EXR_CAPS (gst_static_caps_get(&exr_caps)) +static void +exr_type_find (GstTypeFind * tf, gpointer ununsed) +{ + const guint8 *data = gst_type_find_peek (tf, 0, 8); + + if (data) { + guint32 flags; + + if (GST_READ_UINT32_LE (data) != 0x01312f76) + return; + + flags = GST_READ_UINT32_LE (data + 4); + if ((flags & 0xff) != 1 && (flags & 0xff) != 2) + return; + + /* If bit 9 is set, bit 11 and 12 must be 0 */ + if ((flags & 0x200) && (flags & 0x1800)) + return; + + gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, EXR_CAPS); + } +} + + /*** PNM ***/ static GstStaticCaps pnm_caps = GST_STATIC_CAPS ("image/x-portable-bitmap; " @@ -5544,6 +5571,8 @@ plugin_init (GstPlugin * plugin) "tif,tiff", TIFF_CAPS, NULL, NULL); TYPE_FIND_REGISTER_RIFF (plugin, "image/webp", GST_RANK_PRIMARY, "webp", "WEBP"); + TYPE_FIND_REGISTER (plugin, "image/x-exr", GST_RANK_PRIMARY, exr_type_find, + "exr", EXR_CAPS, NULL, NULL); TYPE_FIND_REGISTER (plugin, "image/x-portable-pixmap", GST_RANK_SECONDARY, pnm_type_find, "pnm,ppm,pgm,pbm", PNM_CAPS, NULL, NULL); TYPE_FIND_REGISTER (plugin, "video/x-matroska", GST_RANK_PRIMARY,