jpegparse: on app0 use fourcc rather than strings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5838>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-12-20 20:58:04 +01:00
parent 367deef132
commit 470b90a14a

View file

@ -430,9 +430,9 @@ static gboolean
gst_jpeg_parse_app0 (GstJpegParse * parse, GstJpegSegment * seg)
{
GstByteReader reader;
const gchar *id_str;
guint16 xd, yd;
guint8 unit, xt, yt;
guint32 id;
if (seg->size < 6) /* less than 6 means no id string */
return FALSE;
@ -440,14 +440,22 @@ gst_jpeg_parse_app0 (GstJpegParse * parse, GstJpegSegment * seg)
gst_byte_reader_init (&reader, seg->data + seg->offset, seg->size);
gst_byte_reader_skip_unchecked (&reader, 2);
if (!gst_byte_reader_get_string_utf8 (&reader, &id_str))
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
if (!gst_byte_reader_get_uint32_le (&reader, &id))
return FALSE;
#else
if (!gst_byte_reader_get_uint32_be (&reader, &id))
return FALSE;
#endif
if (!valid_state (parse->state, GST_JPEG_PARSER_STATE_GOT_JFIF)
&& g_strcmp0 (id_str, "JFIF") == 0) {
&& GST_MAKE_FOURCC ('J', 'F', 'I', 'F') == id) {
parse->state |= GST_JPEG_PARSER_STATE_GOT_JFIF;
/* trailing zero-byte */
gst_byte_reader_skip_unchecked (&reader, 1);
/* version */
gst_byte_reader_skip_unchecked (&reader, 2);
@ -499,7 +507,7 @@ gst_jpeg_parse_app0 (GstJpegParse * parse, GstJpegSegment * seg)
}
/* JFIF Extension */
if (g_strcmp0 (id_str, "JFXX") == 0) {
if (GST_MAKE_FOURCC ('J', 'F', 'X', 'X') == id) {
if (!valid_state (parse->state, GST_JPEG_PARSER_STATE_GOT_JFIF))
return FALSE;
@ -507,7 +515,7 @@ gst_jpeg_parse_app0 (GstJpegParse * parse, GstJpegSegment * seg)
}
/* https://exiftool.org/TagNames/JPEG.html#AVI1 */
if (g_strcmp0 (id_str, "AVI1") == 0) {
if (GST_MAKE_FOURCC ('A', 'V', 'I', '1') == id) {
/* polarity */
if (!gst_byte_reader_get_uint8 (&reader, &unit))
return FALSE;