annotate libvo/vo_caca.c @ 21280:db66f5bdb5cd

Remove unnecessary variable indirection.
author diego
date Sun, 26 Nov 2006 22:53:57 +0000
parents ad7747bce52d
children 98eaf29b5dee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
1 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
2 * MPlayer
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
3 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
4 * Video driver for libcaca
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
5 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
6 * by Pigeon <pigeon@pigeond.net>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
7 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
8 * Some functions/codes/ideas are from x11 and aalib vo
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
9 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
10 * TODO: support those draw_alpha stuff?
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
11 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
12 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
13
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
14 #include <stdio.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
15 #include <stdlib.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
16 #include <sys/stat.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
17 #include <unistd.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
18 #include <string.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
19 #include <time.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
20 #include <errno.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
21
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
22 #include "config.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
23 #include "video_out.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
24 #include "video_out_internal.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
25 #include "sub.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
26
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
27 #include "osdep/keycodes.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
28 #include "mp_msg.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
29
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
30 #include <caca.h>
19979
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
31 #ifdef CACA_API_VERSION_1
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
32 /* Include the pre-1.x compatibility header.
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
33 * Once libcaca 1.x is widespread, vo_caca should be fully
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
34 * converted to the new API. A patch exists:
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
35 * http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-July/044674.html
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
36 */
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
37 #include <caca0.h>
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
38 #endif
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
39
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
40 static vo_info_t info = {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
41 "libcaca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
42 "caca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
43 "Pigeon <pigeon@pigeond.net>",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
44 ""
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
45 };
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
46
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
47 LIBVO_EXTERN (caca)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
48
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
49 /* caca stuff */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
50 static struct caca_bitmap *cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
51
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
52 /* image infos */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
53 static int image_format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
54 static int image_width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
55 static int image_height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
56
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
57 static int screen_w, screen_h;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
58
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
59 /* We want 24bpp always for now */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
60 static unsigned int bpp = 24;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
61 static unsigned int depth = 3;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
62 static unsigned int rmask = 0xff0000;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
63 static unsigned int gmask = 0x00ff00;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
64 static unsigned int bmask = 0x0000ff;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
65 static unsigned int amask = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
66
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
67 #define MESSAGE_SIZE 512
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
68 #define MESSAGE_DURATION 5
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
69
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
70 static time_t stoposd = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
71 static int showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
72 static char osdmessagetext[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
73 static char posbar[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
74
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
75 static int osdx = 0, osdy = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
76 static int posbary = 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
77
19053
75327b24e06f marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 16171
diff changeset
78 static void osdmessage(int duration, const char *fmt, ...)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
79 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
80 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
81 * for outputting a centered string at the bottom
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
82 * of our window for a while
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
83 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
84 va_list ar;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
85 char m[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
86
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
87 va_start(ar, fmt);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
88 vsprintf(m, fmt, ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
89 va_end(ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
90 strcpy(osdmessagetext, m);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
91
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
92 showosdmessage = 1;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
93 stoposd = time(NULL) + duration;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
94 osdx = (screen_w - strlen (osdmessagetext)) / 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
95 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
96 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
97
19053
75327b24e06f marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 16171
diff changeset
98 static void osdpercent(int duration, int min, int max, int val, const char *desc, const char *unit)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
99 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
100 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
101 * prints a bar for setting values
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
102 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
103 float step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
104 int where, i;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
105
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
106 step = (float)screen_w / (float)(max - min);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
107 where = (val - min) * step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
108 osdmessage (duration, "%s: %i%s", desc, val, unit);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
109 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
110 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
111
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
112 for (i = 0; i < screen_w; i++)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
113 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
114 if (i == where)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
115 posbar[i] = '#';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
116 else
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
117 posbar[i] = '-';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
118 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
119
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
120 if (where != 0)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
121 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
122
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
123 if (where != (screen_w - 1))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
124 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
125
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
126 posbar[screen_w] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
127 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
128
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
129 static int resize ()
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
130 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
131 screen_w = caca_get_width();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
132 screen_h = caca_get_height();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
133
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
134 if (cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
135 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
136
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
137 cbitmap = caca_create_bitmap(bpp, image_width, image_height,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
138 depth * image_width, rmask, gmask, bmask,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
139 amask);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
140
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
141 if (!cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
142 mp_msg(MSGT_VO, MSGL_FATAL, "vo_caca: caca_create_bitmap failed!\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
143
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
144 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
145 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
146
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
147 static int config(uint32_t width, uint32_t height, uint32_t d_width,
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 12129
diff changeset
148 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
149 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
150 image_height = height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
151 image_width = width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
152 image_format = format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
153
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
154 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
155 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
156
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
157 return resize ();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
158 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
159
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
160 static int draw_frame(uint8_t *src[])
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
161 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
162 caca_draw_bitmap(0, 0, screen_w, screen_h, cbitmap, src[0]);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
163 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
164 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
165
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
166 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
167 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
168 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
169 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
170
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
171 static void flip_page(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
172 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
173
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
174 if (showosdmessage)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
175 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
176 if (time(NULL) >= stoposd)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
177 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
178 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
179 if (posbar)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
180 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
181 } else {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
182 caca_putstr(osdx, osdy, osdmessagetext);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
183
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
184 if (posbar)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
185 caca_putstr(0, posbary, posbar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
186 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
187 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
188
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
189 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
190 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
191
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
192 static void check_events (void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
193 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
194 unsigned int cev;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
195
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
196 if ((cev = caca_get_event(CACA_EVENT_ANY)))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
197 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
198 if (cev & CACA_EVENT_RESIZE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
199 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
200 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
201 resize();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
202 } else if (cev & CACA_EVENT_KEY_RELEASE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
203 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
204 int key = (cev & 0x00ffffff);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
205 enum caca_feature cf;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
206
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
207 switch (key) {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
208 case 'd':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
209 case 'D':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
210 /* Toggle dithering method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
211 cf = 1 + caca_get_feature(CACA_DITHERING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
212 if (cf > CACA_DITHERING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
213 cf = CACA_DITHERING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
214 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
215 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
216 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
217
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
218 case 'a':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
219 case 'A':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
220 /* Toggle antialiasing method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
221 cf = 1 + caca_get_feature(CACA_ANTIALIASING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
222 if (cf > CACA_ANTIALIASING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
223 cf = CACA_ANTIALIASING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
224 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
225 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
226 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
227
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
228 case 'b':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
229 case 'B':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
230 /* Toggle background method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
231 cf = 1 + caca_get_feature(CACA_BACKGROUND);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
232 if (cf > CACA_BACKGROUND_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
233 cf = CACA_BACKGROUND_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
234 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
235 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
236 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
237
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
238 case CACA_KEY_UP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
239 mplayer_put_key(KEY_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
240 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
241 case CACA_KEY_DOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
242 mplayer_put_key(KEY_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
243 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
244 case CACA_KEY_LEFT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
245 mplayer_put_key(KEY_LEFT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
246 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
247 case CACA_KEY_RIGHT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
248 mplayer_put_key(KEY_RIGHT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
249 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
250 case CACA_KEY_ESCAPE:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
251 mplayer_put_key(KEY_ESC);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
252 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
253 case CACA_KEY_PAGEUP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
254 mplayer_put_key(KEY_PAGE_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
255 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
256 case CACA_KEY_PAGEDOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
257 mplayer_put_key(KEY_PAGE_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
258 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
259 case CACA_KEY_RETURN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
260 mplayer_put_key(KEY_ENTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
261 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
262 case CACA_KEY_HOME:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
263 mplayer_put_key(KEY_HOME);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
264 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
265 case CACA_KEY_END:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
266 mplayer_put_key(KEY_END);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
267 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
268 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
269 if (key <= 255)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
270 mplayer_put_key (key);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
271 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
272 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
273 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
274 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
275 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
276
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
277 static void uninit(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
278 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
279 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
280 cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
281 caca_end();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
282 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
283
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
284
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
285 static void draw_osd(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
286 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
287 if (vo_osd_progbar_type != -1)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
288 osdpercent(MESSAGE_DURATION, 0, 255,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
289 vo_osd_progbar_value, __sub_osd_names[vo_osd_progbar_type],
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
290 "");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
291 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
292
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
293 static int preinit(const char *arg)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
294 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
295 if (arg)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
296 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
297 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
298 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
299 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
300
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
301 if (caca_init())
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
302 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
303 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to initialize\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
304 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
305 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
306
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
307 caca_set_window_title("MPlayer");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
308
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
309 /* Default libcaca features */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
310 caca_set_feature(CACA_ANTIALIASING_PREFILTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
311 caca_set_feature(CACA_DITHERING_RANDOM);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
312
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
313 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
314 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
315
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
316 static int query_format(uint32_t format)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
317 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
318 if (format == IMGFMT_BGR24)
21161
ad7747bce52d Make compilation depending on USE_OSD unconditional.
uau
parents: 19979
diff changeset
319 return VFCAP_OSD | VFCAP_CSP_SUPPORTED;
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
320
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
321 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
322 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
323
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
324 static int control(uint32_t request, void *data, ...)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
325 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
326 switch(request)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
327 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
328 case VOCTRL_QUERY_FORMAT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
329 return query_format(*((uint32_t *)data));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
330 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
331 return VO_NOTIMPL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
332 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
333 }