jpegparse: always forward pixel-aspect-ratio

And by default it's 1/1

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 21:41:00 +01:00
parent ae55ebfdf2
commit ec4054e637
3 changed files with 20 additions and 13 deletions

View file

@ -218,6 +218,9 @@ gst_jpeg_parse_set_sink_caps (GstBaseParse * bparse, GstCaps * caps)
gst_structure_get_int (s, "height", &parse->orig_height);
gst_structure_get_int (s, "width", &parse->orig_width);
gst_structure_get_fraction (s, "pixel-aspect-ration", &parse->par_num,
&parse->par_den);
codec_data = gst_structure_get_value (s, "codec_data");
if (codec_data && G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
GstMapInfo map;
@ -487,10 +490,10 @@ gst_jpeg_parse_app0 (GstJpegParse * parse, GstJpegSegment * seg)
if (unit == 0) {
/* no units, X and Y specify the pixel aspect ratio */
if (parse->x_density != xd || parse->y_density != yd) {
if (parse->par_num != xd || parse->par_den != yd) {
parse->renegotiate = TRUE;
parse->x_density = xd;
parse->y_density = yd;
parse->par_num = xd;
parse->par_den = yd;
}
} else if (unit == 1 || unit == 2) {
/* tag pixel per inches */
@ -689,8 +692,8 @@ gst_jpeg_parse_com (GstJpegParse * parse, GstJpegSegment * seg)
if (g_str_has_prefix (buf, "AVID")) {
parse_avid (parse, data, size);
} else if (g_str_has_prefix (buf, "MULTISCOPE II")) {
parse->x_density = 1;
parse->y_density = 2;
parse->par_num = 1;
parse->par_den = 2;
parse->multiscope = TRUE;
} else {
gchar *comment;
@ -775,9 +778,9 @@ gst_jpeg_parse_set_new_caps (GstJpegParse * parse)
gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION,
parse->framerate_numerator, parse->framerate_denominator, NULL);
if (parse->x_density > 0 && parse->y_density > 0) {
if (parse->par_num > 0 && parse->par_den > 0) {
gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION,
parse->x_density, parse->y_density, NULL);
parse->par_num, parse->par_den, NULL);
}
if (parse->codec_data) {
@ -1015,6 +1018,8 @@ gst_jpeg_parse_start (GstBaseParse * bparse)
parse->first_picture = TRUE;
parse->renegotiate = TRUE;
parse->par_num = parse->par_den = 1;
parse->interlace_mode = GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
parse->field_order = GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST;

View file

@ -72,8 +72,8 @@ struct _GstJpegParse {
/* format color space */
guint colorspace;
guint sampling;
guint16 x_density;
guint16 y_density;
gint par_num;
gint par_den;
GstCaps *prev_caps;
/* fps */

View file

@ -193,7 +193,7 @@ GST_START_TEST (test_parse_single_byte)
NULL);
caps_out = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, TRUE,
"framerate", GST_TYPE_FRACTION, 0, 1, "interlace-mode", G_TYPE_STRING,
"progressive", NULL);
"progressive", "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
/* Push the data byte by byte, injecting some garbage. */
buffer_in = make_buffers_in (buffer_in, test_data_garbage);
@ -264,7 +264,7 @@ GST_START_TEST (test_parse_all_in_one_buf)
caps_out = gst_caps_new_simple ("image/jpeg", "parsed", G_TYPE_BOOLEAN, TRUE,
"framerate", GST_TYPE_FRACTION, 0, 1, "interlace-mode", G_TYPE_STRING,
"progressive", NULL);
"progressive", "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 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);
@ -331,7 +331,8 @@ GST_START_TEST (test_parse_app1_exif)
"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", "interlace-mode",
G_TYPE_STRING, "progressive", NULL);
G_TYPE_STRING, "progressive", "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
1, NULL);
buffer_in = make_my_input_buffer (test_data_app1_exif,
sizeof (test_data_app1_exif));
@ -358,7 +359,8 @@ GST_START_TEST (test_parse_comment)
"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", "interlace-mode",
G_TYPE_STRING, "progressive", NULL);
G_TYPE_STRING, "progressive", "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
1, NULL);
buffer_in = make_my_input_buffer (test_data_comment,
sizeof (test_data_comment));