From f5a1164590ecb75afeb2d880f37da7332ea87b07 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 4 Feb 2019 11:48:25 +0100 Subject: [PATCH] videodecoder: remove useless code in negotiate_default_caps() gst_video_decoder_negotiate_default_caps() is meant to pick a default output format when we need one earlier because of an incoming GAP. It tries to use the input caps as a base if available and fallback to a default format (I420 1280x720@30) for the missing fields. But the framerate and pixel-aspect were not explicitly passed to gst_video_decoder_set_output_state() which is solely relying on the input format as reference to get the framerate anx pixel-aspect-ratio. So there is no need to manually handling those two fields as gst_video_decoder_set_output_state() will already use the ones from upstream if available, and they will be ignored anyway if there are not. This also prevent confusing debugging output where we claim to use a specific framerate while actually none was set. --- gst-libs/gst/video/gstvideodecoder.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index e89b0a7..b49c4d1 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -1001,8 +1001,6 @@ gst_video_decoder_negotiate_default_caps (GstVideoDecoder * decoder) GstCaps *sinkcaps = decoder->priv->input_state->caps; GstStructure *structure = gst_caps_get_structure (sinkcaps, 0); gint width, height; - gint par_n, par_d; - gint fps_n, fps_d; if (gst_structure_get_int (structure, "width", &width)) { for (i = 0; i < caps_size; i++) { @@ -1017,26 +1015,11 @@ gst_video_decoder_negotiate_default_caps (GstVideoDecoder * decoder) G_TYPE_INT, height, NULL); } } - - if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) { - for (i = 0; i < caps_size; i++) { - gst_structure_set (gst_caps_get_structure (caps, i), "framerate", - GST_TYPE_FRACTION, fps_n, fps_d, NULL); - } - } - - if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n, - &par_d)) { - for (i = 0; i < caps_size; i++) { - gst_structure_set (gst_caps_get_structure (caps, i), - "pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL); - } - } } for (i = 0; i < caps_size; i++) { structure = gst_caps_get_structure (caps, i); - /* Random I420 1280x720@30 for fixation */ + /* Random I420 1280x720 for fixation */ if (gst_structure_has_field (structure, "format")) gst_structure_fixate_field_string (structure, "format", "I420"); else @@ -1051,20 +1034,6 @@ gst_video_decoder_negotiate_default_caps (GstVideoDecoder * decoder) gst_structure_fixate_field_nearest_int (structure, "height", 720); else gst_structure_set (structure, "height", G_TYPE_INT, 720, NULL); - - if (gst_structure_has_field (structure, "framerate")) - gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, - 1); - else - gst_structure_set (structure, "framerate", GST_TYPE_FRACTION, 30, 1, - NULL); - - if (gst_structure_has_field (structure, "pixel-aspect-ratio")) - gst_structure_fixate_field_nearest_fraction (structure, - "pixel-aspect-ratio", 1, 1); - else - gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION, - 1, 1, NULL); } caps = gst_caps_fixate (caps); -- 2.7.4