From f0d4135b3a7ac6dd0b7a9b78787592aa5eb63b20 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Sat, 18 Jun 2022 10:36:53 +0800 Subject: [PATCH] h265parse: Fix uninitialized width and height when update src caps. The commit b90d0274 introduces uninitialized width and height when we consider to change the "pixel-aspect-ratio" for some interlaced stream. We need to check the resolution in the src caps, and if no resolution info found, there is no need to consider the aspect ratio. Part-of: --- .../gst-plugins-bad/gst/videoparsers/gsth265parse.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gsth265parse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gsth265parse.c index 953174ab90..e60e8398d6 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gsth265parse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gsth265parse.c @@ -2335,6 +2335,7 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps) const gchar *mdi_str = NULL; const gchar *cll_str = NULL; gboolean codec_data_modified = FALSE; + GstStructure *st; gst_caps_set_simple (caps, "parsed", G_TYPE_BOOLEAN, TRUE, "stream-format", G_TYPE_STRING, @@ -2343,7 +2344,15 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps) gst_h265_parse_get_string (h265parse, FALSE, h265parse->align), NULL); gst_h265_parse_get_par (h265parse, &par_n, &par_d); - if (par_n != 0 && par_d != 0 && + + width = 0; + height = 0; + st = gst_caps_get_structure (caps, 0); + gst_structure_get_int (st, "width", &width); + gst_structure_get_int (st, "height", &height); + + /* If no resolution info, do not consider aspect ratio */ + if (par_n != 0 && par_d != 0 && width > 0 && height > 0 && (!s || !gst_structure_has_field (s, "pixel-aspect-ratio"))) { gint new_par_d = par_d; /* Special case for some encoders which provide an 1:2 pixel aspect ratio