Mercurial > mplayer.hg
annotate libvo/vo_directfb.c @ 5373:b476f5d1c91e
10l to nick - ACCEPT_WIDTH fixed
author | arpi |
---|---|
date | Wed, 27 Mar 2002 21:49:19 +0000 |
parents | c9ccddcbdd81 |
children | 1972c3475d93 |
rev | line source |
---|---|
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1 /* |
3341 | 2 MPlayer video driver for DirectFramebuffer device |
3 | |
4 (C) 2001 | |
5 | |
6 Written by Jiri Svoboda <Jiri.Svoboda@seznam.cz> | |
7 | |
8 Inspired by vo_sdl and vo_fbdev. | |
9 | |
10 To get second head working delete line 120 | |
11 from fbdev.c (from DirectFB sources version 0.9.7) | |
12 Line contains following: | |
13 fbdev->fd = open( "/dev/fb0", O_RDWR ); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
14 |
3341 | 15 Parts of this code taken from DirectFB examples: |
16 (c) Copyright 2000 convergence integrated media GmbH. | |
17 All rights reserved. | |
18 | |
19 This library is free software; you can redistribute it and/or | |
20 modify it under the terms of the GNU Lesser General Public | |
21 License as published by the Free Software Foundation; either | |
22 version 2 of the License, or (at your option) any later version. | |
23 | |
24 This library is distributed in the hope that it will be useful, | |
25 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 Lesser General Public License for more details. | |
28 | |
29 You should have received a copy of the GNU Lesser General Public | |
30 License along with this library; if not, write to the | |
31 Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
32 Boston, MA 02111-1307, USA. | |
33 */ | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
34 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
35 // directfb includes |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
36 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
37 #include <directfb.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
38 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
39 // other things |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
40 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
41 #include <stdio.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
42 #include <stdlib.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
43 #include <string.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
44 #include <fcntl.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
45 #include <unistd.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
46 #include <errno.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
47 #include <ctype.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
48 #include <assert.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
49 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
50 #include <sys/mman.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
51 #include <sys/ioctl.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
52 #include <sys/kd.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
53 #include <linux/fb.h> |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
54 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
55 #include "config.h" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
56 #include "video_out.h" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
57 #include "video_out_internal.h" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
58 #include "fastmemcpy.h" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
59 #include "sub.h" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
60 #include "../postproc/rgb2rgb.h" |
5189 | 61 #include "aspect.h" |
62 #include "../mp_image.h" | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
63 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
64 LIBVO_EXTERN(directfb) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
65 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
66 static vo_info_t vo_info = { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
67 "Direct Framebuffer Device", |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
68 "directfb", |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
69 "Jiri Svoboda Jiri.Svoboda@seznam.cz", |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
70 "" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
71 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
72 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
73 extern int verbose; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
74 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
75 /****************************** |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
76 * directfb * |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
77 ******************************/ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
78 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
79 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
80 * (Globals) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
81 */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
82 static IDirectFB *dfb = NULL; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
83 static IDirectFBSurface *primary = NULL; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
84 static IDirectFBInputDevice *keyboard = NULL; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
85 static IDirectFBDisplayLayer *videolayer = NULL; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
86 static DFBDisplayLayerConfig dlc; |
5189 | 87 static unsigned int screen_width = 0; |
88 static unsigned int screen_height = 0; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
89 static DFBSurfacePixelFormat frame_format; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
90 static unsigned int frame_pixel_size = 0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
91 static unsigned int source_pixel_size = 0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
92 static int xoffset=0,yoffset=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
93 #define DFBCHECK(x...) \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
94 { \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
95 DFBResult err = x; \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
96 \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
97 if (err != DFB_OK) \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
98 { \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
99 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
100 DirectFBErrorFatal( #x, err ); \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
101 } \ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
102 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
103 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
104 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
105 * The frame is to be loaded into a surface that we can blit from. |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
106 */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
107 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
108 static IDirectFBSurface *frame = NULL; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
109 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
110 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
111 * A buffer for input events. |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
112 */ |
5026
693b917ac916
DirectFB 0.9.9 support - patch by Aubin Paul <aubin@punknews.org>
arpi
parents:
4596
diff
changeset
|
113 |
693b917ac916
DirectFB 0.9.9 support - patch by Aubin Paul <aubin@punknews.org>
arpi
parents:
4596
diff
changeset
|
114 #ifdef HAVE_DIRECTFB099 |
693b917ac916
DirectFB 0.9.9 support - patch by Aubin Paul <aubin@punknews.org>
arpi
parents:
4596
diff
changeset
|
115 static IDirectFBEventBuffer *buffer = NULL; |
693b917ac916
DirectFB 0.9.9 support - patch by Aubin Paul <aubin@punknews.org>
arpi
parents:
4596
diff
changeset
|
116 #else |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
117 static IDirectFBInputBuffer *buffer = NULL; |
5026
693b917ac916
DirectFB 0.9.9 support - patch by Aubin Paul <aubin@punknews.org>
arpi
parents:
4596
diff
changeset
|
118 #endif |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
119 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
120 /****************************** |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
121 * vo_directfb * |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
122 ******************************/ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
123 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
124 /* command line/config file options */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
125 #ifdef HAVE_FBDEV |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
126 extern char *fb_dev_name; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
127 #else |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
128 char *fb_dev_name; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
129 #endif |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
130 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
131 static void (*draw_alpha_p)(int w, int h, unsigned char *src, |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
132 unsigned char *srca, int stride, unsigned char *dst, |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
133 int dstride); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
134 |
5189 | 135 static uint32_t in_width; |
136 static uint32_t in_height; | |
137 static uint32_t out_width=1; | |
138 static uint32_t out_height=1; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
139 static uint32_t pixel_format; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
140 static int fs; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
141 static int flip; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
142 static int stretch=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
143 struct modes_t { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
144 int valid; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
145 unsigned int width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
146 unsigned int height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
147 int overx,overy; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
148 } modes [4]; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
149 static unsigned int best_bpp=5; |
5189 | 150 // videolayer stuff |
151 static int videolayeractive=0; | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
152 static int videolayerpresent=0; |
5189 | 153 //some info about videolayer - filled on preinit |
154 struct vlayer_t { | |
155 int iv12; | |
156 int i420; | |
157 int yuy2; | |
158 int uyvy; | |
159 int brightness; | |
160 int saturation; | |
161 int contrast; | |
162 int hue; | |
163 } videolayercaps; | |
164 // workabout for DirectFB bug | |
165 static int buggyYV12BitBlt=0; | |
166 static int memcpyBitBlt=0; | |
167 #define DIRECTRENDER | |
168 #ifdef DIRECTRENDER | |
169 static int dr_enabled=0; | |
170 static int framelocked=0; | |
171 #endif | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
172 // primary & frame stuff |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
173 static int frameallocated=0; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
174 static int primaryallocated=0; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
175 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
176 DFBEnumerationResult enum_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
177 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
178 int overx=0,overy=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
179 unsigned int index=bpp/8-1; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
180 int allow_under=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
181 |
5189 | 182 if (verbose) printf("DirectFB: Validator entered %i %i %i\n",width,height,bpp); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
183 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
184 overx=width-out_width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
185 overy=height-out_height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
186 if (!modes[index].valid) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
187 modes[index].valid=1; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
188 modes[index].width=width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
189 modes[index].height=height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
190 modes[index].overx=overx; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
191 modes[index].overy=overy; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
192 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
193 if ((modes[index].overy<0)||(modes[index].overx<0)) allow_under=1; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
194 if (abs(overx*overy)<abs(modes[index].overx * modes[index].overy)) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
195 if (((overx>=0)&&(overy>=0)) || allow_under) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
196 modes[index].valid=1; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
197 modes[index].width=width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
198 modes[index].height=height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
199 modes[index].overx=overx; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
200 modes[index].overy=overy; |
5189 | 201 if (verbose) printf("DirectFB:Better mode added %i %i %i\n",width,height,bpp); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
202 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
203 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
204 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
205 return DFENUM_OK; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
206 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
207 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
208 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
209 DFBEnumerationResult enum_layers_callback( unsigned int id, |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
210 DFBDisplayLayerCapabilities caps, |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
211 void *data ) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
212 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
213 IDirectFBDisplayLayer **layer = (IDirectFBDisplayLayer **)data; |
5189 | 214 if (verbose) { |
215 printf("\nDirectFB: Layer %d:\n", id ); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
216 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
217 if (caps & DLCAPS_SURFACE) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
218 printf( " - Has a surface.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
219 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
220 if (caps & DLCAPS_ALPHACHANNEL) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
221 printf( " - Supports blending based on alpha channel.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
222 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
223 if (caps & DLCAPS_COLORKEYING) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
224 printf( " - Supports color keying.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
225 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
226 if (caps & DLCAPS_FLICKER_FILTERING) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
227 printf( " - Supports flicker filtering.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
228 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
229 if (caps & DLCAPS_INTERLACED_VIDEO) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
230 printf( " - Can natively display interlaced video.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
231 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
232 if (caps & DLCAPS_OPACITY) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
233 printf( " - Supports blending based on global alpha factor.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
234 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
235 if (caps & DLCAPS_SCREEN_LOCATION) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
236 printf( " - Can be positioned on the screen.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
237 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
238 if (caps & DLCAPS_BRIGHTNESS) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
239 printf( " - Brightness can be adjusted.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
240 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
241 if (caps & DLCAPS_CONTRAST) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
242 printf( " - Contrast can be adjusted.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
243 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
244 if (caps & DLCAPS_HUE) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
245 printf( " - Hue can be adjusted.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
246 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
247 if (caps & DLCAPS_SATURATION) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
248 printf( " - Saturation can be adjusted.\n" ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
249 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
250 printf("\n"); |
5189 | 251 } |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
252 /* We take the first layer not being the primary */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
253 if (id != DLID_PRIMARY) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
254 DFBResult ret; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
255 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
256 ret = dfb->GetDisplayLayer( dfb, id, layer ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
257 if (ret) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
258 DirectFBError( "dfb->GetDisplayLayer failed", ret ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
259 else |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
260 return DFENUM_CANCEL; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
261 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
262 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
263 return DFENUM_OK; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
264 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
265 |
4354 | 266 static uint32_t preinit(const char *arg) |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
267 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
268 DFBSurfaceDescription dsc; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
269 DFBResult ret; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
270 DFBDisplayLayerConfigFlags failed; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
271 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
272 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
273 * (Initialize) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
274 */ |
5189 | 275 |
276 if (verbose) printf("DirectFB: Preinit entered\n"); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
277 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
278 DFBCHECK (DirectFBInit (NULL,NULL)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
279 |
3651
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
280 if ((directfb_major_version >= 0) && |
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
281 (directfb_minor_version >= 9) && |
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
282 (directfb_micro_version >= 7)) |
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
283 { |
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
284 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) fb_dev_name = "/dev/fb0"; |
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
285 DFBCHECK (DirectFBSetOption ("fbdev",fb_dev_name)); |
8148193fee93
working with 0.9.6 too (0.9.6 is coming with debian woody)
alex
parents:
3588
diff
changeset
|
286 } |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
287 |
5189 | 288 // disable YV12 for dfb 0.9.9 - there is a bug in dfb! |
289 if ((directfb_major_version <= 0) && | |
290 (directfb_minor_version <= 9) && | |
291 (directfb_micro_version <= 9)) { | |
292 buggyYV12BitBlt=1; | |
293 if (verbose) printf("DirectFB: Buggy YV12BitBlt!\n"); | |
294 } | |
295 | |
3588
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
296 // uncomment this if you do not wish to create a new vt for DirectFB |
5189 | 297 DFBCHECK (DirectFBSetOption ("no-vt-switch","")); |
3588
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
298 |
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
299 // uncomment this if you want to allow vt switching |
5189 | 300 DFBCHECK (DirectFBSetOption ("vt-switching","")); |
301 #ifdef HAVE_DIRECTFB099 | |
302 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9) | |
303 DFBCHECK (DirectFBSetOption ("no-cursor","")); | |
304 #endif | |
305 | |
3588
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
306 DFBCHECK (DirectFBSetOption ("bg-color","00000000")); |
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
307 |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
308 DFBCHECK (DirectFBCreate (&dfb)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
309 DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
310 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
311 // lets try to get YUY2 layer - borrowed from DirectFb examples |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
312 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
313 /* Enumerate display layers */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
314 DFBCHECK (dfb->EnumDisplayLayers( dfb, enum_layers_callback, &videolayer )); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
315 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
316 if (!videolayer) { |
5189 | 317 if (verbose) printf("DirectFB: No videolayer found\n"); |
318 // no videolayer found | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
319 // printf( "\nNo additional layers have been found.\n" ); |
5189 | 320 videolayeractive=0; |
321 | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
322 } else { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
323 |
5189 | 324 // there is an additional layer so test it for YUV formats |
325 // some videolayers support RGB formats - not used now | |
326 if (verbose) printf("DirectFB: Testing videolayer caps\n"); | |
327 | |
328 dlc.flags = DLCONF_PIXELFORMAT; | |
329 #ifdef HAVE_DIRECTFB099 | |
330 dlc.pixelformat = DSPF_YV12; | |
331 ret = videolayer->TestConfiguration( videolayer, &dlc, &failed ); | |
332 if (ret==DFB_OK) { | |
333 videolayercaps.iv12=1; | |
334 if (verbose) printf("DirectFB: Videolayer supports YV12 format\n"); | |
335 } else { | |
336 videolayercaps.iv12=0; | |
337 if (verbose) printf("DirectFB: Videolayer doesn't support YV12 format\n"); | |
338 }; | |
339 | |
340 dlc.pixelformat = DSPF_I420; | |
341 ret = videolayer->TestConfiguration( videolayer, &dlc, &failed ); | |
342 if (ret==DFB_OK) { | |
343 videolayercaps.i420=1; | |
344 if (verbose) printf("DirectFB: Videolayer supports I420 format\n"); | |
345 } else { | |
346 videolayercaps.i420=0; | |
347 if (verbose) printf("DirectFB: Videolayer doesn't support I420 format\n"); | |
348 }; | |
349 #else | |
350 videolayercaps.yuy2=0; | |
351 #endif | |
352 | |
353 dlc.pixelformat = DSPF_YUY2; | |
354 ret = videolayer->TestConfiguration( videolayer, &dlc, &failed ); | |
355 if (ret==DFB_OK) { | |
356 videolayercaps.yuy2=1; | |
357 if (verbose) printf("DirectFB: Videolayer supports YUY2 format\n"); | |
358 } else { | |
359 videolayercaps.yuy2=0; | |
360 if (verbose) printf("DirectFB: Videolayer doesn't support YUY2 format\n"); | |
361 }; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
362 |
5189 | 363 dlc.pixelformat = DSPF_UYVY; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
364 ret = videolayer->TestConfiguration( videolayer, &dlc, &failed ); |
5189 | 365 if (ret==DFB_OK) { |
366 videolayercaps.uyvy=1; | |
367 if (verbose) printf("DirectFB: Videolayer supports UYVY format\n"); | |
368 } else { | |
369 videolayercaps.uyvy=0; | |
370 if (verbose) printf("DirectFB: Videolayer doesn't support UYVY format\n"); | |
371 }; | |
372 | |
373 // test for color caps | |
374 { | |
375 DFBDisplayLayerCapabilities caps; | |
376 videolayer->GetCapabilities(videolayer,&caps); | |
377 if (caps & DLCAPS_BRIGHTNESS) { | |
378 videolayercaps.brightness=1; | |
379 } else { | |
380 videolayercaps.brightness=0; | |
381 }; | |
382 | |
383 if (caps & DLCAPS_CONTRAST) { | |
384 videolayercaps.contrast=1; | |
385 } else { | |
386 videolayercaps.contrast=0; | |
387 }; | |
388 | |
389 if (caps & DLCAPS_HUE) { | |
390 videolayercaps.hue=1; | |
391 } else { | |
392 videolayercaps.hue=0; | |
393 }; | |
394 | |
395 if (caps & DLCAPS_SATURATION) { | |
396 videolayercaps.saturation=1; | |
397 } else { | |
398 videolayercaps.saturation=0; | |
399 }; | |
400 | |
401 | |
402 } | |
403 | |
404 | |
405 // is there a working yuv ? if no we will not use videolayer | |
406 if ((videolayercaps.iv12==0)&&(videolayercaps.i420==0)&&(videolayercaps.yuy2==0)&&(videolayercaps.uyvy==0)) { | |
407 // videolayer doesn't work with yuv so release it | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
408 videolayerpresent=0; |
5189 | 409 videolayer->SetOpacity(videolayer,0); |
410 videolayer->Release(videolayer); | |
411 } else { | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
412 videolayerpresent=1; |
5189 | 413 }; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
414 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
415 |
5189 | 416 // just look at RGB things for main layer |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
417 modes[0].valid=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
418 modes[1].valid=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
419 modes[2].valid=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
420 modes[3].valid=0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
421 DFBCHECK (dfb->EnumVideoModes(dfb,enum_modes_callback,NULL)); |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
422 |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
423 /* |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
424 * (Get keyboard) |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
425 */ |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
426 DFBCHECK (dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard)); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
427 |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
428 /* |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
429 * Create an input buffer for the keyboard. |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
430 */ |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
431 #ifdef HAVE_DIRECTFB099 |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
432 DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer)); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
433 #else |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
434 DFBCHECK (keyboard->CreateInputBuffer (keyboard, &buffer)); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
435 #endif |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
436 // just to start with clean ... |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
437 buffer->Reset(buffer); |
4359
266ebffd8fc9
no longer required to call preinit from init and query_format, mplayer.c does this
alex
parents:
4354
diff
changeset
|
438 return 0; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
439 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
440 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
441 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
442 |
4433 | 443 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
444 uint32_t d_height, uint32_t fullscreen, char *title, |
4433 | 445 uint32_t format,const vo_tune_info_t *info) |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
446 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
447 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
448 * (Locals) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
449 */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
450 DFBSurfaceDescription dsc; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
451 DFBResult ret; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
452 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
453 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
454 int vm = fullscreen & 0x02; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
455 int zoom = fullscreen & 0x04; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
456 |
5189 | 457 if (verbose) printf("DirectFB: Config entered [%ix%i]\n",width,height); |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
458 if (verbose) printf("DirectFB: With requested format: %s\n",vo_format_name(format)); |
5189 | 459 |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
460 fs = fullscreen & 0x01; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
461 flip = fullscreen & 0x08; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
462 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
463 pixel_format=format; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
464 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
465 in_width = width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
466 in_height = height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
467 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
468 if (d_width) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
469 out_width = d_width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
470 out_height = d_height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
471 } else { |
5189 | 472 d_width = out_width = in_width; |
473 d_height = out_height = in_height; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
474 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
475 |
5189 | 476 // just look at RGB things for main layer - once again - now we now desired screen size |
477 modes[0].valid=0; | |
478 modes[1].valid=0; | |
479 modes[2].valid=0; | |
480 modes[3].valid=0; | |
481 DFBCHECK (dfb->EnumVideoModes(dfb,enum_modes_callback,NULL)); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
482 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
483 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
484 if (vm) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
485 // need better algorithm just hack |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
486 if (modes[source_pixel_size-1].valid) dfb->SetVideoMode(dfb,modes[source_pixel_size-1].width,modes[source_pixel_size-1].height,source_pixel_size); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
487 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
488 |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
489 // release primary if it is already allocated |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
490 if (primaryallocated) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
491 if (verbose ) printf("DirectFB: Release primary\n"); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
492 primary->Release (primary); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
493 primaryallocated=0; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
494 }; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
495 |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
496 videolayeractive=0; // will be enabled on succes later |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
497 |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
498 if (videolayerpresent) { |
5189 | 499 |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
500 // try to set proper w a h values matching image size |
5189 | 501 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
502 dlc.width = in_width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
503 dlc.height = in_height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
504 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
505 ret = videolayer->SetConfiguration( videolayer, &dlc ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
506 |
5189 | 507 if (ret) { |
508 if (verbose) printf("DirectFB: Set layer size failed\n"); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
509 }; |
5189 | 510 |
511 // try to set correct pixel format (closest to required) | |
512 | |
513 dlc.flags = DLCONF_PIXELFORMAT; | |
514 dlc.pixelformat = 0; | |
515 switch (pixel_format) { | |
516 case IMGFMT_YV12: | |
517 #ifdef HAVE_DIRECTFB099 | |
518 if (videolayercaps.i420==1) { | |
519 dlc.pixelformat=DSPF_I420; | |
520 break; | |
521 } else if (videolayercaps.iv12==1) { | |
522 dlc.pixelformat=DSPF_YV12; | |
523 break; | |
524 }; | |
525 | |
526 #endif | |
527 case IMGFMT_YUY2: if (videolayercaps.yuy2==1) { | |
528 dlc.pixelformat=DSPF_YUY2; | |
529 break; | |
530 // temporary disabled - do not have conv tool to uyvy | |
531 /* } else if (videolayercaps.uyvy==1) { | |
532 dlc.pixelformat=DSPF_UYVY; | |
533 break; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
534 */ |
5189 | 535 #ifdef HAVE_DIRECTFB099 |
536 } else if (videolayercaps.i420==1) { | |
537 dlc.pixelformat=DSPF_I420; | |
538 break; | |
539 } else if (videolayercaps.iv12==1) { | |
540 dlc.pixelformat=DSPF_YV12; | |
541 break; | |
542 #endif | |
543 }; | |
544 // shouldn't happen - if it reaches here -> bug | |
545 | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
546 case IMGFMT_RGB32: dlc.pixelformat = DSPF_ARGB; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
547 case IMGFMT_BGR32: dlc.pixelformat = DSPF_ARGB; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
548 case IMGFMT_RGB24: dlc.pixelformat = DSPF_RGB24; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
549 case IMGFMT_BGR24: dlc.pixelformat = DSPF_RGB24; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
550 case IMGFMT_RGB16: dlc.pixelformat = DSPF_RGB16; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
551 case IMGFMT_BGR16: dlc.pixelformat = DSPF_RGB16; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
552 case IMGFMT_RGB15: dlc.pixelformat = DSPF_RGB15; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
553 case IMGFMT_BGR15: dlc.pixelformat = DSPF_RGB15; break; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
554 default: dlc.pixelformat = DSPF_RGB24; break; |
5189 | 555 } |
556 | |
557 if (verbose) switch (dlc.pixelformat) { | |
558 case DSPF_ARGB: printf("DirectFB: layer format ARGB\n"); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
559 break; |
5189 | 560 case DSPF_RGB32: printf("DirectFB: layer format RGB32\n"); |
561 break; | |
562 case DSPF_RGB24: printf("DirectFB: layer format RGB24\n"); | |
563 break; | |
564 case DSPF_RGB16: printf("DirectFB: layer format RGB16\n"); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
565 break; |
5189 | 566 case DSPF_RGB15: printf("DirectFB: layer format RGB15\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
567 break; |
5189 | 568 case DSPF_YUY2: printf("DirectFB: layer format YUY2\n"); |
569 break; | |
570 case DSPF_UYVY: printf("DirectFB: layer format UYVY\n"); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
571 break; |
5189 | 572 #ifdef HAVE_DIRECTFB099 |
573 case DSPF_YV12: printf("DirectFB: layer format YV12\n"); | |
574 break; | |
575 case DSPF_I420: printf("DirectFB: layer format I420\n"); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
576 break; |
5189 | 577 #endif |
578 default: printf("DirectFB: - unknown format ->exit\n"); return 1; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
579 } |
5189 | 580 |
581 ret =videolayer->SetConfiguration( videolayer, &dlc ); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
582 if (!ret) { |
5189 | 583 if (verbose) printf("DirectFB: SetConfiguration for layer OK\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
584 ret = videolayer->GetSurface( videolayer, &primary ); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
585 if (!ret){ |
5189 | 586 videolayeractive=1; |
587 if (verbose) printf("DirectFB: Get surface for layer OK\n"); | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
588 primaryallocated=1; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
589 } else { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
590 videolayeractive=0; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
591 if (videolayer) videolayer->SetOpacity(videolayer,0); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
592 }; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
593 } else { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
594 videolayeractive=0; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
595 if (videolayer) videolayer->SetOpacity(videolayer,0); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
596 }; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
597 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
598 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
599 |
5189 | 600 // for flipping we will use BitBlt not integrated directfb flip |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
601 dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
602 dsc.caps = DSCAPS_PRIMARY | DSCAPS_VIDEOONLY;//| DSCAPS_FLIPPING; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
603 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
604 switch (format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
605 case IMGFMT_RGB32: dsc.pixelformat = DSPF_ARGB; source_pixel_size= 4; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
606 case IMGFMT_BGR32: dsc.pixelformat = DSPF_ARGB; source_pixel_size= 4; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
607 case IMGFMT_RGB24: dsc.pixelformat = DSPF_RGB24; source_pixel_size= 3; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
608 case IMGFMT_BGR24: dsc.pixelformat = DSPF_RGB24; source_pixel_size= 3; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
609 case IMGFMT_RGB16: dsc.pixelformat = DSPF_RGB16; source_pixel_size= 2; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
610 case IMGFMT_BGR16: dsc.pixelformat = DSPF_RGB16; source_pixel_size= 2; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
611 case IMGFMT_RGB15: dsc.pixelformat = DSPF_RGB15; source_pixel_size= 2; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
612 case IMGFMT_BGR15: dsc.pixelformat = DSPF_RGB15; source_pixel_size= 2; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
613 default: dsc.pixelformat = DSPF_RGB24; source_pixel_size=2; break; //YUV formats |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
614 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
615 |
5189 | 616 if (!videolayeractive) { |
617 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary )); | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
618 if (verbose) printf("DirectFB: Get primary surface OK\n"); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
619 primaryallocated=1; |
5189 | 620 } |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
621 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
622 DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
623 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
624 DFBCHECK (primary->GetPixelFormat (primary, &frame_format)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
625 |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
626 // temporary frame buffer |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
627 dsc.flags = DSDESC_CAPS | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
628 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
629 dsc.width = in_width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
630 dsc.height = in_height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
631 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
632 // at this time use pixel req format or format of main disp |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
633 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
634 switch (format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
635 case IMGFMT_RGB32: dsc.pixelformat = DSPF_ARGB; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
636 case IMGFMT_BGR32: dsc.pixelformat = DSPF_ARGB; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
637 case IMGFMT_RGB24: dsc.pixelformat = DSPF_RGB24; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
638 case IMGFMT_BGR24: dsc.pixelformat = DSPF_RGB24; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
639 case IMGFMT_RGB16: dsc.pixelformat = DSPF_RGB16; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
640 case IMGFMT_BGR16: dsc.pixelformat = DSPF_RGB16; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
641 case IMGFMT_RGB15: dsc.pixelformat = DSPF_RGB15; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
642 case IMGFMT_BGR15: dsc.pixelformat = DSPF_RGB15; break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
643 default: dsc.pixelformat = frame_format; break; // uknown or YUV -> retain layer format eg. RGB or YUY2 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
644 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
645 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
646 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
647 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
648 * Create a surface based on the description of the source frame |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
649 */ |
5189 | 650 #ifdef HAVE_DIRECTFB099 |
651 if (((dsc.pixelformat==DSPF_YV12)||(dsc.pixelformat==DSPF_I420)) && buggyYV12BitBlt) { | |
652 memcpyBitBlt = 1; | |
653 } else { | |
654 memcpyBitBlt = 0; | |
655 }; | |
656 #else | |
657 memcpyBitBlt = 0; | |
658 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
659 |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
660 // release frame if it is already allocated |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
661 if (frameallocated) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
662 if (verbose ) printf("DirectFB: Release frame\n"); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
663 frame->Release (frame); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
664 frameallocated=0; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
665 }; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
666 |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
667 |
5189 | 668 // prevent from memcpy from videomemory to videomemory |
669 /* if (memcpyBitBlt) { | |
670 dsc.caps = DSCAPS_SYSTEMONLY; | |
671 } else { | |
672 dsc.caps = DSCAPS_VIDEOONLY; | |
673 } | |
674 ret = dfb->CreateSurface( dfb, &dsc, &frame); | |
675 if (ret) { | |
676 if (verbose) printf ("DirectFB: Trying do create buffer in system memory (2)\n");*/ | |
677 dsc.caps = DSCAPS_SYSTEMONLY; | |
678 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame)); | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
679 frameallocated=1; |
5189 | 680 // } |
681 | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
682 DFBCHECK (frame->GetPixelFormat (frame, &frame_format)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
683 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
684 switch (frame_format) { |
5189 | 685 case DSPF_ARGB: if (verbose) printf("DirectFB: frame format ARGB\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
686 frame_pixel_size = 4; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
687 break; |
5189 | 688 case DSPF_RGB32: if (verbose) printf("DirectFB: frame format RGB32\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
689 frame_pixel_size = 4; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
690 break; |
5189 | 691 case DSPF_RGB24: if (verbose) printf("DirectFB: frame format RGB24\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
692 frame_pixel_size = 3; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
693 break; |
5189 | 694 case DSPF_RGB16: if (verbose) printf("DirectFB: frame format RGB16\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
695 frame_pixel_size = 2; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
696 break; |
5189 | 697 case DSPF_RGB15: if (verbose) printf("DirectFB: frame format RGB15\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
698 frame_pixel_size = 2; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
699 break; |
5189 | 700 case DSPF_YUY2: if (verbose) printf("DirectFB: frame format YUY2\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
701 frame_pixel_size = 2; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
702 break; |
5189 | 703 case DSPF_UYVY: if (verbose) printf("DirectFB: frame format UYVY\n"); |
704 frame_pixel_size = 2; | |
705 break; | |
706 #ifdef HAVE_DIRECTFB099 | |
707 case DSPF_YV12: if (verbose) printf("DirectFB: frame format YV12\n"); | |
708 frame_pixel_size = 1; | |
709 break; | |
710 case DSPF_I420: if (verbose) printf("DirectFB: frame format I420\n"); | |
711 frame_pixel_size = 1; | |
712 break; | |
713 #endif | |
714 default: printf("DirectFB: - unknown format ->exit\n"); return 1; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
715 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
716 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
717 if ((out_width < in_width || out_height < in_height) && (!fs)) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
718 printf("Screensize is smaller than video size !\n"); |
5189 | 719 // return 1; // doesn't matter we will rescale |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
720 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
721 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
722 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
723 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
724 // yuv2rgb transform init |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
725 |
5189 | 726 if (((format == IMGFMT_YV12) || (format == IMGFMT_YUY2)) && (!videolayeractive)){ yuv2rgb_init(frame_pixel_size * 8,MODE_RGB);}; |
727 | |
728 // picture size and position | |
729 | |
730 aspect_save_orig(in_width,in_height); | |
731 aspect_save_prescale(d_width,d_height); | |
732 if (videolayeractive) {// try to set pos for YUY2 layer and proper aspect ratio | |
733 aspect_save_screenres(10000,10000); | |
734 aspect(&out_width,&out_height,A_ZOOM); | |
735 | |
736 ret = videolayer->SetScreenLocation(videolayer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000)); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
737 |
5189 | 738 xoffset = 0; |
739 yoffset = 0; | |
740 } else { | |
741 // aspect ratio correction for zoom to fullscreen | |
742 aspect_save_screenres(screen_width,screen_height); | |
743 | |
744 if(fs) /* -fs */ | |
745 aspect(&out_width,&out_height,A_ZOOM); | |
746 else | |
747 aspect(&out_width,&out_height,A_NOZOOM); | |
748 | |
749 | |
750 xoffset = (screen_width - out_width) / 2; | |
751 yoffset = (screen_height - out_height) / 2; | |
752 } | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
753 |
5189 | 754 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 |
755 | |
756 if ((verbose)&&(memcpyBitBlt)) printf("DirectFB: Using memcpyBitBlt\n"); | |
757 #ifdef DIRECTRENDER | |
758 //direct rendering is enabled in case of sane buffer and im format | |
759 if ((format==IMGFMT_RGB32)&&(frame_format ==DSPF_ARGB) || | |
760 (format==IMGFMT_BGR32)&&(frame_format ==DSPF_ARGB) || | |
761 (format==IMGFMT_RGB24)&&(frame_format ==DSPF_RGB24) || | |
762 (format==IMGFMT_BGR24)&&(frame_format ==DSPF_RGB24) || | |
763 (format==IMGFMT_RGB16)&&(frame_format ==DSPF_RGB16) || | |
764 (format==IMGFMT_BGR16)&&(frame_format ==DSPF_RGB16) || | |
765 (format==IMGFMT_RGB15)&&(frame_format ==DSPF_RGB15) || | |
766 (format==IMGFMT_BGR15)&&(frame_format ==DSPF_RGB15) || | |
767 #ifdef HAVE_DIRECTFB099 | |
768 (format==IMGFMT_YUY2)&&(frame_format ==DSPF_YUY2) || | |
769 (format==IMGFMT_YV12)&&(frame_format ==DSPF_I420) || | |
770 (format==IMGFMT_YV12)&&(frame_format ==DSPF_YV12)){ | |
771 #else | |
772 (format==IMGFMT_YUY2)&&(frame_format ==DSPF_YUY2)){ | |
773 #endif | |
774 dr_enabled=1; | |
775 if (verbose) printf("DirectFB: Direct rendering supported\n"); | |
776 } else { | |
777 dr_enabled=0; | |
778 if (verbose) printf("DirectFB: Direct rendering not supported\n"); | |
779 }; | |
780 #endif | |
781 | |
782 | |
783 if (verbose) printf("DirectFB: Config finished [%ix%i]\n",out_width,out_height); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
784 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
785 return 0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
786 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
787 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
788 static uint32_t query_format(uint32_t format) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
789 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
790 int ret = 0x4; /* osd/sub is supported on every bpp */ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
791 |
4359
266ebffd8fc9
no longer required to call preinit from init and query_format, mplayer.c does this
alex
parents:
4354
diff
changeset
|
792 // preinit(NULL); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
793 |
5189 | 794 if (verbose ) printf("DirectFB: Format query: %s\n",vo_format_name(format)); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
795 switch (format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
796 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
797 // RGB mode works only if color depth is same as on screen and this driver doesn't know before init |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
798 // so we couldn't report supported formats well |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
799 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
800 // Just support those detected by preinit |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
801 case IMGFMT_RGB32: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
802 case IMGFMT_BGR32: if (modes[3].valid) return ret|0x2; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
803 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
804 case IMGFMT_RGB24: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
805 case IMGFMT_BGR24: if (modes[2].valid) return ret|0x2; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
806 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
807 case IMGFMT_RGB16: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
808 case IMGFMT_BGR16: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
809 case IMGFMT_RGB15: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
810 case IMGFMT_BGR15: if (modes[1].valid) return ret|0x2; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
811 break; |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
812 case IMGFMT_YUY2: if (videolayerpresent) { |
5189 | 813 if (videolayercaps.yuy2) { |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
814 return ret|0x2|0x1; |
5189 | 815 } else { |
816 return ret|0x1; | |
817 }; | |
818 }; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
819 break; |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
820 case IMGFMT_YV12: if ((videolayerpresent) && |
5189 | 821 (videolayercaps.i420 || videolayercaps.iv12)) |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
822 return ret|0x2|0x1; else return ret|0x1; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
823 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
824 // YV12 should work in all cases |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
825 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
826 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
827 return 0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
828 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
829 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
830 static const vo_info_t *get_info(void) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
831 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
832 return &vo_info; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
833 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
834 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
835 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
836 unsigned char *srca, int stride) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
837 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
838 void *dst; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
839 int pitch; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
840 int len; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
841 |
5189 | 842 #ifdef DIRECTRENDER |
843 if(framelocked) { | |
844 frame->Unlock(frame); | |
845 framelocked=0; | |
846 }; | |
847 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
848 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
849 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
850 switch(frame_format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
851 case DSPF_RGB32: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
852 case DSPF_ARGB: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
853 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + frame_pixel_size*x0,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
854 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
855 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
856 case DSPF_RGB24: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
857 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + frame_pixel_size*x0,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
858 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
859 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
860 case DSPF_RGB16: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
861 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + frame_pixel_size*x0,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
862 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
863 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
864 case DSPF_RGB15: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
865 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + frame_pixel_size*x0,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
866 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
867 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
868 case DSPF_YUY2: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
869 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + frame_pixel_size*x0,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
870 break; |
3341 | 871 |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
872 case DSPF_UYVY: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
873 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + frame_pixel_size*x0 + 1,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
874 break; |
5189 | 875 |
876 #ifdef HAVE_DIRECTFB099 | |
877 case DSPF_I420: | |
878 case DSPF_YV12: | |
879 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + frame_pixel_size*x0,pitch); | |
880 break; | |
881 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
882 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
883 DFBCHECK (frame->Unlock(frame)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
884 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
885 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
886 static uint32_t draw_frame(uint8_t *src[]) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
887 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
888 void *dst; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
889 int pitch; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
890 int len; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
891 |
5189 | 892 // printf("Drawframe\n"); |
893 #ifdef DIRECTRENDER | |
894 if(framelocked) { | |
895 frame->Unlock(frame); | |
896 framelocked=0; | |
897 }; | |
898 #endif | |
899 | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
900 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
901 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
902 switch (frame_format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
903 case DSPF_ARGB: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
904 case DSPF_RGB32: |
5189 | 905 case DSPF_RGB24: |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
906 case DSPF_RGB16: |
5189 | 907 case DSPF_RGB15: switch (pixel_format) { |
908 case IMGFMT_YV12: | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
909 yuv2rgb(dst,src[0],src[1],src[2],in_width,in_height,pitch,in_width,in_width/2); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
910 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
911 /* how to handle this? need conversion from YUY2 to RGB*/ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
912 /* case IMGFMT_YUY2: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
913 yuv2rgb(dst,src[0],src[0]+1,src[0]+3,1,in_height*in_width/2,frame_pixel_size*2,4,4); //odd pixels |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
914 yuv2rgb(dst+1,src[0]+2,src[0]+1,src[0]+3,1,in_height*in_width/2,frame_pixel_size*2,4,4); //even pixels |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
915 break;*/ |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
916 // RGB - just copy |
5189 | 917 default: if (source_pixel_size==frame_pixel_size) { |
918 if (pitch==(in_width*frame_pixel_size)) { | |
919 memcpy(dst,src[0],in_width * in_height * source_pixel_size); | |
920 } else { | |
921 int i; | |
922 int sp=in_width*source_pixel_size; | |
923 int ll=min(sp,pitch); | |
924 for (i=0;i<in_height;i++) { | |
925 memcpy(dst+i*pitch,src[0]+i*sp,ll); | |
926 }; | |
927 }; | |
928 }; | |
929 }; | |
930 break; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
931 case DSPF_YUY2: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
932 switch (pixel_format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
933 case IMGFMT_YV12: yv12toyuy2(src[0],src[1],src[2],dst,in_width,in_height,in_width,in_width >>1,pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
934 break; |
5189 | 935 case IMGFMT_YUY2: if (pitch==(in_width*2)) { |
936 memcpy(dst,src[0],in_width * in_height * source_pixel_size); | |
937 } else { | |
938 int i; | |
939 for (i=0;i<in_height;i++) { | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
940 memcpy(dst+i*pitch,src[0]+i*in_width*2,in_width*2); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
941 } |
5189 | 942 } |
943 break; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
944 // hopefully there will be no RGB in this case otherwise convert - not implemented |
5189 | 945 }; |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
946 break; |
5189 | 947 |
948 #ifdef HAVE_DIRECTFB099 | |
949 case DSPF_YV12: | |
950 switch (pixel_format) { | |
951 case IMGFMT_YV12: { | |
952 int i; | |
953 int p=min(in_width,pitch); | |
954 for (i=0;i<in_height;i++) { | |
955 memcpy(dst+i*pitch,src[0]+i*in_width,p); | |
956 } | |
957 dst += pitch*in_height; | |
958 p = p/2; | |
959 for (i=0;i<in_height/2;i++) { | |
960 memcpy(dst+i*pitch/2,src[2]+i*in_width/2,p); | |
961 } | |
962 dst += pitch*in_height/4; | |
963 for (i=0;i<in_height/2;i++) { | |
964 memcpy(dst+i*pitch/2,src[1]+i*in_width/2,p); | |
965 } | |
966 }; | |
967 break; | |
968 case IMGFMT_YUY2: yuy2toyv12(src[0],dst,dst+pitch*in_height+pitch*in_height/4,dst+pitch*in_height,in_width,in_height,pitch,pitch/2,pitch/2); | |
969 break; | |
970 // hopefully there will be no RGB in this case otherwise convert - not implemented | |
971 } | |
972 break; | |
973 case DSPF_I420: | |
974 switch (pixel_format) { | |
975 case IMGFMT_YV12: { | |
976 int i; | |
977 int p=min(in_width,pitch); | |
978 for (i=0;i<in_height;i++) { | |
979 memcpy(dst+i*pitch,src[0]+i*in_width,p); | |
980 } | |
981 dst += pitch*in_height; | |
982 p = p/2; | |
983 for (i=0;i<in_height/2;i++) { | |
984 memcpy(dst+i*pitch/2,src[1]+i*in_width/2,p); | |
985 } | |
986 dst += pitch*in_height/4; | |
987 for (i=0;i<in_height/2;i++) { | |
988 memcpy(dst+i*pitch/2,src[2]+i*in_width/2,p); | |
989 } | |
990 }; | |
991 break; | |
992 case IMGFMT_YUY2: yuy2toyv12(src[0],dst,dst+pitch*in_height,dst+pitch*in_height+pitch*in_height/4,in_width,in_height,pitch,pitch/2,pitch/2); | |
993 break; | |
994 // hopefully there will be no RGB in this case otherwise convert - not implemented | |
995 } | |
996 break; | |
997 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
998 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
999 DFBCHECK (frame->Unlock(frame)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1000 return 0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1001 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1002 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1003 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1004 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1005 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1006 int err; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1007 void *dst; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1008 uint8_t *s; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1009 int pitch; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1010 int i; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1011 |
5189 | 1012 #ifdef DIRECTRENDER |
1013 if(framelocked) { | |
1014 frame->Unlock(frame); | |
1015 framelocked=0; | |
1016 }; | |
1017 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1018 |
5189 | 1019 err = frame->Lock(frame,DSLF_WRITE,&dst,&pitch); |
1020 // err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); // for direct rendering | |
1021 | |
1022 // printf("Drawslice w=%i h=%i x=%i y=%i pitch=%i\n",w,h,x,y,pitch); | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1023 |
5189 | 1024 if (err) { |
1025 printf("DirectFB: Frame lock failed!"); | |
1026 return 1; | |
1027 }; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1028 switch (frame_format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1029 case DSPF_ARGB: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1030 case DSPF_RGB32: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1031 case DSPF_RGB24: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1032 case DSPF_RGB16: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1033 case DSPF_RGB15: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1034 switch (pixel_format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1035 case IMGFMT_YV12: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1036 yuv2rgb(dst+ y * pitch + frame_pixel_size*x ,src[0],src[1],src[2],w,h,pitch,stride[0],stride[1]); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1037 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1038 default: if (source_pixel_size==frame_pixel_size) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1039 dst += x * frame_pixel_size; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1040 s = src[0]; |
5189 | 1041 for (i=y;i<(y+h);i++) { |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1042 memcpy(dst,s,w); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1043 dst += (pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1044 s += stride[0]; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1045 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1046 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1047 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1048 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1049 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1050 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1051 case DSPF_YUY2: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1052 switch (pixel_format) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1053 case IMGFMT_YV12: yv12toyuy2(src[0],src[1],src[2],dst + pitch*y + frame_pixel_size*x ,w,h,stride[0],stride[1],pitch); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1054 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1055 // hopefully there will be no RGB in this case otherwise convert - not implemented |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1056 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1057 break; |
5189 | 1058 |
1059 #ifdef HAVE_DIRECTFB099 | |
1060 case DSPF_YV12: | |
1061 switch (pixel_format) { | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1062 case IMGFMT_YV12: { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1063 void *d,*s; |
5189 | 1064 int i; |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1065 d = dst + pitch*y + x; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1066 s = src[0]; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1067 for (i=0;i<h;i++) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1068 memcpy(d,s,w); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1069 d+=pitch; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1070 s+=stride[0]; |
5189 | 1071 } |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1072 d = dst + pitch*in_height + pitch*y/4 + x/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1073 s = src[2]; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1074 for (i=0;i<h/2;i++) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1075 memcpy(d,s,w/2); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1076 d+=pitch/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1077 s+=stride[2]; |
5189 | 1078 } |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1079 d = dst + pitch*in_height + pitch*in_height/4 + pitch*y/4 + x/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1080 s = src[1]; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1081 for (i=0;i<h/2;i++) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1082 memcpy(d,s,w/2); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1083 d+=pitch/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1084 s+=stride[1]; |
5189 | 1085 } |
1086 }; | |
1087 break; | |
1088 /* case IMGFMT_YUY2: { | |
1089 int i; | |
1090 for (i=y;i<(y+h);i++) { | |
1091 yuy2toyv12(src[0]+i*stride[0],dst+i*pitch+x*frame_pixel_size,dst+pitch*(in_height+i/2)+x*frame_pixel_size/2,dst+pitch*(in_height+in_height/4+i/2)+x*frame_pixel_size/2,w,h,pitch,pitch/2,pitch/2); | |
1092 } | |
1093 } | |
1094 | |
1095 break; | |
1096 */ // hopefully there will be no RGB in this case otherwise convert - not implemented | |
1097 } | |
1098 break; | |
1099 | |
1100 case DSPF_I420: | |
1101 switch (pixel_format) { | |
1102 case IMGFMT_YV12: { | |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1103 void *d,*s; |
5189 | 1104 int i; |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1105 d = dst + pitch*y + x; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1106 s = src[0]; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1107 for (i=0;i<h;i++) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1108 memcpy(d,s,w); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1109 d+=pitch; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1110 s+=stride[0]; |
5189 | 1111 } |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1112 d = dst + pitch*in_height + pitch*y/4 + x/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1113 s = src[1]; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1114 for (i=0;i<h/2;i++) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1115 memcpy(d,s,w/2); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1116 d+=pitch/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1117 s+=stride[1]; |
5189 | 1118 } |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1119 d = dst + pitch*in_height + pitch*in_height/4 + pitch*y/4 + x/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1120 s = src[2]; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1121 for (i=0;i<h/2;i++) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1122 memcpy(d,s,w/2); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1123 d+=pitch/2; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1124 s+=stride[2]; |
5189 | 1125 } |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1126 }; |
5189 | 1127 break; |
1128 /* case IMGFMT_YUY2: { | |
1129 int i; | |
1130 for (i=y;i<(y+h);i++) { | |
1131 yuy2toyv12(src[0]+i*stride[0],dst+i*pitch+x*frame_pixel_size,dst+pitch*(in_height+in_height/4+i/2)+x*frame_pixel_size/2,dst+pitch*(in_height+i/2)+x*frame_pixel_size/2,w,h,pitch,pitch/2,pitch/2); | |
1132 } | |
1133 } | |
1134 | |
1135 break; | |
1136 */ // hopefully there will be no RGB in this case otherwise convert - not implemented | |
1137 } | |
1138 break; | |
1139 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1140 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1141 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1142 frame->Unlock(frame); |
5189 | 1143 // primary->Unlock(primary); |
1144 | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1145 return 0; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1146 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1147 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1148 extern void mplayer_put_key(int code); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1149 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1150 #include "../linux/keycodes.h" |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1151 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1152 static void check_events(void) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1153 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1154 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1155 DFBInputEvent event; |
5189 | 1156 //if (verbose) printf ("DirectFB: Check events entered\n"); |
1157 if (buffer->GetEvent(buffer, &event) == DFB_OK) { | |
3341 | 1158 if (event.type == DIET_KEYPRESS) { |
1159 switch (event.keycode) { | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1160 case DIKC_ESCAPE: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1161 mplayer_put_key('q'); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1162 break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1163 case DIKC_KP_PLUS: mplayer_put_key('+');break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1164 case DIKC_KP_MINUS: mplayer_put_key('-');break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1165 case DIKC_TAB: mplayer_put_key('\t');break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1166 case DIKC_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1167 case DIKC_PAGEDOWN: mplayer_put_key(KEY_PAGE_DOWN);break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1168 case DIKC_UP: mplayer_put_key(KEY_UP);break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1169 case DIKC_DOWN: mplayer_put_key(KEY_DOWN);break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1170 case DIKC_LEFT: mplayer_put_key(KEY_LEFT);break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1171 case DIKC_RIGHT: mplayer_put_key(KEY_RIGHT);break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1172 case DIKC_ASTERISK: |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1173 case DIKC_KP_MULT:mplayer_put_key('*');break; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1174 case DIKC_KP_DIV: mplayer_put_key('/');break; |
3341 | 1175 case DIKC_INSERT: mplayer_put_key(KEY_INSERT);break; |
1176 case DIKC_DELETE: mplayer_put_key(KEY_DELETE);break; | |
1177 case DIKC_HOME: mplayer_put_key(KEY_HOME);break; | |
1178 case DIKC_END: mplayer_put_key(KEY_END);break; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1179 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1180 default:mplayer_put_key(event.key_ascii); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1181 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1182 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1183 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1184 // empty buffer, because of repeating (keyboard repeat is faster than key handling |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1185 // and this causes problems during seek) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1186 // temporary workabout should be solved in the future |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1187 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1188 buffer->Reset(buffer); |
5189 | 1189 //if (verbose) printf ("DirectFB: Check events finished\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1190 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1191 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1192 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1193 static void draw_osd(void) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1194 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1195 vo_draw_text(in_width, in_height, draw_alpha); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1196 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1197 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1198 static void flip_page(void) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1199 { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1200 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1201 |
5189 | 1202 // if (verbose) printf("DirectFB: Flip page entered"); |
1203 | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1204 DFBCHECK (primary->SetBlittingFlags(primary,flags)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1205 |
5189 | 1206 #ifdef DIRECTRENDER |
1207 if(framelocked) { | |
1208 frame->Unlock(frame); | |
1209 framelocked=0; | |
1210 }; | |
1211 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1212 if (stretch) { |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1213 DFBRectangle rect; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1214 rect.x=xoffset; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1215 rect.y=yoffset; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1216 rect.w=out_width; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1217 rect.h=out_height; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1218 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1219 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1220 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1221 else { |
5189 | 1222 #ifdef HAVE_DIRECTFB099 |
1223 if (!memcpyBitBlt) { | |
1224 #endif | |
1225 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset)); | |
1226 #ifdef HAVE_DIRECTFB099 | |
1227 } else { | |
1228 | |
1229 int err,err2; | |
1230 void *dst,*src; | |
1231 int pitch,pitch2; | |
1232 | |
1233 // printf("MemcpyBlit"); | |
1234 | |
1235 err = frame->Lock(frame,DSLF_READ,&src,&pitch); | |
1236 err2 = primary->Lock(primary,DSLF_WRITE,&dst,&pitch2); | |
1237 | |
1238 // printf("DirectFB: pitch=%i pitch2=%i\n",pitch,pitch2); | |
1239 | |
1240 | |
1241 if (pitch==pitch2) { | |
1242 memcpy(dst,src,in_height * pitch * 1.5); | |
1243 } else | |
1244 { | |
1245 int i; | |
1246 int p=min(pitch,pitch2); | |
1247 for (i=0;i<in_height;i++) { | |
1248 memcpy (dst+i*pitch2,src+i*pitch,p); | |
1249 }; | |
1250 dst+= in_height * pitch2; | |
1251 src+= in_height * pitch; | |
1252 p=p/2; | |
1253 for (i=0;i<in_height/2;i++) { | |
1254 memcpy (dst+i*pitch2/2,src+i*pitch/2,p); | |
1255 }; | |
1256 dst+= in_height * pitch2/4; | |
1257 src+= in_height * pitch/4; | |
1258 for (i=0;i<in_height/2;i++) { | |
1259 memcpy (dst+i*pitch2/2,src+i*pitch/2,p); | |
1260 }; | |
1261 } | |
1262 frame->Unlock(frame); | |
1263 primary->Unlock(primary); | |
1264 }; | |
1265 #endif | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1266 }; |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1267 // DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC)); |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1268 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1269 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1270 static void uninit(void) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1271 { |
5189 | 1272 if (verbose ) printf("DirectFB: uninit entered\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1273 /* |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1274 * (Release) |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1275 */ |
5189 | 1276 if (verbose ) printf("DirectFB: Release buffer\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1277 buffer->Release (buffer); |
5189 | 1278 if (verbose ) printf("DirectFB: Release keyboard\n"); |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1279 keyboard->Release (keyboard); |
5258
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1280 if (frameallocated) { |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1281 if (verbose ) printf("DirectFB: Release frame\n"); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1282 frame->Release (frame); |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1283 frameallocated=0; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1284 }; |
c9ccddcbdd81
ixes bug in draw_slice and also fixes compilance to
atmos4
parents:
5189
diff
changeset
|
1285 |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1286 // we will not release dfb and layer because there could be a new film |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1287 |
5189 | 1288 if (verbose ) printf("DirectFB: Release primary\n"); |
3588
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
1289 primary->Release (primary); |
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
1290 // switch off BES |
8e56fe18e7fb
Applied patch by Jiri Svoboda <Jiri.Svoboda@seznam.cz>:
pl
parents:
3341
diff
changeset
|
1291 if (videolayer) videolayer->SetOpacity(videolayer,0); |
5189 | 1292 |
1293 #ifdef HAVE_DIRECTFB099 | |
1294 if (verbose&&videolayer ) printf("DirectFB: Release videolayer\n"); | |
1295 if (videolayer) videolayer->Release(videolayer); | |
1296 | |
1297 if (verbose ) printf("DirectFB: Release DirectFB library\n"); | |
1298 dfb->Release (dfb); | |
1299 #endif | |
1300 | |
1301 if (verbose ) printf("DirectFB: Uninit done.\n"); | |
1302 } | |
1303 | |
1304 static int directfb_set_video_eq( const vidix_video_eq_t *info) | |
1305 { | |
1306 if (videolayeractive) { | |
1307 DFBColorAdjustment ca; | |
1308 float factor = (float)0xffff / 2000.0; | |
1309 | |
1310 ca.flags=DCAF_NONE; | |
1311 | |
1312 if ((videolayercaps.brightness)&&(info->cap&VEQ_CAP_BRIGHTNESS)) { | |
1313 ca.brightness = info->brightness * factor +0x8000; | |
1314 ca.flags |= DCAF_BRIGHTNESS; | |
1315 if (verbose) printf("DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,info->brightness); | |
1316 } | |
1317 | |
1318 if ((videolayercaps.contrast)&&(info->cap&VEQ_CAP_CONTRAST)) { | |
1319 ca.contrast = info->contrast * factor + 0x8000; | |
1320 ca.flags |= DCAF_CONTRAST; | |
1321 if (verbose) printf("DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,info->contrast); | |
1322 } | |
1323 | |
1324 if ((videolayercaps.hue)&&(info->cap&VEQ_CAP_HUE)) { | |
1325 ca.hue = info->hue * factor + 0x8000; | |
1326 ca.flags |= DCAF_HUE; | |
1327 if (verbose) printf("DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,info->hue); | |
1328 } | |
1329 | |
1330 if ((videolayercaps.saturation)&&(info->cap&VEQ_CAP_HUE)) { | |
1331 ca.saturation = info->saturation * factor + 0x8000; | |
1332 ca.flags |= DCAF_SATURATION; | |
1333 if (verbose) printf("DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,info->saturation); | |
1334 } | |
1335 | |
1336 videolayer->SetColorAdjustment(videolayer,&ca); | |
1337 }; | |
1338 return 0; | |
3275
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1339 |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1340 } |
38344371432f
vo DirectFB support by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
arpi
parents:
diff
changeset
|
1341 |
5189 | 1342 static int directfb_get_video_eq( vidix_video_eq_t *info) |
1343 { | |
1344 if (videolayeractive) { | |
1345 DFBColorAdjustment ca; | |
1346 float factor = 2000.0 / (float)0xffff; | |
1347 videolayer->GetColorAdjustment(videolayer,&ca); | |
1348 | |
1349 if ((videolayercaps.brightness)&&(ca.flags&DCAF_BRIGHTNESS)) { | |
1350 info->brightness = (ca.brightness-0x8000) * factor; | |
1351 info->cap |= VEQ_CAP_BRIGHTNESS; | |
1352 if (verbose) printf("DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,info->brightness); | |
1353 } | |
1354 | |
1355 if ((videolayercaps.contrast)&&(ca.flags&DCAF_CONTRAST)) { | |
1356 info->contrast = (ca.contrast-0x8000) * factor; | |
1357 info->cap |= VEQ_CAP_CONTRAST; | |
1358 if (verbose) printf("DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,info->contrast); | |
1359 } | |
1360 | |
1361 if ((videolayercaps.hue)&&(ca.flags&DCAF_HUE)) { | |
1362 info->hue = (ca.hue-0x8000) * factor; | |
1363 info->cap |= VEQ_CAP_HUE; | |
1364 if (verbose) printf("DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,info->hue); | |
1365 } | |
1366 | |
1367 if ((videolayercaps.saturation)&&(ca.flags&DCAF_SATURATION)) { | |
1368 info->saturation = (ca.saturation-0x8000) * factor; | |
1369 info->cap |= VEQ_CAP_SATURATION; | |
1370 if (verbose) printf("DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,info->saturation); | |
1371 } | |
1372 | |
1373 }; | |
1374 return 0; | |
1375 } | |
1376 static void query_vaa(vo_vaa_t *vaa) | |
1377 { | |
1378 memset(vaa,0,sizeof(vo_vaa_t)); | |
1379 vaa->get_video_eq = directfb_get_video_eq; | |
1380 vaa->set_video_eq = directfb_set_video_eq; | |
1381 } | |
1382 | |
1383 #ifdef DIRECTRENDER | |
1384 static uint32_t get_image(mp_image_t *mpi){ | |
1385 int err; | |
1386 void *dst; | |
1387 int pitch; | |
1388 | |
1389 // printf("DirectFB: get_image() called\n"); | |
1390 | |
1391 // now we are always in system memory (in this version - mybe will change in future) | |
1392 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram | |
1393 | |
1394 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags); | |
1395 if((mpi->width==pitch/frame_pixel_size) || | |
1396 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){ | |
1397 // we're lucky or codec accepts stride => ok, let's go! | |
1398 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
1399 | |
1400 #ifdef HAVE_DIRECTFB099 | |
1401 err = frame->Lock(frame,DSLF_WRITE/*|DSLF_READ*/,&dst,&pitch); | |
1402 // err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); // for real direct rendering | |
1403 | |
1404 if (err) { | |
1405 printf("DirectFB: Frame lock failed!"); | |
1406 return VO_FALSE; | |
1407 }; | |
1408 framelocked=1; | |
1409 | |
1410 //YV12 format | |
1411 mpi->planes[0]=dst; | |
1412 switch(frame_format) { | |
1413 case DSPF_I420: mpi->planes[1]=dst + pitch*in_height; | |
1414 mpi->planes[2]=mpi->planes[1] + pitch*in_height/4; | |
1415 break; | |
1416 case DSPF_YV12: mpi->planes[2]=dst + pitch*in_height; | |
1417 mpi->planes[1]=mpi->planes[1] + pitch*in_height/4; | |
1418 break; | |
1419 | |
1420 } | |
1421 mpi->width=mpi->stride[0]=pitch; | |
1422 mpi->stride[1]=mpi->stride[2]=pitch/2; | |
1423 #else | |
1424 return VO_FALSE; | |
1425 #endif | |
1426 } else { | |
1427 err = frame->Lock(frame,DSLF_WRITE/*|DSLF_READ*/,&dst,&pitch); | |
1428 // err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch); // for real direct rendering | |
1429 | |
1430 if (err) { | |
1431 printf("DirectFB: Frame lock failed!"); | |
1432 return VO_FALSE; | |
1433 }; | |
1434 framelocked=1; | |
1435 //YUY2 and RGB formats | |
1436 mpi->planes[0]=dst; | |
1437 mpi->width=pitch/frame_pixel_size; | |
1438 mpi->stride[0]=pitch; | |
1439 } | |
1440 mpi->flags|=MP_IMGFLAG_DIRECT; | |
1441 // printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
1442 return VO_TRUE; | |
1443 } | |
1444 | |
1445 if(framelocked) { | |
1446 frame->Unlock(frame); | |
1447 framelocked=0; | |
1448 }; | |
1449 return VO_FALSE; | |
1450 } | |
1451 #endif | |
1452 | |
4596 | 1453 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1454 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
1455 switch (request) { |
5189 | 1456 case VOCTRL_QUERY_VAA: |
1457 query_vaa((vo_vaa_t*)data); | |
1458 return VO_TRUE; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
1459 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
1460 return query_format(*((uint32_t*)data)); |
5189 | 1461 #ifdef DIRECTRENDER |
1462 case VOCTRL_GET_IMAGE: | |
1463 // printf("DirectFB: control(VOCTRL_GET_IMAGE) called\n"); | |
1464 if (dr_enabled) return get_image(data); | |
1465 #endif | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
1466 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
1467 return VO_NOTIMPL; |
4352 | 1468 } |