FFmpeg
ansi.c
Go to the documentation of this file.
1 /*
2  * ASCII/ANSI art decoder
3  * Copyright (c) 2010 Peter Ross <pross@xvid.org>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * ASCII/ANSI art decoder
25  */
26 
27 #include "libavutil/common.h"
28 #include "libavutil/frame.h"
29 #include "libavutil/lfg.h"
31 #include "avcodec.h"
32 #include "cga_data.h"
33 #include "internal.h"
34 
35 #define ATTR_BOLD 0x01 /**< Bold/Bright-foreground (mode 1) */
36 #define ATTR_FAINT 0x02 /**< Faint (mode 2) */
37 #define ATTR_UNDERLINE 0x08 /**< Underline (mode 4) */
38 #define ATTR_BLINK 0x10 /**< Blink/Bright-background (mode 5) */
39 #define ATTR_REVERSE 0x40 /**< Reverse (mode 7) */
40 #define ATTR_CONCEALED 0x80 /**< Concealed (mode 8) */
41 
42 #define DEFAULT_FG_COLOR 7 /**< CGA color index */
43 #define DEFAULT_BG_COLOR 0
44 #define DEFAULT_SCREEN_MODE 3 /**< 80x25 */
45 
46 #define FONT_WIDTH 8 /**< Font width */
47 
48 /** map ansi color index to cga palette index */
49 static const uint8_t ansi_to_cga[16] = {
50  0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15
51 };
52 
53 typedef struct AnsiContext {
55  int x; /**< x cursor position (pixels) */
56  int y; /**< y cursor position (pixels) */
57  int sx; /**< saved x cursor position (pixels) */
58  int sy; /**< saved y cursor position (pixels) */
59  const uint8_t* font; /**< font */
60  int font_height; /**< font height */
61  int attributes; /**< attribute flags */
62  int fg; /**< foreground color */
63  int bg; /**< background color */
65 
66  /* ansi parser state machine */
67  enum {
72  } state;
73 #define MAX_NB_ARGS 4
75  int nb_args; /**< number of arguments (may exceed MAX_NB_ARGS) */
76 } AnsiContext;
77 
79 {
80  AnsiContext *s = avctx->priv_data;
81  avctx->pix_fmt = AV_PIX_FMT_PAL8;
82 
83  /* defaults */
84  s->font = avpriv_vga16_font;
85  s->font_height = 16;
86  s->fg = DEFAULT_FG_COLOR;
87  s->bg = DEFAULT_BG_COLOR;
88 
89  if (!avctx->width || !avctx->height) {
90  int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4);
91  if (ret < 0)
92  return ret;
93  } else if (avctx->width % FONT_WIDTH || avctx->height % s->font_height) {
94  av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %d %d\n", avctx->width, avctx->height);
95  return AVERROR(EINVAL);
96  }
97 
98  s->frame = av_frame_alloc();
99  if (!s->frame)
100  return AVERROR(ENOMEM);
101 
102  return 0;
103 }
104 
105 static void set_palette(uint32_t *pal)
106 {
107  int r, g, b;
108  memcpy(pal, ff_cga_palette, 16 * 4);
109  pal += 16;
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++)
114  *pal++ = 0xFF000000 | (COLOR(r) << 16) | (COLOR(g) << 8) | COLOR(b);
115 #define GRAY(x) ((x) * 10 + 8)
116  for (g = 0; g < 24; g++)
117  *pal++ = 0xFF000000 | (GRAY(g) << 16) | (GRAY(g) << 8) | GRAY(g);
118 }
119 
120 static void hscroll(AVCodecContext *avctx)
121 {
122  AnsiContext *s = avctx->priv_data;
123  int i;
124 
125  if (s->y <= avctx->height - 2*s->font_height) {
126  s->y += s->font_height;
127  return;
128  }
129 
130  i = 0;
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],
134  avctx->width);
135  for (; i < avctx->height; i++)
136  memset(s->frame->data[0] + i * s->frame->linesize[0],
137  DEFAULT_BG_COLOR, avctx->width);
138 }
139 
140 static void erase_line(AVCodecContext * avctx, int xoffset, int xlength)
141 {
142  AnsiContext *s = avctx->priv_data;
143  int i;
144  for (i = 0; i < s->font_height; i++)
145  memset(s->frame->data[0] + (s->y + i)*s->frame->linesize[0] + xoffset,
146  DEFAULT_BG_COLOR, xlength);
147 }
148 
149 static void erase_screen(AVCodecContext *avctx)
150 {
151  AnsiContext *s = avctx->priv_data;
152  int i;
153  for (i = 0; i < avctx->height; i++)
154  memset(s->frame->data[0] + i * s->frame->linesize[0], DEFAULT_BG_COLOR, avctx->width);
155  s->x = s->y = 0;
156 }
157 
158 /**
159  * Draw character to screen
160  */
161 static void draw_char(AVCodecContext *avctx, int c)
162 {
163  AnsiContext *s = avctx->priv_data;
164  int fg = s->fg;
165  int bg = s->bg;
166 
167  if ((s->attributes & ATTR_BOLD))
168  fg += 8;
169  if ((s->attributes & ATTR_BLINK))
170  bg += 8;
171  if ((s->attributes & ATTR_REVERSE))
172  FFSWAP(int, fg, bg);
173  if ((s->attributes & ATTR_CONCEALED))
174  fg = bg;
175  ff_draw_pc_font(s->frame->data[0] + s->y * s->frame->linesize[0] + s->x,
176  s->frame->linesize[0], s->font, s->font_height, c, fg, bg);
177  s->x += FONT_WIDTH;
178  if (s->x > avctx->width - FONT_WIDTH) {
179  s->x = 0;
180  hscroll(avctx);
181  }
182 }
183 
184 /**
185  * Execute ANSI escape code
186  * @return 0 on success, negative on error
187  */
188 static int execute_code(AVCodecContext * avctx, int c)
189 {
190  AnsiContext *s = avctx->priv_data;
191  int ret, i;
192  int width = avctx->width;
193  int height = avctx->height;
194 
195  switch(c) {
196  case 'A': //Cursor Up
197  s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
198  break;
199  case 'B': //Cursor Down
200  s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
201  break;
202  case 'C': //Cursor Right
203  s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH);
204  break;
205  case 'D': //Cursor Left
206  s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
207  break;
208  case 'H': //Cursor Position
209  case 'f': //Horizontal and Vertical Position
210  s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
211  s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
212  break;
213  case 'h': //set screen mode
214  case 'l': //reset screen mode
215  if (s->nb_args < 2)
216  s->args[0] = DEFAULT_SCREEN_MODE;
217  switch(s->args[0]) {
218  case 0: case 1: case 4: case 5: case 13: case 19: //320x200 (25 rows)
219  s->font = avpriv_cga_font;
220  s->font_height = 8;
221  width = 40<<3;
222  height = 25<<3;
223  break;
224  case 2: case 3: //640x400 (25 rows)
225  s->font = avpriv_vga16_font;
226  s->font_height = 16;
227  width = 80<<3;
228  height = 25<<4;
229  break;
230  case 6: case 14: //640x200 (25 rows)
231  s->font = avpriv_cga_font;
232  s->font_height = 8;
233  width = 80<<3;
234  height = 25<<3;
235  break;
236  case 7: //set line wrapping
237  break;
238  case 15: case 16: //640x350 (43 rows)
239  s->font = avpriv_cga_font;
240  s->font_height = 8;
241  width = 80<<3;
242  height = 43<<3;
243  break;
244  case 17: case 18: //640x480 (60 rows)
245  s->font = avpriv_cga_font;
246  s->font_height = 8;
247  width = 80<<3;
248  height = 60<<4;
249  break;
250  default:
251  avpriv_request_sample(avctx, "Unsupported screen mode");
252  }
253  s->x = av_clip(s->x, 0, width - FONT_WIDTH);
254  s->y = av_clip(s->y, 0, height - s->font_height);
255  if (width != avctx->width || height != avctx->height) {
256  av_frame_unref(s->frame);
257  ret = ff_set_dimensions(avctx, width, height);
258  if (ret < 0)
259  return ret;
260  if ((ret = ff_get_buffer(avctx, s->frame,
262  return ret;
263  s->frame->pict_type = AV_PICTURE_TYPE_I;
264  s->frame->palette_has_changed = 1;
265  set_palette((uint32_t *)s->frame->data[1]);
266  erase_screen(avctx);
267  } else if (c == 'l') {
268  erase_screen(avctx);
269  }
270  break;
271  case 'J': //Erase in Page
272  switch (s->args[0]) {
273  case 0:
274  erase_line(avctx, s->x, avctx->width - s->x);
275  if (s->y < avctx->height - s->font_height)
276  memset(s->frame->data[0] + (s->y + s->font_height)*s->frame->linesize[0],
277  DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame->linesize[0]);
278  break;
279  case 1:
280  erase_line(avctx, 0, s->x);
281  if (s->y > 0)
282  memset(s->frame->data[0], DEFAULT_BG_COLOR, s->y * s->frame->linesize[0]);
283  break;
284  case 2:
285  erase_screen(avctx);
286  }
287  break;
288  case 'K': //Erase in Line
289  switch(s->args[0]) {
290  case 0:
291  erase_line(avctx, s->x, avctx->width - s->x);
292  break;
293  case 1:
294  erase_line(avctx, 0, s->x);
295  break;
296  case 2:
297  erase_line(avctx, 0, avctx->width);
298  }
299  break;
300  case 'm': //Select Graphics Rendition
301  if (s->nb_args == 0) {
302  s->nb_args = 1;
303  s->args[0] = 0;
304  }
305  for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) {
306  int m = s->args[i];
307  if (m == 0) {
308  s->attributes = 0;
309  s->fg = DEFAULT_FG_COLOR;
310  s->bg = DEFAULT_BG_COLOR;
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) {
314  s->fg = ansi_to_cga[m - 30];
315  } else if (m == 38 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
316  int index = s->args[i + 2];
317  s->fg = index < 16 ? ansi_to_cga[index] : index;
318  i += 2;
319  } else if (m == 39) {
321  } else if (m >= 40 && m <= 47) {
322  s->bg = ansi_to_cga[m - 40];
323  } else if (m == 48 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
324  int index = s->args[i + 2];
325  s->bg = index < 16 ? ansi_to_cga[index] : index;
326  i += 2;
327  } else if (m == 49) {
329  } else {
330  avpriv_request_sample(avctx, "Unsupported rendition parameter");
331  }
332  }
333  break;
334  case 'n': //Device Status Report
335  case 'R': //report current line and column
336  /* ignore */
337  break;
338  case 's': //Save Cursor Position
339  s->sx = s->x;
340  s->sy = s->y;
341  break;
342  case 'u': //Restore Cursor Position
343  s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH);
344  s->y = av_clip(s->sy, 0, avctx->height - s->font_height);
345  break;
346  default:
347  avpriv_request_sample(avctx, "Unknown escape code");
348  break;
349  }
350  s->x = av_clip(s->x, 0, avctx->width - FONT_WIDTH);
351  s->y = av_clip(s->y, 0, avctx->height - s->font_height);
352  return 0;
353 }
354 
355 static int decode_frame(AVCodecContext *avctx,
356  void *data, int *got_frame,
357  AVPacket *avpkt)
358 {
359  AnsiContext *s = avctx->priv_data;
360  uint8_t *buf = avpkt->data;
361  int buf_size = avpkt->size;
362  const uint8_t *buf_end = buf+buf_size;
363  int ret, i, count;
364 
365  if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
366  return ret;
367  if (!avctx->frame_number) {
368  for (i=0; i<avctx->height; i++)
369  memset(s->frame->data[0]+ i*s->frame->linesize[0], 0, avctx->width);
370  memset(s->frame->data[1], 0, AVPALETTE_SIZE);
371  }
372 
373  s->frame->pict_type = AV_PICTURE_TYPE_I;
374  s->frame->palette_has_changed = 1;
375  set_palette((uint32_t *)s->frame->data[1]);
376  if (!s->first_frame) {
377  erase_screen(avctx);
378  s->first_frame = 1;
379  }
380 
381  while(buf < buf_end) {
382  switch(s->state) {
383  case STATE_NORMAL:
384  switch (buf[0]) {
385  case 0x00: //NUL
386  case 0x07: //BEL
387  case 0x1A: //SUB
388  /* ignore */
389  break;
390  case 0x08: //BS
391  s->x = FFMAX(s->x - 1, 0);
392  break;
393  case 0x09: //HT
394  i = s->x / FONT_WIDTH;
395  count = ((i + 8) & ~7) - i;
396  for (i = 0; i < count; i++)
397  draw_char(avctx, ' ');
398  break;
399  case 0x0A: //LF
400  hscroll(avctx);
401  case 0x0D: //CR
402  s->x = 0;
403  break;
404  case 0x0C: //FF
405  erase_screen(avctx);
406  break;
407  case 0x1B: //ESC
408  s->state = STATE_ESCAPE;
409  break;
410  default:
411  draw_char(avctx, buf[0]);
412  }
413  break;
414  case STATE_ESCAPE:
415  if (buf[0] == '[') {
416  s->state = STATE_CODE;
417  s->nb_args = 0;
418  s->args[0] = -1;
419  } else {
420  s->state = STATE_NORMAL;
421  draw_char(avctx, 0x1B);
422  continue;
423  }
424  break;
425  case STATE_CODE:
426  switch(buf[0]) {
427  case '0': case '1': case '2': case '3': case '4':
428  case '5': case '6': case '7': case '8': case '9':
429  if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553)
430  s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
431  break;
432  case ';':
433  if (s->nb_args < MAX_NB_ARGS)
434  s->nb_args++;
435  if (s->nb_args < MAX_NB_ARGS)
436  s->args[s->nb_args] = 0;
437  break;
438  case 'M':
439  s->state = STATE_MUSIC_PREAMBLE;
440  break;
441  case '=': case '?':
442  /* ignore */
443  break;
444  default:
445  if (s->nb_args > MAX_NB_ARGS)
446  av_log(avctx, AV_LOG_WARNING, "args overflow (%i)\n", s->nb_args);
447  if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] >= 0)
448  s->nb_args++;
449  if ((ret = execute_code(avctx, buf[0])) < 0)
450  return ret;
451  s->state = STATE_NORMAL;
452  }
453  break;
454  case STATE_MUSIC_PREAMBLE:
455  if (buf[0] == 0x0E || buf[0] == 0x1B)
456  s->state = STATE_NORMAL;
457  /* ignore music data */
458  break;
459  }
460  buf++;
461  }
462 
463  *got_frame = 1;
464  if ((ret = av_frame_ref(data, s->frame)) < 0)
465  return ret;
466  return buf_size;
467 }
468 
470 {
471  AnsiContext *s = avctx->priv_data;
472 
473  av_frame_free(&s->frame);
474  return 0;
475 }
476 
477 static const AVCodecDefault ansi_defaults[] = {
478  { "max_pixels", "640*480" },
479  { NULL },
480 };
481 
483  .name = "ansi",
484  .long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
485  .type = AVMEDIA_TYPE_VIDEO,
486  .id = AV_CODEC_ID_ANSI,
487  .priv_data_size = sizeof(AnsiContext),
488  .init = decode_init,
489  .close = decode_close,
490  .decode = decode_frame,
491  .capabilities = AV_CODEC_CAP_DR1,
492  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
494 };
AV_CODEC_ID_ANSI
@ AV_CODEC_ID_ANSI
Definition: avcodec.h:360
AVCodec
AVCodec.
Definition: avcodec.h:3481
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
decode_close
static av_cold int decode_close(AVCodecContext *avctx)
Definition: ansi.c:469
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
r
const char * r
Definition: vf_curves.c:114
AVERROR
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
ff_cga_palette
const uint32_t ff_cga_palette[16]
Definition: cga_data.c:30
COLOR
#define COLOR(x)
FFSWAP
#define FFSWAP(type, a, b)
Definition: common.h:99
count
void INT64 INT64 count
Definition: avisynth_c.h:767
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
internal.h
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
execute_code
static int execute_code(AVCodecContext *avctx, int c)
Execute ANSI escape code.
Definition: ansi.c:188
b
#define b
Definition: input.c:41
data
const char data[16]
Definition: mxf.c:91
ff_reget_buffer
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...
Definition: decode.c:2012
AnsiContext
Definition: ansi.c:53
AnsiContext::state
enum AnsiContext::@35 state
AnsiContext::font
const uint8_t * font
font
Definition: ansi.c:59
AnsiContext::sy
int sy
saved y cursor position (pixels)
Definition: ansi.c:58
AnsiContext::first_frame
int first_frame
Definition: ansi.c:64
AnsiContext::nb_args
int nb_args
number of arguments (may exceed MAX_NB_ARGS)
Definition: ansi.c:75
ff_ansi_decoder
AVCodec ff_ansi_decoder
Definition: ansi.c:482
defaults
static const AVCodecDefault defaults[]
Definition: amfenc_h264.c:361
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:189
AnsiContext::STATE_MUSIC_PREAMBLE
@ STATE_MUSIC_PREAMBLE
Definition: ansi.c:71
ff_draw_pc_font
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.
Definition: cga_data.c:46
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
buf
void * buf
Definition: avisynth_c.h:766
av_cold
#define av_cold
Definition: attributes.h:84
AnsiContext::STATE_ESCAPE
@ STATE_ESCAPE
Definition: ansi.c:69
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
width
#define width
AnsiContext::y
int y
y cursor position (pixels)
Definition: ansi.c:56
s
#define s(width, name)
Definition: cbs_vp9.c:257
g
const char * g
Definition: vf_curves.c:115
AV_GET_BUFFER_FLAG_REF
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:1176
lfg.h
draw_char
static void draw_char(AVCodecContext *avctx, int c)
Draw character to screen.
Definition: ansi.c:161
AnsiContext::STATE_CODE
@ STATE_CODE
Definition: ansi.c:70
ATTR_BLINK
#define ATTR_BLINK
Blink/Bright-background (mode 5)
Definition: ansi.c:38
ATTR_CONCEALED
#define ATTR_CONCEALED
Concealed (mode 8)
Definition: ansi.c:40
ATTR_BOLD
#define ATTR_BOLD
Bold/Bright-foreground (mode 1)
Definition: ansi.c:35
AVCodecDefault
Definition: internal.h:231
GRAY
#define GRAY(x)
NULL
#define NULL
Definition: coverity.c:32
DEFAULT_SCREEN_MODE
#define DEFAULT_SCREEN_MODE
80x25
Definition: ansi.c:44
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
index
int index
Definition: gxfenc.c:89
c
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
Definition: undefined.txt:32
AnsiContext::STATE_NORMAL
@ STATE_NORMAL
Definition: ansi.c:68
AnsiContext::sx
int sx
saved x cursor position (pixels)
Definition: ansi.c:57
AnsiContext::attributes
int attributes
attribute flags
Definition: ansi.c:61
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1965
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:981
AVPacket::size
int size
Definition: avcodec.h:1478
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
av_frame_ref
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:443
MAX_NB_ARGS
#define MAX_NB_ARGS
Definition: ansi.c:73
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
hscroll
static void hscroll(AVCodecContext *avctx)
Definition: ansi.c:120
frame.h
cga_data.h
erase_line
static void erase_line(AVCodecContext *avctx, int xoffset, int xlength)
Definition: ansi.c:140
height
#define height
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
DEFAULT_FG_COLOR
#define DEFAULT_FG_COLOR
CGA color index.
Definition: ansi.c:42
xga_font_data.h
AnsiContext::frame
AVFrame * frame
Definition: ansi.c:54
avpriv_vga16_font
const uint8_t avpriv_vga16_font[4096]
Definition: xga_font_data.c:160
set_palette
static void set_palette(uint32_t *pal)
Definition: ansi.c:105
ATTR_REVERSE
#define ATTR_REVERSE
Reverse (mode 7)
Definition: ansi.c:39
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
DEFAULT_BG_COLOR
#define DEFAULT_BG_COLOR
Definition: ansi.c:43
common.h
uint8_t
uint8_t
Definition: audio_convert.c:194
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:553
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3488
AVCodecContext::height
int height
Definition: avcodec.h:1738
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1775
AnsiContext::bg
int bg
background color
Definition: ansi.c:63
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ret
ret
Definition: filter_design.txt:187
FONT_WIDTH
#define FONT_WIDTH
Font width.
Definition: ansi.c:46
ansi_defaults
static const AVCodecDefault ansi_defaults[]
Definition: ansi.c:477
AnsiContext::fg
int fg
foreground color
Definition: ansi.c:62
AVCodecContext
main external API structure.
Definition: avcodec.h:1565
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_set_dimensions
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.
Definition: utils.c:104
AVCodecContext::frame_number
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:2256
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:39
avpriv_cga_font
const uint8_t avpriv_cga_font[2048]
Definition: xga_font_data.c:29
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1592
decode_frame
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: ansi.c:355
AnsiContext::args
int args[MAX_NB_ARGS]
Definition: ansi.c:74
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:1738
AnsiContext::x
int x
x cursor position (pixels)
Definition: ansi.c:55
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AnsiContext::font_height
int font_height
font height
Definition: ansi.c:60
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: ansi.c:78
erase_screen
static void erase_screen(AVCodecContext *avctx)
Definition: ansi.c:149
ansi_to_cga
static const uint8_t ansi_to_cga[16]
map ansi color index to cga palette index
Definition: ansi.c:49