Mercurial > mplayer.hg
annotate libvo/vosub_vidix.c @ 5039:da65bafd5e99
very obsoleted...
author | arpi |
---|---|
date | Mon, 11 Mar 2002 00:58:32 +0000 |
parents | ddc28e9aa726 |
children | 6f28d6ccbd91 |
rev | line source |
---|---|
4010 | 1 /* |
2 * vosub_vidix.c | |
3 * | |
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - 2002 | |
4280 | 5 * Copyright (C) Alex Beregszaszi |
4010 | 6 * |
7 * You can redistribute this file under terms and conditions | |
8 * of GNU General Public licence v2. | |
9 * | |
10 * This file contains vidix interface to any mplayer's VO plugin. | |
11 * (Partly based on vesa_lvo.c from mplayer's package) | |
12 */ | |
13 | |
14 #include <inttypes.h> | |
15 #include <sys/ioctl.h> | |
16 #include <unistd.h> | |
17 #include <fcntl.h> | |
18 #include <sys/mman.h> | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
4372 | 22 #include <errno.h> |
4010 | 23 |
24 #include "config.h" | |
25 | |
26 #include "vosub_vidix.h" | |
27 #include "../vidix/vidixlib.h" | |
28 #include "fastmemcpy.h" | |
29 #include "osd.h" | |
30 #include "video_out.h" | |
4991 | 31 #include "../mp_image.h" |
32 | |
4010 | 33 |
4929 | 34 #define NUM_FRAMES VID_PLAY_MAXFRAMES /* Temporary: driver will overwrite it */ |
4010 | 35 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */ |
36 | |
37 static VDL_HANDLE vidix_handler = NULL; | |
38 static uint8_t *vidix_mem = NULL; | |
39 static uint8_t next_frame; | |
4999 | 40 static unsigned image_Bpp,image_height,image_width,src_format; |
4010 | 41 extern int verbose; |
4372 | 42 static int video_on=0; |
4010 | 43 |
44 static vidix_capability_t vidix_cap; | |
45 static vidix_playback_t vidix_play; | |
46 static vidix_fourcc_t vidix_fourcc; | |
4454 | 47 static vo_functions_t * vo_server; |
4999 | 48 static vidix_yuv_t dstrides; |
4739 | 49 static uint32_t (*server_control)(uint32_t request, void *data, ...); |
50 | |
4010 | 51 |
4372 | 52 static int vidix_get_bes_da(bes_da_t *); |
4379 | 53 static int vidix_get_video_eq(vidix_video_eq_t *info); |
54 static int vidix_set_video_eq(const vidix_video_eq_t *info); | |
55 static int vidix_get_num_fx(unsigned *info); | |
56 static int vidix_get_oem_fx(vidix_oem_fx_t *info); | |
57 static int vidix_set_oem_fx(const vidix_oem_fx_t *info); | |
58 static int vidix_set_deint(const vidix_deinterlace_t *info); | |
4372 | 59 |
60 static void vidix_query_vaa(vo_vaa_t *vaa) | |
61 { | |
62 memset(vaa,0,sizeof(vo_vaa_t)); | |
63 vaa->query_bes_da=vidix_get_bes_da; | |
4379 | 64 vaa->get_video_eq=vidix_get_video_eq; |
65 vaa->set_video_eq=vidix_set_video_eq; | |
66 vaa->get_num_fx=vidix_get_num_fx; | |
67 vaa->get_oem_fx=vidix_get_oem_fx; | |
68 vaa->set_oem_fx=vidix_set_oem_fx; | |
69 vaa->set_deint=vidix_set_deint; | |
4372 | 70 } |
71 | |
4229 | 72 extern int vo_gamma_brightness; |
73 extern int vo_gamma_saturation; | |
74 extern int vo_gamma_contrast; | |
75 extern int vo_gamma_hue; | |
4317 | 76 extern int vo_gamma_red_intensity; |
77 extern int vo_gamma_green_intensity; | |
78 extern int vo_gamma_blue_intensity; | |
4229 | 79 |
4240 | 80 static vidix_video_eq_t vid_eq; |
4229 | 81 |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
82 int vidix_start(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
83 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
84 int err; |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
85 if((err=vdlPlaybackOn(vidix_handler))!=0) |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
86 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
87 printf("vosub_vidix: Can't start playback: %s\n",strerror(err)); |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
88 return -1; |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
89 } |
4379 | 90 video_on=1; |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
91 if (vidix_cap.flags & FLAG_EQUALIZER) |
4229 | 92 { |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
93 if(verbose > 1) |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
94 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
95 printf("vosub_vidix: vo_gamma_brightness=%i\n" |
4229 | 96 "vosub_vidix: vo_gamma_saturation=%i\n" |
97 "vosub_vidix: vo_gamma_contrast=%i\n" | |
98 "vosub_vidix: vo_gamma_hue=%i\n" | |
4317 | 99 "vosub_vidix: vo_gamma_red_intensity=%i\n" |
100 "vosub_vidix: vo_gamma_green_intensity=%i\n" | |
101 "vosub_vidix: vo_gamma_blue_intensity=%i\n" | |
4229 | 102 ,vo_gamma_brightness |
103 ,vo_gamma_saturation | |
104 ,vo_gamma_contrast | |
105 ,vo_gamma_hue | |
4317 | 106 ,vo_gamma_red_intensity |
107 ,vo_gamma_green_intensity | |
108 ,vo_gamma_blue_intensity); | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
109 } |
4317 | 110 /* To use full set of vid_eq.cap */ |
4379 | 111 if(vidix_get_video_eq(&vid_eq) == 0) |
4317 | 112 { |
113 vid_eq.brightness = vo_gamma_brightness; | |
114 vid_eq.saturation = vo_gamma_saturation; | |
115 vid_eq.contrast = vo_gamma_contrast; | |
116 vid_eq.hue = vo_gamma_hue; | |
117 vid_eq.red_intensity = vo_gamma_red_intensity; | |
118 vid_eq.green_intensity = vo_gamma_green_intensity; | |
119 vid_eq.blue_intensity = vo_gamma_blue_intensity; | |
120 vid_eq.flags = VEQ_FLG_ITU_R_BT_601; | |
4379 | 121 vidix_set_video_eq(&vid_eq); |
4317 | 122 } |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
123 } |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
124 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
125 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
126 |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
127 int vidix_stop(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
128 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
129 int err; |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
130 if((err=vdlPlaybackOff(vidix_handler))!=0) |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
131 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
132 printf("vosub_vidix: Can't stop playback: %s\n",strerror(err)); |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
133 return -1; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
134 } |
4372 | 135 video_on=0; |
4234
0ec1d81c8f94
sorry, i really wanted to add vidix_start and stop as int, to detect if something went into the wrong way (also implement check in vo_xvidix)
alex
parents:
4231
diff
changeset
|
136 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
137 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
138 |
4010 | 139 void vidix_term( void ) |
140 { | |
141 if(verbose > 1) printf("vosub_vidix: vidix_term() was called\n"); | |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
142 vidix_stop(); |
4010 | 143 vdlClose(vidix_handler); |
144 } | |
145 | |
4430 | 146 static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4010 | 147 { |
148 uint8_t *src; | |
149 uint8_t *dest; | |
150 int i; | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
151 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
152 /* Plane Y */ |
4032 | 153 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4999 | 154 dest += dstrides.y*y + x; |
4010 | 155 src = image[0]; |
156 for(i=0;i<h;i++){ | |
157 memcpy(dest,src,w); | |
158 src+=stride[0]; | |
4999 | 159 dest += dstrides.y; |
4010 | 160 } |
161 | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
162 if (vidix_play.flags & VID_PLAY_INTERLEAVED_UV) |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
163 { |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
164 int hi,wi; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
165 uint8_t *src2; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
166 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
4999 | 167 dest += dstrides.y*y/2 + x; // <- is this correct ? |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
168 h/=2; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
169 w/=2; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
170 src = image[1]; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
171 src2 = image[2]; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
172 for(hi = 0; hi < h; hi++) |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
173 { |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
174 for(wi = 0; wi < w; wi++) |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
175 { |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
176 dest[2*wi+0] = src[wi]; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
177 dest[2*wi+1] = src2[wi]; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
178 } |
4999 | 179 dest += dstrides.y; |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
180 src += stride[1]; |
4999 | 181 src2+= stride[2]; |
182 } | |
183 } | |
184 else | |
185 { | |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
186 /* Plane V */ |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
187 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
4999 | 188 dest += dstrides.v*y/4 + x; |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
189 src = image[1]; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
190 for(i=0;i<h/2;i++){ |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
191 memcpy(dest,src,w/2); |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
192 src+=stride[1]; |
4999 | 193 dest+=dstrides.v/2; |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
194 } |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
195 |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
196 /* Plane U */ |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
197 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u; |
4999 | 198 dest += dstrides.u*y/4 + x; |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
199 src = image[2]; |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
200 for(i=0;i<h/2;i++){ |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
201 memcpy(dest,src,w/2); |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
202 src+=stride[2]; |
4999 | 203 dest += dstrides.u/2; |
4744
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
204 } |
da595f0e882e
vidix interleaved U V planes (for g200) by Attila Kinali <kinali@gmx.net>
nick
parents:
4741
diff
changeset
|
205 return 0; |
4999 | 206 } |
4010 | 207 } |
208 | |
4999 | 209 static uint32_t vidix_draw_slice_packed(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4010 | 210 { |
211 uint8_t *src; | |
212 uint8_t *dest; | |
213 int i; | |
4032 | 214 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4999 | 215 dest += dstrides.y*y + x; |
4010 | 216 src = image[0]; |
217 for(i=0;i<h;i++){ | |
4999 | 218 memcpy(dest,src,w*image_Bpp); |
4010 | 219 src+=stride[0]; |
4999 | 220 dest += dstrides.y; |
4010 | 221 } |
4240 | 222 return 0; |
4010 | 223 } |
224 | |
4999 | 225 static uint32_t vidix_draw_slice_packed_fast(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4454 | 226 { |
227 uint8_t *src; | |
228 uint8_t *dest; | |
229 int i; | |
230 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
4999 | 231 dest += dstrides.y*y + x; |
4430 | 232 src = image[0]; |
4999 | 233 memcpy(dest,src,h*dstrides.y); |
4454 | 234 return 0; |
235 } | |
236 | |
4010 | 237 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) |
238 { | |
4454 | 239 printf("vosub_vidix: Error unoptimized draw_slice was called\nExiting..."); |
240 vidix_term(); | |
241 exit( EXIT_FAILURE ); | |
242 return 0; | |
4010 | 243 } |
244 | |
245 uint32_t vidix_draw_frame(uint8_t *image[]) | |
246 { | |
4454 | 247 int stride[1]; |
4010 | 248 if(verbose > 1) printf("vosub_vidix: vidix_draw_frame() was called\n"); |
249 /* Note it's very strange but sometime for YUY2 draw_frame is called */ | |
250 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
4442
49c410f359e0
return error if unknown depth given. more informative error messages. dont exit if draw_frame was called with Planar YUV, only warn the user
alex
parents:
4434
diff
changeset
|
251 printf("vosub_vidix: draw_frame for YUV420 called, frame cannot be written\n"); |
4010 | 252 else |
4430 | 253 if(src_format == IMGFMT_RGB32 || src_format == IMGFMT_BGR32) |
254 stride[0] = vidix_play.src.w*4; | |
255 else | |
256 if(src_format == IMGFMT_RGB24 || src_format == IMGFMT_BGR24) | |
257 stride[0] = vidix_play.src.w*3; | |
258 else | |
4010 | 259 stride[0] = vidix_play.src.w*2; |
4454 | 260 return vo_server->draw_slice(image,stride,vidix_play.src.w,vidix_play.src.h, |
261 vidix_play.src.x,vidix_play.src.y); | |
4010 | 262 } |
263 | |
264 void vidix_flip_page(void) | |
265 { | |
266 if(verbose > 1) printf("vosub_vidix: vidix_flip_page() was called\n"); | |
267 if(vo_doublebuffering) | |
268 { | |
4032 | 269 vdlPlaybackFrameSelect(vidix_handler,next_frame); |
4010 | 270 next_frame=(next_frame+1)%vidix_play.num_frames; |
271 } | |
272 } | |
273 | |
274 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
275 { | |
276 UNUSED(x0); | |
277 UNUSED(y0); | |
278 UNUSED(w); | |
279 UNUSED(h); | |
280 UNUSED(src); | |
281 UNUSED(srca); | |
282 UNUSED(stride); | |
283 } | |
284 | |
285 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
286 { | |
4032 | 287 uint32_t apitch,bespitch; |
4010 | 288 void *lvo_mem; |
4032 | 289 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
290 apitch = vidix_play.dest.pitch.y-1; | |
4010 | 291 switch(vidix_play.fourcc){ |
292 case IMGFMT_YV12: | |
293 case IMGFMT_IYUV: | |
294 case IMGFMT_I420: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
295 bespitch = (vidix_play.src.w + apitch) & (~apitch); |
4010 | 296 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch); |
297 break; | |
298 case IMGFMT_YUY2: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
299 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch); |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
300 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0,bespitch); |
4010 | 301 break; |
302 case IMGFMT_UYVY: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
303 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch); |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
304 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+bespitch*y0+2*x0+1,bespitch); |
4010 | 305 break; |
4430 | 306 case IMGFMT_RGB32: |
307 case IMGFMT_BGR32: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
308 bespitch = (vidix_play.src.w*4 + apitch) & (~apitch); |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
309 vo_draw_alpha_rgb32(w,h,src,srca,stride,lvo_mem+y0*bespitch+4*x0,bespitch); |
4430 | 310 break; |
311 case IMGFMT_RGB24: | |
312 case IMGFMT_BGR24: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
313 bespitch = (vidix_play.src.w*3 + apitch) & (~apitch); |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
314 vo_draw_alpha_rgb24(w,h,src,srca,stride,lvo_mem+y0*bespitch+3*x0,bespitch); |
4430 | 315 break; |
316 case IMGFMT_RGB16: | |
317 case IMGFMT_BGR16: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
318 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch); |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
319 vo_draw_alpha_rgb16(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch); |
4430 | 320 break; |
321 case IMGFMT_RGB15: | |
322 case IMGFMT_BGR15: | |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
323 bespitch = (vidix_play.src.w*2 + apitch) & (~apitch); |
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
324 vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+y0*bespitch+2*x0,bespitch); |
4430 | 325 break; |
4010 | 326 default: |
327 draw_alpha_null(x0,y0,w,h,src,srca,stride); | |
328 } | |
329 } | |
330 | |
331 void vidix_draw_osd(void) | |
332 { | |
333 if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n"); | |
334 /* TODO: hw support */ | |
335 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha); | |
336 } | |
337 | |
338 uint32_t vidix_query_fourcc(uint32_t format) | |
339 { | |
340 if(verbose > 1) printf("vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
341 vidix_fourcc.fourcc = format; | |
342 vdlQueryFourcc(vidix_handler,&vidix_fourcc); | |
4372 | 343 if (vidix_fourcc.depth == VID_DEPTH_NONE) return(0); |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
344 return(0x2); /* hw support without conversion */ |
4010 | 345 } |
4240 | 346 |
4255 | 347 int vidix_grkey_support(void) |
348 { | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
349 return(vidix_fourcc.flags & VID_CAP_COLORKEY); |
4255 | 350 } |
351 | |
4240 | 352 int vidix_grkey_get(vidix_grkey_t *gr_key) |
353 { | |
354 return(vdlGetGrKeys(vidix_handler, gr_key)); | |
355 } | |
356 | |
357 int vidix_grkey_set(const vidix_grkey_t *gr_key) | |
358 { | |
359 return(vdlSetGrKeys(vidix_handler, gr_key)); | |
360 } | |
4372 | 361 |
362 static int vidix_get_bes_da(bes_da_t *info) | |
363 { | |
364 if(!video_on) return EPERM; | |
365 info->dest.x = vidix_play.src.x; | |
366 info->dest.y = vidix_play.src.y; | |
367 info->dest.w = vidix_play.src.w; | |
368 info->dest.h = vidix_play.src.h; | |
369 info->dest.pitch.y = vidix_play.dest.pitch.y; | |
370 info->dest.pitch.u = vidix_play.dest.pitch.u; | |
371 info->dest.pitch.v = vidix_play.dest.pitch.v; | |
372 info->flags = vidix_play.flags; | |
373 info->frame_size = vidix_play.frame_size; | |
374 info->num_frames = vidix_play.num_frames; | |
375 memcpy(info->offsets,vidix_play.offsets,sizeof(unsigned)*vidix_play.num_frames); | |
376 memcpy(&info->offset,&vidix_play.offset,sizeof(vidix_yuv_t)); | |
377 info->dga_addr = vidix_play.dga_addr; | |
378 return 0; | |
379 } | |
4379 | 380 |
381 static int vidix_get_video_eq(vidix_video_eq_t *info) | |
382 { | |
383 if(!video_on) return EPERM; | |
384 return vdlPlaybackGetEq(vidix_handler, info); | |
385 } | |
386 | |
387 static int vidix_set_video_eq(const vidix_video_eq_t *info) | |
388 { | |
389 if(!video_on) return EPERM; | |
390 return vdlPlaybackSetEq(vidix_handler, info); | |
391 } | |
392 | |
393 static int vidix_get_num_fx(unsigned *info) | |
394 { | |
395 if(!video_on) return EPERM; | |
396 return vdlQueryNumOemEffects(vidix_handler, info); | |
397 } | |
398 | |
399 static int vidix_get_oem_fx(vidix_oem_fx_t *info) | |
400 { | |
401 if(!video_on) return EPERM; | |
402 return vdlGetOemEffect(vidix_handler, info); | |
403 } | |
404 | |
405 static int vidix_set_oem_fx(const vidix_oem_fx_t *info) | |
406 { | |
407 if(!video_on) return EPERM; | |
408 return vdlSetOemEffect(vidix_handler, info); | |
409 } | |
410 | |
411 static int vidix_set_deint(const vidix_deinterlace_t *info) | |
412 { | |
413 if(!video_on) return EPERM; | |
414 return vdlPlaybackSetDeint(vidix_handler, info); | |
415 } | |
4454 | 416 |
5028 | 417 static int is_422_planes_eq=0; |
4454 | 418 int vidix_init(unsigned src_width,unsigned src_height, |
419 unsigned x_org,unsigned y_org,unsigned dst_width, | |
420 unsigned dst_height,unsigned format,unsigned dest_bpp, | |
421 unsigned vid_w,unsigned vid_h,const void *info) | |
422 { | |
423 size_t i,awidth; | |
5028 | 424 int err; |
4999 | 425 uint32_t sstride,apitch; |
4454 | 426 if(verbose > 1) |
427 printf("vosub_vidix: vidix_init() was called\n" | |
428 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n" | |
429 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n" | |
430 ,src_width,src_height,x_org,y_org,dst_width,dst_height | |
431 ,vo_format_name(format),dest_bpp,vid_w,vid_h); | |
432 | |
433 if(((vidix_cap.maxwidth != -1) && (vid_w > vidix_cap.maxwidth)) || | |
434 ((vidix_cap.minwidth != -1) && (vid_w < vidix_cap.minwidth)) || | |
435 ((vidix_cap.maxheight != -1) && (vid_h > vidix_cap.maxheight)) || | |
436 ((vidix_cap.minwidth != -1 ) && (vid_h < vidix_cap.minheight))) | |
437 { | |
438 printf("vosub_vidix: video server has unsupported resolution (%dx%d), supported: %dx%d-%dx%d\n", | |
439 vid_w, vid_h, vidix_cap.minwidth, vidix_cap.minheight, | |
440 vidix_cap.maxwidth, vidix_cap.maxheight); | |
441 return -1; | |
442 } | |
443 | |
444 err = 0; | |
445 switch(dest_bpp) | |
446 { | |
447 case 1: err = ((vidix_fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break; | |
448 case 2: err = ((vidix_fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break; | |
449 case 4: err = ((vidix_fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break; | |
450 case 8: err = ((vidix_fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break; | |
451 case 12:err = ((vidix_fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break; | |
4540 | 452 case 15:err = ((vidix_fourcc.depth & VID_DEPTH_15BPP) != VID_DEPTH_15BPP); break; |
4454 | 453 case 16:err = ((vidix_fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break; |
454 case 24:err = ((vidix_fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break; | |
455 case 32:err = ((vidix_fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break; | |
456 default: err=1; break; | |
457 } | |
458 if(err) | |
459 { | |
460 printf("vosub_vidix: video server has unsupported color depth by vidix (%d)\n" | |
461 ,vidix_fourcc.depth); | |
462 return -1; | |
463 } | |
464 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER) | |
465 { | |
466 printf("vosub_vidix: vidix driver can't upscale image (%d%d -> %d%d)\n", | |
467 src_width, src_height, dst_width, dst_height); | |
468 return -1; | |
469 } | |
470 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER) | |
471 { | |
472 printf("vosub_vidix: vidix driver can't downscale image (%d%d -> %d%d)\n", | |
473 src_width, src_height, dst_width, dst_height); | |
474 return -1; | |
475 } | |
476 image_width = src_width; | |
477 image_height = src_height; | |
478 src_format = format; | |
479 memset(&vidix_play,0,sizeof(vidix_playback_t)); | |
480 vidix_play.fourcc = format; | |
481 vidix_play.capability = vidix_cap.flags; /* every ;) */ | |
482 vidix_play.blend_factor = 0; /* for now */ | |
483 /* display the full picture. | |
484 Nick: we could implement here zooming to a specified area -- alex */ | |
485 vidix_play.src.x = vidix_play.src.y = 0; | |
486 vidix_play.src.w = src_width; | |
487 vidix_play.src.h = src_height; | |
488 vidix_play.dest.x = x_org; | |
489 vidix_play.dest.y = y_org; | |
490 vidix_play.dest.w = dst_width; | |
491 vidix_play.dest.h = dst_height; | |
4929 | 492 vidix_play.num_frames=vo_doublebuffering?NUM_FRAMES-1:1; |
4454 | 493 vidix_play.src.pitch.y = vidix_play.src.pitch.u = vidix_play.src.pitch.v = 0; |
494 if(info) | |
495 { | |
496 switch(((const vo_tune_info_t *)info)->pitch[0]) | |
497 { | |
498 case 2: | |
499 case 4: | |
500 case 8: | |
501 case 16: | |
502 case 32: | |
503 case 64: | |
504 case 128: | |
505 case 256: vidix_play.src.pitch.y = ((const vo_tune_info_t *)info)->pitch[0]; | |
506 break; | |
507 default: break; | |
508 } | |
509 switch(((const vo_tune_info_t *)info)->pitch[1]) | |
510 { | |
511 case 2: | |
512 case 4: | |
513 case 8: | |
514 case 16: | |
515 case 32: | |
516 case 64: | |
517 case 128: | |
518 case 256: vidix_play.src.pitch.u = ((const vo_tune_info_t *)info)->pitch[1]; | |
519 break; | |
520 default: break; | |
521 } | |
522 switch(((const vo_tune_info_t *)info)->pitch[2]) | |
523 { | |
524 case 2: | |
525 case 4: | |
526 case 8: | |
527 case 16: | |
528 case 32: | |
529 case 64: | |
530 case 128: | |
531 case 256: vidix_play.src.pitch.v = ((const vo_tune_info_t *)info)->pitch[2]; | |
532 break; | |
533 default: break; | |
534 } | |
535 } | |
536 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0) | |
537 { | |
538 printf("vosub_vidix: Can't configure playback: %s\n",strerror(err)); | |
539 return -1; | |
540 } | |
4895 | 541 printf("vosub_vidix: using %d buffers\n", vidix_play.num_frames); |
4454 | 542 |
543 vidix_mem = vidix_play.dga_addr; | |
544 | |
545 /* select first frame */ | |
546 next_frame = 0; | |
547 // vdlPlaybackFrameSelect(vidix_handler,next_frame); | |
548 | |
549 /* clear every frame with correct address and frame_size */ | |
550 for (i = 0; i < vidix_play.num_frames; i++) | |
551 memset(vidix_mem + vidix_play.offsets[i], 0x80, | |
552 vidix_play.frame_size); | |
4999 | 553 switch(format) |
554 { | |
555 /* | |
556 case IMGFMT_YV09: | |
557 case IMGFMT_IF09: | |
558 */ | |
559 case IMGFMT_I420: | |
560 case IMGFMT_IYUV: | |
561 case IMGFMT_YV12: | |
562 apitch = vidix_play.dest.pitch.y-1; | |
563 dstrides.y = (image_width + apitch) & ~apitch; | |
564 apitch = vidix_play.dest.pitch.v-1; | |
565 dstrides.v = (image_width + apitch) & ~apitch; | |
566 apitch = vidix_play.dest.pitch.u-1; | |
567 dstrides.u = (image_width + apitch) & ~apitch; | |
568 image_Bpp=1; | |
569 break; | |
570 case IMGFMT_RGB32: | |
571 case IMGFMT_BGR32: | |
572 apitch = vidix_play.dest.pitch.y-1; | |
573 dstrides.y = (image_width*4 + apitch) & ~apitch; | |
574 dstrides.u = dstrides.v = 0; | |
575 image_Bpp=4; | |
576 break; | |
577 case IMGFMT_RGB24: | |
578 case IMGFMT_BGR24: | |
579 apitch = vidix_play.dest.pitch.y-1; | |
580 dstrides.y = (image_width*3 + apitch) & ~apitch; | |
581 dstrides.u = dstrides.v = 0; | |
582 image_Bpp=3; | |
583 break; | |
584 default: | |
585 apitch = vidix_play.dest.pitch.y-1; | |
586 dstrides.y = (image_width*2 + apitch) & ~apitch; | |
587 dstrides.u = dstrides.v = 0; | |
588 image_Bpp=2; | |
589 break; | |
590 } | |
4454 | 591 /* tune some info here */ |
4745
398e3663ed71
Allow using direct rendering with any HW pitches (even on matrox g400).
nick
parents:
4744
diff
changeset
|
592 sstride = src_width*2; |
4999 | 593 is_422_planes_eq = sstride == dstrides.y; |
4454 | 594 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) |
595 vo_server->draw_slice = vidix_draw_slice_420; | |
4999 | 596 else vo_server->draw_slice = |
4741 | 597 is_422_planes_eq ? |
4999 | 598 vidix_draw_slice_packed_fast: |
599 vidix_draw_slice_packed; | |
4454 | 600 return 0; |
601 } | |
602 | |
4991 | 603 static uint32_t vidix_get_image(mp_image_t *mpi) |
604 { | |
605 if(mpi->type==MP_IMGTYPE_STATIC && vidix_play.num_frames>1) return VO_FALSE; | |
606 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; /* slow video ram */ | |
5028 | 607 if(is_422_planes_eq || (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))) |
4991 | 608 { |
5028 | 609 mpi->planes[0]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.y; |
610 mpi->stride[0]=dstrides.y; | |
611 if(mpi->flags&MP_IMGFLAG_PLANAR) | |
612 { | |
613 mpi->planes[2]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.v; | |
614 mpi->stride[2]=dstrides.v; | |
615 mpi->planes[1]=vidix_mem+vidix_play.offsets[next_frame]+vidix_play.offset.u; | |
616 mpi->stride[1]=dstrides.u; | |
617 } | |
618 mpi->flags|=MP_IMGFLAG_DIRECT; | |
4991 | 619 } |
620 return VO_TRUE; | |
621 } | |
622 | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
623 uint32_t vidix_control(uint32_t request, void *data, ...) |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
624 { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
625 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
626 case VOCTRL_QUERY_VAA: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
627 vidix_query_vaa((vo_vaa_t*)data); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
628 return VO_TRUE; |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
629 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
630 return vidix_query_fourcc(*((uint32_t*)data)); |
4739 | 631 case VOCTRL_SCREENSHOT: |
632 return (*server_control)(request,data); | |
4991 | 633 case VOCTRL_GET_IMAGE: |
634 return vidix_get_image(data); | |
5002 | 635 case VOCTRL_GET_FRAME_NUM: |
636 *(uint32_t *)data = next_frame; | |
637 return VO_TRUE; | |
638 case VOCTRL_SET_FRAME_NUM: | |
639 next_frame = *(uint32_t *)data; | |
640 return VO_TRUE; | |
641 case VOCTRL_GET_NUM_FRAMES: | |
642 *(uint32_t *)data = vidix_play.num_frames; | |
643 return VO_TRUE; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
644 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
645 return VO_NOTIMPL; |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
646 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
647 |
4454 | 648 int vidix_preinit(const char *drvname,void *server) |
649 { | |
650 int err; | |
651 if(verbose > 1) printf("vosub_vidix: vidix_preinit(%s) was called\n",drvname); | |
652 if(vdlGetVersion() != VIDIX_VERSION) | |
653 { | |
654 printf("vosub_vidix: You have wrong version of VIDIX library\n"); | |
655 return -1; | |
656 } | |
657 vidix_handler = vdlOpen(LIBDIR"/vidix/", | |
658 drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL, | |
659 TYPE_OUTPUT, | |
660 verbose); | |
661 if(vidix_handler == NULL) | |
662 { | |
663 printf("vosub_vidix: Couldn't find working VIDIX driver\n"); | |
664 return -1; | |
665 } | |
666 if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0) | |
667 { | |
668 printf("vosub_vidix: Couldn't get capability: %s\n",strerror(err)); | |
669 return -1; | |
670 } | |
671 printf("vosub_vidix: Using: %s by %s\n",vidix_cap.name,vidix_cap.author); | |
672 /* we are able to tune up this stuff depend on fourcc format */ | |
673 ((vo_functions_t *)server)->draw_slice=vidix_draw_slice; | |
674 ((vo_functions_t *)server)->draw_frame=vidix_draw_frame; | |
675 ((vo_functions_t *)server)->flip_page=vidix_flip_page; | |
676 ((vo_functions_t *)server)->draw_osd=vidix_draw_osd; | |
4739 | 677 server_control = ((vo_functions_t *)server)->control; |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4540
diff
changeset
|
678 ((vo_functions_t *)server)->control=vidix_control; |
4454 | 679 vo_server = server; |
680 return 0; | |
681 } |