Mercurial > mplayer.hg
annotate libvo/vo_aa.c @ 1537:7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
author | folke |
---|---|
date | Wed, 15 Aug 2001 19:27:57 +0000 |
parents | 187aa4b576a7 |
children | f3f4fc77fd88 |
rev | line source |
---|---|
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
1 / /* configuration */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
2 /* |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
3 if (osdcolor; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
4 int subcolor; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
5 int extended; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
6 int eight; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
7 char *driver; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
8 char *font; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
9 int dim; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
10 int bold; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
11 int reverse; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
12 int normal; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
13 int boldfont; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
14 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
15 int inverse; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
16 int bright; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
17 int contrast; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
18 int gamma; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
19 int dimmul; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
20 int boldmul; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
21 */* |
1511 | 22 * MPlayer |
23 * | |
24 * Video driver for AAlib - alpha version | |
25 * | |
26 * by Folke Ashberg <folke@ashberg.de> | |
27 * | |
28 * Code started: Sun Aug 12 2001 | |
29 * | |
30 */ | |
31 | |
32 #include <stdio.h> | |
33 #include <stdlib.h> | |
34 | |
35 | |
36 #include <limits.h> | |
37 #include <math.h> | |
38 #include <stdarg.h> | |
39 #include <time.h> | |
40 #include <string.h> | |
41 | |
42 #include "config.h" | |
43 #include "video_out.h" | |
44 #include "video_out_internal.h" | |
45 #include "yuv2rgb.h" | |
46 #include "sub.h" | |
47 | |
48 #include "linux/keycodes.h" | |
49 #include <aalib.h> | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
50 #include "cfgparser.h" |
1511 | 51 |
52 #define RGB 0 | |
53 #define BGR 1 | |
54 | |
55 #define DO_INC(val,max,step) if (val + step <=max) val+=step; else val=max; | |
56 #define DO_DEC(val,min,step) if (val - step >=min) val-=step; else val=min; | |
57 | |
58 #define MESSAGE_DURATION 3 | |
59 #define MESSAGE_SIZE 512 | |
60 #define MESSAGE_DEKO " +++ %s +++ " | |
61 | |
62 | |
63 | |
64 LIBVO_EXTERN(aa) | |
65 | |
66 static vo_info_t vo_info = { | |
67 "AAlib", | |
68 "aa", | |
69 "Folke Ashberg <folke@ashberg.de>", | |
70 "" | |
71 }; | |
72 | |
73 /* aa's main context we use */ | |
74 aa_context *c; | |
75 aa_renderparams *p; | |
76 static int fast =0; | |
77 /* used for YV12 streams for the converted RGB image */ | |
78 uint8_t * convertbuf=NULL; | |
79 | |
80 /* image infos */ | |
81 static int image_format, bpp=24; | |
82 static int image_width; | |
83 static int image_height; | |
84 static int bppmul; | |
85 | |
86 /* osd stuff */ | |
87 time_t stoposd = 0; | |
88 static int showosd = 0; | |
89 char osdtext[MESSAGE_SIZE]; | |
90 char posbar[MESSAGE_SIZE]; | |
91 static int osdx, osdy; | |
92 | |
93 /* for resizing/scaling */ | |
94 static int *stx; | |
95 static int *sty; | |
96 double accum; | |
97 | |
98 /* our version of the playmodes :) */ | |
1527 | 99 static char * osdmodes[] ={ "|>", "||", "[]", "<<" , ">>" }; |
1511 | 100 |
101 extern void mplayer_put_key(int code); | |
102 | |
1518 | 103 /* to disable stdout outputs when curses/linux mode */ |
104 extern int quiet; | |
105 | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
106 /* configuration */ |
1518 | 107 int aaopt_osdcolor = AA_SPECIAL; |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
108 int aaopt_subcolor = AA_SPECIAL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
109 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
110 extern struct aa_hardware_params aa_defparams; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
111 extern struct aa_renderparams aa_defrenderparams; |
1511 | 112 |
113 void | |
114 resize(void){ | |
115 /* | |
116 * this function is called by aa lib if windows resizes | |
117 * further during init, because here we have to calculate | |
118 * a little bit | |
119 */ | |
120 | |
121 int i; | |
122 aa_resize(c); | |
123 | |
124 showosd=0; | |
125 osdy=aa_scrheight(c) - ( aa_scrheight(c)/10 ); | |
126 | |
127 /* now calculating the needed values for resizing */ | |
128 | |
129 /* We only need to use floating point to determine the correct | |
130 stretch vector for one line's worth. */ | |
131 stx = (int *) malloc(sizeof(int) * image_width); | |
132 sty = (int *) malloc(sizeof(int) * image_height); | |
133 accum = 0; | |
134 for (i=0; (i < image_width); i++) { | |
135 int got; | |
136 accum += (double)aa_imgwidth(c)/(double)image_width; | |
137 got = (int) floor(accum); | |
138 stx[i] = got; | |
139 accum -= got; | |
140 } | |
141 accum = 0; | |
142 for (i=0; (i < image_height); i++) { | |
143 int got; | |
144 accum += (double)aa_imgheight(c)/(double)image_height; | |
145 got = (int) floor(accum); | |
146 sty[i] = got; | |
147 accum -= got; | |
148 } | |
149 } | |
150 | |
151 void | |
152 osdmessage(int duration, int deko, char *fmt, ...) | |
153 { | |
154 /* | |
155 * for outputting a centered string at the bottom | |
156 * of our window for a while | |
157 */ | |
158 va_list ar; | |
159 char m[MESSAGE_SIZE]; | |
160 va_start(ar, fmt); | |
161 vsprintf(m, fmt, ar); | |
162 va_end(ar); | |
163 if (deko==1) sprintf(osdtext, MESSAGE_DEKO , m); | |
164 else strcpy(osdtext, m); | |
165 showosd=1; | |
166 stoposd = time(NULL) + duration; | |
167 osdx=(aa_scrwidth(c) / 2) - (strlen(osdtext) / 2 ) ; | |
168 posbar[0]='\0'; | |
169 } | |
170 | |
171 void | |
172 osdpercent(int duration, int deko, int min, int max, int val, char * desc, char * unit) | |
173 { | |
174 /* | |
175 * prints a bar for setting values | |
176 */ | |
177 float step; | |
178 int where; | |
179 char m[MESSAGE_SIZE]; | |
180 int i; | |
181 step=(float)aa_scrwidth(c) /(float)(max-min); | |
182 where=(val-min)*step; | |
183 sprintf(m,"%s: %i%s",desc, val, unit); | |
184 if (deko==1) sprintf(osdtext, MESSAGE_DEKO , m); | |
185 else strcpy(osdtext, m); | |
186 posbar[0]='|'; | |
187 posbar[aa_scrwidth(c)-1]='|'; | |
188 for (i=0;i<aa_scrwidth(c);i++){ | |
189 if (i==where) posbar[i]='#'; | |
190 else posbar[i]='-'; | |
191 } | |
192 if (where!=0) posbar[0]='|'; | |
193 if (where!=(aa_scrwidth(c)-1) ) posbar[aa_scrwidth(c)-1]='|'; | |
194 /* snipp */ | |
195 posbar[aa_scrwidth(c)]='\0'; | |
196 showosd=1; | |
197 stoposd = time(NULL) + duration; | |
198 osdx=(aa_scrwidth(c) / 2) - (strlen(osdtext) / 2 ) ; | |
199 } | |
200 | |
201 static uint32_t | |
202 init(uint32_t width, uint32_t height, uint32_t d_width, | |
203 uint32_t d_height, uint32_t fullscreen, char *title, | |
204 uint32_t format) { | |
205 /* | |
206 * main init | |
207 * called by mplayer | |
208 */ | |
209 | |
210 switch(format) { | |
211 case IMGFMT_BGR24: | |
212 bpp = 24; | |
213 break; | |
214 case IMGFMT_RGB24: | |
215 bpp = 24; | |
216 break; | |
217 case IMGFMT_YV12: | |
218 bpp = 24; | |
219 /* YUV ? then initialize what we will need */ | |
220 convertbuf=malloc(width*height*3); | |
221 yuv2rgb_init(24,MODE_BGR); | |
222 break; | |
223 default: | |
224 return 1; | |
225 } | |
226 bppmul=bpp/8; | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
227 |
1511 | 228 |
229 /* initializing of aalib */ | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
230 /* |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
231 TODO check /dev/vcsa |
1511 | 232 aa_recommendhidisplay("curses"); |
233 aa_recommendhidisplay("X11"); | |
234 aa_recommendlowdisplay("linux"); | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
235 */ |
1518 | 236 |
1511 | 237 c = aa_autoinit(&aa_defparams); |
238 aa_resizehandler(c, (void *)resize); | |
239 | |
240 if (c == NULL) { | |
241 printf("Can not intialize aalib\n"); | |
242 return 0; | |
243 } | |
244 if (!aa_autoinitkbd(c,0)) { | |
245 printf("Can not intialize keyboard\n"); | |
246 aa_close(c); | |
247 return 0; | |
248 } | |
249 /* | |
250 if (!aa_autoinitmouse(c,0)) { | |
251 printf("Can not intialize mouse\n"); | |
252 aa_close(c); | |
253 return 0; | |
254 } | |
255 */ | |
256 aa_hidecursor(c); | |
257 p = aa_getrenderparams(); | |
258 | |
1520 | 259 if ((strstr(c->driver->name,"Curses")) || (strstr(c->driver->name,"Linux"))){ |
1511 | 260 freopen("/dev/null", "w", stderr); |
1518 | 261 quiet=1; /* disable mplayer outputs */ |
262 } | |
1511 | 263 |
264 image_height = height; | |
265 image_width = width; | |
266 image_format = format; | |
267 | |
268 /* needed by prepare_image */ | |
269 stx = (int *) malloc(sizeof(int) * image_width); | |
270 sty = (int *) malloc(sizeof(int) * image_height); | |
271 | |
272 /* nothing will change its size, be we need some values initialized */ | |
273 resize(); | |
274 | |
275 /* say hello */ | |
276 osdmessage(5, 1, "Welcome to ASCII ARTS MPlayer"); | |
277 | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
278 printf("VO: [aa] screendriver: %s\n", c->driver->name); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
279 printf("VO: [aa] keyboarddriver: %s\n", c->kbddriver->name); |
1511 | 280 //printf("VO: mousedriver: %s\n", c->mousedriver->name); |
281 | |
282 printf( | |
283 "\n" | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
284 "Important Options\n" |
1518 | 285 "\t-aaextended use use all 256 characters\n" |
286 "\t-aaeight use eight bit ascii\n" | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
287 "\t-aadriver set recommended aalib driver (X11,curses,linux)\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
288 "\t-aahelp to see all options provided by aalib\n" |
1518 | 289 "\n" |
290 "AA-MPlayer Keys:\n" | |
1511 | 291 "\t1 : fast rendering\n" |
292 "\t2 : dithering\n" | |
293 "\t3 : invert image\n" | |
294 "\t4 : contrast -\n" | |
295 "\t5 : contrast +\n" | |
296 "\t6 : brightness -\n" | |
297 "\t7 : brightness +\n" | |
298 "\n" | |
1527 | 299 "All other keys are MPlayer defaults.\n" |
1511 | 300 |
301 | |
302 ); | |
303 | |
304 return 0; | |
305 } | |
306 | |
307 static uint32_t | |
308 query_format(uint32_t format) { | |
309 /* | |
310 * ...are we able to... ? | |
311 * called by mplayer | |
312 */ | |
313 switch(format){ | |
314 case IMGFMT_YV12: | |
315 case IMGFMT_RGB|24: | |
316 case IMGFMT_BGR|24: | |
317 return 1; | |
318 } | |
319 return 0; | |
320 } | |
321 | |
322 static const vo_info_t* | |
323 get_info(void) { | |
324 /* who i am? */ | |
325 return (&vo_info); | |
326 } | |
327 | |
328 int | |
329 prepare_image(uint8_t *data, int inx, int iny, int outx, int outy){ | |
330 /* | |
331 * copies an RGB-Image to the aalib imagebuffer | |
332 * also scaling an grayscaling is done here | |
333 * show_image calls us | |
334 */ | |
335 | |
336 int value; | |
337 int x, y; | |
338 int tox, toy; | |
339 int ydest; | |
340 int i; | |
341 int pos; | |
342 | |
343 toy = 0; | |
344 for (y=0; (y < (0 + iny)); y++) { | |
345 for (ydest=0; (ydest < sty[y-0]); ydest++) { | |
346 tox = 0; | |
347 for (x=0; (x < (0 + inx)); x++) { | |
348 if (!stx[x - 0]) { | |
349 continue; | |
350 } | |
351 pos=3*(inx*y)+(3*x); | |
352 value=(data[pos]+data[pos+1]+data[pos+2])/3; | |
353 for (i=0; (i < stx[x - 0]); i++) { | |
354 //printf("ToX: %i, ToY %i, i=%i, stx=%i, x=%i\n", tox, toy, i, stx[x], x); | |
355 c->imagebuffer[(toy*outx) +tox]=value; | |
356 tox++; | |
357 } | |
358 } | |
359 toy++; | |
360 } | |
361 } | |
362 return 0; | |
363 } | |
364 | |
365 void | |
366 printosd() | |
367 { | |
368 /* | |
369 * places the mplayer status osd | |
370 */ | |
371 if (vo_osd_text){ | |
372 if (vo_osd_text[0]-1<=5) | |
1518 | 373 aa_puts(c, 0,0, aaopt_osdcolor, osdmodes[vo_osd_text[0]-1]); |
374 else aa_puts(c, 0,0, aaopt_osdcolor, "?"); | |
375 aa_puts(c,2,0, aaopt_osdcolor, vo_osd_text+1); | |
376 aa_puts(c,strlen(vo_osd_text)+1,0, aaopt_osdcolor, " "); | |
1511 | 377 } |
378 } | |
379 | |
380 void | |
381 show_image(uint8_t * src){ | |
382 /* | |
383 * every frame (flip_page/draw_frame) we will be called | |
384 */ | |
385 | |
386 /* events? */ | |
387 check_events(); | |
388 | |
389 /* RGB->gray , scaling/resizing, stores data in aalib imgbuf */ | |
390 prepare_image( src, image_width, image_height, | |
391 aa_imgwidth(c), aa_imgheight(c) ); | |
392 | |
393 /* Now 'ASCIInate' the image */ | |
394 if (fast) | |
395 aa_fastrender(c, 0, 0, aa_scrwidth(c), aa_scrheight(c) ); | |
396 else | |
397 aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c)); | |
398 | |
399 /* do we have to put our osd to aa's txtbuf ? */ | |
400 if (showosd) | |
401 { | |
402 if (time(NULL)>=stoposd ) showosd=0; | |
403 /* update osd */ | |
404 aa_puts(c, osdx, osdy, AA_SPECIAL, osdtext); | |
405 /* posbar? */ | |
406 if (posbar[0]!='\0') | |
407 aa_puts(c, 0, osdy + 1, AA_SPECIAL, posbar); | |
408 } | |
409 /* and the real OSD, but only the time & playmode */ | |
410 printosd(); | |
411 | |
412 /* print out */ | |
413 aa_flush(c); | |
414 } | |
415 | |
416 static uint32_t | |
417 draw_frame(uint8_t *src[]) { | |
418 /* | |
419 * RGB-Video's Only | |
420 * src[0] is handled bu prepare_image | |
421 */ | |
422 show_image(src[0]); | |
423 return 0; | |
424 } | |
425 | |
426 static uint32_t | |
427 draw_slice(uint8_t *src[], int stride[], | |
428 int w, int h, int x, int y) { | |
429 /* | |
430 * for MPGEGS YV12 | |
431 * draw a rectangle converted to RGB to a | |
432 * temporary RGB Buffer | |
433 */ | |
434 uint8_t *dst; | |
435 | |
436 dst = convertbuf+(image_width * y + x) * 3; | |
437 yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*3,stride[0],stride[1]); | |
438 | |
439 return 0; | |
440 } | |
441 | |
442 static void | |
443 flip_page(void) { | |
444 /* | |
445 * wow! another ready Image, so draw it ! | |
446 */ | |
447 if(image_format == IMGFMT_YV12) | |
448 show_image(convertbuf); | |
449 } | |
450 | |
451 static void | |
452 check_events(void) { | |
453 /* | |
454 * any events? | |
455 * called by show_image and mplayer | |
456 */ | |
457 int key; | |
458 while ((key=aa_getevent(c,0))!=AA_NONE ){ | |
459 if (key>255){ | |
460 /* some conversations */ | |
461 switch (key) { | |
462 case AA_UP: | |
463 mplayer_put_key(KEY_UP); | |
464 break; | |
465 case AA_DOWN: | |
466 mplayer_put_key(KEY_DOWN); | |
467 break; | |
468 case AA_LEFT: | |
469 mplayer_put_key(KEY_LEFT); | |
470 break; | |
471 case AA_RIGHT: | |
472 mplayer_put_key(KEY_RIGHT); | |
473 break; | |
474 case AA_ESC: | |
475 mplayer_put_key(KEY_ESC); | |
476 break; | |
477 case 65765: | |
478 mplayer_put_key(KEY_PAGE_UP); | |
479 break; | |
480 case 65766: | |
481 mplayer_put_key(KEY_PAGE_DOWN); | |
482 break; | |
483 default: | |
484 continue; /* aa lib special key */ | |
485 break; | |
486 } | |
487 } | |
488 switch (key) { | |
489 /* AA image controls */ | |
490 case '1': | |
491 fast=!fast; | |
492 osdmessage(MESSAGE_DURATION, 1, "Fast mode is now %s", fast==1 ? "on" : "off"); | |
493 break; | |
494 case '2': | |
495 if (p->dither==AA_FLOYD_S){ | |
496 p->dither=AA_NONE; | |
497 osdmessage(MESSAGE_DURATION, 1, "Dithering: Off"); | |
498 }else if (p->dither==AA_NONE){ | |
499 p->dither=AA_ERRORDISTRIB; | |
500 osdmessage(MESSAGE_DURATION, 1, "Dithering: Error Distribution"); | |
501 }else if (p->dither==AA_ERRORDISTRIB){ | |
502 p->dither=AA_FLOYD_S; | |
503 osdmessage(MESSAGE_DURATION, 1, "Dithering: Floyd Steinberg"); | |
504 } | |
505 break; | |
506 case '3': | |
507 p->inversion=!p->inversion; | |
508 osdmessage(MESSAGE_DURATION, 1, "Invert mode is now %s", | |
509 p->inversion==1 ? "on" : "off"); | |
510 break; | |
511 | |
512 case '4': /* contrast */ | |
513 DO_DEC(p->contrast,0,1); | |
514 osdpercent(MESSAGE_DURATION, 1, 0, 255, p->contrast, "AA-Contrast", ""); | |
515 | |
516 break; | |
517 case '5': /* contrast */ | |
518 DO_INC(p->contrast,255,1); | |
519 osdpercent(MESSAGE_DURATION, 1, 0, 255, p->contrast, "AA-Contrast", ""); | |
520 break; | |
521 case '6': /* brightness */ | |
522 DO_DEC(p->bright,0,1); | |
523 osdpercent(MESSAGE_DURATION, 1, 0, 255, p->bright, "AA-Brightnes", ""); | |
524 break; | |
525 case '7': /* brightness */ | |
526 DO_INC(p->bright,255,1); | |
527 osdpercent(MESSAGE_DURATION, 1, 0, 255, p->bright, "AA-Brightnes", ""); | |
528 break; | |
529 | |
530 default : | |
531 /* nothing if we're interested in? | |
532 * the mplayer should handle it! | |
533 */ | |
534 mplayer_put_key(key); | |
535 break; | |
536 } | |
537 } | |
538 } | |
539 | |
540 static void | |
541 uninit(void) { | |
542 /* | |
543 * THE END | |
544 */ | |
545 aa_close(c); | |
546 free(stx); | |
547 free(sty); | |
548 if (convertbuf!=NULL) free(convertbuf); | |
1520 | 549 if (strstr(c->driver->name,"Curses") || strstr(c->driver->name,"Linux")){ |
1511 | 550 freopen("/dev/tty", "w", stderr); |
1518 | 551 quiet=0; /* enable mplayer outputs */ |
552 } | |
1511 | 553 } |
554 | |
555 static void | |
556 draw_osd(void){ | |
557 } | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
558 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
559 int |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
560 getcolor(char * s){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
561 int i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
562 char * rest; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
563 if (s==NULL) return -1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
564 i=strtol(s, &rest, 10); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
565 if ((rest==NULL || strlen(rest)==0) && i>=0 && i<=5) return i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
566 if (!strcasecmp(s, "normal")) return AA_NORMAL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
567 else if (!strcasecmp(s, "dim")) return AA_DIM; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
568 else if (!strcasecmp(s, "bold")) return AA_BOLD; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
569 else if (!strcasecmp(s, "boldfont")) return AA_BOLDFONT; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
570 else if (!strcasecmp(s, "special")) return AA_SPECIAL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
571 else return -1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
572 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
573 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
574 int |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
575 vo_aa_parseoption(struct config * conf, char *opt, char *param){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
576 /* got an option starting with aa */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
577 char *pseudoargv[3]; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
578 int pseudoargc; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
579 char * x, *help; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
580 int i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
581 /* do WE need it ? */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
582 if (!strcasecmp(opt, "aaosdcolor")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
583 if (param==NULL) return ERR_MISSING_PARAM; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
584 if ((i=getcolor(param))==-1) return ERR_OUT_OF_RANGE; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
585 aaopt_osdcolor=i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
586 return 1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
587 }else if (!strcasecmp(opt, "aasubcolor")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
588 if ((i=getcolor(param))==-1) return ERR_OUT_OF_RANGE; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
589 aaopt_subcolor=i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
590 return 1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
591 }else if (!strcasecmp(opt, "aahelp")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
592 printf("Here are the aalib options:\n"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
593 help=strdup(aa_help); /* aa_help is const :( */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
594 x=strtok(help,"-"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
595 printf(x); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
596 while (x=strtok(NULL, "-")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
597 if (*(x-2)==' ') printf("-aa"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
598 else printf("-"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
599 printf("%s", x); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
600 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
601 printf( |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
602 "\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
603 "\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
604 "Additional options vo_aa provides:\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
605 " -aaosdcolor set osd color\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
606 " -aasubcolor set subtitle color\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
607 " the color params are:\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
608 " 0 : normal\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
609 " 1 : dark\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
610 " 2 : bold\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
611 " 3 : boldfont\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
612 " 4 : reverse\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
613 " 6 : special\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
614 "\n\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
615 " dT8 8Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
616 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
617 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
618 " <PROJECT><PROJECT>\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
619 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
620 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
621 "\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
622 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
623 ); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
624 exit(0); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
625 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
626 }else{ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
627 /* parse param to aalib */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
628 pseudoargv[1]=malloc(strlen(opt)); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
629 pseudoargv[3]=NULL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
630 sprintf(pseudoargv[1], "-%s", opt+2); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
631 if (param!=NULL){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
632 pseudoargv[2]=param; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
633 pseudoargc=3; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
634 }else{ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
635 pseudoargv[2]=NULL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
636 pseudoargc=2; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
637 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
638 fprintf(stderr,"VO: [aa] "); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
639 i=aa_parseoptions(&aa_defparams, &aa_defrenderparams, &pseudoargc, pseudoargv); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
640 if (i!=1){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
641 return ERR_MISSING_PARAM; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
642 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
643 if (pseudoargv[1]!=NULL){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
644 /* aalib has given param back */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
645 fprintf(stderr," Parameter -%s accepted\n", opt, param); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
646 return 0; /* param could be the filename */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
647 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
648 fprintf(stderr," Parameter -%s %s accepted\n", opt, param==NULL ? "" : param); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
649 return 1; /* all opt & params accepted */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
650 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
651 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
652 return ERR_NOT_AN_OPTION; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
653 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
654 } |