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