display: fix display aspect ratio when display is rotated.

This commit is contained in:
Gwenole Beauchesne 2012-09-06 11:51:41 +02:00
parent 30a8c566b7
commit 09724e12de

View file

@ -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