diff --git a/gst-libs/gst/pbutils/descriptions.c b/gst-libs/gst/pbutils/descriptions.c index c32e3d92cd..5e7de0377e 100644 --- a/gst-libs/gst/pbutils/descriptions.c +++ b/gst-libs/gst/pbutils/descriptions.c @@ -231,6 +231,7 @@ static const FormatInfo formats[] = { {"image/x-quicktime", "QuickTime Image Format (QTIF)", 0}, {"image/x-sun-raster", "Sun Raster Format (RAS)", 0}, {"image/x-tga", "TGA", 0}, + {"image/vnd.wap.wbmp", "Wireless Bitmap", 0}, /* subtitle formats with static descriptions */ {"application/x-ass", "ASS", 0}, diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 1000a524e3..19bdabb882 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -4006,6 +4006,61 @@ windows_icon_typefind (GstTypeFind * find, gpointer user_data) "image/x-icon", NULL); } +/*** WAP WBMP typefinder ***/ + +static void +wbmp_typefind (GstTypeFind * find, gpointer user_data) +{ + guint8 *data; + gint64 datalen; + guint w, h, size; + + /* http://en.wikipedia.org/wiki/Wireless_Application_Protocol_Bitmap_Format */ + datalen = gst_type_find_get_length (find); + if (datalen == 0) + return; + + data = gst_type_find_peek (find, 0, 5); + if (data == NULL) + return; + + /* want 0x00 0x00 at start */ + if (*data++ != 0 || *data++ != 0) + return; + + /* min header size */ + size = 4; + + /* let's assume max width/height is 65536 */ + w = *data++; + if ((w & 0x80)) { + w = (w << 8) | *data++; + if ((w & 0x80)) + return; + ++size; + data = gst_type_find_peek (find, 4, 2); + if (data == NULL) + return; + } + h = *data++; + if ((h & 0x80)) { + h = (h << 8) | *data++; + if ((h & 0x80)) + return; + ++size; + } + + if (w == 0 || h == 0) + return; + + /* now add bitmap size */ + size += h * (GST_ROUND_UP_8 (w) / 8); + + if (datalen == size) { + gst_type_find_suggest_simple (find, GST_TYPE_FIND_POSSIBLE - 10, + "image/vnd.wap.wbmp", NULL); + } +} /*** DEGAS Atari images (also to avoid false positives, see #625129) ***/ static void @@ -4521,6 +4576,8 @@ plugin_init (GstPlugin * plugin) TYPE_FIND_REGISTER_START_WITH (plugin, "image/vnd.adobe.photoshop", GST_RANK_SECONDARY, psd_exts, "8BPS\000\001\000\000\000\000", 10, GST_TYPE_FIND_LIKELY); + TYPE_FIND_REGISTER (plugin, "image/vnd.wap.wbmp", GST_RANK_MARGINAL, + wbmp_typefind, NULL, NULL, NULL, NULL); TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-yuv4mpeg", GST_RANK_SECONDARY, y4m_exts, "YUV4MPEG2 ", 10, GST_TYPE_FIND_LIKELY); TYPE_FIND_REGISTER (plugin, "image/x-icon", GST_RANK_MARGINAL,