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
106 #define COLOR(x) ((x) * 40 + 55)
107 for (r = 0; r < 6; r++)
108 for (g = 0; g < 6; g++)
109 for (b = 0; b < 6; b++)
111 #define GRAY(x) ((x) * 10 + 8)
112 for (g = 0; g < 24; g++)
113 *pal++ = 0xFF000000 | (
GRAY(g) << 16) | (
GRAY(g) << 8) |
GRAY(g);
131 for (; i < avctx->
height; i++)
149 for (i = 0; i < avctx->
height; i++)
207 s->
x = s->
nb_args > 1 ? av_clip((s->
args[1] - 1)*FONT_WIDTH, 0, avctx->
width - FONT_WIDTH) : 0;
214 case 0:
case 1:
case 4:
case 5:
case 13:
case 19:
249 s->
x = av_clip(s->
x, 0, width - FONT_WIDTH);
251 if (width != avctx->
width || height != avctx->
height) {
263 }
else if (c ==
'l') {
268 switch (s->
args[0]) {
307 }
else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
309 }
else if (m >= 30 && m <= 37) {
315 }
else if (m == 39) {
317 }
else if (m >= 40 && m <= 47) {
323 }
else if (m == 49) {
339 s->
x = av_clip(s->
sx, 0, avctx->
width - FONT_WIDTH);
352 void *
data,
int *got_frame,
357 int buf_size = avpkt->
size;
358 const uint8_t *buf_end = buf+buf_size;
364 for (i=0; i<avctx->
height; i++)
377 while(buf < buf_end) {
391 count = ((i + 8) & ~7) - i;
392 for (i = 0; i <
count; i++)
404 s->
state = STATE_ESCAPE;
412 s->
state = STATE_CODE;
416 s->
state = STATE_NORMAL;
423 case '0':
case '1':
case '2':
case '3':
case '4':
424 case '5':
case '6':
case '7':
case '8':
case '9':
434 s->
state = STATE_MUSIC_PREAMBLE;
446 s->
state = STATE_NORMAL;
449 case STATE_MUSIC_PREAMBLE:
450 if (buf[0] == 0x0E || buf[0] == 0x1B)
451 s->
state = STATE_NORMAL;
static void draw_char(AVCodecContext *avctx, int c)
Draw character to screen.
#define FONT_WIDTH
Font width.
int x
x cursor position (pixels)
#define ATTR_REVERSE
Reverse (mode 7)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
#define ATTR_CONCEALED
Concealed (mode 8)
#define AV_LOG_WARNING
Something somehow does not look correct.
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.
static av_cold int init(AVCodecContext *avctx)
int nb_args
number of arguments (may exceed MAX_NB_ARGS)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const uint8_t avpriv_vga16_font[4096]
#define DEFAULT_SCREEN_MODE
80x25
static void erase_screen(AVCodecContext *avctx)
static int execute_code(AVCodecContext *avctx, int c)
Execute ANSI escape code.
static void hscroll(AVCodecContext *avctx)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
8 bit with AV_PIX_FMT_RGB32 palette
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static av_cold int decode_close(AVCodecContext *avctx)
int sy
saved y cursor position (pixels)
const uint8_t avpriv_cga_font[2048]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void erase_line(AVCodecContext *avctx, int xoffset, int xlength)
const char * name
Name of the codec implementation.
reference-counted frame API
#define ATTR_BLINK
Blink/Bright-background (mode 5)
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 AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_cold int decode_init(AVCodecContext *avctx)
#define ATTR_BOLD
Bold/Bright-foreground (mode 1)
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.
Libavcodec external API header.
int font_height
font height
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
BYTE int const BYTE int int int height
int palette_has_changed
Tell user application that palette has changed from previous frame.
static const uint8_t ansi_to_cga[16]
map ansi color index to cga palette index
static void set_palette(uint32_t *pal)
const uint32_t ff_cga_palette[16]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
int sx
saved x cursor position (pixels)
common internal api header.
common internal and external API header
int y
y cursor position (pixels)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
enum AnsiContext::@35 state
int frame_number
Frame counter, set by libavcodec.
#define DEFAULT_FG_COLOR
CGA color index.
#define FFSWAP(type, a, b)
int attributes
attribute flags
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
CGA/EGA/VGA ROM font data.