Mercurial > mplayer.hg
annotate libvo/vo_aa.c @ 5892:2e71feda5e0f
Added ICY error 401: Service unavailable.
author | bertrand |
---|---|
date | Sun, 28 Apr 2002 22:37:35 +0000 |
parents | 125d667e9eac |
children | b93497af9ddc |
rev | line source |
---|---|
1538
f3f4fc77fd88
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new. fixed wrong char
folke
parents:
1537
diff
changeset
|
1 /* |
1511 | 2 * MPlayer |
3 * | |
1553
12551899e83f
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking +header change
folke
parents:
1551
diff
changeset
|
4 * Video driver for AAlib - 1.0 |
1511 | 5 * |
6 * by Folke Ashberg <folke@ashberg.de> | |
7 * | |
8 * Code started: Sun Aug 12 2001 | |
1553
12551899e83f
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking +header change
folke
parents:
1551
diff
changeset
|
9 * Version 1.0 : Thu Aug 16 2001 |
1511 | 10 * |
11 */ | |
12 | |
13 #include <stdio.h> | |
14 #include <stdlib.h> | |
15 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
16 #include <sys/stat.h> |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
17 #include <unistd.h> |
1511 | 18 |
19 #include <limits.h> | |
20 #include <math.h> | |
21 #include <stdarg.h> | |
22 #include <time.h> | |
23 #include <string.h> | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4674
diff
changeset
|
24 #include <errno.h> |
1511 | 25 |
26 #include "config.h" | |
27 #include "video_out.h" | |
28 #include "video_out_internal.h" | |
5870 | 29 #include "aspect.h" |
30 #include "../postproc/swscale.h" | |
5295 | 31 #include "font_load.h" |
1511 | 32 #include "sub.h" |
33 | |
34 #include "linux/keycodes.h" | |
35 #include <aalib.h> | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
36 #include "cfgparser.h" |
5870 | 37 #include "mp_msg.h" |
1511 | 38 |
39 | |
40 #define MESSAGE_DURATION 3 | |
41 #define MESSAGE_SIZE 512 | |
42 #define MESSAGE_DEKO " +++ %s +++ " | |
43 | |
44 LIBVO_EXTERN(aa) | |
45 | |
46 static vo_info_t vo_info = { | |
47 "AAlib", | |
48 "aa", | |
5870 | 49 "Alban Bedel <albeu@free.fr> and Folke Ashberg <folke@ashberg.de>", |
1511 | 50 "" |
51 }; | |
52 | |
53 /* aa's main context we use */ | |
54 aa_context *c; | |
55 aa_renderparams *p; | |
56 static int fast =0; | |
5870 | 57 /* used for the sws */ |
58 static uint8_t * image[3]; | |
59 static int image_stride[3]; | |
1511 | 60 |
61 /* image infos */ | |
5870 | 62 static int image_format; |
1511 | 63 static int image_width; |
64 static int image_height; | |
5870 | 65 static int image_x, image_y; |
66 static int screen_x, screen_y; | |
67 static int screen_w, screen_h; | |
68 static int src_width; | |
69 static int src_height; | |
1511 | 70 |
71 /* osd stuff */ | |
72 time_t stoposd = 0; | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
73 static int showosdmessage = 0; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
74 char osdmessagetext[MESSAGE_SIZE]; |
1511 | 75 char posbar[MESSAGE_SIZE]; |
76 static int osdx, osdy; | |
5870 | 77 static int osd_text_length = 0; |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
78 int aaconfigmode=1; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
79 #ifdef USE_OSD |
5870 | 80 font_desc_t* vo_font_save = NULL; |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
81 #endif |
5870 | 82 static SwsContext *sws=NULL; |
83 extern m_config_t *mconfig; | |
1511 | 84 |
85 /* our version of the playmodes :) */ | |
86 | |
87 extern void mplayer_put_key(int code); | |
88 | |
1518 | 89 /* to disable stdout outputs when curses/linux mode */ |
90 extern int quiet; | |
91 | |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
92 /* configuration */ |
1518 | 93 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
|
94 int aaopt_subcolor = AA_SPECIAL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
95 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
96 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
|
97 extern struct aa_renderparams aa_defrenderparams; |
1511 | 98 |
99 void | |
100 resize(void){ | |
101 /* | |
102 * this function is called by aa lib if windows resizes | |
103 * further during init, because here we have to calculate | |
104 * a little bit | |
105 */ | |
106 | |
107 aa_resize(c); | |
108 | |
5870 | 109 aspect_save_screenres(aa_imgwidth(c),aa_imgheight(c)); |
110 image_height = aa_imgheight(c); //src_height; | |
111 image_width = aa_imgwidth(c); //src_width; | |
112 | |
113 aspect(&image_width,&image_height,A_ZOOM); | |
114 | |
115 image_x = (aa_imgwidth(c) - image_width) / 2; | |
116 image_y = (aa_imgheight(c) - image_height) / 2; | |
117 screen_w = image_width * aa_scrwidth(c) / aa_imgwidth(c); | |
118 screen_h = image_height * aa_scrheight(c) / aa_imgheight(c); | |
119 screen_x = (aa_scrwidth(c) - screen_w) / 2; | |
120 screen_y = (aa_scrheight(c) - screen_h) / 2; | |
121 | |
122 if(sws) freeSwsContext(sws); | |
123 // Use YV12 while Y8/Y800 isn't avaible as sws output :-( | |
124 sws = getSwsContextFromCmdLine(src_width,src_height,image_format, | |
125 image_width,image_height,IMGFMT_YV12); | |
126 | |
127 image[0] = aa_image(c) + image_y * image_width + image_x; | |
128 image[1] = NULL; | |
129 // Allocate the V plan for YV12 | |
130 image[2] = realloc(image[2], image_width * image_height / 4); | |
131 | |
132 image_stride[0] = image_width; | |
133 image_stride[1] = 0; | |
134 image_stride[2] = image_width / 2; | |
135 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
136 showosdmessage=0; |
1511 | 137 |
138 } | |
139 | |
140 void | |
141 osdmessage(int duration, int deko, char *fmt, ...) | |
142 { | |
143 /* | |
144 * for outputting a centered string at the bottom | |
145 * of our window for a while | |
146 */ | |
147 va_list ar; | |
148 char m[MESSAGE_SIZE]; | |
5870 | 149 unsigned int old_len = strlen(osdmessagetext); |
150 | |
1511 | 151 va_start(ar, fmt); |
152 vsprintf(m, fmt, ar); | |
153 va_end(ar); | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
154 if (deko==1) sprintf(osdmessagetext, MESSAGE_DEKO , m); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
155 else strcpy(osdmessagetext, m); |
5870 | 156 |
157 if(old_len > strlen(osdmessagetext)) { | |
158 memset(c->textbuffer + osdy * aa_scrwidth(c) + osdx,' ',old_len); | |
159 memset(c->attrbuffer + osdy * aa_scrwidth(c) + osdx,0,old_len); | |
160 } | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
161 showosdmessage=1; |
1511 | 162 stoposd = time(NULL) + duration; |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
163 osdx=(aa_scrwidth(c) / 2) - (strlen(osdmessagetext) / 2 ) ; |
1511 | 164 posbar[0]='\0'; |
165 } | |
166 | |
167 void | |
168 osdpercent(int duration, int deko, int min, int max, int val, char * desc, char * unit) | |
169 { | |
170 /* | |
171 * prints a bar for setting values | |
172 */ | |
173 float step; | |
174 int where; | |
175 int i; | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
176 |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
177 |
1511 | 178 step=(float)aa_scrwidth(c) /(float)(max-min); |
179 where=(val-min)*step; | |
5870 | 180 osdmessage(duration,deko,"%s: %i%s",desc, val, unit); |
1511 | 181 posbar[0]='|'; |
182 posbar[aa_scrwidth(c)-1]='|'; | |
183 for (i=0;i<aa_scrwidth(c);i++){ | |
184 if (i==where) posbar[i]='#'; | |
185 else posbar[i]='-'; | |
186 } | |
187 if (where!=0) posbar[0]='|'; | |
188 if (where!=(aa_scrwidth(c)-1) ) posbar[aa_scrwidth(c)-1]='|'; | |
5870 | 189 |
1511 | 190 posbar[aa_scrwidth(c)]='\0'; |
5870 | 191 |
1511 | 192 } |
193 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
194 void |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
195 printosdtext() |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
196 { |
5870 | 197 if(osd_text_length > 0 && !vo_osd_text) { |
198 memset(c->textbuffer,' ',osd_text_length); | |
199 memset(c->attrbuffer,0,osd_text_length); | |
200 osd_text_length = 0; | |
201 } | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
202 /* |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
203 * places the mplayer status osd |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
204 */ |
5870 | 205 if (vo_osd_text) { |
206 int len; | |
207 if(vo_osd_text[0] < 32) { | |
208 len = strlen(__sub_osd_names_short[vo_osd_text[0]]) + strlen(vo_osd_text+1) + 2; | |
209 aa_printf(c, 0, 0 , aaopt_osdcolor, "%s %s ", __sub_osd_names_short[vo_osd_text[0]], vo_osd_text+1); | |
210 } else { | |
211 len = strlen(vo_osd_text) + 1; | |
212 aa_printf(c, 0, 0 , aaopt_osdcolor, "%s ",vo_osd_text); | |
213 } | |
214 | |
215 if(len < osd_text_length) { | |
216 memset(c->textbuffer + len,' ',osd_text_length - len); | |
217 memset(c->attrbuffer + len,0,osd_text_length - len); | |
218 } | |
219 osd_text_length = len; | |
220 | |
221 } | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
222 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
223 |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
224 void |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
225 printosdprogbar(){ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
226 /* print mplayer osd-progbar */ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
227 if (vo_osd_progbar_type!=-1){ |
2498 | 228 osdpercent(1,1,0,255,vo_osd_progbar_value, __sub_osd_names[vo_osd_progbar_type], ""); |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
229 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
230 } |
1511 | 231 static uint32_t |
4433 | 232 config(uint32_t width, uint32_t height, uint32_t d_width, |
1511 | 233 uint32_t d_height, uint32_t fullscreen, char *title, |
4433 | 234 uint32_t format,const vo_tune_info_t *info) { |
1511 | 235 /* |
236 * main init | |
237 * called by mplayer | |
238 */ | |
5870 | 239 |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
240 int i; |
1511 | 241 |
5870 | 242 aspect_save_orig(width,height); |
243 aspect_save_prescale(d_width,d_height); | |
1511 | 244 |
5870 | 245 src_height = height; |
246 src_width = width; | |
1511 | 247 image_format = format; |
248 | |
249 /* nothing will change its size, be we need some values initialized */ | |
250 resize(); | |
251 | |
1554 | 252 #ifdef USE_OSD |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
253 /* now init out own 'font' (to use vo_draw_text_sub without edit them) */ |
5870 | 254 if(!vo_font_save) vo_font_save = vo_font; |
255 if(vo_font == vo_font_save) { | |
256 vo_font=malloc(sizeof(font_desc_t));//if(!desc) return NULL; | |
257 memset(vo_font,0,sizeof(font_desc_t)); | |
258 vo_font->pic_a[0]=malloc(sizeof(raw_file)); | |
259 vo_font->pic_b[0]=malloc(sizeof(raw_file)); | |
1572 | 260 |
5870 | 261 vo_font->spacewidth=1; |
262 vo_font->charspace=0; | |
263 vo_font->height=1; | |
264 vo_font->pic_a[0]->bmp=malloc(255); | |
265 vo_font->pic_b[0]->bmp=malloc(255); | |
266 vo_font->pic_a[0]->w=1; | |
267 vo_font->pic_a[0]->h=1; | |
268 for (i=0; i<255; i++){ | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
269 vo_font->width[i]=1; |
1572 | 270 vo_font->font[i]=0; |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
271 vo_font->start[i]=i; |
1572 | 272 vo_font->pic_a[0]->bmp[i]=i; |
273 vo_font->pic_b[0]->bmp[i]=i; | |
5870 | 274 } |
275 } | |
1554 | 276 #endif |
1511 | 277 /* say hello */ |
278 osdmessage(5, 1, "Welcome to ASCII ARTS MPlayer"); | |
279 | |
5870 | 280 mp_msg(MSGT_VO,MSGL_V,"VO: [aa] screendriver: %s\n", c->driver->name); |
281 mp_msg(MSGT_VO,MSGL_V,"VO: [aa] keyboarddriver: %s\n", c->kbddriver->name); | |
1511 | 282 |
5870 | 283 mp_msg(MSGT_VO,MSGL_INFO, |
1511 | 284 "\n" |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
285 "Important Options\n" |
1518 | 286 "\t-aaextended use use all 256 characters\n" |
287 "\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
|
288 "\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
|
289 "\t-aahelp to see all options provided by aalib\n" |
1518 | 290 "\n" |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
291 "AA-MPlayer Keys\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
292 "\t1 : contrast -\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
293 "\t2 : contrast +\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
294 "\t3 : brightness -\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
295 "\t4 : brightness +\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
296 "\t5 : fast rendering\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
297 "\t6 : dithering\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
298 "\t7 : invert image\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
299 "\ta : toggles between aa and mplayer control\n" |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
300 |
1511 | 301 "\n" |
1527 | 302 "All other keys are MPlayer defaults.\n" |
1511 | 303 |
304 | |
305 ); | |
306 | |
307 return 0; | |
308 } | |
309 | |
310 static uint32_t | |
311 query_format(uint32_t format) { | |
312 /* | |
313 * ...are we able to... ? | |
314 * called by mplayer | |
5870 | 315 * All input format supported by the sws |
1511 | 316 */ |
317 switch(format){ | |
318 case IMGFMT_YV12: | |
5870 | 319 case IMGFMT_I420: |
320 case IMGFMT_IYUV: | |
321 case IMGFMT_IYU2: | |
322 case IMGFMT_BGR32: | |
5027 | 323 case IMGFMT_BGR24: |
5870 | 324 case IMGFMT_BGR16: |
325 case IMGFMT_BGR15: | |
326 case IMGFMT_RGB32: | |
327 case IMGFMT_RGB24: | |
328 case IMGFMT_Y8: | |
329 case IMGFMT_Y800: | |
1511 | 330 return 1; |
331 } | |
332 return 0; | |
333 } | |
334 | |
335 static const vo_info_t* | |
336 get_info(void) { | |
337 /* who i am? */ | |
338 return (&vo_info); | |
339 } | |
340 | |
341 static uint32_t | |
342 draw_frame(uint8_t *src[]) { | |
5870 | 343 int stride[3] = { 0 , 0 , 0 }; |
344 | |
345 switch(image_format) { | |
346 case IMGFMT_BGR15: | |
347 case IMGFMT_BGR16: | |
348 stride[0] = src_width*2; | |
349 break; | |
350 case IMGFMT_IYU2: | |
351 case IMGFMT_BGR24: | |
352 stride[0] = src_width*3; | |
353 break; | |
354 case IMGFMT_BGR32: | |
355 stride[0] = src_width*4; | |
356 break; | |
357 } | |
358 | |
359 sws->swScale(sws,src,stride,0,src_height,image,image_stride); | |
360 | |
361 /* Now 'ASCIInate' the image */ | |
362 if (fast) | |
363 aa_fastrender(c, screen_x, screen_y, screen_w + screen_x, screen_h + screen_y ); | |
364 else | |
365 aa_render(c, p,screen_x, screen_y, screen_w + screen_x, screen_h + screen_y ); | |
366 | |
367 return 0; | |
1511 | 368 } |
369 | |
370 static uint32_t | |
371 draw_slice(uint8_t *src[], int stride[], | |
372 int w, int h, int x, int y) { | |
5870 | 373 |
374 int dx1 = screen_x + (x * screen_w / src_width); | |
375 int dy1 = screen_y + (y * screen_h / src_height); | |
376 int dx2 = screen_x + ((x+w) * screen_w / src_width); | |
377 int dy2 = screen_y + ((y+h) * screen_h / src_height); | |
378 | |
379 sws->swScale(sws,src,stride,y,h,image,image_stride); | |
1511 | 380 |
5870 | 381 /* Now 'ASCIInate' the image */ |
382 if (fast) | |
383 aa_fastrender(c, dx1, dy1, dx2, dy2 ); | |
384 else | |
385 aa_render(c, p,dx1, dy1, dx2, dy2 ); | |
4674 | 386 |
5870 | 387 |
388 return 0; | |
1511 | 389 } |
390 | |
391 static void | |
392 flip_page(void) { | |
5870 | 393 |
394 /* do we have to put *our* (messages, progbar) osd to aa's txtbuf ? */ | |
395 if (showosdmessage) | |
396 { | |
397 if (time(NULL)>=stoposd ) { | |
398 showosdmessage=0; | |
399 if(osdmessagetext) { | |
400 memset(c->textbuffer + osdy * aa_scrwidth(c) + osdx,' ',strlen(osdmessagetext)); | |
401 memset(c->attrbuffer + osdy * aa_scrwidth(c) + osdx ,0,strlen(osdmessagetext)); | |
402 osdmessagetext[0] = '\0'; | |
403 } | |
404 if(posbar) { | |
405 memset(c->textbuffer + (osdy+1) * aa_scrwidth(c),' ',strlen(posbar)); | |
406 memset(c->attrbuffer + (osdy+1) * aa_scrwidth(c),0,strlen(posbar)); | |
407 } | |
408 } else { | |
409 /* update osd */ | |
410 aa_puts(c, osdx, osdy, AA_SPECIAL, osdmessagetext); | |
411 /* posbar? */ | |
412 if (posbar[0]!='\0') | |
413 aa_puts(c, 0, osdy + 1, AA_SPECIAL, posbar); | |
414 } | |
415 } | |
416 /* OSD time & playmode , subtitles */ | |
417 #ifdef USE_OSD | |
418 printosdtext(); | |
419 #endif | |
420 | |
421 | |
422 /* print out */ | |
423 aa_flush(c); | |
1511 | 424 } |
425 | |
426 static void | |
427 check_events(void) { | |
428 /* | |
429 * any events? | |
430 * called by show_image and mplayer | |
431 */ | |
432 int key; | |
433 while ((key=aa_getevent(c,0))!=AA_NONE ){ | |
434 if (key>255){ | |
435 /* some conversations */ | |
436 switch (key) { | |
437 case AA_UP: | |
438 mplayer_put_key(KEY_UP); | |
439 break; | |
440 case AA_DOWN: | |
441 mplayer_put_key(KEY_DOWN); | |
442 break; | |
443 case AA_LEFT: | |
444 mplayer_put_key(KEY_LEFT); | |
445 break; | |
446 case AA_RIGHT: | |
447 mplayer_put_key(KEY_RIGHT); | |
448 break; | |
449 case AA_ESC: | |
450 mplayer_put_key(KEY_ESC); | |
451 break; | |
452 case 65765: | |
453 mplayer_put_key(KEY_PAGE_UP); | |
454 break; | |
455 case 65766: | |
456 mplayer_put_key(KEY_PAGE_DOWN); | |
457 break; | |
458 default: | |
459 continue; /* aa lib special key */ | |
460 break; | |
461 } | |
462 } | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
463 if (key=='a' || key=='A'){ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
464 aaconfigmode=!aaconfigmode; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
465 osdmessage(MESSAGE_DURATION, 1, "aa config mode is now %s", |
5870 | 466 aaconfigmode==1 ? "on. use keys 5-7" : "off"); |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
467 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
468 if (aaconfigmode==1) { |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
469 switch (key) { |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
470 /* AA image controls */ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
471 case '5': |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
472 fast=!fast; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
473 osdmessage(MESSAGE_DURATION, 1, "Fast mode is now %s", fast==1 ? "on" : "off"); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
474 break; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
475 case '6': |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
476 if (p->dither==AA_FLOYD_S){ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
477 p->dither=AA_NONE; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
478 osdmessage(MESSAGE_DURATION, 1, "Dithering: Off"); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
479 }else if (p->dither==AA_NONE){ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
480 p->dither=AA_ERRORDISTRIB; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
481 osdmessage(MESSAGE_DURATION, 1, "Dithering: Error Distribution"); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
482 }else if (p->dither==AA_ERRORDISTRIB){ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
483 p->dither=AA_FLOYD_S; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
484 osdmessage(MESSAGE_DURATION, 1, "Dithering: Floyd Steinberg"); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
485 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
486 break; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
487 case '7': |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
488 p->inversion=!p->inversion; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
489 osdmessage(MESSAGE_DURATION, 1, "Invert mode is now %s", |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
490 p->inversion==1 ? "on" : "off"); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
491 break; |
1511 | 492 |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
493 default : |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
494 /* nothing if we're interested in? |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
495 * the mplayer should handle it! |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
496 */ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
497 mplayer_put_key(key); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
498 break; |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
499 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
500 }// aaconfigmode |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
501 else mplayer_put_key(key); |
1511 | 502 } |
503 } | |
504 | |
505 static void | |
506 uninit(void) { | |
507 /* | |
508 * THE END | |
5870 | 509 */ |
510 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
511 if (strstr(c->driver->name,"Curses") || strstr(c->driver->name,"Linux")){ |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
512 freopen("/dev/tty", "w", stderr); |
5870 | 513 m_config_set_flag(mconfig,"quiet",0); /* enable mplayer outputs */ |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
514 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
515 #ifdef USE_OSD |
5870 | 516 if(vo_font_save) { |
517 free(vo_font->pic_a[0]->bmp); | |
518 free(vo_font->pic_a[0]); | |
519 free(vo_font->pic_b[0]->bmp); | |
520 free(vo_font->pic_b[0]); | |
521 free(vo_font); | |
522 vo_font = vo_font_save; | |
523 vo_font_save = NULL; | |
524 } | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
525 #endif |
1511 | 526 aa_close(c); |
5870 | 527 if(image[2]) free(image[2]); |
1511 | 528 } |
529 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
530 #ifdef USE_OSD |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
531 static void draw_alpha(int x,int y, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
5870 | 532 |
533 c->textbuffer[x + y*aa_scrwidth(c)] = src[0]; | |
534 c->attrbuffer[x + y*aa_scrwidth(c)] = aaopt_subcolor; | |
535 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
536 } |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
537 |
5870 | 538 static void clear_alpha(int x0,int y0, int w,int h) { |
539 int l; | |
540 | |
541 for(l = 0 ; l < h ; l++) { | |
542 memset(c->textbuffer + (y0 + l) * aa_scrwidth(c) + x0,' ',w); | |
543 memset(c->attrbuffer + (y0 + l) * aa_scrwidth(c) + x0,0,w); | |
544 } | |
545 } | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
546 |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
547 |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
548 #endif |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
549 |
1511 | 550 static void |
551 draw_osd(void){ | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
552 #ifdef USE_OSD |
1575 | 553 char * vo_osd_text_save; |
554 int vo_osd_progbar_type_save; | |
555 | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
556 printosdprogbar(); |
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
557 /* let vo_draw_text only write subtitle */ |
1575 | 558 vo_osd_text_save=vo_osd_text; /* we have to save the osd_text */ |
559 vo_osd_text=NULL; | |
560 vo_osd_progbar_type_save=vo_osd_progbar_type; | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
561 vo_osd_progbar_type=-1; |
5870 | 562 vo_remove_text(aa_scrwidth(c), aa_scrheight(c),clear_alpha); |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
563 vo_draw_text(aa_scrwidth(c), aa_scrheight(c), draw_alpha); |
1575 | 564 vo_osd_text=vo_osd_text_save; |
565 vo_osd_progbar_type=vo_osd_progbar_type_save; | |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
566 #endif |
1511 | 567 } |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
568 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
569 int |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
570 getcolor(char * s){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
571 int i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
572 char * rest; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
573 if (s==NULL) return -1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
574 i=strtol(s, &rest, 10); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
575 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
|
576 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
|
577 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
|
578 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
|
579 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
|
580 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
|
581 else return -1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
582 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
583 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
584 int |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
585 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
|
586 /* got an option starting with aa */ |
4094
f2abd12e9231
'mplayer -aadriver stdout' segfault fixed by Fredrik Kuivinen <freku045@student.liu.se>
arpi
parents:
2732
diff
changeset
|
587 char *pseudoargv[4]; |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
588 int pseudoargc; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
589 char * x, *help; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
590 int i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
591 /* do WE need it ? */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
592 if (!strcasecmp(opt, "aaosdcolor")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
593 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
|
594 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
|
595 aaopt_osdcolor=i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
596 return 1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
597 }else if (!strcasecmp(opt, "aasubcolor")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
598 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
|
599 aaopt_subcolor=i; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
600 return 1; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
601 }else if (!strcasecmp(opt, "aahelp")){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
602 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
|
603 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
|
604 x=strtok(help,"-"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
605 printf(x); |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
606 while ((x=strtok(NULL, "-"))){ |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
607 if (*(x-2)==' ') printf("-aa"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
608 else printf("-"); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
609 printf("%s", x); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
610 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
611 printf( |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
612 "\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
613 "\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
614 "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
|
615 " -aaosdcolor set osd color\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
616 " -aasubcolor set subtitle color\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
617 " the color params are:\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
618 " 0 : normal\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
619 " 1 : dark\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
620 " 2 : bold\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
621 " 3 : boldfont\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
622 " 4 : reverse\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
623 " 6 : special\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
624 "\n\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
625 " dT8 8Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
626 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
627 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
628 " <PROJECT><PROJECT>\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
629 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
630 " dT 8 8 Tb\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
631 "\n" |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
632 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
633 ); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
634 exit(0); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
635 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
636 }else{ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
637 /* parse param to aalib */ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
638 pseudoargv[1]=malloc(strlen(opt)); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
639 pseudoargv[3]=NULL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
640 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
|
641 if (param!=NULL){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
642 pseudoargv[2]=param; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
643 pseudoargc=3; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
644 }else{ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
645 pseudoargv[2]=NULL; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
646 pseudoargc=2; |
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,"VO: [aa] "); |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
649 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
|
650 if (i!=1){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
651 return ERR_MISSING_PARAM; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
652 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
653 if (pseudoargv[1]!=NULL){ |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
654 /* aalib has given param back */ |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
655 fprintf(stderr," Parameter -%s accepted\n", opt); |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
656 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
|
657 } |
1551
267816fbdab3
vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents:
1538
diff
changeset
|
658 fprintf(stderr," Parameter -%s %s accepted\n", opt, ((param==NULL) ? "" : param) ); |
1537
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
659 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
|
660 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
661 } |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
662 return ERR_NOT_AN_OPTION; |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
663 |
7bdf6a585b67
All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents:
1527
diff
changeset
|
664 } |
4258 | 665 |
666 void | |
667 vo_aa_revertoption(config_t* opt,char* param) { | |
5870 | 668 if (!strcasecmp(param, "aaosdcolor")) |
4258 | 669 aaopt_osdcolor= AA_SPECIAL; |
5870 | 670 else if (!strcasecmp(param, "aasubcolor")) |
4258 | 671 aaopt_subcolor= AA_SPECIAL; |
672 } | |
673 | |
4352 | 674 static uint32_t preinit(const char *arg) |
675 { | |
5870 | 676 char * hidis = NULL; |
677 struct stat sbuf; | |
678 int fd, vt, major, minor; | |
679 FILE * fp; | |
680 char fname[12]; | |
681 extern aa_linkedlist *aa_displayrecommended; | |
682 | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4674
diff
changeset
|
683 if(arg) |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4674
diff
changeset
|
684 { |
5870 | 685 mp_msg(MSGT_VO,MSGL_ERR,"vo_aa: Unknown subdevice: %s\n",arg); |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4674
diff
changeset
|
686 return ENOSYS; |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4674
diff
changeset
|
687 } |
5870 | 688 |
689 /* initializing of aalib */ | |
690 | |
691 hidis=aa_getfirst(&aa_displayrecommended); | |
692 if ( hidis==NULL ){ | |
693 /* check /dev/vcsa<vt> */ | |
694 /* check only, if no driver is explicit set */ | |
695 fd = dup (fileno (stderr)); | |
696 fstat (fd, &sbuf); | |
697 major = sbuf.st_rdev >> 8; | |
698 vt = minor = sbuf.st_rdev & 0xff; | |
699 close (fd); | |
700 sprintf (fname, "/dev/vcsa%2.2i", vt); | |
701 fp = fopen (fname, "w+"); | |
702 if (fp==NULL){ | |
703 fprintf(stderr,"VO: [aa] cannot open %s for writing," | |
704 "so we'll not use linux driver\n", fname); | |
705 aa_recommendlowdisplay("linux"); | |
706 aa_recommendhidisplay("curses"); | |
707 aa_recommendhidisplay("X11"); | |
708 }else fclose(fp); | |
709 } else aa_recommendhidisplay(hidis); | |
710 c = aa_autoinit(&aa_defparams); | |
711 | |
712 if (c == NULL) { | |
713 mp_msg(MSGT_VO,MSGL_ERR,"Can not intialize aalib\n"); | |
714 return VO_ERROR; | |
715 } | |
716 if (!aa_autoinitkbd(c,0)) { | |
717 mp_msg(MSGT_VO,MSGL_ERR,"Can not intialize keyboard\n"); | |
718 aa_close(c); | |
719 return VO_ERROR; | |
720 } | |
721 | |
722 aa_resizehandler(c, (void *)resize); | |
723 aa_hidecursor(c); | |
724 p = aa_getrenderparams(); | |
725 | |
726 if ((strstr(c->driver->name,"Curses")) || (strstr(c->driver->name,"Linux"))){ | |
727 freopen("/dev/null", "w", stderr); | |
728 m_config_set_flag(mconfig,"quiet",0); /* disable mplayer outputs */ | |
729 /* disable console blanking */ | |
730 printf("\033[9;0]"); | |
731 } | |
732 | |
733 memset(image,0,3*sizeof(uint8_t)); | |
734 osdmessagetext[0] = '\0'; | |
735 osdx = osdy = 0; | |
736 | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4674
diff
changeset
|
737 return 0; |
4352 | 738 } |
739 | |
5870 | 740 static int get_video_eq(vidix_video_eq_t *info) { |
741 | |
742 memset(info,0,sizeof(vidix_video_eq_t)); | |
743 | |
744 info->cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST; | |
745 | |
746 info->contrast = (p->contrast - 64) * 1000 / 64; | |
747 info->brightness = (p->bright - 128) * 1000 / 128; | |
748 | |
749 return 0; | |
750 } | |
751 | |
752 static int set_video_eq(const vidix_video_eq_t *info) { | |
753 | |
754 p->contrast = ( info->contrast + 1000 ) * 64 / 1000; | |
755 p->bright = ( info->brightness + 1000) * 128 / 1000; | |
756 | |
757 return 0; | |
758 } | |
759 | |
760 static void query_vaa(vo_vaa_t *vaa) | |
761 { | |
762 memset(vaa,0,sizeof(vo_vaa_t)); | |
763 vaa->get_video_eq = get_video_eq; | |
764 vaa->set_video_eq = set_video_eq; | |
765 } | |
766 | |
4596 | 767 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 768 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
769 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
770 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
771 return query_format(*((uint32_t*)data)); |
5870 | 772 case VOCTRL_QUERY_VAA: |
773 query_vaa((vo_vaa_t*)data); | |
774 return VO_TRUE; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
775 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
776 return VO_NOTIMPL; |
4352 | 777 } |