diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-09-06 11:51:41 +0200 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-09-06 13:39:50 +0200 |
commit | 09724e12defa3c2f78fafebe3316d8173086a4a2 (patch) | |
tree | 469862488ca94486d227c0540283fc169bdc0dbe | |
parent | 30a8c566b7cfccc60ea4e8b4781c4176bb54f8b3 (diff) |
display: fix display aspect ratio when display is rotated.
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay.c | 24 |
1 files 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 |