annotate libvo/vo_aa.c @ 35310:7077d1aed027

Abort when opening the file failed instead of calling "write" with an invalid descriptor.
author reimar
date Sat, 10 Nov 2012 14:16:33 +0000
parents ddb45e9443ec
children 389d43c448b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 /*
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
2 * video output driver for AAlib
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
3 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
4 * copyright (c) 2001 Folke Ashberg <folke@ashberg.de>
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
5 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
6 * This file is part of MPlayer.
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
7 *
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
9 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
11 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
12 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
16 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
17 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
18 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28049
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
21 */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
22
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
23 #include <stdio.h>
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
24 #include <stdlib.h>
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
25
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
26 #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
27 #include <unistd.h>
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
28
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
29 #include <limits.h>
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
30 #include <math.h>
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
31 #include <stdarg.h>
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
32 #include <time.h>
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
33 #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
34 #include <errno.h>
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
35
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
36 #include "config.h"
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
37 #include "video_out.h"
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
38 #include "video_out_internal.h"
33301
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
39 #include "libmpcodecs/vf.h"
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
40 #include "aspect.h"
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents: 17566
diff changeset
41 #include "libswscale/swscale.h"
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 10595
diff changeset
42 #include "libmpcodecs/vf_scale.h"
32466
9e627a1793b1 Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents: 30556
diff changeset
43 #include "sub/font_load.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 32466
diff changeset
44 #include "sub/sub.h"
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
45
9380
edfe34c5405d linux->osdep
arpi
parents: 9176
diff changeset
46 #include "osdep/keycodes.h"
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
47 #include <aalib.h>
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
48 #include "subopt-helper.h"
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
49 #include "help_mp.h"
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
50 #include "mp_msg.h"
22823
98eaf29b5dee Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents: 21161
diff changeset
51 #include "mp_fifo.h"
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
52
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
53
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
54 #define MESSAGE_DURATION 3
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
55 #define MESSAGE_SIZE 512
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
56 #define MESSAGE_DEKO " +++ %s +++ "
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
57
25216
3aee342be929 Make vo info structs const
reimar
parents: 24237
diff changeset
58 static const vo_info_t info = {
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
59 "AAlib",
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
60 "aa",
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
61 "Alban Bedel <albeu@free.fr> and Folke Ashberg <folke@ashberg.de>",
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
62 ""
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
63 };
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
64
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
65 const LIBVO_EXTERN(aa)
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7625
diff changeset
66
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
67 /* aa's main context we use */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
68 aa_context *c;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
69 aa_renderparams *p;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
70 static int fast =0;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
71 /* used for the sws */
29062
6a0a30aa2b4a Consistently use MP_MAX_PLANES as size for plane pointer/stride arrays in libvo.
reimar
parents: 28922
diff changeset
72 static uint8_t * image[MP_MAX_PLANES];
6a0a30aa2b4a Consistently use MP_MAX_PLANES as size for plane pointer/stride arrays in libvo.
reimar
parents: 28922
diff changeset
73 static int image_stride[MP_MAX_PLANES];
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
74
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
75 /* image infos */
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
76 static int image_format;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
77 static int image_width;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
78 static int image_height;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
79 static int image_x, image_y;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
80 static int screen_x, screen_y;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
81 static int screen_w, screen_h;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
82 static int src_width;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
83 static int src_height;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
84
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
85 /* osd stuff */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
86 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
87 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
88 char osdmessagetext[MESSAGE_SIZE];
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
89 char posbar[MESSAGE_SIZE];
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
90 static int osdx, osdy;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
91 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
92 int aaconfigmode=1;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
93 font_desc_t* vo_font_save = NULL;
9496
michael
parents: 9380
diff changeset
94 static struct SwsContext *sws=NULL;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
95
1537
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
96 /* configuration */
1518
e0ceb814471d vo_aa: configurable now
folke
parents: 1511
diff changeset
97 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
98 int aaopt_subcolor = AA_SPECIAL;
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
99
30556
358ac046eccc libvo: Mark functions not used outside of their files as static.
diego
parents: 30150
diff changeset
100 static void
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
101 resize(void){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
102 /*
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
103 * this function is called by aa lib if windows resizes
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
104 * further during init, because here we have to calculate
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
105 * a little bit
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
106 */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
107
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
108 aa_resize(c);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
109
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
110 aspect_save_screenres(aa_imgwidth(c),aa_imgheight(c));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
111 image_height = aa_imgheight(c); //src_height;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
112 image_width = aa_imgwidth(c); //src_width;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
113
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
114 aspect(&image_width,&image_height,A_ZOOM);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
115
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
116 image_x = (aa_imgwidth(c) - image_width) / 2;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
117 image_y = (aa_imgheight(c) - image_height) / 2;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
118 screen_w = image_width * aa_scrwidth(c) / aa_imgwidth(c);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
119 screen_h = image_height * aa_scrheight(c) / aa_imgheight(c);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
120 screen_x = (aa_scrwidth(c) - screen_w) / 2;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
121 screen_y = (aa_scrheight(c) - screen_h) / 2;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
122
9496
michael
parents: 9380
diff changeset
123 if(sws) sws_freeContext(sws);
michael
parents: 9380
diff changeset
124 sws = sws_getContextFromCmdLine(src_width,src_height,image_format,
6522
ed8a717a423e Use the new Y8 support in place of YV12.
albeu
parents: 6210
diff changeset
125 image_width,image_height,IMGFMT_Y8);
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
126
29062
6a0a30aa2b4a Consistently use MP_MAX_PLANES as size for plane pointer/stride arrays in libvo.
reimar
parents: 28922
diff changeset
127 memset(image, 0, sizeof(image));
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
128 image[0] = aa_image(c) + image_y * aa_imgwidth(c) + image_x;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
129
29062
6a0a30aa2b4a Consistently use MP_MAX_PLANES as size for plane pointer/stride arrays in libvo.
reimar
parents: 28922
diff changeset
130 memset(image_stride, 0, sizeof(image_stride));
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
131 image_stride[0] = aa_imgwidth(c);
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
132
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
133 showosdmessage=0;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
134
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
135 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
136
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
137 static void
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
138 osdmessage(int duration, int deko, const char *fmt, ...)
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
139 {
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
140 /*
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
141 * for outputting a centered string at the bottom
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
142 * of our window for a while
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
143 */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
144 va_list ar;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
145 char m[MESSAGE_SIZE];
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
146 unsigned int old_len = strlen(osdmessagetext);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
147
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
148 va_start(ar, fmt);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
149 vsprintf(m, fmt, ar);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
150 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
151 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
152 else strcpy(osdmessagetext, m);
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
153
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
154 if(old_len > strlen(osdmessagetext)) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
155 memset(c->textbuffer + osdy * aa_scrwidth(c) + osdx,' ',old_len);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
156 memset(c->attrbuffer + osdy * aa_scrwidth(c) + osdx,0,old_len);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
157 }
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
158 showosdmessage=1;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
159 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
160 osdx=(aa_scrwidth(c) / 2) - (strlen(osdmessagetext) / 2 ) ;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
161 posbar[0]='\0';
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
162 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
163
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
164 static void
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
165 osdpercent(int duration, int deko, int min, int max, int val, const char * desc, const char * unit)
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
166 {
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
167 /*
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
168 * prints a bar for setting values
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
169 */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
170 float step;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
171 int where;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
172 int i;
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
173
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
174
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
175 step=(float)aa_scrwidth(c) /(float)(max-min);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
176 where=(val-min)*step;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
177 osdmessage(duration,deko,"%s: %i%s",desc, val, unit);
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
178 posbar[0]='|';
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
179 posbar[aa_scrwidth(c)-1]='|';
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
180 for (i=0;i<aa_scrwidth(c);i++){
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
181 if (i==where) posbar[i]='#';
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
182 else posbar[i]='-';
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
183 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
184 if (where!=0) posbar[0]='|';
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
185 if (where!=(aa_scrwidth(c)-1) ) posbar[aa_scrwidth(c)-1]='|';
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
186
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
187 posbar[aa_scrwidth(c)]='\0';
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
188
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
189 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
190
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
191 static void
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16171
diff changeset
192 printosdtext(void)
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
193 {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
194 if(osd_text_length > 0 && !vo_osd_text) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
195 memset(c->textbuffer,' ',osd_text_length);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
196 memset(c->attrbuffer,0,osd_text_length);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
197 osd_text_length = 0;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
198 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
199 /*
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
200 * 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
201 */
6757
f72fc85934e5 10L bugs founds by Jindrich Makovicka <makovicki at KMLinux dot fjfi dot cvuti dot cz>
albeu
parents: 6522
diff changeset
202 if (vo_osd_text && vo_osd_text[0] != 0) {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
203 int len;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
204 if(vo_osd_text[0] < 32) {
24046
7e2808fb1807 Identifiers should not start with two underscores.
diego
parents: 24032
diff changeset
205 len = strlen(sub_osd_names_short[vo_osd_text[0]]) + strlen(vo_osd_text+1) + 2;
7e2808fb1807 Identifiers should not start with two underscores.
diego
parents: 24032
diff changeset
206 aa_printf(c, 0, 0 , aaopt_osdcolor, "%s %s ", sub_osd_names_short[vo_osd_text[0]], vo_osd_text+1);
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
207 } else {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
208 len = strlen(vo_osd_text) + 1;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
209 aa_printf(c, 0, 0 , aaopt_osdcolor, "%s ",vo_osd_text);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
210 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
211
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
212 if(len < osd_text_length) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
213 memset(c->textbuffer + len,' ',osd_text_length - len);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
214 memset(c->attrbuffer + len,0,osd_text_length - len);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
215 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
216 osd_text_length = len;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
217
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
218 }
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
219 }
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
220
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
221 static void
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16171
diff changeset
222 printosdprogbar(void){
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
223 /* 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
224 if (vo_osd_progbar_type!=-1){
24046
7e2808fb1807 Identifiers should not start with two underscores.
diego
parents: 24032
diff changeset
225 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
226 }
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
227 }
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
228 static int
4433
df8e0f71cc3c new info for tuning
nick
parents: 4352
diff changeset
229 config(uint32_t width, uint32_t height, uint32_t d_width,
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
230 uint32_t d_height, uint32_t flags, char *title,
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 6809
diff changeset
231 uint32_t format) {
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
232 /*
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
233 * main init
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
234 * called by mplayer
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
235 */
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
236
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
237 int i;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
238
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
239 aspect_save_orig(width,height);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
240 aspect_save_prescale(d_width,d_height);
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
241
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
242 src_height = height;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
243 src_width = width;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
244 image_format = format;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
245
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
246 /* nothing will change its size, be we need some values initialized */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
247 resize();
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
248
28049
887ecb9a3792 Remove unused declarations and references to vo_draw_text_osd(),
diego
parents: 27393
diff changeset
249 /* now init our own 'font' */
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
250 if(!vo_font_save) vo_font_save = vo_font;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
251 if(vo_font == vo_font_save) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
252 vo_font=malloc(sizeof(font_desc_t));//if(!desc) return NULL;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
253 memset(vo_font,0,sizeof(font_desc_t));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
254 vo_font->pic_a[0]=malloc(sizeof(raw_file));
9176
237b7e51521a better fix of vo_aa font segfault
henry
parents: 8164
diff changeset
255 memset(vo_font->pic_a[0],0,sizeof(raw_file));
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
256 vo_font->pic_b[0]=malloc(sizeof(raw_file));
9176
237b7e51521a better fix of vo_aa font segfault
henry
parents: 8164
diff changeset
257 memset(vo_font->pic_b[0],0,sizeof(raw_file));
1572
25c2ee4de8b1 vo_font SEGFAULT fixed
arpi
parents: 1554
diff changeset
258
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 25220
diff changeset
259 #ifdef CONFIG_FREETYPE
7140
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
260 vo_font->dynamic = 0;
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
261 #endif
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
262
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
263 vo_font->spacewidth=1;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
264 vo_font->charspace=0;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
265 vo_font->height=1;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
266 vo_font->pic_a[0]->bmp=malloc(255);
9176
237b7e51521a better fix of vo_aa font segfault
henry
parents: 8164
diff changeset
267 vo_font->pic_a[0]->pal=NULL;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
268 vo_font->pic_b[0]->bmp=malloc(255);
9176
237b7e51521a better fix of vo_aa font segfault
henry
parents: 8164
diff changeset
269 vo_font->pic_b[0]->pal=NULL;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
270 vo_font->pic_a[0]->w=1;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
271 vo_font->pic_a[0]->h=1;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
272 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
273 vo_font->width[i]=1;
1572
25c2ee4de8b1 vo_font SEGFAULT fixed
arpi
parents: 1554
diff changeset
274 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
275 vo_font->start[i]=i;
1572
25c2ee4de8b1 vo_font SEGFAULT fixed
arpi
parents: 1554
diff changeset
276 vo_font->pic_a[0]->bmp[i]=i;
25c2ee4de8b1 vo_font SEGFAULT fixed
arpi
parents: 1554
diff changeset
277 vo_font->pic_b[0]->bmp[i]=i;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
278 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
279 }
21161
ad7747bce52d Make compilation depending on USE_OSD unconditional.
uau
parents: 18950
diff changeset
280
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
281 /* say hello */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
282 osdmessage(5, 1, "Welcome to ASCII ART MPlayer");
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
283
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
284 mp_msg(MSGT_VO,MSGL_V,"VO: [aa] screendriver: %s\n", c->driver->name);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
285 mp_msg(MSGT_VO,MSGL_V,"VO: [aa] keyboarddriver: %s\n", c->kbddriver->name);
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
286
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
287 mp_msg(MSGT_VO,MSGL_INFO,
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
288 "\n"
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
289 "Important suboptions\n"
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
290 "\textended use use all 256 characters\n"
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
291 "\teight use eight bit ascii\n"
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
292 "\tdriver set recommended aalib driver (X11,curses,linux)\n"
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
293 "\thelp to see all options provided by aalib\n"
1518
e0ceb814471d vo_aa: configurable now
folke
parents: 1511
diff changeset
294 "\n"
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
295 "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
296 "\t1 : contrast -\n"
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
297 "\t2 : contrast +\n"
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
298 "\t3 : brightness -\n"
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
299 "\t4 : brightness +\n"
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
300 "\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
301 "\t6 : dithering\n"
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
302 "\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
303 "\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
304
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
305 "\n"
1527
187aa4b576a7 Fix OSD, small misspelling.
atmos4
parents: 1520
diff changeset
306 "All other keys are MPlayer defaults.\n"
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
307
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
308
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
309 );
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
310
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
311 return 0;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
312 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
313
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
314 static int
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
315 query_format(uint32_t format) {
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
316 /*
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
317 * ...are we able to... ?
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
318 * called by mplayer
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
319 * All input format supported by the sws
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
320 */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
321 switch(format){
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
322 case IMGFMT_YV12:
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
323 case IMGFMT_I420:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
324 case IMGFMT_IYUV:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
325 case IMGFMT_IYU2:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
326 case IMGFMT_BGR32:
5027
0c7a6a9d2243 32bpp support not implemented - do not lie
arpi
parents: 4737
diff changeset
327 case IMGFMT_BGR24:
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
328 case IMGFMT_BGR16:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
329 case IMGFMT_BGR15:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
330 case IMGFMT_RGB32:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
331 case IMGFMT_RGB24:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
332 case IMGFMT_Y8:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
333 case IMGFMT_Y800:
21161
ad7747bce52d Make compilation depending on USE_OSD unconditional.
uau
parents: 18950
diff changeset
334 return VFCAP_CSP_SUPPORTED | VFCAP_SWSCALE | VFCAP_OSD;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
335 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
336 return 0;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
337 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
338
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
339 static int
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
340 draw_frame(uint8_t *src[]) {
29062
6a0a30aa2b4a Consistently use MP_MAX_PLANES as size for plane pointer/stride arrays in libvo.
reimar
parents: 28922
diff changeset
341 int stride[MP_MAX_PLANES] = {0};
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
342
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
343 switch(image_format) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
344 case IMGFMT_BGR15:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
345 case IMGFMT_BGR16:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
346 stride[0] = src_width*2;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
347 break;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
348 case IMGFMT_IYU2:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
349 case IMGFMT_BGR24:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
350 stride[0] = src_width*3;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
351 break;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
352 case IMGFMT_BGR32:
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
353 stride[0] = src_width*4;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
354 break;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
355 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
356
30150
16c71b965952 Replace deprecated sws_scale_ordered usages by sws_scale (which does the same).
reimar
parents: 29263
diff changeset
357 sws_scale(sws,src,stride,0,src_height,image,image_stride);
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
358
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
359 /* Now 'ASCIInate' the image */
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
360 if (fast)
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
361 aa_fastrender(c, screen_x, screen_y, screen_w + screen_x, screen_h + screen_y );
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
362 else
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
363 aa_render(c, p,screen_x, screen_y, screen_w + screen_x, screen_h + screen_y );
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
364
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
365 return 0;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
366 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
367
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
368 static int
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
369 draw_slice(uint8_t *src[], int stride[],
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
370 int w, int h, int x, int y) {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
371
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
372 int dx1 = screen_x + (x * screen_w / src_width);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
373 int dy1 = screen_y + (y * screen_h / src_height);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
374 int dx2 = screen_x + ((x+w) * screen_w / src_width);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
375 int dy2 = screen_y + ((y+h) * screen_h / src_height);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
376
30150
16c71b965952 Replace deprecated sws_scale_ordered usages by sws_scale (which does the same).
reimar
parents: 29263
diff changeset
377 sws_scale(sws,src,stride,y,h,image,image_stride);
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
378
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
379 /* Now 'ASCIInate' the image */
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
380 if (fast)
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
381 aa_fastrender(c, dx1, dy1, dx2, dy2 );
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
382 else
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
383 aa_render(c, p,dx1, dy1, dx2, dy2 );
4674
5a7eb882bb19 rgb/bgr 32bpp and IYUV/I420 support
alex
parents: 4596
diff changeset
384
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
385
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
386 return 0;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
387 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
388
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
389 static void
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
390 flip_page(void) {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
391
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
392 /* do we have to put *our* (messages, progbar) osd to aa's txtbuf ? */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
393 if (showosdmessage)
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
394 {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
395 if (time(NULL)>=stoposd ) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
396 showosdmessage=0;
24032
144162149176 Fix likely mistake when using char*.
cehoyos
parents: 23618
diff changeset
397 if(*osdmessagetext) {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
398 memset(c->textbuffer + osdy * aa_scrwidth(c) + osdx,' ',strlen(osdmessagetext));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
399 memset(c->attrbuffer + osdy * aa_scrwidth(c) + osdx ,0,strlen(osdmessagetext));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
400 osdmessagetext[0] = '\0';
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
401 }
24032
144162149176 Fix likely mistake when using char*.
cehoyos
parents: 23618
diff changeset
402 if(*posbar) {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
403 memset(c->textbuffer + (osdy+1) * aa_scrwidth(c),' ',strlen(posbar));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
404 memset(c->attrbuffer + (osdy+1) * aa_scrwidth(c),0,strlen(posbar));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
405 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
406 } else {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
407 /* update osd */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
408 aa_puts(c, osdx, osdy, AA_SPECIAL, osdmessagetext);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
409 /* posbar? */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
410 if (posbar[0]!='\0')
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
411 aa_puts(c, 0, osdy + 1, AA_SPECIAL, posbar);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
412 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
413 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
414 /* OSD time & playmode , subtitles */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
415 printosdtext();
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
416
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
417
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
418 /* print out */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
419 aa_flush(c);
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
420 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
421
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
422 static void
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
423 check_events(void) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
424 /*
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
425 * any events?
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
426 * called by show_image and mplayer
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
427 */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
428 int key;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
429 while ((key=aa_getevent(c,0))!=AA_NONE ){
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
430 if (key>255){
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
431 /* some conversations */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
432 switch (key) {
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
433 case AA_UP:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
434 mplayer_put_key(KEY_UP);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
435 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
436 case AA_DOWN:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
437 mplayer_put_key(KEY_DOWN);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
438 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
439 case AA_LEFT:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
440 mplayer_put_key(KEY_LEFT);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
441 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
442 case AA_RIGHT:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
443 mplayer_put_key(KEY_RIGHT);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
444 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
445 case AA_ESC:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
446 mplayer_put_key(KEY_ESC);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
447 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
448 case 65765:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
449 mplayer_put_key(KEY_PAGE_UP);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
450 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
451 case 65766:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
452 mplayer_put_key(KEY_PAGE_DOWN);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
453 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
454 default:
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
455 continue; /* aa lib special key */
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
456 break;
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
457 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
458 }
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
459 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
460 aaconfigmode=!aaconfigmode;
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
461 osdmessage(MESSAGE_DURATION, 1, "aa config mode is now %s",
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
462 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
463 }
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
464 if (aaconfigmode==1) {
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
465 switch (key) {
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
466 /* AA image controls */
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
467 case '5':
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
468 fast=!fast;
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
469 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
470 break;
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
471 case '6':
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
472 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
473 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
474 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
475 }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
476 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
477 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
478 }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
479 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
480 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
481 }
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
482 break;
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
483 case '7':
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
484 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
485 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
486 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
487 break;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
488
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
489 default :
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
490 /* 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
491 * 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
492 */
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
493 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
494 break;
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
495 }
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
496 }// aaconfigmode
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
497 else mplayer_put_key(key);
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
498 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
499 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
500
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
501 static void
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
502 uninit(void) {
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
503 /*
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
504 * THE END
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
505 */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
506
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
507 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
508 freopen("/dev/tty", "w", stderr);
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
509 }
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
510 if(vo_font_save) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
511 free(vo_font->pic_a[0]->bmp);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
512 free(vo_font->pic_a[0]);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
513 free(vo_font->pic_b[0]->bmp);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
514 free(vo_font->pic_b[0]);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
515 free(vo_font);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
516 vo_font = vo_font_save;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
517 vo_font_save = NULL;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
518 }
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
519 aa_close(c);
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
520 }
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
521
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
522 static void draw_alpha(int x,int y, int w,int h, unsigned char* src, unsigned char *srca, int stride){
7140
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
523 int i,j;
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
524 for (i = 0; i < h; i++) {
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
525 for (j = 0; j < w; j++) {
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
526 if (src[i*stride+j] > 0) {
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
527 c->textbuffer[x + j + (y+i)*aa_scrwidth(c)] = src[i*stride+j];
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
528 c->attrbuffer[x + j + (y+i)*aa_scrwidth(c)] = aaopt_subcolor;
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
529 }
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
530 }
b9ce54c7f30f add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents: 7124
diff changeset
531 }
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
532 }
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
533
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
534 static void clear_alpha(int x0,int y0, int w,int h) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
535 int l;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
536
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
537 for(l = 0 ; l < h ; l++) {
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
538 memset(c->textbuffer + (y0 + l) * aa_scrwidth(c) + x0,' ',w);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
539 memset(c->attrbuffer + (y0 + l) * aa_scrwidth(c) + x0,0,w);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
540 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
541 }
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
542
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
543
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
544 static void
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
545 draw_osd(void){
1575
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
546 char * vo_osd_text_save;
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
547 int vo_osd_progbar_type_save;
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
548
1551
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
549 printosdprogbar();
267816fbdab3 vo_aa: +subtitles, +progressbar, key violation with mplayer keys fixed, +consoleblanking disabled, +/dev/vcsa checking
folke
parents: 1538
diff changeset
550 /* let vo_draw_text only write subtitle */
1575
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
551 vo_osd_text_save=vo_osd_text; /* we have to save the osd_text */
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
552 vo_osd_text=NULL;
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
553 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
554 vo_osd_progbar_type=-1;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
555 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
556 vo_draw_text(aa_scrwidth(c), aa_scrheight(c), draw_alpha);
1575
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
557 vo_osd_text=vo_osd_text_save;
2766b0d3863d osd problem with YV12 fixed
folke
parents: 1572
diff changeset
558 vo_osd_progbar_type=vo_osd_progbar_type_save;
1511
f29e0c2bb675 Added cool aalib vo driver.
atmos4
parents:
diff changeset
559 }
1537
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
560
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18861
diff changeset
561 static int
1537
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
562 getcolor(char * s){
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
563 int i;
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
564 char * rest;
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
565 if (s==NULL) return -1;
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
566 i=strtol(s, &rest, 10);
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
567 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
568 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
569 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
570 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
571 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
572 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
573 else return -1;
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
574 }
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
575
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
576 static int parse_suboptions(const char *arg) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
577 char *pseudoargv[4], *osdcolor = NULL, *subcolor = NULL, **strings,
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
578 *helpmsg = NULL;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
579 int pseudoargc, displayhelp = 0, *booleans;
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 28446
diff changeset
580 const opt_t extra_opts[] = {
28922
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
581 {"osdcolor", OPT_ARG_MSTRZ, &osdcolor, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
582 {"subcolor", OPT_ARG_MSTRZ, &subcolor, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
583 {"help", OPT_ARG_BOOL, &displayhelp, NULL} };
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
584 opt_t *subopts = NULL, *p;
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 28446
diff changeset
585 char * const strings_list[] = {"-driver", "-kbddriver", "-mousedriver", "-font",
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
586 "-width", "-height", "-minwidth", "-minheight", "-maxwidth",
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
587 "-maxheight", "-recwidth", "-recheight", "-bright", "-contrast",
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
588 "-gamma", "-dimmul", "-boldmul", "-random" };
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 28446
diff changeset
589 char * const booleans_list[] = {"-dim", "-bold", "-reverse", "-normal",
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
590 "-boldfont", "-inverse", "-extended", "-eight", "-dither",
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
591 "-floyd_steinberg", "-error_distribution"};
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 28446
diff changeset
592 char * const nobooleans_list[] = {"-nodim", "-nobold", "-noreverse", "-nonormal",
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
593 "-noboldfont", "-noinverse", "-noextended", "-noeight", "-nodither",
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
594 "-nofloyd_steinberg", "-noerror_distribution"};
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
595 const int nstrings = sizeof(strings_list) / sizeof(char*);
24227
cc567f93fb3b Fix wrong calculation of nbooleans that causes a crash on 64 bit systems
reimar
parents: 24175
diff changeset
596 const int nbooleans = sizeof(booleans_list) / sizeof(char*);
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
597 const int nextra_opts = sizeof(extra_opts) / sizeof(opt_t);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
598 const int nsubopts = nstrings + nbooleans + nextra_opts;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
599 int i, retval = 0;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
600
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
601 subopts = calloc(nsubopts + 1, sizeof(opt_t));
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
602 strings = calloc(nstrings, sizeof(char*));
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
603 booleans = calloc(nbooleans, sizeof(int));
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
604
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
605 p = subopts;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
606 for (i=0; i<nstrings; i++, p++) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
607 p->name = strings_list[i] + 1; // skip '-'
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
608 p->type = OPT_ARG_MSTRZ;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
609 p->valp = &strings[i];
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
610 }
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
611 for (i=0; i<nbooleans; i++, p++) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
612 p->name = booleans_list[i] + 1;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
613 p->type = OPT_ARG_BOOL;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
614 p->valp = &booleans[i];
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
615 }
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
616 memcpy(p, extra_opts, sizeof(extra_opts));
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
617
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
618 retval = subopt_parse(arg, subopts);
1537
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
619
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
620 if (retval == 0 && displayhelp) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
621 helpmsg = strdup(aa_help);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
622 for (i=0; i<(signed)strlen(helpmsg); i++)
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
623 if (helpmsg[i] == '-') helpmsg[i] = ' ';
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
624 mp_msg(MSGT_VO, MSGL_INFO, MSGTR_VO_AA_HelpHeader);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
625 mp_msg(MSGT_VO, MSGL_INFO, "%s\n\n", helpmsg);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
626 mp_msg(MSGT_VO, MSGL_INFO, MSGTR_VO_AA_AdditionalOptions);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
627 retval = -1;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
628 }
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
629 if (retval == 0) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
630 pseudoargv[3] = NULL;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
631 for (i=0; i<nstrings; i++) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
632 pseudoargc = 3; // inside loop because aalib changes it
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
633 if (strings[i] != NULL) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
634 pseudoargv[1] = strings_list[i];
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
635 pseudoargv[2] = strings[i];
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
636 aa_parseoptions(&aa_defparams, &aa_defrenderparams,
23618
c1ef739c185e Remove completely pointless "!= 1".
reimar
parents: 22823
diff changeset
637 &pseudoargc, pseudoargv);
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
638 }
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
639 }
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
640 pseudoargv[2] = NULL;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
641 for (i=0; i<nbooleans; i++) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
642 pseudoargc = 2;
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
643 if (booleans[i]) pseudoargv[1] = booleans_list[i];
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
644 else pseudoargv[1] = nobooleans_list[i];
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
645 aa_parseoptions(&aa_defparams, &aa_defrenderparams,
23618
c1ef739c185e Remove completely pointless "!= 1".
reimar
parents: 22823
diff changeset
646 &pseudoargc, pseudoargv);
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
647 }
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
648 if (osdcolor) aaopt_osdcolor = getcolor(osdcolor);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
649 if (subcolor) aaopt_subcolor = getcolor(subcolor);
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
650 }
1537
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
651
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
652 free(subopts);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
653 free(booleans);
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
654 if (strings) {
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
655 for (i=0; i<nstrings; i++)
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
656 free(strings[i]);
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
657 free(strings);
1537
7bdf6a585b67 All aalib options can be passed to aalib (-aaXXX), also -aahelp is new
folke
parents: 1527
diff changeset
658 }
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
659 free(osdcolor);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
660 free(subcolor);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
661 free(helpmsg);
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
662 return retval;
4258
31ed0b5d8126 Added reverting support for -aa* options
albeu
parents: 4094
diff changeset
663 }
31ed0b5d8126 Added reverting support for -aa* options
albeu
parents: 4094
diff changeset
664
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
665 static int preinit(const char *arg)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4258
diff changeset
666 {
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
667 char * hidis = NULL;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
668 struct stat sbuf;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
669 int fd, vt, major, minor;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
670 FILE * fp;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
671 char fname[12];
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
672
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
673 if(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
674 {
14935
b3274e6b88ef Convert vo_aa suboption parser to using the subopt-helper.
ivo
parents: 13787
diff changeset
675 if (parse_suboptions(arg) != 0)
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4674
diff changeset
676 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
677 }
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
678
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
679 /* initializing of aalib */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
680
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
681 hidis=aa_getfirst(&aa_displayrecommended);
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
682 if ( hidis==NULL ){
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
683 /* check /dev/vcsa<vt> */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
684 /* check only, if no driver is explicit set */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
685 fd = dup (fileno (stderr));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
686 fstat (fd, &sbuf);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
687 major = sbuf.st_rdev >> 8;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
688 vt = minor = sbuf.st_rdev & 0xff;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
689 close (fd);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
690 sprintf (fname, "/dev/vcsa%2.2i", vt);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
691 fp = fopen (fname, "w+");
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
692 if (fp==NULL){
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
693 fprintf(stderr,"VO: [aa] cannot open %s for writing,"
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
694 "so we'll not use linux driver\n", fname);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
695 aa_recommendlowdisplay("linux");
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
696 aa_recommendhidisplay("curses");
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
697 aa_recommendhidisplay("X11");
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
698 }else fclose(fp);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
699 } else aa_recommendhidisplay(hidis);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
700 c = aa_autoinit(&aa_defparams);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
701
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
702 if (c == NULL) {
7625
0f1691d27d75 Fixed some typos and an error in the help output.
diego
parents: 7140
diff changeset
703 mp_msg(MSGT_VO,MSGL_ERR,"Cannot initialize aalib\n");
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
704 return VO_ERROR;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29062
diff changeset
705 }
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
706 if (!aa_autoinitkbd(c,0)) {
7625
0f1691d27d75 Fixed some typos and an error in the help output.
diego
parents: 7140
diff changeset
707 mp_msg(MSGT_VO,MSGL_ERR,"Cannot initialize keyboard\n");
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
708 aa_close(c);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
709 return VO_ERROR;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
710 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
711
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
712 aa_resizehandler(c, (void *)resize);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
713 aa_hidecursor(c);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
714 p = aa_getrenderparams();
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
715
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
716 if ((strstr(c->driver->name,"Curses")) || (strstr(c->driver->name,"Linux"))){
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
717 freopen("/dev/null", "w", stderr);
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
718 /* disable console blanking */
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
719 printf("\033[9;0]");
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
720 }
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
721
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
722 memset(image,0,3*sizeof(uint8_t));
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
723 osdmessagetext[0] = '\0';
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
724 osdx = osdy = 0;
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
725
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4674
diff changeset
726 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4258
diff changeset
727 }
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4258
diff changeset
728
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 33301
diff changeset
729 static int control(uint32_t request, void *data)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4258
diff changeset
730 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
731 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
732 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
733 return query_format(*((uint32_t*)data));
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
734 case VOCTRL_SET_EQUALIZER: {
33301
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
735 vf_equalizer_t *eq=data;
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
736
33301
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
737 if(strcmp(eq->item,"contrast") == 0)
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
738 p->contrast = ( eq->value + 100 ) * 64 / 100;
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
739 else if(strcmp(eq->item,"brightness") == 0)
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
740 p->bright = ( eq->value + 100) * 128 / 100;
5870
125d667e9eac A almost complete rewrite.
albeu
parents: 5295
diff changeset
741 return VO_TRUE;
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
742 }
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
743 case VOCTRL_GET_EQUALIZER: {
33301
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
744 vf_equalizer_t *eq=data;
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
745
33301
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
746 if(strcmp(eq->item,"contrast") == 0)
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
747 eq->value = (p->contrast - 64) * 100 / 64;
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
748 else if(strcmp(eq->item,"brightness") == 0)
899d817e56fc Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents: 32537
diff changeset
749 eq->value = (p->bright - 128) * 100 / 128;
6809
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
750
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
751 return VO_TRUE;
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
752 }
0250f691037e 10L bugs founds by Jindrich Makovicka <makovick at MLinux dot fjfi dot cvut dotcz>
albeu
parents: 6757
diff changeset
753 }
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
754 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4258
diff changeset
755 }