jpegparse: Rewrite element.

Now it uses the JPEG parser in libgstcodecparsers, while the whole
code is simplified by relying more in baseparser class for tag
handling.

The element now signals chroma-format and default framerate is 0/1,
which is for still-images.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1473>
This commit is contained in:
Víctor Manuel Jáquez Leal 2021-12-22 19:23:37 +01:00
parent fa2b697389
commit 5542dd395d
5 changed files with 540 additions and 633 deletions

View file

@ -29620,7 +29620,7 @@
"rank": "secondary"
},
"jpegparse": {
"author": "Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>",
"author": "Víctor Jáquez <vjaquez@igalia.com>",
"description": "Parse JPEG images into single-frame buffers",
"hierarchy": [
"GstJpegParse",
@ -29630,7 +29630,7 @@
"GInitiallyUnowned",
"GObject"
],
"klass": "Video/Parser",
"klass": "Codec/Parser/Image",
"long-name": "JPEG stream parser",
"pad-templates": {
"sink": {
@ -29639,7 +29639,7 @@
"presence": "always"
},
"src": {
"caps": "image/jpeg:\n format: { I420, Y41B, UYVY, YV12 }\n width: [ 0, 2147483647 ]\n height: [ 0, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n parsed: true\n",
"caps": "image/jpeg:\n framerate: [ 0/1, 2147483647/1 ]\n parsed: true\n",
"direction": "src",
"presence": "always"
}

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
* jpegparse: a parser for JPEG streams
*
* Copyright (C) <2009> Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
* <2022> Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -47,30 +48,22 @@ struct _GstJpegParse {
GstBaseParse parse;
guint last_offset;
guint last_entropy_len;
gboolean last_resync;
gint state;
/* negotiated state */
gint caps_width, caps_height;
gint caps_framerate_numerator;
gint caps_framerate_denominator;
gint8 sof;
gint8 adobe_transform;
/* the parsed frame size */
guint16 width, height;
/* format color space */
const gchar *format;
guint colorspace;
guint sampling;
guint16 x_density;
guint16 y_density;
GstCaps *prev_caps;
/* TRUE if the src caps sets a specific framerate */
gboolean has_fps;
/* the (expected) timestamp of the next frame */
guint64 next_ts;
/* duration of the current frame */
guint64 duration;
/* video state */
/* fps */
gint framerate_numerator;
gint framerate_denominator;

View file

@ -8,7 +8,7 @@ gstjpegformat = library('gstjpegformat',
jpegf_sources,
c_args : gst_plugins_bad_args + [ '-DGST_USE_UNSTABLE_API' ],
include_directories : [configinc],
dependencies : [gstbase_dep, gstcodecparsers_dep, gsttag_dep],
dependencies : [gstbase_dep, gstcodecparsers_dep, gstvideo_dep, gsttag_dep],
install : true,
install_dir : plugins_install_dir,
)

View file

@ -192,7 +192,7 @@ GST_START_TEST (test_parse_single_byte)
caps_in = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, FALSE,
NULL);
caps_out = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, TRUE,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
"framerate", GST_TYPE_FRACTION, 0, 1, NULL);
/* Push the data byte by byte, injecting some garbage. */
buffer_in = make_buffers_in (buffer_in, test_data_garbage);
@ -262,7 +262,7 @@ GST_START_TEST (test_parse_all_in_one_buf)
buffer_in = g_list_append (buffer_in, buffer);
caps_out = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, TRUE,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
"framerate", GST_TYPE_FRACTION, 0, 1, NULL);
buffer_out = make_buffers_out (buffer_out, test_data_short_frame);
buffer_out = make_buffers_out (buffer_out, test_data_normal_frame);
buffer_out = make_buffers_out (buffer_out, test_data_entropy);
@ -326,8 +326,9 @@ GST_START_TEST (test_parse_app1_exif)
G_TYPE_BOOLEAN, FALSE, NULL);
caps_out = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, TRUE,
"framerate", GST_TYPE_FRACTION, 1, 1, "format", G_TYPE_STRING,
"I420", "width", G_TYPE_INT, 80, "height", G_TYPE_INT, 60, NULL);
"framerate", GST_TYPE_FRACTION, 0, 1, "width", G_TYPE_INT, 80, "height",
G_TYPE_INT, 60, "sof-marker", G_TYPE_INT, 0, "colorspace", G_TYPE_STRING,
"sYUV", "sampling", G_TYPE_STRING, "YCbCr-4:2:0", NULL);
buffer_in = make_my_input_buffer (test_data_app1_exif,
sizeof (test_data_app1_exif));
@ -351,8 +352,9 @@ GST_START_TEST (test_parse_comment)
G_TYPE_BOOLEAN, FALSE, NULL);
caps_out = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, TRUE,
"framerate", GST_TYPE_FRACTION, 1, 1, "format", G_TYPE_STRING,
"I420", "width", G_TYPE_INT, 80, "height", G_TYPE_INT, 60, NULL);
"framerate", GST_TYPE_FRACTION, 0, 1, "width", G_TYPE_INT, 80, "height",
G_TYPE_INT, 60, "sof-marker", G_TYPE_INT, 0, "colorspace", G_TYPE_STRING,
"sYUV", "sampling", G_TYPE_STRING, "YCbCr-4:2:0", NULL);
buffer_in = make_my_input_buffer (test_data_comment,
sizeof (test_data_comment));