summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorzdar <zdar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-11-25 20:05:50 +0000
committerzdar <zdar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-11-25 20:05:50 +0000
commitbd656159250c79bafb09f92302cbdcf33726e496 (patch)
tree9f74e5750888d8e1c3c4e7dce907ce923b2f9672 /libvo
parent236cda3d251caae5ed9b072a1ae31ea7504b1ede (diff)
downloadmpv-bd656159250c79bafb09f92302cbdcf33726e496.tar.bz2
mpv-bd656159250c79bafb09f92302cbdcf33726e496.tar.xz
Removal of vo_directfb.c. From now DirectFB => 0.9.13 is required for vo directfb.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14044 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_directfb.c1872
1 files changed, 0 insertions, 1872 deletions
diff --git a/libvo/vo_directfb.c b/libvo/vo_directfb.c
deleted file mode 100644
index ba3251e5db..0000000000
--- a/libvo/vo_directfb.c
+++ /dev/null
@@ -1,1872 +0,0 @@
-/*
- MPlayer video driver for DirectFramebuffer device
-
- (C) 2001
-
- Written by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
-
- Inspired by vo_sdl and vo_fbdev.
-
- To get second head working delete line 120
- from fbdev.c (from DirectFB sources version 0.9.7)
- Line contains following:
- fbdev->fd = open( "/dev/fb0", O_RDWR );
-
- Parts of this code taken from DirectFB examples:
- (c) Copyright 2000 convergence integrated media GmbH.
- All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-// directfb includes
-
-#include <directfb.h>
-
-// other things
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <ctype.h>
-#include <assert.h>
-
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/kd.h>
-#include <linux/fb.h>
-
-#include "config.h"
-#include "video_out.h"
-#include "video_out_internal.h"
-#include "fastmemcpy.h"
-#include "sub.h"
-#include "postproc/rgb2rgb.h"
-
-#include "aspect.h"
-
-#ifndef min
-#define min(x,y) (((x)<(y))?(x):(y))
-#endif
-
-static vo_info_t info = {
- "Direct Framebuffer Device",
- "directfb",
- "Jiri Svoboda Jiri.Svoboda@seznam.cz",
- ""
-};
-
-LIBVO_EXTERN(directfb)
-
-extern int verbose;
-
-/******************************
-* directfb *
-******************************/
-
- /*
- * (Globals)
- */
-static IDirectFB *dfb = NULL;
-static IDirectFBSurface *primary = NULL;
-static IDirectFBInputDevice *keyboard = NULL;
-static IDirectFBDisplayLayer *videolayer = NULL;
-static DFBDisplayLayerConfig dlc;
-static unsigned int screen_width = 0;
-static unsigned int screen_height = 0;
-static DFBSurfacePixelFormat frame_format;
-static unsigned int frame_pixel_size = 0;
-static unsigned int source_pixel_size = 0;
-static int xoffset=0,yoffset=0;
-#define DFBCHECK(x...) \
- { \
- DFBResult err = x; \
- \
- if (err != DFB_OK) \
- { \
- fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
- DirectFBErrorFatal( #x, err ); \
- } \
- }
-
-/*
- * The frame is to be loaded into a surface that we can blit from.
- */
-
-static IDirectFBSurface *frame = NULL;
-
-/*
- * A buffer for input events.
- */
-
-#if DIRECTFBVERSION > 908
-static IDirectFBEventBuffer *buffer = NULL;
-#else
-static IDirectFBInputBuffer *buffer = NULL;
-#endif
-
-/******************************
-* vo_directfb *
-******************************/
-
-/* command line/config file options */
-#ifdef HAVE_FBDEV
-extern char *fb_dev_name;
-#else
-char *fb_dev_name;
-#endif
-
-static void (*draw_alpha_p)(int w, int h, unsigned char *src,
- unsigned char *srca, int stride, unsigned char *dst,
- int dstride);
-
-static uint32_t in_width;
-static uint32_t in_height;
-static uint32_t out_width=1;
-static uint32_t out_height=1;
-static uint32_t pixel_format;
-static int fs;
-static int flip;
-static int stretch=0;
-struct modes_t {
- int valid;
- unsigned int width;
- unsigned int height;
- int overx,overy;
- } modes [4];
-static unsigned int best_bpp=5;
-// videolayer stuff
-static int videolayeractive=0;
-static int videolayerpresent=0;
-//some info about videolayer - filled on preinit
-struct vlayer_t {
- int iv12;
- int i420;
- int yuy2;
- int uyvy;
- int brightness;
- int saturation;
- int contrast;
- int hue;
- int hwscale;
- } videolayercaps;
-// workabout for DirectFB bug
-static int buggyYV12BitBlt=0;
-static int memcpyBitBlt=0;
-//
-static int hwstretchblit=0;
-#define DIRECTRENDER
-#ifdef DIRECTRENDER
-static int dr_enabled=0;
-static int framelocked=0;
-#endif
-#define FLIPPING
-#ifdef FLIPPING
-static int do_flipping=1; // turn (on) off flipping - prepared for cmd line switch
-static int wait_vsync_after_flip=0;
-static int flipping=0; // flipping is active
-static int invram=0; // backbuffer in video memory
-static int blitperformed=0; // in case of temporary frame we will blit before drawing osd
-#endif
-// primary & frame stuff
-static int frameallocated=0;
-static int primaryallocated=0;
-
-DFBEnumerationResult enum_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data)
-{
-int overx=0,overy=0,closer=0,over=0;
-unsigned int index=bpp/8-1;
-int we_are_under=0;
-
-if (verbose) printf("DirectFB: Validator entered %i %i %i\n",width,height,bpp);
-
-overx=width-out_width;
-overy=height-out_height;
-if (!modes[index].valid) {
- modes[index].valid=1;
- modes[index].width=width;
- modes[index].height=height;
- modes[index].overx=overx;
- modes[index].overy=overy;
- if (verbose) printf("DirectFB: Mode added %i %i %i\n",width,height,bpp);
- }
-if ((modes[index].overy<0)||(modes[index].overx<0)) we_are_under=1; // stored mode is smaller than req mode
-if (abs(overx*overy)<abs(modes[index].overx * modes[index].overy)) closer=1; // current mode is closer to desired res
-if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res
-if ((closer && (over || we_are_under)) || (we_are_under && over)) {
- modes[index].valid=1;
- modes[index].width=width;
- modes[index].height=height;
- modes[index].overx=overx;
- modes[index].overy=overy;
- if (verbose) printf("DirectFB: Better mode added %i %i %i\n",width,height,bpp);
- };
-
-return DFENUM_OK;
-}
-
-
-#if DIRECTFBVERSION > 912
-DFBEnumerationResult enum_layers_callback( DFBDisplayLayerID id,
- DFBDisplayLayerDescription desc,
- void *data )
-{
- DFBDisplayLayerCapabilities caps = desc.caps;
-#else
-DFBEnumerationResult enum_layers_callback( unsigned int id,
- DFBDisplayLayerCapabilities caps,
- void *data )
-{
-#endif
- IDirectFBDisplayLayer **layer = (IDirectFBDisplayLayer **)data;
-if (verbose) {
- printf("\nDirectFB: Layer %d:\n", id );
-
- if (caps & DLCAPS_SURFACE)
- printf( " - Has a surface.\n" );
-
- if (caps & DLCAPS_ALPHACHANNEL)
- printf( " - Supports blending based on alpha channel.\n" );
-
-#if DIRECTFBVERSION > 909
- if (caps & DLCAPS_SRC_COLORKEY)
- printf( " - Supports source based color keying.\n" );
-
- if (caps & DLCAPS_DST_COLORKEY)
- printf( " - Supports destination based color keying.\n" );
-#else
- if (caps & DLCAPS_COLORKEYING)
- printf( " - Supports color keying.\n" );
-#endif
-
- if (caps & DLCAPS_FLICKER_FILTERING)
- printf( " - Supports flicker filtering.\n" );
-
-/* renamed in dfb v. 0.9.13
- if (caps & DLCAPS_INTERLACED_VIDEO)
- printf( " - Can natively display interlaced video.\n" );
-*/
- if (caps & DLCAPS_OPACITY)
- printf( " - Supports blending based on global alpha factor.\n" );
-
- if (caps & DLCAPS_SCREEN_LOCATION)
- printf( " - Can be positioned on the screen.\n" );
-
- if (caps & DLCAPS_BRIGHTNESS)
- printf( " - Brightness can be adjusted.\n" );
-
- if (caps & DLCAPS_CONTRAST)
- printf( " - Contrast can be adjusted.\n" );
-
- if (caps & DLCAPS_HUE)
- printf( " - Hue can be adjusted.\n" );
-
- if (caps & DLCAPS_SATURATION)
- printf( " - Saturation can be adjusted.\n" );
-
- printf("\n");
-}
- /* We take the first layer not being the primary */
- if (id != DLID_PRIMARY) {
- DFBResult ret;
-
- ret = dfb->GetDisplayLayer( dfb, id, layer );
- if (ret)
- DirectFBError( "dfb->GetDisplayLayer failed", ret );
- else
- return DFENUM_CANCEL;
- }
-
- return DFENUM_OK;
-}
-
-static uint32_t preinit(const char *arg)
-{
- DFBSurfaceDescription dsc;
- DFBResult ret;
- DFBDisplayLayerConfigFlags failed;
-
- /*
- * (Initialize)
- */
-
-if (verbose) printf("DirectFB: Preinit entered\n");
-
- DFBCHECK (DirectFBInit (NULL,NULL));
-
- if (!((directfb_major_version <= 0) &&
- (directfb_minor_version <= 9) &&
- (directfb_micro_version < 7)))
- {
- if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) fb_dev_name = strdup("/dev/fb0");
- DFBCHECK (DirectFBSetOption ("fbdev",fb_dev_name));
- }
-
- // use own bitblt for YV12 beacuse bug in dfb till 0.9.11
- if ((directfb_major_version <= 0) &&
- (directfb_minor_version <= 9) &&
- (directfb_micro_version <= 11)) {
- buggyYV12BitBlt=1;
- if (verbose) printf("DirectFB: Buggy YV12BitBlt!\n");
- }
-
-#ifdef FLIPPING
- // activate flipping from release 0.9.11
- if ((directfb_major_version <= 0) &&
- (directfb_minor_version <= 9) &&
- (directfb_micro_version <= 10)) {
- do_flipping=0;
- } else {
-// (de)activated by default - should be overwritten by cmd line option
-// do_flipping=1;
- }
- // wait for vsync if ver <0.9.13
- if ((directfb_major_version <= 0) &&
- (directfb_minor_version <= 9) &&
- (directfb_micro_version <= 12)) {
- wait_vsync_after_flip=1;
- if (verbose) printf("DirectFB: Manual wait for vsync enabled!\n");
- } else {
- wait_vsync_after_flip=0;
- }
-#endif
-
-// uncomment this if you do not wish to create a new vt for DirectFB
-// DFBCHECK (DirectFBSetOption ("no-vt-switch",""));
-
-// uncomment this if you want to allow vt switching
-// DFBCHECK (DirectFBSetOption ("vt-switching",""));
-#if DIRECTFBVERSION > 908
-// uncomment this if you want to hide gfx cursor (req dfb >=0.9.9)
- DFBCHECK (DirectFBSetOption ("no-cursor",""));
-#endif
-
- DFBCHECK (DirectFBSetOption ("bg-color","00000000"));
-
- DFBCHECK (DirectFBCreate (&dfb));
- DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
-
- // let's try to get YUY2 layer - borrowed from DirectFb examples
-
- /* Enumerate display layers */
- DFBCHECK (dfb->EnumDisplayLayers( dfb, enum_layers_callback, &videolayer ));
-
- if (!videolayer) {
- if (verbose) printf("DirectFB: No videolayer found\n");
- // no videolayer found
-// printf( "\nNo additional layers have been found.\n" );
- videolayeractive=0;
-
- } else {
- // just to be sure that layer is hidden during config
- videolayer->SetOpacity(videolayer,0);
-
- // there is an additional layer so test it for YUV formats
- // some videolayers support RGB formats - not used now
- if (verbose) printf("DirectFB: Testing videolayer caps\n");
-
- dlc.flags = DLCONF_PIXELFORMAT;
-#if DIRECTFBVERSION > 908
- dlc.pixelformat = DSPF_YV12;
- ret = videolayer->TestConfiguration( videolayer, &dlc, &failed );
- if (ret==DFB_OK) {
- videolayercaps.iv12=1;
- if (verbose) printf("DirectFB: Videolayer supports YV12 format\n");
- } else {
- videolayercaps.iv12=0;
- if (verbose) printf("DirectFB: Videolayer doesn't support YV12 format\n");
- };
-
- dlc.pixelformat = DSPF_I420;
- ret = videolayer->TestConfiguration( videolayer, &dlc, &failed );
- if (ret==DFB_OK) {
- videolayercaps.i420=1;
- if (verbose) printf("DirectFB: Videolayer supports I420 format\n");
- } else {
- videolayercaps.i420=0;
- if (verbose) printf("DirectFB: Videolayer doesn't support I420 format\n");
- };
-#else
- videolayercaps.yuy2=0;
-#endif
-
- dlc.pixelformat = DSPF_YUY2;
- ret = videolayer->TestConfiguration( videolayer, &dlc, &failed );
- if (ret==DFB_OK) {
- videolayercaps.yuy2=1;
- if (verbose) printf("DirectFB: Videolayer supports YUY2 format\n");
- } else {
- videolayercaps.yuy2=0;
- if (verbose) printf("DirectFB: Videolayer doesn't support YUY2 format\n");
- };
-
- dlc.pixelformat = DSPF_UYVY;
- ret = videolayer->TestConfiguration( videolayer, &dlc, &failed );
- if (ret==DFB_OK) {
- videolayercaps.uyvy=1;
- if (verbose) printf("DirectFB: Videolayer supports UYVY format\n");
- } else {
- videolayercaps.uyvy=0;
- if (verbose) printf("DirectFB: Videolayer doesn't support UYVY format\n");
- };
-
- // test for color caps
- {
- DFBDisplayLayerCapabilities caps;
-#if DIRECTFBVERSION > 912
- DFBDisplayLayerDescription desc;
- videolayer->GetDescription(videolayer,&desc);
- caps = desc.caps;
-#else
- videolayer->GetCapabilities(videolayer,&caps);
-#endif
- if (caps & DLCAPS_BRIGHTNESS) {
- videolayercaps.brightness=1;
- } else {
- videolayercaps.brightness=0;
- };
-
- if (caps & DLCAPS_CONTRAST) {
- videolayercaps.contrast=1;
- } else {
- videolayercaps.contrast=0;
- };
-
- if (caps & DLCAPS_HUE) {
- videolayercaps.hue=1;
- } else {
- videolayercaps.hue=0;
- };
-
- if (caps & DLCAPS_SATURATION) {
- videolayercaps.saturation=1;
- } else {
- videolayercaps.saturation=0;
- };
-
- // test if layer can change size/position
- if (caps & DLCAPS_SCREEN_LOCATION) {
- videolayercaps.hwscale=1;
- } else {
- videolayercaps.hwscale=0;
- };
-
-
- }
-
-
- // is there a working yuv ? if no we will not use videolayer
- if ((videolayercaps.iv12==0)&&(videolayercaps.i420==0)&&(videolayercaps.yuy2==0)&&(videolayercaps.uyvy==0)) {
- // videolayer doesn't work with yuv so release it
- videolayerpresent=0;
- videolayer->SetOpacity(videolayer,0);
- videolayer->Release(videolayer);
- } else {
- videolayerpresent=1;
- };
- }
-
-// check generic card capabilities (for hw scaling)
- {
- DFBCardCapabilities caps;
- DFBCHECK (dfb->GetCardCapabilities(dfb,&caps));
- if (caps.acceleration_mask & DFXL_STRETCHBLIT) hwstretchblit=1; else hwstretchblit=0;
- if (verbose && hwstretchblit) printf("DirectFB: Card supports hw stretch blit\n");
- }
-
-// just look at RGB things for main layer
- modes[0].valid=0;
- modes[1].valid=0;
- modes[2].valid=0;
- modes[3].valid=0;
- DFBCHECK (dfb->EnumVideoModes(dfb,enum_modes_callback,NULL));
-
-
- /*
- * (Get keyboard)
- */
- ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);
-
- if (ret==DFB_OK) {
- if (verbose) {
- printf("DirectFB: Keyboard init OK\n");
- }
- } else {
- keyboard = NULL;
- printf("DirectFB: Keyboard init FAILED\n");
- }
-
- /*
- * Create an input buffer for the keyboard.
- */
-#if DIRECTFBVERSION > 908
- if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer));
-#else
- if (keyboard) DFBCHECK (keyboard->CreateInputBuffer (keyboard, &buffer));
-#endif
- // just to start with clean ...
- if (buffer) buffer->Reset(buffer);
- return 0;
-
-}
-
-
-static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
- uint32_t d_height, uint32_t fullscreen, char *title,
- uint32_t format)
-{
- /*
- * (Locals)
- */
- DFBSurfaceDescription dsc;
- DFBResult ret;
-
-
- int vm = fullscreen & 0x02;
- int zoom = fullscreen & 0x04;
-
- if (verbose) printf("DirectFB: Config entered [%ix%i]\n",width,height);
- if (verbose) printf("DirectFB: With requested format: %s\n",vo_format_name(format));
-
- fs = fullscreen & 0x01;
- flip = fullscreen & 0x08;
-
- pixel_format=format;
-
- in_width = width;
- in_height = height;
-
- if (d_width) {
- out_width = d_width;
- out_height = d_height;
- } else {
- d_width = out_width = in_width;
- d_height = out_height = in_height;
- }
-
-// just look at RGB things for main layer - once again - now we now desired screen size
- modes[0].valid=0;
- modes[1].valid=0;
- modes[2].valid=0;
- modes[3].valid=0;
- DFBCHECK (dfb->EnumVideoModes(dfb,enum_modes_callback,NULL));
-
- if (vm) {
- // need better algorithm just hack
- switch (format) {
- case IMGFMT_RGB32:
- case IMGFMT_BGR32:
- if (modes[3].valid) {
- dfb->SetVideoMode(dfb,modes[3].width,modes[3].height,32);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 32 bpp]\n",modes[3].width,modes[3].height);
- };
- break;
- case IMGFMT_RGB24:
- case IMGFMT_BGR24:
- if (modes[2].valid) {
- dfb->SetVideoMode(dfb,modes[2].width,modes[2].height,24);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 24 bpp]\n",modes[2].width,modes[2].height);
- };
- break;
- case IMGFMT_RGB16:
- case IMGFMT_BGR16:
- case IMGFMT_RGB15:
- case IMGFMT_BGR15:
- if (modes[1].valid) {
- dfb->SetVideoMode(dfb,modes[1].width,modes[1].height,16);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 16 bpp]\n",modes[1].width,modes[1].height);
- };
- break;
-
- default: // try all of them in order 24bit 16bit 32bit 8bit
- if (modes[2].valid) {
- dfb->SetVideoMode(dfb,modes[2].width,modes[2].height,24);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 24 bpp]\n",modes[2].width,modes[2].height);
- }
- else if (modes[1].valid) {
- dfb->SetVideoMode(dfb,modes[1].width,modes[1].height,16);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 16 bpp]\n",modes[1].width,modes[1].height);
- }
- else if (modes[3].valid) {
- dfb->SetVideoMode(dfb,modes[3].width,modes[3].height,32);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 32 bpp]\n",modes[3].width,modes[3].height);
- }
- else if (modes[0].valid) {
- dfb->SetVideoMode(dfb,modes[0].width,modes[0].height,8);
- if (verbose) printf("DirectFB: Trying to set videomode [%ix%i 8 bpp]\n",modes[0].width,modes[0].height);
- }
- break;
- };
-
- }
-
- // release primary if it is already allocated
- if (primaryallocated) {
- if (verbose ) printf("DirectFB: Release primary\n");
- primary->Release (primary);
- primaryallocated=0;
- };
-
- videolayeractive=0; // will be enabled on succes later
-
- if (videolayerpresent) {
-
- // try to set proper w a h values matching image size
- dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
- dlc.width = in_width;
- dlc.height = in_height;
-
- ret = videolayer->SetConfiguration( videolayer, &dlc );
-
- if (ret) {
- if (verbose) printf("DirectFB: Set layer size failed\n");
- };
-
- // try to set correct pixel format (closest to required)
-
- dlc.flags = DLCONF_PIXELFORMAT;
- dlc.pixelformat = 0;
- switch (pixel_format) {
- case IMGFMT_YV12:
-#if DIRECTFBVERSION > 908
- if (videolayercaps.i420==1) {
- dlc.pixelformat=DSPF_I420;
- break;
- } else if (videolayercaps.iv12==1) {
- dlc.pixelformat=DSPF_YV12;
- break;
- };
-
-#endif
- case IMGFMT_YUY2: if (videolayercaps.yuy2==1) {
- dlc.pixelformat=DSPF_YUY2;
- break;
-// temporary disabled - do not have conv tool to uyvy
-/* } else if (videolayercaps.uyvy==1) {
- dlc.pixelformat=DSPF_UYVY;
- break;
-*/
-#if DIRECTFBVERSION > 908
- } else if (videolayercaps.i420==1) {
- dlc.pixelformat=DSPF_I420;
- break;
- } else if (videolayercaps.iv12==1) {
- dlc.pixelformat=DSPF_YV12;
- break;
-#endif
- };
- // shouldn't happen - if it reaches here -> bug
-
- case IMGFMT_RGB32: dlc.pixelformat = DSPF_ARGB; break;
- case IMGFMT_BGR32: dlc.pixelformat = DSPF_ARGB; break;
- case IMGFMT_RGB24: dlc.pixelformat = DSPF_RGB24; break;
- case IMGFMT_BGR24: dlc.pixelformat = DSPF_RGB24; break;
- case IMGFMT_RGB16: dlc.pixelformat = DSPF_RGB16; break;
- case IMGFMT_BGR16: dlc.pixelformat = DSPF_RGB16; break;
- case IMGFMT_RGB15: dlc.pixelformat = DSPF_RGB15; break;
- case IMGFMT_BGR15: dlc.pixelformat = DSPF_RGB15; break;
- default: dlc.pixelformat = DSPF_RGB24; break;
- }
-
- if (verbose) switch (dlc.pixelformat) {
- case DSPF_ARGB: printf("DirectFB: layer format ARGB\n");
- break;
- case DSPF_RGB32: printf("DirectFB: layer format RGB32\n");
- break;
- case DSPF_RGB24: printf("DirectFB: layer format RGB24\n");
- break;
- case DSPF_RGB16: printf("DirectFB: layer format RGB16\n");
- break;
- case DSPF_RGB15: printf("DirectFB: layer format RGB15\n");
- break;
- case DSPF_YUY2: printf("DirectFB: layer format YUY2\n");
- break;
- case DSPF_UYVY: printf("DirectFB: layer format UYVY\n");
- break;
-#if DIRECTFBVERSION > 908
- case DSPF_YV12: printf("DirectFB: layer format YV12\n");
- break;
- case DSPF_I420: printf("DirectFB: layer format I420\n");
- break;
-#endif
- default: printf("DirectFB: - unknown format ->exit\n"); return 1;
- }
-
- ret =videolayer->SetConfiguration( videolayer, &dlc );
- if (!ret) {
- if (verbose) printf("DirectFB: SetConfiguration for layer OK\n");
-
-#ifdef FLIPPING
- // try to set flipping for videolayer
- if (do_flipping) {
- dlc.flags = DLCONF_BUFFERMODE;
- dlc.buffermode = DLBM_BACKVIDEO;
- invram = 1;
- flipping = 1;
- ret =videolayer->SetConfiguration( videolayer, &dlc );
- if (ret!=DFB_OK) {
- invram = 0;
- if (!((directfb_major_version <= 0) &&
- (directfb_minor_version <= 9) &&
- (directfb_micro_version <= 11))) {
-
- dlc.buffermode = DLBM_BACKSYSTEM;
- ret =videolayer->SetConfiguration( videolayer, &dlc );
- if (ret!=DFB_OK) {
- flipping = 0;
- }
- } else { flipping = 0; };
- }
- if (verbose) if (flipping) {
- printf("DirectFB: SetFlipping for layer: OK (vram=%i)\n",invram);
- } else {
- printf("DirectFB: SetFlipping for layer: FAILED\n");
- }
- } else flipping=0;
-#endif
- ret = videolayer->GetSurface( videolayer, &primary );
- if (!ret){
- videolayeractive=1;
- if (verbose) printf("DirectFB: Get surface for layer: OK\n");
- primaryallocated=1;
- // set videolayer to be visible
- videolayer->SetOpacity(videolayer,0xFF);
- } else {
- videolayeractive=0;
- if (videolayer) videolayer->SetOpacity(videolayer,0);
- };
- } else {
- videolayeractive=0;
- if (videolayer) videolayer->SetOpacity(videolayer,0);
- };
-
- }
-
-// for flipping we will use BitBlt not integrated directfb flip (if necessary)
- dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
- dsc.caps = DSCAPS_PRIMARY /*| DSCAPS_VIDEOONLY*/;
-
- switch (format) {
- case IMGFMT_RGB32: dsc.pixelformat = DSPF_ARGB; source_pixel_size= 4; break;
- case IMGFMT_BGR32: dsc.pixelformat = DSPF_ARGB; source_pixel_size= 4; break;
- case IMGFMT_RGB24: dsc.pixelformat = DSPF_RGB24; source_pixel_size= 3; break;
- case IMGFMT_BGR24: dsc.pixelformat = DSPF_RGB24; source_pixel_size= 3; break;
- case IMGFMT_RGB16: dsc.pixelformat = DSPF_RGB16; source_pixel_size= 2; break;
- case IMGFMT_BGR16: dsc.pixelformat = DSPF_RGB16; source_pixel_size= 2; break;
- case IMGFMT_RGB15: dsc.pixelformat = DSPF_RGB15; source_pixel_size= 2; break;
- case IMGFMT_BGR15: dsc.pixelformat = DSPF_RGB15; source_pixel_size= 2; break;
- default: dsc.pixelformat = DSPF_RGB24; source_pixel_size=2; break; //YUV formats
- };
-
- if (!videolayeractive) {
-#ifdef FLIPPING
- if (do_flipping) {
- flipping = 1;
- invram = 0;
- dsc.caps |= DSCAPS_FLIPPING;
- ret = dfb->CreateSurface( dfb, &dsc, &primary );
- if (ret!=DFB_OK) {
- dsc.caps &= ~DSCAPS_FLIPPING;
- DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
- flipping = 0;
- } else {
- // test flipping again
- DFBCHECK (primary->GetCapabilities(primary,&dsc.caps));
- if (!(dsc.caps & DSCAPS_FLIPPING)) {
- printf("DirectFB: Error - surface sucesfully created with flipping flag, but doesn't support it.\n");
- flipping = 0;
- } else {
- // test fliping in real - sometimes flips fails even if shouldn't
- DFBResult ret;
- ret = primary->Flip(primary,NULL,0);
- if (ret!=DFB_OK) {
- // recreate surface as non flipping
- printf("DirectFB: Error - surface sucesfully created with flipping flag, but test flip failed.\n");
- flipping = 0;
- dsc.caps &= ~DSCAPS_FLIPPING;
- primary->Release(primary);
- DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
- }
-
- }
- }
-/* if (verbose) if (flipping) {
- printf("DirectFB: Flipping for primary: OK\n");
- } else {
- printf("DirectFB: Flipping for primary: FAILED\n");
- }
-*/ } else {
- flipping = 0;
-#endif
- DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
-#ifdef FLIPPING
- }
-#endif
-
- if (verbose) printf("DirectFB: Get primary surface: OK\n");
-
- primaryallocated=1;
- }
-
-#ifdef FLIPPING
-// final check for flipping - based on real caps
-
- DFBCHECK (primary->GetCapabilities(primary,&dsc.caps));
- if (!(dsc.caps & DSCAPS_FLIPPING)) {
- printf("DirectFB: Flipping si NOT active.\n");
- flipping = 0;
- } else {
- printf("DirectFB: Flipping is active.\n");
- flipping = 1;
- }
-// }
-#endif
-
- DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
-
- DFBCHECK (primary->GetPixelFormat (primary, &frame_format));
-
-// temporary frame buffer
- dsc.flags = DSDESC_CAPS | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH;
-
- dsc.width = in_width;
- dsc.height = in_height;
-
- // at this time use pixel req format or format of main disp
-
- switch (format) {
- case IMGFMT_RGB32: dsc.pixelformat = DSPF_ARGB; break;
- case IMGFMT_BGR32: dsc.pixelformat = DSPF_ARGB; break;
- case IMGFMT_RGB24: dsc.pixelformat = DSPF_RGB24; break;
- case IMGFMT_BGR24: dsc.pixelformat = DSPF_RGB24; break;
- case IMGFMT_RGB16: dsc.pixelformat = DSPF_RGB16; break;
- case IMGFMT_BGR16: dsc.pixelformat = DSPF_RGB16; break;
- case IMGFMT_RGB15: dsc.pixelformat = DSPF_RGB15; break;
- case IMGFMT_BGR15: dsc.pixelformat = DSPF_RGB15; break;
- default: dsc.pixelformat = frame_format; break; // uknown or YUV -> retain layer format eg. RGB or YUY2
- };
-
-
- /*
- * Create a surface based on the description of the source frame
- */
-#if DIRECTFBVERSION > 908
- if (((dsc.pixelformat==DSPF_YV12)||(dsc.pixelformat==DSPF_I420)) && buggyYV12BitBlt) {
- memcpyBitBlt = 1;
- } else {
- memcpyBitBlt = 0;
- };
-#else
- memcpyBitBlt = 0;
-#endif
-
-
- // release frame if it is already allocated
- if (frameallocated) {
- if (verbose ) printf("DirectFB: Release frame\n");
- frame->Release (frame);
- frameallocated=0;
- };
-
-// picture size and position
-
- aspect_save_orig(in_width,in_height);
- aspect_save_prescale(d_width,d_height);
- if (videolayeractive) {// try to set pos for YUY2 layer and proper aspect ratio
- aspect_save_screenres(10000,10000);
- aspect(&out_width,&out_height,A_ZOOM);
-
- ret = videolayer->SetScreenLocation(videolayer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000));
-
- xoffset = 0;
- yoffset = 0;
- } else {
- // aspect ratio correction for zoom to fullscreen
- aspect_save_screenres(screen_width,screen_height);
-
- if(fs) /* -fs */
- aspect(&out_width,&out_height,A_ZOOM);
- else
- aspect(&out_width,&out_height,A_NOZOOM);
-
-
- xoffset = (screen_width - out_width) / 2;
- yoffset = (screen_height - out_height) / 2;
- }
-
- if (((out_width != in_width) || (out_height != in_height)) && (!videolayeractive)) {stretch = 1;} else stretch=0; //yuy doesn't like strech and should not be needed
-
-#ifdef FLIPPING
- // frame will not be allocated in case of overlay or nonstrech blit on primary
- if (flipping && (!stretch)) {
- frame = primary;
- frameallocated = 0;
- if (verbose) printf("DirectFB: Frame is NOT used (flipping is active).\n");
- } else {
-#endif
- /*
- dsc.caps = DSCAPS_SYSTEMONLY;
- //let dfb decide where frame should be - preparation for AGP support
- */
- dsc.flags &=~DSDESC_CAPS;
-
- DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame));
- frameallocated=1;
-#ifdef FLIPPING
- if (verbose) if (flipping) {
- printf("DirectFB: Frame created (flipping&stretch is active).\n");
- } else {
- printf("DirectFB: Frame created (flipping is NOT active).\n");
- };
- };
-#endif
-
- DFBCHECK (frame->GetPixelFormat (frame, &frame_format));
-
- switch (frame_format) {
- case DSPF_ARGB: if (verbose) printf("DirectFB: frame format ARGB\n");
- frame_pixel_size = 4;
- break;
- case DSPF_RGB32: if (verbose) printf("DirectFB: frame format RGB32\n");
- frame_pixel_size = 4;
- break;
- case DSPF_RGB24: if (verbose) printf("DirectFB: frame format RGB24\n");
- frame_pixel_size = 3;
- break;
- case DSPF_RGB16: if (verbose) printf("DirectFB: frame format RGB16\n");
- frame_pixel_size = 2;
- break;
- case DSPF_RGB15: if (verbose) printf("DirectFB: frame format RGB15\n");
- frame_pixel_size = 2;
- break;
- case DSPF_YUY2: if (verbose) printf("DirectFB: frame format YUY2\n");
- frame_pixel_size = 2;
- break;
- case DSPF_UYVY: if (verbose) printf("DirectFB: frame format UYVY\n");
- frame_pixel_size = 2;
- break;
-#if DIRECTFBVERSION > 908
- case DSPF_YV12: if (verbose) printf("DirectFB: frame format YV12\n");
- frame_pixel_size = 1;
- break;
- case DSPF_I420: if (verbose) printf("DirectFB: frame format I420\n");
- frame_pixel_size = 1;
- break;
-#endif
- default: printf("DirectFB: - unknown format ->exit\n"); return 1;
- }
-
- if ((out_width < in_width || out_height < in_height) && (!fs)) {
- printf("Screensize is smaller than video size !\n");
-// return 1; // doesn't matter we will rescale
- }
-
-
-
-// yuv2rgb transform init
-
- if (((format == IMGFMT_YV12) || (format == IMGFMT_YUY2)) && (!videolayeractive)){ yuv2rgb_init(frame_pixel_size * 8,MODE_RGB);};
-
- if ((verbose)&&(memcpyBitBlt)) printf("DirectFB: Using memcpyBitBlt\n");
-#ifdef DIRECTRENDER
-//direct rendering is enabled in case of same buffer and img format
- if ((format==IMGFMT_RGB32)&&(frame_format ==DSPF_ARGB) ||
- (format==IMGFMT_BGR32)&&(frame_format ==DSPF_ARGB) ||
- (format==IMGFMT_RGB24)&&(frame_format ==DSPF_RGB24) ||
- (format==IMGFMT_BGR24)&&(frame_format ==DSPF_RGB24) ||
- (format==IMGFMT_RGB16)&&(frame_format ==DSPF_RGB16) ||
- (format==IMGFMT_BGR16)&&(frame_format ==DSPF_RGB16) ||
- (format==IMGFMT_RGB15)&&(frame_format ==DSPF_RGB15) ||
- (format==IMGFMT_BGR15)&&(frame_format ==DSPF_RGB15) ||
-#if DIRECTFBVERSION > 908
- (format==IMGFMT_YUY2)&&(frame_format ==DSPF_YUY2) ||
- (format==IMGFMT_YV12)&&(frame_format ==DSPF_I420) ||
- (format==IMGFMT_YV12)&&(frame_format ==DSPF_YV12)){
-#else
- (format==IMGFMT_YUY2)&&(frame_format ==DSPF_YUY2)){
-#endif
- dr_enabled=1;
- if (verbose) printf("DirectF