Mercurial > mplayer.hg
annotate libvo/vosub_vidix.c @ 4434:e956fa7f79c7
Use new tune info
author | nick |
---|---|
date | Thu, 31 Jan 2002 10:23:39 +0000 |
parents | b4cc68c448db |
children | 49c410f359e0 |
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, | |
4434 | 103 unsigned vid_w,unsigned vid_h,const void *info) |
4010 | 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; | |
4434 | 169 vidix_play.src.pitch.y = vidix_play.src.pitch.u = vidix_play.src.pitch.v = 0; |
170 if(info) | |
171 { | |
172 switch(((const vo_tune_info_t *)info)->pitch[0]) | |
173 { | |
174 case 2: | |
175 case 4: | |
176 case 8: | |
177 case 16: | |
178 case 32: | |
179 case 64: | |
180 case 128: | |
181 case 256: vidix_play.src.pitch.y = ((const vo_tune_info_t *)info)->pitch[0]; | |
182 break; | |
183 default: break; | |
184 } | |
185 switch(((const vo_tune_info_t *)info)->pitch[1]) | |
186 { | |
187 case 2: | |
188 case 4: | |
189 case 8: | |
190 case 16: | |
191 case 32: | |
192 case 64: | |
193 case 128: | |
194 case 256: vidix_play.src.pitch.u = ((const vo_tune_info_t *)info)->pitch[1]; | |
195 break; | |
196 default: break; | |
197 } | |
198 switch(((const vo_tune_info_t *)info)->pitch[2]) | |
199 { | |
200 case 2: | |
201 case 4: | |
202 case 8: | |
203 case 16: | |
204 case 32: | |
205 case 64: | |
206 case 128: | |
207 case 256: vidix_play.src.pitch.v = ((const vo_tune_info_t *)info)->pitch[2]; | |
208 break; | |
209 default: break; | |
210 } | |
211 } | |
4010 | 212 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0) |
213 { | |
214 printf("vosub_vidix: Can't configure playback: %s\n",strerror(err)); | |
215 return -1; | |
216 } | |
217 | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
218 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
|
219 |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
220 /* select first frame */ |
4010 | 221 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
|
222 // vdlPlaybackFrameSelect(vidix_handler,next_frame); |
4010 | 223 |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
224 /* 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
|
225 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
|
226 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
|
227 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
|
228 return 0; |
4010 | 229 } |
230 | |
4229 | 231 extern int vo_gamma_brightness; |
232 extern int vo_gamma_saturation; | |
233 extern int vo_gamma_contrast; | |
234 extern int vo_gamma_hue; | |
4317 | 235 extern int vo_gamma_red_intensity; |
236 extern int vo_gamma_green_intensity; | |
237 extern int vo_gamma_blue_intensity; | |
4229 | 238 |
4240 | 239 static vidix_video_eq_t vid_eq; |
4229 | 240 |
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
|
241 int vidix_start(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
242 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
243 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
|
244 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
|
245 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
246 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
|
247 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
|
248 } |
4379 | 249 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
|
250 if (vidix_cap.flags & FLAG_EQUALIZER) |
4229 | 251 { |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
252 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
|
253 { |
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
254 printf("vosub_vidix: vo_gamma_brightness=%i\n" |
4229 | 255 "vosub_vidix: vo_gamma_saturation=%i\n" |
256 "vosub_vidix: vo_gamma_contrast=%i\n" | |
257 "vosub_vidix: vo_gamma_hue=%i\n" | |
4317 | 258 "vosub_vidix: vo_gamma_red_intensity=%i\n" |
259 "vosub_vidix: vo_gamma_green_intensity=%i\n" | |
260 "vosub_vidix: vo_gamma_blue_intensity=%i\n" | |
4229 | 261 ,vo_gamma_brightness |
262 ,vo_gamma_saturation | |
263 ,vo_gamma_contrast | |
264 ,vo_gamma_hue | |
4317 | 265 ,vo_gamma_red_intensity |
266 ,vo_gamma_green_intensity | |
267 ,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
|
268 } |
4317 | 269 /* To use full set of vid_eq.cap */ |
4379 | 270 if(vidix_get_video_eq(&vid_eq) == 0) |
4317 | 271 { |
272 vid_eq.brightness = vo_gamma_brightness; | |
273 vid_eq.saturation = vo_gamma_saturation; | |
274 vid_eq.contrast = vo_gamma_contrast; | |
275 vid_eq.hue = vo_gamma_hue; | |
276 vid_eq.red_intensity = vo_gamma_red_intensity; | |
277 vid_eq.green_intensity = vo_gamma_green_intensity; | |
278 vid_eq.blue_intensity = vo_gamma_blue_intensity; | |
279 vid_eq.flags = VEQ_FLG_ITU_R_BT_601; | |
4379 | 280 vidix_set_video_eq(&vid_eq); |
4317 | 281 } |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
282 } |
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
|
283 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
284 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
285 |
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
|
286 int vidix_stop(void) |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
287 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
288 int err; |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
289 if((err=vdlPlaybackOff(vidix_handler))!=0) |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
290 { |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
291 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
|
292 return -1; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
293 } |
4372 | 294 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
|
295 return 0; |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
296 } |
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4138
diff
changeset
|
297 |
4010 | 298 void vidix_term( void ) |
299 { | |
300 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
|
301 vidix_stop(); |
4010 | 302 vdlClose(vidix_handler); |
303 } | |
304 | |
4430 | 305 static uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4010 | 306 { |
307 uint8_t *src; | |
308 uint8_t *dest; | |
4014 | 309 unsigned bespitch,apitch; |
4010 | 310 int i; |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
311 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
312 /* Plane Y */ |
4014 | 313 apitch = vidix_play.dest.pitch.y-1; |
314 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
|
315 |
4032 | 316 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4010 | 317 dest += bespitch*y + x; |
318 src = image[0]; | |
319 for(i=0;i<h;i++){ | |
320 memcpy(dest,src,w); | |
321 src+=stride[0]; | |
322 dest += bespitch; | |
323 } | |
324 | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
325 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
|
326 { |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
327 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
|
328 return 0; |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
329 } |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
330 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
331 /* Plane V */ |
4014 | 332 apitch = vidix_play.dest.pitch.v-1; |
333 bespitch = (w + apitch) & ~apitch; | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
334 |
4032 | 335 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v; |
4031 | 336 dest += bespitch*y/4 + x; |
4014 | 337 src = image[1]; |
338 for(i=0;i<h/2;i++){ | |
339 memcpy(dest,src,w/2); | |
340 src+=stride[1]; | |
341 dest+=bespitch/2; | |
342 } | |
4324
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
343 |
09f15844c960
don't render UV planes if interleaved (also add support later)
alex
parents:
4317
diff
changeset
|
344 /* Plane U */ |
4014 | 345 apitch = vidix_play.dest.pitch.u-1; |
346 bespitch = (w + apitch) & ~apitch; | |
4010 | 347 |
4032 | 348 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u; |
4031 | 349 dest += bespitch*y/4 + x; |
4010 | 350 src = image[2]; |
4014 | 351 for(i=0;i<h/2;i++){ |
352 memcpy(dest,src,w/2); | |
4010 | 353 src+=stride[2]; |
4014 | 354 dest += bespitch/2; |
4010 | 355 } |
356 return 0; | |
357 } | |
358 | |
4430 | 359 static uint32_t vidix_draw_slice_422(uint8_t *image[], int stride[], int w,int h,int x,int y) |
4010 | 360 { |
361 uint8_t *src; | |
362 uint8_t *dest; | |
4014 | 363 unsigned bespitch,apitch; |
4010 | 364 int i; |
4014 | 365 apitch = vidix_play.dest.pitch.y-1; |
366 bespitch = (w*2 + apitch) & ~apitch; | |
4032 | 367 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
4010 | 368 dest += bespitch*y + x; |
369 src = image[0]; | |
370 for(i=0;i<h;i++){ | |
371 memcpy(dest,src,w*2); | |
372 src+=stride[0]; | |
373 dest += bespitch; | |
374 } | |
4240 | 375 |
376 return 0; | |
4010 | 377 } |
378 | |
4430 | 379 static uint32_t vidix_draw_slice_32(uint8_t *image[], int stride[], int w,int h,int x,int y) |
380 { | |
381 uint8_t *src; | |
382 uint8_t *dest; | |
383 unsigned bespitch,apitch; | |
384 int i; | |
385 apitch = vidix_play.dest.pitch.y-1; | |
386 bespitch = (w*4 + apitch) & ~apitch; | |
387 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
388 dest += bespitch*y + x; | |
389 src = image[0]; | |
390 for(i=0;i<h;i++){ | |
391 memcpy(dest,src,w*4); | |
392 src+=stride[0]; | |
393 dest += bespitch; | |
394 } | |
395 | |
396 return 0; | |
397 } | |
398 | |
399 static uint32_t vidix_draw_slice_24(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
400 { | |
401 uint8_t *src; | |
402 uint8_t *dest; | |
403 unsigned bespitch,apitch; | |
404 int i; | |
405 apitch = vidix_play.dest.pitch.y-1; | |
406 bespitch = (w*3 + apitch) & ~apitch; | |
407 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; | |
408 dest += bespitch*y + x; | |
409 src = image[0]; | |
410 for(i=0;i<h;i++){ | |
411 memcpy(dest,src,w*3); | |
412 src+=stride[0]; | |
413 dest += bespitch; | |
414 } | |
415 | |
416 return 0; | |
417 } | |
4010 | 418 |
419 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
420 { | |
421 if(verbose > 1) printf("vosub_vidix: vidix_draw_slice() was called\n"); | |
422 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
423 vidix_draw_slice_420(image,stride,w,h,x,y); | |
424 else | |
4430 | 425 if(src_format == IMGFMT_RGB32 || src_format == IMGFMT_BGR32) |
426 vidix_draw_slice_32(image,stride,w,h,x,y); | |
427 else | |
428 if(src_format == IMGFMT_RGB24 || src_format == IMGFMT_BGR24) | |
429 vidix_draw_slice_24(image,stride,w,h,x,y); | |
430 else | |
4010 | 431 vidix_draw_slice_422(image,stride,w,h,x,y); |
432 return 0; | |
433 } | |
434 | |
435 uint32_t vidix_draw_frame(uint8_t *image[]) | |
436 { | |
437 if(verbose > 1) printf("vosub_vidix: vidix_draw_frame() was called\n"); | |
438 /* Note it's very strange but sometime for YUY2 draw_frame is called */ | |
439 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV) | |
440 { | |
4240 | 441 printf("vosub_vidix: draw_frame for YUV420 called\nExiting...\n"); |
4010 | 442 vidix_term(); |
443 exit( EXIT_FAILURE ); | |
444 } | |
445 else | |
4430 | 446 if(src_format == IMGFMT_RGB32 || src_format == IMGFMT_BGR32) |
447 { | |
448 int stride[1]; | |
449 stride[0] = vidix_play.src.w*4; | |
450 vidix_draw_slice_32(image,stride,vidix_play.src.w,vidix_play.src.h, | |
451 vidix_play.src.x,vidix_play.src.y); | |
452 } | |
453 else | |
454 if(src_format == IMGFMT_RGB24 || src_format == IMGFMT_BGR24) | |
455 { | |
456 int stride[1]; | |
457 stride[0] = vidix_play.src.w*3; | |
458 vidix_draw_slice_24(image,stride,vidix_play.src.w,vidix_play.src.h, | |
459 vidix_play.src.x,vidix_play.src.y); | |
460 } | |
461 else | |
4010 | 462 { |
463 int stride[1]; | |
464 stride[0] = vidix_play.src.w*2; | |
465 vidix_draw_slice_422(image,stride,vidix_play.src.w,vidix_play.src.h, | |
466 vidix_play.src.x,vidix_play.src.y); | |
467 } | |
468 return 0; | |
469 } | |
470 | |
471 void vidix_flip_page(void) | |
472 { | |
473 if(verbose > 1) printf("vosub_vidix: vidix_flip_page() was called\n"); | |
474 if(vo_doublebuffering) | |
475 { | |
4032 | 476 vdlPlaybackFrameSelect(vidix_handler,next_frame); |
4010 | 477 next_frame=(next_frame+1)%vidix_play.num_frames; |
478 } | |
479 } | |
480 | |
481 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
482 { | |
483 UNUSED(x0); | |
484 UNUSED(y0); | |
485 UNUSED(w); | |
486 UNUSED(h); | |
487 UNUSED(src); | |
488 UNUSED(srca); | |
489 UNUSED(stride); | |
490 } | |
491 | |
492 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) | |
493 { | |
4032 | 494 uint32_t apitch,bespitch; |
4010 | 495 void *lvo_mem; |
4032 | 496 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y; |
497 apitch = vidix_play.dest.pitch.y-1; | |
498 bespitch = (vidix_play.src.w + apitch) & (~apitch); | |
4010 | 499 switch(vidix_play.fourcc){ |
500 case IMGFMT_YV12: | |
501 case IMGFMT_IYUV: | |
502 case IMGFMT_I420: | |
503 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch); | |
504 break; | |
505 case IMGFMT_YUY2: | |
4032 | 506 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),2*bespitch); |
4010 | 507 break; |
508 case IMGFMT_UYVY: | |
4032 | 509 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0)+1,2*bespitch); |
4010 | 510 break; |
4430 | 511 case IMGFMT_RGB32: |
512 case IMGFMT_BGR32: | |
513 vo_draw_alpha_rgb32(w,h,src,srca,stride,lvo_mem+4*(y0*bespitch+x0),4*bespitch); | |
514 break; | |
515 case IMGFMT_RGB24: | |
516 case IMGFMT_BGR24: | |
517 vo_draw_alpha_rgb24(w,h,src,srca,stride,lvo_mem+3*(y0*bespitch+x0),3*bespitch); | |
518 break; | |
519 case IMGFMT_RGB16: | |
520 case IMGFMT_BGR16: | |
521 vo_draw_alpha_rgb16(w,h,src,srca,stride,lvo_mem+2*(y0*bespitch+x0),2*bespitch); | |
522 break; | |
523 case IMGFMT_RGB15: | |
524 case IMGFMT_BGR15: | |
525 vo_draw_alpha_rgb15(w,h,src,srca,stride,lvo_mem+2*(y0*bespitch+x0),2*bespitch); | |
526 break; | |
4010 | 527 default: |
528 draw_alpha_null(x0,y0,w,h,src,srca,stride); | |
529 } | |
530 } | |
531 | |
532 void vidix_draw_osd(void) | |
533 { | |
534 if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n"); | |
535 /* TODO: hw support */ | |
536 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha); | |
537 } | |
538 | |
539 uint32_t vidix_query_fourcc(uint32_t format) | |
540 { | |
541 if(verbose > 1) printf("vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
542 vidix_fourcc.fourcc = format; | |
543 vdlQueryFourcc(vidix_handler,&vidix_fourcc); | |
4372 | 544 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
|
545 return(0x2); /* hw support without conversion */ |
4010 | 546 } |
4240 | 547 |
4255 | 548 int vidix_grkey_support(void) |
549 { | |
4270
178c84b1090e
clearing safely the buffer, queryfourcc returns 0x2 (hw accel, noconv.), setting eq only if drivers i able
alex
parents:
4255
diff
changeset
|
550 return(vidix_fourcc.flags & VID_CAP_COLORKEY); |
4255 | 551 } |
552 | |
4240 | 553 int vidix_grkey_get(vidix_grkey_t *gr_key) |
554 { | |
555 return(vdlGetGrKeys(vidix_handler, gr_key)); | |
556 } | |
557 | |
558 int vidix_grkey_set(const vidix_grkey_t *gr_key) | |
559 { | |
560 return(vdlSetGrKeys(vidix_handler, gr_key)); | |
561 } | |
4372 | 562 |
563 static int vidix_get_bes_da(bes_da_t *info) | |
564 { | |
565 if(!video_on) return EPERM; | |
566 info->dest.x = vidix_play.src.x; | |
567 info->dest.y = vidix_play.src.y; | |
568 info->dest.w = vidix_play.src.w; | |
569 info->dest.h = vidix_play.src.h; | |
570 info->dest.pitch.y = vidix_play.dest.pitch.y; | |
571 info->dest.pitch.u = vidix_play.dest.pitch.u; | |
572 info->dest.pitch.v = vidix_play.dest.pitch.v; | |
573 info->flags = vidix_play.flags; | |
574 info->frame_size = vidix_play.frame_size; | |
575 info->num_frames = vidix_play.num_frames; | |
576 memcpy(info->offsets,vidix_play.offsets,sizeof(unsigned)*vidix_play.num_frames); | |
577 memcpy(&info->offset,&vidix_play.offset,sizeof(vidix_yuv_t)); | |
578 info->dga_addr = vidix_play.dga_addr; | |
579 return 0; | |
580 } | |
4379 | 581 |
582 static int vidix_get_video_eq(vidix_video_eq_t *info) | |
583 { | |
584 if(!video_on) return EPERM; | |
585 return vdlPlaybackGetEq(vidix_handler, info); | |
586 } | |
587 | |
588 static int vidix_set_video_eq(const vidix_video_eq_t *info) | |
589 { | |
590 if(!video_on) return EPERM; | |
591 return vdlPlaybackSetEq(vidix_handler, info); | |
592 } | |
593 | |
594 static int vidix_get_num_fx(unsigned *info) | |
595 { | |
596 if(!video_on) return EPERM; | |
597 return vdlQueryNumOemEffects(vidix_handler, info); | |
598 } | |
599 | |
600 static int vidix_get_oem_fx(vidix_oem_fx_t *info) | |
601 { | |
602 if(!video_on) return EPERM; | |
603 return vdlGetOemEffect(vidix_handler, info); | |
604 } | |
605 | |
606 static int vidix_set_oem_fx(const vidix_oem_fx_t *info) | |
607 { | |
608 if(!video_on) return EPERM; | |
609 return vdlSetOemEffect(vidix_handler, info); | |
610 } | |
611 | |
612 static int vidix_set_deint(const vidix_deinterlace_t *info) | |
613 { | |
614 if(!video_on) return EPERM; | |
615 return vdlPlaybackSetDeint(vidix_handler, info); | |
616 } |