1 /*
2 * Copyright (c) 2012 Paul B Mahol
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <caca.h>
25
31
35
39
43
45 {
47
49
53 }
55 caca_free_dither(c->
dither);
57 }
59 caca_free_canvas(c->
canvas);
61 }
62 return 0;
63 }
64
66 {
67 const char *const *drivers = caca_get_display_driver_list();
68 int i;
69
71 for (i = 0; drivers[i]; i += 2)
73 }
74
75 #define DEFINE_LIST_DITHER(thing, thing_str) \
76 static void list_dither_## thing(CACAContext *c) \
77 { \
78 const char *const *thing = caca_get_dither_## thing ##_list(c->dither); \
79 int i; \
80 \
81 av_log(c->ctx, AV_LOG_INFO, "Available %s:\n", thing_str); \
82 for (i = 0; thing[i]; i += 2) \
83 av_log(c->ctx, AV_LOG_INFO, "%s : %s\n", thing[i], thing[i + 1]); \
84 }
85
90
92 {
97
102 }
105 list_dither_color(c);
107 list_dither_charset(c);
108 }
else if (!strcmp(c->
list_dither,
"algorithms")) {
109 list_dither_algorithm(c);
110 }
else if (!strcmp(c->
list_dither,
"antialiases")) {
111 list_dither_antialias(c);
112 } else {
114 "Invalid argument '%s', for 'list_dither' option\n"
115 "Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\n",
118 }
120 }
121
127 }
128
131 "Unsupported pixel format '%s', choose rgb24\n",
134 }
135
140 goto fail;
141 }
142
145 bpp / 8 * encctx->
width,
146 0x0000ff, 0x00ff00, 0xff0000, 0);
150 goto fail;
151 }
152
153 #define CHECK_DITHER_OPT(opt) \
154 if (caca_set_dither_##opt(c->dither, c->opt) < 0) { \
155 ret = AVERROR(errno); \
156 av_log(s, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", \
157 c->opt, #opt); \
158 goto fail; \
159 }
164
170 goto fail;
171 }
172
176 }
177
182
183 return 0;
184
185 fail:
188 }
189
191 {
193
195 caca_refresh_display(c->
display);
196
197 return 0;
198 }
199
200 #define OFFSET(x) offsetof(CACAContext,x)
201 #define ENC AV_OPT_FLAG_ENCODING_PARAM
202
220 };
221
228 };
229
240 .priv_class = &caca_class,
241 };