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 {
96 int ret, bpp;
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
141 }
142
145 bpp / 8 * encctx->
width,
146 0x0000ff, 0x00ff00, 0xff0000, 0);
151 }
152
153 #define CHECK_DITHER_OPT(opt) do { \
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 } \
160 } while (0)
161
166
173 }
174
178 }
179
184
185 return 0;
186
189 return ret;
190 }
191
193 {
195
197 caca_refresh_display(c->
display);
198
199 return 0;
200 }
201
202 #define OFFSET(x) offsetof(CACAContext,x)
203 #define ENC AV_OPT_FLAG_ENCODING_PARAM
204
220 };
221
228 };
229
240 .priv_class = &caca_class,
241 };
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define LIBAVUTIL_VERSION_INT
packed RGB 8:8:8, 24bpp, RGBRGB...
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int caca_write_trailer(AVFormatContext *s)
static void list_drivers(CACAContext *c)
AVStream ** streams
A list of all streams in the file.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Main libavdevice API header.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVCodecContext * codec
Codec context associated with this stream.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
char filename[1024]
input or output filename
int width
picture width / height.
static int write_trailer(AVFormatContext *s1)
AVOutputFormat ff_caca_muxer
static const AVOption options[]
#define CHECK_DITHER_OPT(opt)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define DEFINE_LIST_DITHER(thing, thing_str)
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
char * av_strdup(const char *s)
Duplicate the string s.
main external API structure.
static const char * window_title
Describe the class of an AVClass context structure.
offset must point to two consecutive integers
static int caca_write_header(AVFormatContext *s)
static int caca_write_packet(AVFormatContext *s, AVPacket *pkt)
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static const AVClass caca_class
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)