[MPlayer-dev-eng] [PATCH] vo_dfbmga update
Ville Syrjälä
syrjala at sci.fi
Thu Oct 16 06:18:17 CEST 2003
Here's an update to vo_dfbmga.
Changes:
- Add black bars around the video when using the BES.
- Clean up properly in uninit().
- Advertise only YUY2 on a G200.
- Add "G200" to the description :)
- Remove/fix a few leftovers from old patches.
--
Ville Syrjälä
syrjala at sci.fi
http://www.sci.fi/~syrjala/
-------------- next part --------------
--- main/libvo/vo_dfbmga.c 2003-04-25 02:11:06.000000000 +0300
+++ main/libvo/vo_dfbmga.c 2003-10-16 06:38:47.000000000 +0300
@@ -1,5 +1,5 @@
/*
- MPlayer video driver for DirectFB / Matrox G400/G450/G550
+ MPlayer video driver for DirectFB / Matrox G200/G400/G450/G550
Copyright (C) 2002,2003 Ville Syrjala <syrjala at sci.fi>
@@ -39,7 +39,7 @@
#include "aspect.h"
static vo_info_t info = {
- "DirectFB / Matrox G400/G450/G550",
+ "DirectFB / Matrox G200/G400/G450/G550",
"dfbmga",
"Ville Syrjala <syrjala at sci.fi>",
""
@@ -75,13 +75,13 @@
static DFBSurfacePixelFormat frame_format;
static DFBSurfacePixelFormat subframe_format;
-static DFBRectangle drect;
+static DFBRectangle besrect;
+static DFBRectangle c2rect;
+static DFBRectangle *subrect;
static IDirectFBInputDevice *keyboard;
static IDirectFBEventBuffer *buffer;
-static int inited = 0;
-
static int blit_done;
static int stretch;
@@ -98,6 +98,8 @@
static int osd_current;
static int osd_max;
+static int is_g200 = 0;
+
/******************************
* vo_dfbmga *
******************************/
@@ -161,7 +163,7 @@
switch (format) {
case IMGFMT_RGB32:
case IMGFMT_BGR32:
- return DSPF_ARGB;
+ return DSPF_RGB32;
case IMGFMT_RGB24:
case IMGFMT_BGR24:
return DSPF_RGB24;
@@ -206,7 +208,8 @@
return DFENUM_CANCEL;
#else
/* Fake it according to id */
- if ((id == 1 && !strcmp( l->name, "Matrox Backend Scaler" )) ||
+ if ((id == 0 && !strcmp( l->name, "FBDev Primary Layer" )) ||
+ (id == 1 && !strcmp( l->name, "Matrox Backend Scaler" )) ||
(id == 2 && !strcmp( l->name, "Matrox CRTC2" )) ||
(id == 3 && !strcmp( l->name, "Matrox CRTC2 Sub-Picture" )))
if ((l->res = dfb->GetDisplayLayer( dfb, id, l->layer )) == DFB_OK)
@@ -350,7 +353,6 @@
return -1;
}
- if (!inited) {
if ((res = DirectFBInit( NULL, NULL )) != DFB_OK) {
mp_msg( MSGT_VO, MSGL_ERR,
"vo_dfbmga: DirectFBInit() failed - %s\n",
@@ -371,10 +373,9 @@
return -1;
}
- inited = 1;
- }
-
if (use_bes) {
+ DFBDisplayLayerConfig dlc;
+ DFBDisplayLayerConfigFlags failed;
struct layer_enum l = {
"Matrox Backend Scaler",
&bes,
@@ -392,6 +393,12 @@
DirectFBErrorString( res ) );
return -1;
}
+ dlc.flags = DLCONF_PIXELFORMAT;
+ dlc.pixelformat = DSPF_RGB16;
+ if (bes->TestConfiguration( bes, &dlc, &failed ) != DFB_OK) {
+ is_g200 = 1;
+ use_crtc2 = 0;
+ }
bes->SetOpacity( bes, 0 );
}
@@ -500,9 +507,37 @@
* BES
*/
if (use_bes) {
+ IDirectFBDisplayLayer *primary;
+ DFBDisplayLayerConfig pdlc;
+ struct layer_enum l = {
+ "FBDev Primary Layer",
+ &primary,
+ DFB_UNSUPPORTED
+ };
+ dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );
+ if (l.res != DFB_OK) {
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get primary layer - %s\n",
+ DirectFBErrorString( l.res ) );
+ return -1;
+ }
+ if ((res = primary->GetConfiguration( primary, &pdlc )) != DFB_OK) {
+ mp_msg( MSGT_VO, MSGL_ERR,
+ "vo_dfbmga: Can't get primary layer configuration - %s!\n",
+ DirectFBErrorString( res ) );
+ return -1;
+ }
+ primary->Release( primary );
+
+ aspect_save_screenres( pdlc.width, pdlc.height );
+ aspect( &out_width, &out_height, A_ZOOM );
+ besrect.x = (pdlc.width - out_width) * in_width / pdlc.width / 2;
+ besrect.y = (pdlc.height - out_height) * in_height / pdlc.height / 2;
+ besrect.w = in_width;
+ besrect.h = in_height;
+
dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
- dlc.width = in_width;
- dlc.height = in_height;
+ dlc.width = besrect.w + besrect.x * 2;
+ dlc.height = besrect.h + besrect.y * 2;
if (use_crtc2)
dlc.buffermode = DLBM_FRONTONLY;
@@ -524,13 +560,7 @@
bes->GetSurface( bes, &besframe );
besframe->SetBlittingFlags( besframe, DSBLIT_NOFX );
- aspect_save_screenres( 10000, 10000 );
- aspect( &out_width, &out_height, A_ZOOM );
- bes->SetScreenLocation( bes,
- (1.0f - (float) out_width / 10000.0f) / 2.0f,
- (1.0f - (float) out_height / 10000.0f) / 2.0f,
- (float) out_width / 10000.0f,
- (float) out_height / 10000.0f );
+ bes->SetScreenLocation( bes, 0.0, 0.0, 1.0, 1.0 );
besframe->Clear( besframe, 0, 0, 0, 0xff );
besframe->Flip( besframe, NULL, 0 );
@@ -554,7 +584,7 @@
#if DIRECTFBVERSION > 916
if (field_parity != -1) {
- dlc.options = DLOP_FIELD_PARITY;
+ dlc.options |= DLOP_FIELD_PARITY;
}
#endif
@@ -620,10 +650,10 @@
else
stretch = 0;
- drect.x = (screen_width - out_width) / 2;
- drect.y = (screen_height - out_height) / 2;
- drect.w = out_width;
- drect.h = out_height;
+ c2rect.x = (screen_width - out_width) / 2;
+ c2rect.y = (screen_height - out_height) / 2;
+ c2rect.w = out_width;
+ c2rect.h = out_height;
c2frame->Clear( c2frame, 0, 0, 0, 0xff );
c2frame->Flip( c2frame, NULL, 0 );
@@ -710,9 +740,11 @@
} else if (use_crtc2) {
/* Draw OSD to CRTC2 surface */
subframe = c2frame;
+ subrect = &c2rect;
} else {
/* Draw OSD to BES surface */
subframe = besframe;
+ subrect = &besrect;
}
subframe->GetSize( subframe, &sub_width, &sub_height );
@@ -749,11 +781,13 @@
case IMGFMT_BGR16:
case IMGFMT_RGB15:
case IMGFMT_BGR15:
- case IMGFMT_YUY2:
case IMGFMT_UYVY:
case IMGFMT_YV12:
case IMGFMT_I420:
case IMGFMT_IYUV:
+ if (is_g200)
+ return 0;
+ case IMGFMT_YUY2:
return (VFCAP_HWSCALE_UP |
VFCAP_HWSCALE_DOWN |
VFCAP_CSP_SUPPORTED_BY_HW |
@@ -807,11 +841,11 @@
if (!osd_changed || (!flipping && !vo_osd_changed))
return;
osd_dirty |= osd_current;
- } else if (use_crtc2) {
- if (x0 < drect.x ||
- y0 < drect.y ||
- x0 + w > drect.x + drect.w ||
- y0 + h > drect.y + drect.h)
+ } else {
+ if (x0 < subrect->x ||
+ y0 < subrect->y ||
+ x0 + w > subrect->x + subrect->w ||
+ y0 + h > subrect->y + subrect->h)
osd_dirty |= osd_current;
}
@@ -915,13 +949,15 @@
blit_to_screen( void )
{
IDirectFBSurface *blitsrc = frame;
+ DFBRectangle *srect = NULL;
if (use_bes) {
if (vo_vsync && !flipping && !use_crtc2)
bes->WaitForSync( bes );
- besframe->Blit( besframe, blitsrc, NULL, 0, 0 );
+ besframe->Blit( besframe, blitsrc, NULL, besrect.x, besrect.y );
blitsrc = besframe;
+ srect = &besrect;
}
if (use_crtc2) {
@@ -929,9 +965,9 @@
crtc2->WaitForSync( crtc2 );
if (stretch)
- c2frame->StretchBlit( c2frame, blitsrc, NULL, &drect );
+ c2frame->StretchBlit( c2frame, blitsrc, srect, &c2rect );
else
- c2frame->Blit( c2frame, blitsrc, NULL, drect.x, drect.y );
+ c2frame->Blit( c2frame, blitsrc, srect, c2rect.x, c2rect.y );
}
}
@@ -946,20 +982,20 @@
if (use_spic) {
if (flipping)
subframe->Clear( subframe, 0, 0, 0, 0 );
- } else if (use_crtc2) {
+ } else {
/* Clear black bars around the picture */
subframe->FillRectangle( subframe,
0, 0,
- screen_width, drect.y );
+ sub_width, subrect->y );
subframe->FillRectangle( subframe,
- 0, drect.y + drect.h,
- screen_width, drect.y );
+ 0, subrect->y + subrect->h,
+ sub_width, subrect->y );
subframe->FillRectangle( subframe,
- 0, drect.y,
- drect.x, drect.h );
+ 0, subrect->y,
+ subrect->x, subrect->h );
subframe->FillRectangle( subframe,
- drect.x + drect.w, drect.y,
- drect.x, drect.h );
+ subrect->x + subrect->w, subrect->y,
+ subrect->x, subrect->h );
}
osd_dirty &= ~osd_current;
}
@@ -998,7 +1034,7 @@
}
blit_done = 0;
- current_buf = 0;//vo_directrendering ? 0 : (current_buf + 1) % num_bufs;
+ current_buf = 0;
}
static void
@@ -1041,13 +1077,10 @@
subframe = NULL;
spic = NULL;
}
-
- /*
- * Don't release. Segfault in preinit() if
- * DirectFBCreate() called more than once.
- *
- * dfb->Release( dfb );
- */
+ if (dfb) {
+ dfb->Release( dfb );
+ dfb = NULL;
+ }
}
static uint32_t
@@ -1057,11 +1090,6 @@
void *dst;
int pitch;
- if (use_bes &&
- (mpi->type == MP_IMGTYPE_STATIC ||
- mpi->flags & MP_IMGFLAG_READABLE))
- return VO_FALSE;
-
if (mpi->flags & MP_IMGFLAG_READABLE &&
(mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) {
if (num_bufs < 2)
More information about the MPlayer-dev-eng
mailing list