From aa168041218d2ac8890d96719b3c16c3ee898824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 14 Apr 2016 17:02:23 +0200 Subject: [PATCH] vaapidecode: refactor is_display_resolution_changed() Make the comparisons more readable and simple. https://bugzilla.gnome.org/show_bug.cgi?id=764316 --- gst/vaapi/gstvaapidecode.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index cdf5c15c51..6b904e41e7 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -389,8 +389,8 @@ is_display_resolution_changed (GstVaapiDecode * decode, { GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode); GstVideoCodecState *state; - GstVideoInfo *vinfo; guint display_width, display_height; + guint negotiated_width, negotiated_height; display_width = GST_VIDEO_INFO_WIDTH (&decode->decoded_info); display_height = GST_VIDEO_INFO_HEIGHT (&decode->decoded_info); @@ -402,23 +402,17 @@ is_display_resolution_changed (GstVaapiDecode * decode, state = gst_video_decoder_get_output_state (vdec); if (G_UNLIKELY (!state)) goto set_display_res; - vinfo = &state->info; - if (!crop_rect) { - if (G_UNLIKELY (display_width != decode->display_width - || display_height != decode->display_height)) - goto set_display_res; - } + negotiated_width = GST_VIDEO_INFO_WIDTH (&state->info); + negotiated_height = GST_VIDEO_INFO_HEIGHT (&state->info); + gst_video_codec_state_unref (state); - if (GST_VIDEO_INFO_WIDTH (vinfo) == display_width - && GST_VIDEO_INFO_HEIGHT (vinfo) == display_height) { - gst_video_codec_state_unref (state); + if ((display_width == negotiated_width && display_height == negotiated_height) + && (decode->display_width == negotiated_width + && decode->display_height == negotiated_height)) return FALSE; - } set_display_res: - if (state) - gst_video_codec_state_unref (state); decode->display_width = display_width; decode->display_height = display_height; return TRUE;