Mercurial > mplayer.hg
annotate libvo/vosub_vidix.c @ 4417:4f507d28716d
It seems that there no direct support for RGB24 :(
author | nick |
---|---|
date | Wed, 30 Jan 2002 10:04:43 +0000 |
parents | 7a4837091398 |
children | b4cc68c448db |
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" | |
31 | |
32 #define NUM_FRAMES 10 /* Temporary: driver will overwrite it */ | |
33 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */ | |
34 | |
35 static VDL_HANDLE vidix_handler = NULL; | |
36 static uint8_t *vidix_mem = NULL; | |
37 static uint8_t next_frame; | |
38 static unsigned image_bpp,image_height,image_width,src_format; | |
39 extern int verbose; | |
4372 | 40 static int video_on=0; |
4010 | 41 |
42 static vidix_capability_t vidix_cap; | |
43 static vidix_playback_t vidix_play; | |
44 static vidix_fourcc_t vidix_fourcc; | |
45 | |
4372 | 46 static int vidix_get_bes_da(bes_da_t *); |
4379 | 47 static int vidix_get_video_eq(vidix_video_eq_t *info); |
48 static int vidix_set_video_eq(const vidix_video_eq_t *info); | |
49 static int vidix_get_num_fx(unsigned *info); | |
50 static int vidix_get_oem_fx(vidix_oem_fx_t *info); | |
51 static int vidix_set_oem_fx(const vidix_oem_fx_t *info); | |
52 static int vidix_set_deint(const vidix_deinterlace_t *info); | |
4372 | 53 |
54 static void vidix_query_vaa(vo_vaa_t *vaa) | |
55 { | |
56 memset(vaa,0,sizeof(vo_vaa_t)); | |
57 vaa->query_bes_da=vidix_get_bes_da; | |
4379 | 58 vaa->get_video_eq=vidix_get_video_eq; |
59 vaa->set_video_eq=vidix_set_video_eq; | |
60 vaa->get_num_fx=vidix_get_num_fx; | |
61 vaa->get_oem_fx=vidix_get_oem_fx; | |
62 vaa->set_oem_fx=vidix_set_oem_fx; | |
63 vaa->set_deint=vidix_set_deint; | |
4372 | 64 } |
65 | |
4082 | 66 int vidix_preinit(const char *drvname,void *server) |
4010 | 67 { |
68 int err; | |
69 if(verbose > 1) printf("vosub_vidix: vidix_preinit(%s) was called\n",drvname); | |
70 if(vdlGetVersion() != VIDIX_VERSION) | |
71 { | |
72 printf("vosub_vidix: You have wrong version of VIDIX library\n"); | |
73 return -1; | |
74 } | |
4138 | 75 vidix_handler = vdlOpen(LIBDIR"/vidix/", |
4132
84ecfd03c86a
test for preinit errors and correct handling subdevice
nick
parents:
4082
diff
changeset
|
76 drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL, |
4010 | 77 TYPE_OUTPUT, |
78 verbose); | |
79 if(vidix_handler == NULL) | |
80 { | |
81 printf("vosub_vidix: Couldn't find working VIDIX driver\n"); | |
82 return -1; | |
83 } | |
84 if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0) | |
85 { | |
86 printf("vosub_vidix: Couldn't get capability: %s\n",strerror(err)); | |
87 return -1; | |
88 } | |
4013 | 89 printf("vosub_vidix: Using: %s\n",vidix_cap.name); |
4010 | 90 /* we are able to tune up this stuff depend on fourcc format */ |
4082 | 91 ((vo_functions_t *)server)->draw_slice=vidix_draw_slice; |
92 ((vo_functions_t *)server)->draw_frame=vidix_draw_frame; | |
93 ((vo_functions_t *)server)->flip_page=vidix_flip_page; | |
94 ((vo_functions_t *)server)->draw_osd=vidix_draw_osd; | |
4362 | 95 ((vo_functions_t *)server)->query_format=vidix_query_fourcc; |
4372 | 96 ((vo_functions_t *)server)->query_vaa=vidix_query_vaa; |
4010 | 97 return 0; |
98 } | |
99 | |
100 int vidix_init(unsigned src_width,unsigned src_height, | |
101 unsigned x_org,unsigned y_org,unsigned dst_width, | |
102 unsigned dst_height,unsigned format,unsigned dest_bpp, | |
103 unsigned vid_w,unsigned vid_h) | |
104 { | |
105 size_t i,awidth; | |
106 int err; | |
4082 | 107 if(verbose > 1) |
108 printf("vosub_vidix: vidix_init() was called\n" | |
109 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n" | |
110 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n" | |
111 ,src_width,src_height,x_org,y_org,dst_width,dst_height | |
112 ,vo_format_name(format),dest_bpp,vid_w,vid_h); | |
4280 | 113 |
114 if(((vidix_cap.maxwidth != -1) && (vid_w > vidix_cap.maxwidth)) || | |
115 ((vidix_cap.minwidth != -1) && (vid_w < vidix_cap.minwidth)) || | |
116 ((vidix_cap.maxheight != -1) && (vid_h > vidix_cap.maxheight)) || | |
117 ((vidix_cap.minwidth != -1 ) && (vid_h < vidix_cap.minheight))) | |
4010 | 118 { |
4280 | 119 printf("vosub_vidix: video server has unsupported resolution (%dx%d), supported: %dx%d-%dx%d\n", |
120 vid_w, vid_h, vidix_cap.minwidth, vidix_cap.minheight, | |
121 vidix_cap.maxwidth, vidix_cap.maxheight); | |
4010 | 122 return -1; |
123 } | |
4280 | 124 |
4010 | 125 err = 0; |
126 switch(dest_bpp) | |
127 { | |
128 case 1: err = ((vidix_fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break; | |
129 case 2: err = ((vidix_fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break; | |
130 case 4: err = ((vidix_fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break; | |
131 case 8: err = ((vidix_fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break; | |
132 case 12:err = ((vidix_fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break; | |
133 case 16:err = ((vidix_fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break; | |
134 case 24:err = ((vidix_fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break; | |
135 case 32:err = ((vidix_fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break; | |
136 } | |
137 if(err) | |
138 { | |
139 printf("vosub_vidix: video server has unsupported color depth by vidix\n"); | |
140 return -1; | |
141 } | |
142 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER) | |
143 { | |
144 printf("vosub_vidix: vidix driver can't upscale image\n"); | |
145 return -1; | |
146 } | |
147 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER) | |
148 { | |
149 printf("vosub_vidix: vidix driver can't downscale image\n"); | |
150 return -1; | |
151 } | |
152 image_width = src_width; | |
153 image_height = src_height; | |
4014 | 154 src_format = format; |
4010 | 155 memset(&vidix_play,0,sizeof(vidix_playback_t)); |
156 vidix_play.fourcc = format; | |
157 vidix_play.capability = vidix_cap.flags; /* every ;) */ | |
158 vidix_play.blend_factor = 0; /* for now */ | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
159 /* display the full picture. |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
160 Nick: we could implement here zooming to a specified area -- alex */ |
4010 | 161 vidix_play.src.x = vidix_play.src.y = 0; |
162 vidix_play.src.w = src_width; | |
163 vidix_play.src.h = src_height; | |
164 vidix_play.dest.x = x_org; | |
165 vidix_play.dest.y = y_org; | |
166 vidix_play.dest.w = dst_width; | |
167 vidix_play.dest.h = dst_height; | |
168 vidix_play.num_frames=NUM_FRAMES; | |
169 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0) | |
170 { | |
171 printf("vosub_vidix: Can't configure playback: %s\n",strerror(err)); | |
172 return -1; | |
173 } | |
174 | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
175 vidix_mem = vidix_play.dga_addr; |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
176 |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
177 /* select first frame */ |
4010 | 178 next_frame = 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
|
179 // vdlPlaybackFrameSelect(vidix_handler,next_frame); |
4010 | 180 |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
181 /* clear every frame with correct address and frame_size */ |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
182 for (i = 0; i < vidix_play.num_frames; i++) |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
183 memset(vidix_mem + vidix_play.offsets[i], 0x80, |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
184 vidix_play.frame_size); |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
185 return 0; |
4010 | 186 } |
187 | |
4229 | 188 extern int vo_gamma_brightness; |
189 extern int vo_gamma_saturation; | |
190 extern int vo_gamma_contrast; | |
191 extern int vo_gamma_hue; | |
4317 | 192 extern int vo_gamma_red_intensity; |
193 extern int vo_gamma_green_intensity; | |
194 extern int vo_gamma_blue_intensity; | |
4229 | 195 |
4240 | 196 static vidix_video_eq_t vid_eq; |
4229 | 197 |
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
|
198 int vidix_start(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
199 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
200 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
|
201 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
|
202 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
203 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
|
204 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
|
205 } |
4379 | 206 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
|
207 if (vidix_cap.flags & FLAG_EQUALIZER) |
4229 | 208 { |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
209 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
|
210 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
211 printf("vosub_vidix: vo_gamma_brightness=%i\n" |
4229 | 212 "vosub_vidix: vo_gamma_saturation=%i\n" |
213 "vosub_vidix: vo_gamma_contrast=%i\n" | |
214 "vosub_vidix: vo_gamma_hue=%i\n" | |
4317 | 215 "vosub_vidix: vo_gamma_red_intensity=%i\n" |
216 "vosub_vidix: vo_gamma_green_intensity=%i\n" | |
217 "vosub_vidix: vo_gamma_blue_intensity=%i\n" | |
4229 | 218 ,vo_gamma_brightness |
219 ,vo_gamma_saturation | |
220 ,vo_gamma_contrast | |
221 ,vo_gamma_hue | |
4317 | 222 ,vo_gamma_red_intensity |
223 ,vo_gamma_green_intensity | |
224 ,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
|
225 } |
4317 | 226 /* To use full set of vid_eq.cap */ |
4379 | 227 if(vidix_get_video_eq(&vid_eq) == 0) |
4317 | 228 { |
229 vid_eq.brightness = vo_gamma_brightness; | |
230 vid_eq.saturation = vo_gamma_saturation; | |
231 vid_eq.contrast = vo_gamma_contrast; | |
232 vid_eq.hue = vo_gamma_hue; | |
233 vid_eq.red_intensity = vo_gamma_red_intensity; | |
234 vid_eq.green_intensity = vo_gamma_green_intensity; | |
235 vid_eq.blue_intensity = vo_gamma_blue_intensity; | |
236 vid_eq.flags = VEQ_FLG_ITU_R_BT_601; | |
4379 | 237 vidix_set_video_eq(&vid_eq); |
4317 | 238 } |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
239 } |
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
|
240 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
241 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
242 |
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
|
243 int vidix_stop(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
244 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
245 int err; |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
246 if((err=vdlPlaybackOff(vidix_handler))!=0) |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
247 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
248 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
|
249 return -1; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
250 } |
4372 | 251 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
|
252 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
253 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
254 |
4010 | 255 void vidix_term( void ) |
256 { | |
257 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
|
258 vidix_stop(); |
4010 | 259 vdlClose(vidix_handler); |
260 } | |
261 | |
262 uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
263 { | |
264 uint8_t *src; | |
265 uint8_t *dest; | |
4014 | 266 unsigned bespitch,apitch; |
4010 | 267 int i; |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
268 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
269 /* Plane Y */ |
4014 | 270 apitch = vidix_play.dest.pitch.y-1; |
271 bespitch = (w + apitch) & ~apitch; | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
272 |
4032 | 273 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4010 | 274 dest += bespitch*y + x; |
275 src = image[0]; | |
276 for(i=0;i<h;i++){ | |
277 memcpy(dest,src,w); | |
278 src+=stride[0]; | |
279 dest += bespitch; | |
280 } | |
281 | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
282 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
|
283 { |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
284 printf("vosub_vidix: interleaving UV planes not supported yet\n"); |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
285 return 0; |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
286 } |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
287 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
288 /* Plane V */ |
4014 | 289 apitch = vidix_play.dest.pitch.v-1; |
290 bespitch = (w + apitch) & ~apitch; | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
291 |
4032 | 292 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
4031 | 293 dest += bespitch*y/4 + x; |
4014 | 294 src = image[1]; |
295 for(i=0;i<h/2;i++){ | |
296 memcpy(dest,src,w/2); | |
297 src+=stride[1]; | |
298 dest+=bespitch/2; | |
299 } | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
300 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
301 /* Plane U */ |
4014 | 302 apitch = vidix_play.dest.pitch.u-1; |
303 bespitch = (w + apitch) & ~apitch; | |
4010 | 304 |
4032 | 305 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u; |
4031 | 306 dest += bespitch*y/4 + x; |
4010 | 307 src = image[2]; |
4014 | 308 for(i=0;i<h/2;i++){ |
309 memcpy(dest,src,w/2); | |
4010 | 310 src+=stride[2]; |
4014 | 311 dest += bespitch/2; |
4010 | 312 } |
313 return 0; | |
314 } | |
315 | |
316 uint32_t vidix_draw_slice_422(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
317 { | |
318 uint8_t *src; | |
319 uint8_t *dest; | |
4014 | 320 unsigned bespitch,apitch; |
4010 | 321 int i; |
4014 | 322 apitch = vidix_play.dest.pitch.y-1; |
323 bespitch = (w*2 + apitch) & ~apitch; | |
4032 | 324 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4010 | 325 dest += bespitch*y + x; |
326 src = image[0]; | |
327 for(i=0;i<h;i++){ | |
328 memcpy(dest,src,w*2); | |
329 src+=stride[0]; | |
330 dest += bespitch; | |
331 } | |
4240 | 332 |
333 return 0; | |
4010 | 334 } |
335 | |
336 | |
337 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
338 { | |
339 if(verbose > 1) printf("vosub_vidix: vidix_draw_slice() was called\n"); | |
340 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
341 vidix_draw_slice_420(image,stride,w,h,x,y); | |
342 else | |
343 vidix_draw_slice_422(image,stride,w,h,x,y); | |
344 return 0; | |
345 } | |
346 | |
347 uint32_t vidix_draw_frame(uint8_t *image[]) | |
348 { | |
349 if(verbose > 1) printf("vosub_vidix: vidix_draw_frame() was called\n"); | |
350 /* Note it's very strange but sometime for YUY2 draw_frame is called */ | |
351 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
352 { | |
4240 | 353 printf("vosub_vidix: draw_frame for YUV420 called\nExiting...\n"); |
4010 | 354 vidix_term(); |
355 exit( EXIT_FAILURE ); | |
356 } | |
357 else | |
358 { | |
359 int stride[1]; | |
360 stride[0] = vidix_play.src.w*2; | |
361 vidix_draw_slice_422(image,stride,vidix_play.src.w,vidix_play.src.h, | |
362 vidix_play.src.x,vidix_play.src.y); | |
363 } | |
364 return 0; | |
365 } | |
366 | |
367 void vidix_flip_page(void) | |
368 { | |
369 if(verbose > 1) printf("vosub_vidix: vidix_flip_page() was called\n"); | |
370 if(vo_doublebuffering) | |
371 { | |
4032 | 372 vdlPlaybackFrameSelect(vidix_handler,next_frame); |
4010 | 373 next_frame=(next_frame+1)%vidix_play.num_frames; |
374 } | |
375 } | |
376 | |
377 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
378 { | |
379 UNUSED(x0); | |
380 UNUSED(y0); | |
381 UNUSED(w); | |
382 UNUSED(h); | |
383 UNUSED(src); | |
384 UNUSED(srca); | |
385 UNUSED(stride); | |
386 } | |
387 | |
388 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
389 { | |
4032 | 390 uint32_t apitch,bespitch; |
4010 | 391 void *lvo_mem; |
4032 | 392 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
393 apitch = vidix_play.dest.pitch.y-1; | |
394 bespitch = (vidix_play.src.w + apitch) & (~apitch); | |
4010 | 395 switch(vidix_play.fourcc){ |
396 case IMGFMT_YV12: | |
397 case IMGFMT_IYUV: | |
398 case IMGFMT_I420: | |
399 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch); | |
400 break; | |
401 case IMGFMT_YUY2: | |
4032 | 402 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),2*bespitch); |
4010 | 403 break; |
404 case IMGFMT_UYVY: | |
4032 | 405 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0)+1,2*bespitch); |
4010 | 406 break; |
407 default: | |
408 draw_alpha_null(x0,y0,w,h,src,srca,stride); | |
409 } | |
410 } | |
411 | |
412 void vidix_draw_osd(void) | |
413 { | |
414 if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n"); | |
415 /* TODO: hw support */ | |
416 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha); | |
417 } | |
418 | |
419 uint32_t vidix_query_fourcc(uint32_t format) | |
420 { | |
421 if(verbose > 1) printf("vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
422 vidix_fourcc.fourcc = format; | |
423 vdlQueryFourcc(vidix_handler,&vidix_fourcc); | |
4372 | 424 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
|
425 return(0x2); /* hw support without conversion */ |
4010 | 426 } |
4240 | 427 |
4255 | 428 int vidix_grkey_support(void) |
429 { | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
430 return(vidix_fourcc.flags & VID_CAP_COLORKEY); |
4255 | 431 } |
432 | |
4240 | 433 int vidix_grkey_get(vidix_grkey_t *gr_key) |
434 { | |
435 return(vdlGetGrKeys(vidix_handler, gr_key)); | |
436 } | |
437 | |
438 int vidix_grkey_set(const vidix_grkey_t *gr_key) | |
439 { | |
440 return(vdlSetGrKeys(vidix_handler, gr_key)); | |
441 } | |
4372 | 442 |
443 static int vidix_get_bes_da(bes_da_t *info) | |
444 { | |
445 if(!video_on) return EPERM; | |
446 info->dest.x = vidix_play.src.x; | |
447 info->dest.y = vidix_play.src.y; | |
448 info->dest.w = vidix_play.src.w; | |
449 info->dest.h = vidix_play.src.h; | |
450 info->dest.pitch.y = vidix_play.dest.pitch.y; | |
451 info->dest.pitch.u = vidix_play.dest.pitch.u; | |
452 info->dest.pitch.v = vidix_play.dest.pitch.v; | |
453 info->flags = vidix_play.flags; | |
454 info->frame_size = vidix_play.frame_size; | |
455 info->num_frames = vidix_play.num_frames; | |
456 memcpy(info->offsets,vidix_play.offsets,sizeof(unsigned)*vidix_play.num_frames); | |
457 memcpy(&info->offset,&vidix_play.offset,sizeof(vidix_yuv_t)); | |
458 info->dga_addr = vidix_play.dga_addr; | |
459 return 0; | |
460 } | |
4379 | 461 |
462 static int vidix_get_video_eq(vidix_video_eq_t *info) | |
463 { | |
464 if(!video_on) return EPERM; | |
465 return vdlPlaybackGetEq(vidix_handler, info); | |
466 } | |
467 | |
468 static int vidix_set_video_eq(const vidix_video_eq_t *info) | |
469 { | |
470 if(!video_on) return EPERM; | |
471 return vdlPlaybackSetEq(vidix_handler, info); | |
472 } | |
473 | |
474 static int vidix_get_num_fx(unsigned *info) | |
475 { | |
476 if(!video_on) return EPERM; | |
477 return vdlQueryNumOemEffects(vidix_handler, info); | |
478 } | |
479 | |
480 static int vidix_get_oem_fx(vidix_oem_fx_t *info) | |
481 { | |
482 if(!video_on) return EPERM; | |
483 return vdlGetOemEffect(vidix_handler, info); | |
484 } | |
485 | |
486 static int vidix_set_oem_fx(const vidix_oem_fx_t *info) | |
487 { | |
488 if(!video_on) return EPERM; | |
489 return vdlSetOemEffect(vidix_handler, info); | |
490 } | |
491 | |
492 static int vidix_set_deint(const vidix_deinterlace_t *info) | |
493 { | |
494 if(!video_on) return EPERM; | |
495 return vdlPlaybackSetDeint(vidix_handler, info); | |
496 } |