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