From 09724e12defa3c2f78fafebe3316d8173086a4a2 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 6 Sep 2012 11:51:41 +0200 Subject: display: fix display aspect ratio when display is rotated. --- gst-libs/gst/vaapi/gstvaapidisplay.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c index a52339d..8876643 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay.c @@ -382,7 +382,7 @@ gst_vaapi_display_calculate_pixel_aspect_ratio(GstVaapiDisplay *display) { GstVaapiDisplayPrivate * const priv = display->priv; gdouble ratio, delta; - gint i, index; + gint i, j, index, windex; static const gint par[][2] = { {1, 1}, /* regular screen */ @@ -405,21 +405,25 @@ gst_vaapi_display_calculate_pixel_aspect_ratio(GstVaapiDisplay *display) GST_DEBUG("calculated pixel aspect ratio: %f", ratio); /* Now, find the one from par[][2] with the lowest delta to the real one */ -#define DELTA(idx) (ABS(ratio - ((gdouble)par[idx][0] / par[idx][1]))) - delta = DELTA(0); - index = 0; +#define DELTA(idx, w) (ABS(ratio - ((gdouble)par[idx][w] / par[idx][!(w)]))) + delta = DELTA(0, 0); + index = 0; + windex = 0; for (i = 1; i < G_N_ELEMENTS(par); i++) { - const gdouble this_delta = DELTA(i); - if (this_delta < delta) { - index = i; - delta = this_delta; + for (j = 0; j < 2; j++) { + const gdouble this_delta = DELTA(i, j); + if (this_delta < delta) { + index = i; + windex = j; + delta = this_delta; + } } } #undef DELTA - priv->par_n = par[index][0]; - priv->par_d = par[index][1]; + priv->par_n = par[index][windex]; + priv->par_d = par[index][windex ^ 1]; } static void -- cgit v1.2.3