37#define ATTR_FAINT 0x02
38#define ATTR_ITALICS 0x04
39#define ATTR_UNDERLINE 0x08
40#define ATTR_BLINK 0x10
41#define ATTR_REVERSE 0x40
42#define ATTR_CONCEALED 0x80
44#define DEFAULT_FG_COLOR 7
45#define DEFAULT_BG_COLOR 0
46#define DEFAULT_SCREEN_MODE 3
52 0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15
112#define COLOR(x) ((x) * 40 + 55)
113 for (
r = 0;
r < 6;
r++)
114 for (
g = 0;
g < 6;
g++)
115 for (
b = 0;
b < 6;
b++)
117#define GRAY(x) ((x) * 10 + 8)
118 for (
g = 0;
g < 24;
g++)
127 if (
s->y <= avctx->
height - 2*
s->font_height) {
128 s->y +=
s->font_height;
133 for (;
i < avctx->
height -
s->font_height;
i++)
134 memcpy(
s->frame->data[0] +
i *
s->frame->linesize[0],
135 s->frame->data[0] + (
i +
s->font_height) *
s->frame->linesize[0],
138 memset(
s->frame->data[0] +
i *
s->frame->linesize[0],
146 for (
i = 0;
i <
s->font_height;
i++)
147 memset(
s->frame->data[0] + (
s->y +
i)*
s->frame->linesize[0] + xoffset,
178 s->frame->linesize[0],
s->font,
s->font_height,
c, fg, bg);
199 s->y =
FFMAX(
s->y - (
s->nb_args > 0 ?
s->args[0]*
s->font_height :
s->font_height), 0);
202 s->y =
FFMIN(
s->y + (
s->nb_args > 0 ?
s->args[0]*
s->font_height :
s->font_height), avctx->
height -
s->font_height);
212 s->y =
s->nb_args > 0 ?
av_clip((
s->args[0] - 1)*
s->font_height, 0, avctx->
height -
s->font_height) : 0;
220 case 0:
case 1:
case 4:
case 5:
case 13:
case 19:
268 }
else if (
c ==
'l') {
273 switch (
s->args[0]) {
276 if (
s->y < avctx->
height -
s->font_height)
277 memset(
s->frame->data[0] + (
s->y +
s->font_height)*
s->frame->linesize[0],
302 if (
s->nb_args == 0) {
312 }
else if (m == 1 || m == 2 || m == 3 || m == 4 || m == 5 || m == 7 || m == 8) {
313 s->attributes |= 1 << (m - 1);
314 }
else if (m >= 30 && m <= 37) {
316 }
else if (m == 38 &&
i + 2 <
FFMIN(
s->nb_args,
MAX_NB_ARGS) &&
s->args[
i + 1] == 5 &&
s->args[
i + 2] < 256) {
320 }
else if (m == 39) {
322 }
else if (m >= 40 && m <= 47) {
324 }
else if (m == 48 &&
i + 2 <
FFMIN(
s->nb_args,
MAX_NB_ARGS) &&
s->args[
i + 1] == 5 &&
s->args[
i + 2] < 256) {
328 }
else if (m == 49) {
360 const uint8_t *buf = avpkt->
data;
361 int buf_size = avpkt->
size;
362 const uint8_t *buf_end = buf+buf_size;
369 memset(
s->frame->data[0]+
i*
s->frame->linesize[0], 0, avctx->
width);
375 if (!
s->first_frame) {
380 while(buf < buf_end) {
394 count = ((
i + 8) & ~7) -
i;
395 for (
i = 0;
i < count;
i++)
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" },
const FFCodec ff_ansi_decoder
static int execute_code(AVCodecContext *avctx, int c)
Execute ANSI escape code.
#define ATTR_CONCEALED
Concealed (mode 8)
#define DEFAULT_FG_COLOR
CGA color index.
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
#define ATTR_BLINK
Blink/Bright-background (mode 5)
static av_cold int decode_close(AVCodecContext *avctx)
#define ATTR_BOLD
Bold/Bright-foreground (mode 1)
static av_cold int decode_init(AVCodecContext *avctx)
static void hscroll(AVCodecContext *avctx)
#define FONT_WIDTH
Font width.
static void draw_char(AVCodecContext *avctx, int c)
Draw character to screen.
static void erase_screen(AVCodecContext *avctx)
#define DEFAULT_SCREEN_MODE
80x25
static const FFCodecDefault ansi_defaults[]
static void erase_line(AVCodecContext *avctx, int xoffset, int xlength)
#define ATTR_REVERSE
Reverse (mode 7)
static const uint8_t ansi_to_cga[16]
map ansi color index to cga palette index
static void set_palette(uint32_t *pal)
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
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.
const uint32_t ff_cga_palette[16]
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
static struct @346255127015250356166251341105367306144006377143 state
reference-counted frame API
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
static av_cold int decode_close(AVCodecContext *avctx)
Macro definitions for various function/variable attributes.
#define FFSWAP(type, a, b)
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int64_t frame_num
Frame counter, set by libavcodec.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int sy
saved y cursor position (pixels)
int y
y cursor position (pixels)
int x
x cursor position (pixels)
int sx
saved x cursor position (pixels)
int nb_args
number of arguments (may exceed MAX_NB_ARGS)
int attributes
attribute flags
int font_height
font height
#define avpriv_request_sample(...)
const uint8_t * avpriv_vga16_font_get(void)
const uint8_t * avpriv_cga_font_get(void)
CGA/EGA/VGA ROM font data.