This is something that's been bothering me for a while - it's most noticeable for me when watching widescreen DVB from the UK on an NTSC TV.
It's based off of a previous patch from Lucian Muresan which can be found here:
http://mail.directfb.org/pipermail/directfb-dev/2005-November/000895.html
It adds a new parameter to df_xine --displayaspect=d:d which is used in the form --displayaspect=4:3 or --displayaspect=16:9.
In doing this I've created a new struct in df_xine.h which adds back storing of the screen width and height in the context, along with storing the aspect ratio specific values.
I've moved the width and height back here (rather than always using ctx->screen->GetSize each time) as I'd only have to throw those values away after calculating the ratios anyway.
If the screen size can changing during the lifetime of the player let me know, and I'll move back to not storing the sizes and updating the ratios I store whenever the screen size is refetched in dfx_context_configure.
I've seen there is an --aspect setting already, but this doesn't seem to resize the display proportions on the TV in the same way that mplayer does.
Let me know if you'd like me to change anything (moving back to GetSize).
Thanks,
Chris
--- DirectFB-extra/samples/df_xine/context.c 2006-08-26 19:25:18.000000000 -0400
+++ DirectFB-extra.wip/samples/df_xine/context.c 2006-08-26 19:56:25.000000000 -0400
@@ -51,7 +51,9 @@
{
DFXCore *this = (DFXCore*) data;
DFXVideoContext *ctx = &this->ctx;
- bool update_area = (ctx->video.ratio != ratio);
+
+ double corr_frame_ratio = ratio / ctx->display.pixel_aspect;
+ bool update_area = (ctx->video.ratio != corr_frame_ratio);
if (ctx->update ||
ctx->video.width != width ||
@@ -64,27 +66,23 @@
if (ctx->caps & DLCAPS_SCREEN_LOCATION) {
if (update_area) {
- int screen_width;
- int screen_height;
- double screen_ratio;
- float x, y, w, h;
- ctx->screen->GetSize( ctx->screen, &screen_width, &screen_height );
- screen_ratio = (double)screen_width / (double)screen_height;
+ float x, y, w, h;
if (this->scale) {
- if (screen_ratio <= ratio) {
+
+ if (ctx->display.pixel_ratio <= corr_frame_ratio) {
w = 1.0;
- h = ((double)screen_width/ratio) / (float)screen_height;
+ h = ((double)ctx->display.screen_width/corr_frame_ratio) / (float)ctx->display.screen_height;
}
else {
- w = ((double)screen_height*ratio) - (float)screen_width;
+ w = ((double)ctx->display.screen_height*corr_frame_ratio) / (float)ctx->display.screen_width;
h = 1.0;
}
}
else { /* no scale */
- w = (float)width / (float)screen_width;
- h = (float)height / (float)screen_height;
+ w = (float)width / (float)ctx->display.screen_width;
+ h = (float)height / (float)ctx->display.screen_height;
}
w *= ctx->video.zoom;
@@ -105,9 +103,7 @@
} else {
/* first time we are called or format changed */
if (update_area) {
- int screen_width;
- int screen_height;
- double screen_ratio;
+
ctx->surface->Clear( ctx->surface, 0, 0, 0, 0xff );
/* Also clear the surfaces held in the back buffers */
@@ -121,20 +117,17 @@
}
}
- ctx->screen->GetSize( ctx->screen, &screen_width, &screen_height );
- screen_ratio = (double)screen_width / (double)screen_height;
if (this->scale) {
- if (screen_ratio <= ratio) {
- ctx->drect.w = (float) screen_width *
- ctx->video.zoom + .5;
- ctx->drect.h = (double)screen_width / ratio *
- ctx->video.zoom + .5;
+ if (ctx->display.pixel_ratio == corr_frame_ratio) {
+ ctx->drect.w = (float)ctx->display.screen_width * ctx->video.zoom + .5;
+ ctx->drect.h = (float)ctx->display.screen_height * ctx->video.zoom + .5;
+ } else if (ctx->display.pixel_ratio < corr_frame_ratio) {
+ ctx->drect.w = (float)ctx->display.screen_width * ctx->video.zoom + .5;
+ ctx->drect.h = (float)ctx->display.screen_width / corr_frame_ratio * ctx->video.zoom + .5;
} else {
- ctx->drect.w = (double)screen_height * ratio *
- ctx->video.zoom + .5;
- ctx->drect.h = (float) screen_height *
- ctx->video.zoom + .5;
+ ctx->drect.w = (float)ctx->display.screen_height * corr_frame_ratio * ctx->video.zoom + .5;
+ ctx->drect.h = (float)ctx->display.screen_height * ctx->video.zoom + .5;
}
}
else { /* no scale */
@@ -142,8 +135,8 @@
ctx->drect.h = (float)height * ctx->video.zoom + .5;
}
- ctx->drect.x = (screen_width - ctx->drect.w) / 2;
- ctx->drect.y = (screen_height - ctx->drect.h) / 2;
+ ctx->drect.x = (ctx->display.screen_width - ctx->drect.w) / 2;
+ ctx->drect.y = (ctx->display.screen_height - ctx->drect.h) / 2;
}
if (ctx->buffer) {
@@ -157,7 +150,7 @@
ctx->video.width = width;
ctx->video.height = height;
- ctx->video.ratio = ratio;
+ ctx->video.ratio = corr_frame_ratio;
ctx->video.format = format;
ctx->update = false;
}
@@ -797,6 +790,14 @@
layer->GetConfiguration( layer, &ctx->config );
}
+ ctx->screen->GetSize( ctx->screen, &ctx->display.screen_width, &ctx->display.screen_height );
+ ctx->display.pixel_ratio = ((double)ctx->display.screen_width / (double)ctx->display.screen_height);
+ if (this->ctx.display.physical_ratio == 0.0) {
+ this->ctx.display.physical_ratio = ctx->display.pixel_ratio;
+ ctx->display.pixel_aspect = 1.0;
+ } else
+ ctx->display.pixel_aspect = ctx->display.physical_ratio / ctx->display.pixel_ratio;
+
pthread_mutex_unlock( &ctx->mutex );
}
_______________________________________________ directfb-dev mailing list [email protected] http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev
