Go to the documentation of this file.
   35 #define ATTR_BOLD         0x01   
   36 #define ATTR_FAINT        0x02   
   37 #define ATTR_UNDERLINE    0x08   
   38 #define ATTR_BLINK        0x10   
   39 #define ATTR_REVERSE      0x40   
   40 #define ATTR_CONCEALED    0x80   
   42 #define DEFAULT_FG_COLOR     7   
   43 #define DEFAULT_BG_COLOR     0 
   44 #define DEFAULT_SCREEN_MODE  3   
   50     0,  4,  2,  6,  1,  5,  3, 7, 8, 12, 10, 14,  9, 13, 11, 15
 
  110 #define COLOR(x) ((x) * 40 + 55) 
  111     for (
r = 0; 
r < 6; 
r++)
 
  112         for (
g = 0; 
g < 6; 
g++)
 
  113             for (
b = 0; 
b < 6; 
b++)
 
  115 #define GRAY(x) ((x) * 10 + 8) 
  116     for (
g = 0; 
g < 24; 
g++)
 
  125     if (
s->y <= avctx->
height - 2*
s->font_height) {
 
  126         s->y += 
s->font_height;
 
  131     for (; 
i < avctx->
height - 
s->font_height; 
i++)
 
  132         memcpy(
s->frame->data[0] + 
i * 
s->frame->linesize[0],
 
  133                s->frame->data[0] + (
i + 
s->font_height) * 
s->frame->linesize[0],
 
  136         memset(
s->frame->data[0] + 
i * 
s->frame->linesize[0],
 
  144     for (
i = 0; 
i < 
s->font_height; 
i++)
 
  145         memset(
s->frame->data[0] + (
s->y + 
i)*
s->frame->linesize[0] + xoffset,
 
  176                     s->frame->linesize[0], 
s->font, 
s->font_height, 
c, fg, bg);
 
  197         s->y = 
FFMAX(
s->y - (
s->nb_args > 0 ? 
s->args[0]*
s->font_height : 
s->font_height), 0);
 
  200         s->y = 
FFMIN(
s->y + (
s->nb_args > 0 ? 
s->args[0]*
s->font_height : 
s->font_height), avctx->
height - 
s->font_height);
 
  210         s->y = 
s->nb_args > 0 ? av_clip((
s->args[0] - 1)*
s->font_height, 0, avctx->
height - 
s->font_height) : 0;
 
  218         case 0: 
case 1: 
case 4: 
case 5: 
case 13: 
case 19: 
 
  254         s->y = av_clip(
s->y, 0, 
height - 
s->font_height);
 
  264             s->frame->palette_has_changed = 1;
 
  267         } 
else if (
c == 
'l') {
 
  272         switch (
s->args[0]) {
 
  275             if (
s->y < avctx->
height - 
s->font_height)
 
  276                 memset(
s->frame->data[0] + (
s->y + 
s->font_height)*
s->frame->linesize[0],
 
  301         if (
s->nb_args == 0) {
 
  311             } 
else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
 
  312                 s->attributes |= 1 << (m - 1);
 
  313             } 
else if (m >= 30 && m <= 37) {
 
  315             } 
else if (m == 38 && 
i + 2 < 
FFMIN(
s->nb_args, 
MAX_NB_ARGS) && 
s->args[
i + 1] == 5 && 
s->args[
i + 2] < 256) {
 
  319             } 
else if (m == 39) {
 
  321             } 
else if (m >= 40 && m <= 47) {
 
  323             } 
else if (m == 48 && 
i + 2 < 
FFMIN(
s->nb_args, 
MAX_NB_ARGS) && 
s->args[
i + 1] == 5 && 
s->args[
i + 2] < 256) {
 
  327             } 
else if (m == 49) {
 
  344         s->y = av_clip(
s->sy, 0, avctx->
height - 
s->font_height);
 
  351     s->y = av_clip(
s->y, 0, avctx->
height - 
s->font_height);
 
  356                             void *
data, 
int *got_frame,
 
  361     int buf_size = avpkt->
size;
 
  369             memset(
s->frame->data[0]+ 
i*
s->frame->linesize[0], 0, avctx->
width);
 
  374     s->frame->palette_has_changed = 1;
 
  376     if (!
s->first_frame) {
 
  381     while(
buf < buf_end) {
 
  408                 s->state = STATE_ESCAPE;
 
  416                 s->state   = STATE_CODE;
 
  420                 s->state = STATE_NORMAL;
 
  427             case '0': 
case '1': 
case '2': 
case '3': 
case '4':
 
  428             case '5': 
case '6': 
case '7': 
case '8': 
case '9':
 
  430                     s->args[
s->nb_args] = 
FFMAX(
s->args[
s->nb_args], 0) * 10 + 
buf[0] - 
'0';
 
  436                     s->args[
s->nb_args] = 0;
 
  439                 s->state = STATE_MUSIC_PREAMBLE;
 
  451                 s->state = STATE_NORMAL;
 
  454         case STATE_MUSIC_PREAMBLE:
 
  455             if (
buf[0] == 0x0E || 
buf[0] == 0x1B)
 
  456                 s->state = STATE_NORMAL;
 
  478     { 
"max_pixels", 
"640*480" },
 
  
#define AV_LOG_WARNING
Something somehow does not look correct.
 
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
 
static av_cold int decode_close(AVCodecContext *avctx)
 
static av_cold int init(AVCodecContext *avctx)
 
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
 
const uint32_t ff_cga_palette[16]
 
#define FFSWAP(type, a, b)
 
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
 
This structure describes decoded (raw) audio or video data.
 
static int execute_code(AVCodecContext *avctx, int c)
Execute ANSI escape code.
 
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
 
enum AnsiContext::@35 state
 
int sy
saved y cursor position (pixels)
 
int nb_args
number of arguments (may exceed MAX_NB_ARGS)
 
static const AVCodecDefault defaults[]
 
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
 
void ff_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg)
Draw CGA/EGA/VGA font to 8-bit pixel buffer.
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
 
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
 
int y
y cursor position (pixels)
 
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
 
static void draw_char(AVCodecContext *avctx, int c)
Draw character to screen.
 
#define ATTR_BLINK
Blink/Bright-background (mode 5)
 
#define ATTR_CONCEALED
Concealed (mode 8)
 
#define ATTR_BOLD
Bold/Bright-foreground (mode 1)
 
#define DEFAULT_SCREEN_MODE
80x25
 
@ AV_PICTURE_TYPE_I
Intra.
 
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
 
int sx
saved x cursor position (pixels)
 
int attributes
attribute flags
 
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
 
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
 
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
 
static void hscroll(AVCodecContext *avctx)
 
static void erase_line(AVCodecContext *avctx, int xoffset, int xlength)
 
#define DEFAULT_FG_COLOR
CGA color index.
 
const uint8_t avpriv_vga16_font[4096]
 
static void set_palette(uint32_t *pal)
 
#define ATTR_REVERSE
Reverse (mode 7)
 
#define i(width, name, range_min, range_max)
 
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
 
const char * name
Name of the codec implementation.
 
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
 
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
 
#define FONT_WIDTH
Font width.
 
static const AVCodecDefault ansi_defaults[]
 
main external API structure.
 
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
 
int frame_number
Frame counter, set by libavcodec.
 
#define avpriv_request_sample(...)
 
const uint8_t avpriv_cga_font[2048]
 
This structure stores compressed data.
 
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
int width
picture width / height.
 
int x
x cursor position (pixels)
 
int font_height
font height
 
static av_cold int decode_init(AVCodecContext *avctx)
 
static void erase_screen(AVCodecContext *avctx)
 
static const uint8_t ansi_to_cga[16]
map ansi color index to cga palette index