Ville Syrjälä wrote:
> On Tue, Nov 01, 2005 at 03:48:00PM +0100, Lucian Muresan wrote:
>> Hi folks,
>>
>> as you may remember from previous postings of mine, I have serious
>> trouble in using df_xine on my G400 DH TV-out (even with latest DirectFB
>> and matroxfb Matrox-relevant patches from Ville), when playing back
>> interlaced video, which obviously I don't need and want to be
>> deinterlaced by the software when viewing it on my standard PAL TV. The
>> problem is that I can't have both correct aspect ratio AND smooth
>> playback at the same time with some let's call them weird actual aspect
>> ratios they broadcast on DVB. I posted for testing 2 samples which
>> illustrate this, one with a standard 720x576 resolution, which is played
>> ok when selecting "square" (R + 1) in df_xine, and one non-standard,
>> which has to be correctly scaled to look well, 528x576. Both contain
>> horizontal scrolling text on which one can see what I mean. The one with
>> the "correct" resolution of 720x576 is the only one which can beplayed
>> back correctly, but with the other one, as I said, I get either wrong
>> aspect ratio, or non-smooth playback.
>
> StretchBlit() on interlaced content is a bad idea as we (still) scale the
> whole frame in one operation :(
>
So here it is again, my patch. This time it works well for me on the
CRTC2 for different resolutions of 4:3 and standard 720x576 16:9 DVB
interlaced content, I get almost smooth playback AND correct aspect
ratio (well, once in few seconds, there seems to be something like a
little sync catchup, visible as a speed jump on scrolling text, but it's
not always visible). I even pulled an old CRT monitor in the living room
and tested it on the first head, looks ok for all these different
resolutions/aspect ratios.
The patch also takes the pixel ratio into account, therefore I
introduced yet another new command line option to df_xine, -p
--phys-aspect which can specify a 4:3 or 16:9 physical device aspect
ratio, for correct scaling (I think 16:9 content has to be scaled to 5:4
on a standard PAL TV, because of non-square pixels). Well, even this is
an approximation, but I think, a better one.
Is it possible that this occasional "jump" is due to using StretchBlit
(I don't know exactly when and where, it's Claudio's code)? Is there
some way to improve the situation with df_xine?
Regards,
Lucian
diff -Naur DirectFB-extra-9999_orig/samples/df_xine/context.c
DirectFB-extra/samples/df_xine/context.c
--- DirectFB-extra-9999_orig/samples/df_xine/context.c 2005-11-02
00:32:31.000000000 +0100
+++ DirectFB-extra/samples/df_xine/context.c 2005-11-02 00:33:47.000000000
+0100
@@ -51,7 +51,10 @@
{
DFXCore *this = (DFXCore*) data;
DFXVideoContext *ctx = &this->ctx;
- bool update_area = (ctx->video.ratio != ratio);
+ double pixel_aspect = ctx->screen.physical_ratio /
ctx->screen.ratio;
+ // actual ratio on screen taking pixel aspect (stretching) into account
+ double corr_frame_ratio = ratio / pixel_aspect;
+ bool update_area = (ctx->video.ratio != corr_frame_ratio);
if (ctx->update ||
ctx->video.width != width ||
@@ -64,8 +67,8 @@
if (ctx->caps & DLCAPS_SCREEN_LOCATION) {
if (update_area) {
- if (ctx->screen.ratio <= ratio) {
- float h = (double) ctx->screen.width / ratio;
+ if (ctx->screen.ratio <= corr_frame_ratio) {
+ float h = (double) ctx->screen.width / corr_frame_ratio;
ctx->layer->SetScreenLocation( ctx->layer,
0.0,
@@ -75,7 +78,7 @@
h / (float) ctx->screen.height );
}
else {
- float w = (double) ctx->screen.height * ratio;
+ float w = (double) ctx->screen.height * corr_frame_ratio;
ctx->layer->SetScreenLocation( ctx->layer,
((float) ctx->screen.width - w) /
@@ -108,12 +111,16 @@
}
}
- if (ctx->screen.ratio <= ratio) {
+ if (ctx->screen.ratio == corr_frame_ratio) {
+ ctx->drect.w = ctx->screen.width;
+ ctx->drect.h = ctx->screen.height;
+ }
+ else if (ctx->screen.ratio < corr_frame_ratio) {
ctx->drect.w = ctx->screen.width;
- ctx->drect.h = (double) ctx->screen.width / ratio;
+ ctx->drect.h = (double) ctx->screen.width /
corr_frame_ratio;
} else {
- ctx->drect.w = (double) ctx->screen.height * ratio;
- ctx->drect.h = ctx->screen.height;
+ ctx->drect.w = (double) ctx->screen.height *
corr_frame_ratio;
+ ctx->drect.h = ctx->screen.height;
}
ctx->drect.x = (ctx->screen.width - ctx->drect.w) / 2;
@@ -131,7 +138,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;
}
diff -Naur DirectFB-extra-9999_orig/samples/df_xine/df_xine.h
DirectFB-extra/samples/df_xine/df_xine.h
--- DirectFB-extra-9999_orig/samples/df_xine/df_xine.h 2005-11-02
00:32:31.000000000 +0100
+++ DirectFB-extra/samples/df_xine/df_xine.h 2005-11-02 00:33:47.000000000
+0100
@@ -84,6 +84,7 @@
int width;
int height;
double ratio;
+ double physical_ratio;
} screen;
struct {
diff -Naur DirectFB-extra-9999_orig/samples/df_xine/main.c
DirectFB-extra/samples/df_xine/main.c
--- DirectFB-extra-9999_orig/samples/df_xine/main.c 2005-11-02
00:32:31.000000000 +0100
+++ DirectFB-extra/samples/df_xine/main.c 2005-11-02 00:36:56.000000000
+0100
@@ -143,6 +143,9 @@
puts( " 3 = Anamorphic" );
puts( " 4 = DVB" );
puts( " 5 = Screen\n" );
+ puts( " -p N, --phys-aspect=N set physical device aspect ratio:" );
+ puts( " 0 = 4:3" );
+ puts( " 1 = 16:9\n" );
puts( " -s , --sync wait for vertical retrace" );
puts( " (default: don't wait)\n" );
puts( " , --disable-hwscale do not use hardware acceleration to
scale the video" );
@@ -209,6 +212,8 @@
this->ctx.buffermode = DLBM_BACKVIDEO;
this->ctx.gmode = DGM_VIDEO;
this->media.repeat = 1;
+ this->ctx.screen.physical_ratio = 4.0/3.0;
+ DBUG( "default physical device aspect ratio assumed 4:3\n");
DirectFBInit( argn, argp );
@@ -385,6 +390,34 @@
this->ctl.default_ratio );
}
}
+ else if (*option == 'p') {
+ if (isdigit( option[1] ))
+ option++;
+ else if (argv[i+1] && isdigit( *argv[i+1] ))
+ option = argv[i+1];
+ else
+ continue;
+
+ if (*option == '1') {
+ this->ctx.screen.physical_ratio = 16.0/9.0;
+ DBUG( "physical device aspect ratio set to 16:9");
+ }
+ else {
+ this->ctx.screen.physical_ratio = 4.0/3.0;
+ DBUG( "physical device aspect ratio set to 4:3");
+ }
+ }
+ else if (!strncmp( option, "-phys-aspect=", 13 )) {
+ option += 13;
+ if (*option == '1') {
+ this->ctx.screen.physical_ratio = 16.0/9.0;
+ DBUG( "physical device aspect ratio set to 16:9");
+ }
+ else {
+ this->ctx.screen.physical_ratio = 4.0/3.0;
+ DBUG( "physical device aspect ratio set to 4:3");
+ }
+ }
else if (!strcmp( option, "s" ) || !strcmp( option, "-sync" )) {
this->ctx.flipflags = DSFLIP_WAITFORSYNC;
DBUG( "will wait for vertical retrace after flipping\n" );
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev