FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
ansi.c File Reference

ASCII/ANSI art decoder. More...

#include "libavutil/common.h"
#include "libavutil/frame.h"
#include "libavutil/lfg.h"
#include "libavutil/xga_font_data.h"
#include "avcodec.h"
#include "cga_data.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  AnsiContext
 

Macros

#define ATTR_BOLD   0x01
 Bold/Bright-foreground (mode 1) More...
 
#define ATTR_FAINT   0x02
 Faint (mode 2) More...
 
#define ATTR_UNDERLINE   0x08
 Underline (mode 4) More...
 
#define ATTR_BLINK   0x10
 Blink/Bright-background (mode 5) More...
 
#define ATTR_REVERSE   0x40
 Reverse (mode 7) More...
 
#define ATTR_CONCEALED   0x80
 Concealed (mode 8) More...
 
#define DEFAULT_FG_COLOR   7
 CGA color index. More...
 
#define DEFAULT_BG_COLOR   0
 
#define DEFAULT_SCREEN_MODE   3
 80x25 More...
 
#define FONT_WIDTH   8
 Font width. More...
 
#define MAX_NB_ARGS   4
 
#define COLOR(x)   ((x) * 40 + 55)
 
#define GRAY(x)   ((x) * 10 + 8)
 

Functions

static av_cold int decode_init (AVCodecContext *avctx)
 
static void set_palette (uint32_t *pal)
 
static void hscroll (AVCodecContext *avctx)
 
static void erase_line (AVCodecContext *avctx, int xoffset, int xlength)
 
static void erase_screen (AVCodecContext *avctx)
 
static void draw_char (AVCodecContext *avctx, int c)
 Draw character to screen. More...
 
static int execute_code (AVCodecContext *avctx, int c)
 Execute ANSI escape code. More...
 
static int decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
static av_cold int decode_close (AVCodecContext *avctx)
 

Variables

static const uint8_t ansi_to_cga [16]
 map ansi color index to cga palette index More...
 
AVCodec ff_ansi_decoder
 

Detailed Description

ASCII/ANSI art decoder.

Definition in file ansi.c.

Macro Definition Documentation

#define ATTR_BOLD   0x01

Bold/Bright-foreground (mode 1)

Definition at line 35 of file ansi.c.

Referenced by draw_char().

#define ATTR_FAINT   0x02

Faint (mode 2)

Definition at line 36 of file ansi.c.

#define ATTR_UNDERLINE   0x08

Underline (mode 4)

Definition at line 37 of file ansi.c.

#define ATTR_BLINK   0x10

Blink/Bright-background (mode 5)

Definition at line 38 of file ansi.c.

Referenced by draw_char().

#define ATTR_REVERSE   0x40

Reverse (mode 7)

Definition at line 39 of file ansi.c.

Referenced by draw_char().

#define ATTR_CONCEALED   0x80

Concealed (mode 8)

Definition at line 40 of file ansi.c.

Referenced by draw_char().

#define DEFAULT_FG_COLOR   7

CGA color index.

Definition at line 42 of file ansi.c.

Referenced by decode_init(), and execute_code().

#define DEFAULT_BG_COLOR   0

Definition at line 43 of file ansi.c.

Referenced by decode_init(), erase_line(), erase_screen(), execute_code(), and hscroll().

#define DEFAULT_SCREEN_MODE   3

80x25

Definition at line 44 of file ansi.c.

Referenced by execute_code().

#define FONT_WIDTH   8

Font width.

Definition at line 46 of file ansi.c.

Referenced by decode_frame(), draw_char(), and execute_code().

#define MAX_NB_ARGS   4

Definition at line 73 of file ansi.c.

Referenced by decode_frame(), and execute_code().

#define COLOR (   x)    ((x) * 40 + 55)
#define GRAY (   x)    ((x) * 10 + 8)

Referenced by set_palette().

Function Documentation

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 78 of file ansi.c.

static void set_palette ( uint32_t *  pal)
static

Definition at line 101 of file ansi.c.

Referenced by decode_frame(), and execute_code().

static void hscroll ( AVCodecContext avctx)
static

Definition at line 116 of file ansi.c.

Referenced by decode_frame(), and draw_char().

static void erase_line ( AVCodecContext avctx,
int  xoffset,
int  xlength 
)
static

Definition at line 136 of file ansi.c.

Referenced by execute_code().

static void erase_screen ( AVCodecContext avctx)
static

Definition at line 145 of file ansi.c.

Referenced by decode_frame(), and execute_code().

static void draw_char ( AVCodecContext avctx,
int  c 
)
static

Draw character to screen.

Definition at line 157 of file ansi.c.

Referenced by decode_frame().

static int execute_code ( AVCodecContext avctx,
int  c 
)
static

Execute ANSI escape code.

Returns
0 on success, negative on error

Definition at line 184 of file ansi.c.

Referenced by decode_frame().

static int decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame,
AVPacket avpkt 
)
static

Definition at line 351 of file ansi.c.

static av_cold int decode_close ( AVCodecContext avctx)
static

Definition at line 464 of file ansi.c.

Variable Documentation

const uint8_t ansi_to_cga[16]
static
Initial value:
= {
0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15
}

map ansi color index to cga palette index

Definition at line 49 of file ansi.c.

Referenced by execute_code().

AVCodec ff_ansi_decoder
Initial value:
= {
.name = "ansi",
.long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
.priv_data_size = sizeof(AnsiContext),
.close = decode_close,
.capabilities = AV_CODEC_CAP_DR1,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int decode_close(AVCodecContext *avctx)
Definition: ansi.c:464
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static av_cold int decode_init(AVCodecContext *avctx)
Definition: ansi.c:78
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:752
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: ansi.c:351
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:958

Definition at line 472 of file ansi.c.