FFmpeg
Loading...
Searching...
No Matches
caca.c File Reference
#include <caca.h>
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavformat/mux.h"
#include "avdevice.h"

Go to the source code of this file.

Data Structures

struct  CACAContext
 

Macros

#define DEFINE_LIST_DITHER(thing, thing_str)
 
#define CHECK_DITHER_OPT(opt)
 
#define OFFSET(x)
 
#define ENC   AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  { LIST_ALGORITHMS = 1 << 0 , LIST_ANTIALIASES = 1 << 1 , LIST_CHARSETS = 1 << 2 , LIST_COLORS = 1 << 3 }
 

Functions

static void caca_deinit (AVFormatContext *s)
 
static void list_drivers (CACAContext *c)
 
 DEFINE_LIST_DITHER (color, "colors")
 
 DEFINE_LIST_DITHER (charset, "charsets")
 
 DEFINE_LIST_DITHER (algorithm, "algorithms")
 
 DEFINE_LIST_DITHER (antialias, "antialias")
 
static int caca_write_header (AVFormatContext *s)
 
static int caca_write_packet (AVFormatContext *s, AVPacket *pkt)
 

Variables

static const AVOption options []
 
static const AVClass caca_class
 
const FFOutputFormat ff_caca_muxer
 

Macro Definition Documentation

◆ DEFINE_LIST_DITHER

#define DEFINE_LIST_DITHER ( thing,
thing_str )
Value:
static void list_dither_## thing(CACAContext *c) \
{ \
const char *const *thing = caca_get_dither_## thing ##_list(c->dither); \
int i; \
\
av_log(c->ctx, AV_LOG_INFO, "Available %s:\n", thing_str); \
for (i = 0; thing[i]; i += 2) \
av_log(c->ctx, AV_LOG_INFO, "%s: %s\n", thing[i], thing[i + 1]); \
}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define av_log(a,...)
static double c[64]

Definition at line 81 of file caca.c.

◆ CHECK_DITHER_OPT

#define CHECK_DITHER_OPT ( opt)
Value:
do { \
if (caca_set_dither_##opt(c->dither, c->opt) < 0) { \
ret = AVERROR(errno); \
av_log(s, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", \
c->opt, #opt); \
return ret; \
} \
} while (0)
#define s(width, name)
Definition cbs_vp9.c:198
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210

Referenced by caca_write_header().

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(CACAContext,x)

Definition at line 197 of file caca.c.

◆ ENC

#define ENC   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 198 of file caca.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LIST_ALGORITHMS 
LIST_ANTIALIASES 
LIST_CHARSETS 
LIST_COLORS 

Definition at line 28 of file caca.c.

Function Documentation

◆ caca_deinit()

static void caca_deinit ( AVFormatContext * s)
static

Definition at line 53 of file caca.c.

◆ list_drivers()

static void list_drivers ( CACAContext * c)
static

Definition at line 71 of file caca.c.

Referenced by caca_write_header().

◆ DEFINE_LIST_DITHER() [1/4]

DEFINE_LIST_DITHER ( color ,
"colors"  )

◆ DEFINE_LIST_DITHER() [2/4]

DEFINE_LIST_DITHER ( charset ,
"charsets"  )

◆ DEFINE_LIST_DITHER() [3/4]

DEFINE_LIST_DITHER ( algorithm ,
"algorithms"  )

◆ DEFINE_LIST_DITHER() [4/4]

DEFINE_LIST_DITHER ( antialias ,
"antialias"  )

◆ caca_write_header()

static int caca_write_header ( AVFormatContext * s)
static

Definition at line 97 of file caca.c.

◆ caca_write_packet()

static int caca_write_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 187 of file caca.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "window_size", "set window forced size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL }, 0, 0, ENC},
{ "window_title", "set window title", OFFSET(window_title), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, ENC },
{ "driver", "set display driver", OFFSET(driver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, ENC },
{ "algorithm", "set dithering algorithm", OFFSET(algorithm), AV_OPT_TYPE_STRING, {.str = "default" }, 0, 0, ENC },
{ "antialias", "set antialias method", OFFSET(antialias), AV_OPT_TYPE_STRING, {.str = "default" }, 0, 0, ENC },
{ "charset", "set charset used to render output", OFFSET(charset), AV_OPT_TYPE_STRING, {.str = "default" }, 0, 0, ENC },
{ "color", "set color used to render output", OFFSET(color), AV_OPT_TYPE_STRING, {.str = "default" }, 0, 0, ENC },
{ "list_drivers", "list available drivers", OFFSET(list_drivers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, ENC },
{ "list_dither", "list available dither options", OFFSET(list_dither), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, INT_MAX, ENC, .unit = "list_dither" },
{ "algorithms", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = LIST_ALGORITHMS }, 0, 0, ENC, .unit = "list_dither" },
{ "antialiases", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = LIST_ANTIALIASES }, 0, 0, ENC, .unit = "list_dither" },
{ "charsets", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = LIST_CHARSETS }, 0, 0, ENC, .unit = "list_dither" },
{ "colors", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = LIST_COLORS }, 0, 0, ENC, .unit = "list_dither" },
{ NULL },
}
static void list_drivers(CACAContext *c)
Definition caca.c:71
#define ENC
Definition caca.c:198
@ LIST_COLORS
Definition caca.c:32
@ LIST_CHARSETS
Definition caca.c:31
@ LIST_ALGORITHMS
Definition caca.c:29
@ LIST_ANTIALIASES
Definition caca.c:30
#define NULL
Definition coverity.c:32
#define OFFSET(x)
static const char * window_title
Definition ffplay.c:310
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition opt.h:254
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition log.c:98

Definition at line 200 of file caca.c.

◆ caca_class

const AVClass caca_class
static
Initial value:
= {
.class_name = "caca outdev",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT
Definition log.h:41

Definition at line 217 of file caca.c.

◆ ff_caca_muxer

const FFOutputFormat ff_caca_muxer
Initial value:
= {
.p.name = "caca",
.p.long_name = NULL_IF_CONFIG_SMALL("caca (color ASCII art) output device"),
.priv_data_size = sizeof(CACAContext),
.p.audio_codec = AV_CODEC_ID_NONE,
.p.video_codec = AV_CODEC_ID_RAWVIDEO,
.write_header = caca_write_header,
.write_packet = caca_write_packet,
.deinit = caca_deinit,
.p.flags = AVFMT_NOFILE,
.p.priv_class = &caca_class,
}
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition avformat.h:488
static void caca_deinit(AVFormatContext *s)
Definition caca.c:53
static const AVClass caca_class
Definition caca.c:217
static int caca_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition caca.c:187
static int caca_write_header(AVFormatContext *s)
Definition caca.c:97
@ AV_CODEC_ID_RAWVIDEO
Definition codec_id.h:63
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 225 of file caca.c.