FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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  s->frame = av_frame_alloc();
84  if (!s->frame)
85  return AVERROR(ENOMEM);
86 
87  /* defaults */
89  s->font_height = 16;
90  s->fg = DEFAULT_FG_COLOR;
91  s->bg = DEFAULT_BG_COLOR;
92 
93  if (!avctx->width || !avctx->height) {
94  int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4);
95  if (ret < 0)
96  return ret;
97  } else if (avctx->width % FONT_WIDTH || avctx->height % s->font_height) {
98  av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %d %d\n", avctx->width, avctx->height);
99  return AVERROR(EINVAL);
100  }
101  return 0;
102 }
103 
104 static void set_palette(uint32_t *pal)
105 {
106  int r, g, b;
107  memcpy(pal, ff_cga_palette, 16 * 4);
108  pal += 16;
109 #define COLOR(x) ((x) * 40 + 55)
110  for (r = 0; r < 6; r++)
111  for (g = 0; g < 6; g++)
112  for (b = 0; b < 6; b++)
113  *pal++ = 0xFF000000 | (COLOR(r) << 16) | (COLOR(g) << 8) | COLOR(b);
114 #define GRAY(x) ((x) * 10 + 8)
115  for (g = 0; g < 24; g++)
116  *pal++ = 0xFF000000 | (GRAY(g) << 16) | (GRAY(g) << 8) | GRAY(g);
117 }
118 
119 static void hscroll(AVCodecContext *avctx)
120 {
121  AnsiContext *s = avctx->priv_data;
122  int i;
123 
124  if (s->y <= avctx->height - 2*s->font_height) {
125  s->y += s->font_height;
126  return;
127  }
128 
129  i = 0;
130  for (; i < avctx->height - s->font_height; i++)
131  memcpy(s->frame->data[0] + i * s->frame->linesize[0],
132  s->frame->data[0] + (i + s->font_height) * s->frame->linesize[0],
133  avctx->width);
134  for (; i < avctx->height; i++)
135  memset(s->frame->data[0] + i * s->frame->linesize[0],
136  DEFAULT_BG_COLOR, avctx->width);
137 }
138 
139 static void erase_line(AVCodecContext * avctx, int xoffset, int xlength)
140 {
141  AnsiContext *s = avctx->priv_data;
142  int i;
143  for (i = 0; i < s->font_height; i++)
144  memset(s->frame->data[0] + (s->y + i)*s->frame->linesize[0] + xoffset,
145  DEFAULT_BG_COLOR, xlength);
146 }
147 
148 static void erase_screen(AVCodecContext *avctx)
149 {
150  AnsiContext *s = avctx->priv_data;
151  int i;
152  for (i = 0; i < avctx->height; i++)
153  memset(s->frame->data[0] + i * s->frame->linesize[0], DEFAULT_BG_COLOR, avctx->width);
154  s->x = s->y = 0;
155 }
156 
157 /**
158  * Draw character to screen
159  */
160 static void draw_char(AVCodecContext *avctx, int c)
161 {
162  AnsiContext *s = avctx->priv_data;
163  int fg = s->fg;
164  int bg = s->bg;
165 
166  if ((s->attributes & ATTR_BOLD))
167  fg += 8;
168  if ((s->attributes & ATTR_BLINK))
169  bg += 8;
170  if ((s->attributes & ATTR_REVERSE))
171  FFSWAP(int, fg, bg);
172  if ((s->attributes & ATTR_CONCEALED))
173  fg = bg;
174  ff_draw_pc_font(s->frame->data[0] + s->y * s->frame->linesize[0] + s->x,
175  s->frame->linesize[0], s->font, s->font_height, c, fg, bg);
176  s->x += FONT_WIDTH;
177  if (s->x > avctx->width - FONT_WIDTH) {
178  s->x = 0;
179  hscroll(avctx);
180  }
181 }
182 
183 /**
184  * Execute ANSI escape code
185  * @return 0 on success, negative on error
186  */
187 static int execute_code(AVCodecContext * avctx, int c)
188 {
189  AnsiContext *s = avctx->priv_data;
190  int ret, i;
191  int width = avctx->width;
192  int height = avctx->height;
193 
194  switch(c) {
195  case 'A': //Cursor Up
196  s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
197  break;
198  case 'B': //Cursor Down
199  s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
200  break;
201  case 'C': //Cursor Right
202  s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH);
203  break;
204  case 'D': //Cursor Left
205  s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
206  break;
207  case 'H': //Cursor Position
208  case 'f': //Horizontal and Vertical Position
209  s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
210  s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
211  break;
212  case 'h': //set screen mode
213  case 'l': //reset screen mode
214  if (s->nb_args < 2)
215  s->args[0] = DEFAULT_SCREEN_MODE;
216  switch(s->args[0]) {
217  case 0: case 1: case 4: case 5: case 13: case 19: //320x200 (25 rows)
218  s->font = avpriv_cga_font;
219  s->font_height = 8;
220  width = 40<<3;
221  height = 25<<3;
222  break;
223  case 2: case 3: //640x400 (25 rows)
224  s->font = avpriv_vga16_font;
225  s->font_height = 16;
226  width = 80<<3;
227  height = 25<<4;
228  break;
229  case 6: case 14: //640x200 (25 rows)
230  s->font = avpriv_cga_font;
231  s->font_height = 8;
232  width = 80<<3;
233  height = 25<<3;
234  break;
235  case 7: //set line wrapping
236  break;
237  case 15: case 16: //640x350 (43 rows)
238  s->font = avpriv_cga_font;
239  s->font_height = 8;
240  width = 80<<3;
241  height = 43<<3;
242  break;
243  case 17: case 18: //640x480 (60 rows)
244  s->font = avpriv_cga_font;
245  s->font_height = 8;
246  width = 80<<3;
247  height = 60<<4;
248  break;
249  default:
250  avpriv_request_sample(avctx, "Unsupported screen mode");
251  }
252  s->x = av_clip(s->x, 0, width - FONT_WIDTH);
253  s->y = av_clip(s->y, 0, height - s->font_height);
254  if (width != avctx->width || height != avctx->height) {
255  av_frame_unref(s->frame);
256  ret = ff_set_dimensions(avctx, width, height);
257  if (ret < 0)
258  return ret;
259  if ((ret = ff_get_buffer(avctx, s->frame,
261  return ret;
263  s->frame->palette_has_changed = 1;
264  set_palette((uint32_t *)s->frame->data[1]);
265  erase_screen(avctx);
266  } else if (c == 'l') {
267  erase_screen(avctx);
268  }
269  break;
270  case 'J': //Erase in Page
271  switch (s->args[0]) {
272  case 0:
273  erase_line(avctx, s->x, avctx->width - s->x);
274  if (s->y < avctx->height - s->font_height)
275  memset(s->frame->data[0] + (s->y + s->font_height)*s->frame->linesize[0],
276  DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame->linesize[0]);
277  break;
278  case 1:
279  erase_line(avctx, 0, s->x);
280  if (s->y > 0)
281  memset(s->frame->data[0], DEFAULT_BG_COLOR, s->y * s->frame->linesize[0]);
282  break;
283  case 2:
284  erase_screen(avctx);
285  }
286  break;
287  case 'K': //Erase in Line
288  switch(s->args[0]) {
289  case 0:
290  erase_line(avctx, s->x, avctx->width - s->x);
291  break;
292  case 1:
293  erase_line(avctx, 0, s->x);
294  break;
295  case 2:
296  erase_line(avctx, 0, avctx->width);
297  }
298  break;
299  case 'm': //Select Graphics Rendition
300  if (s->nb_args == 0) {
301  s->nb_args = 1;
302  s->args[0] = 0;
303  }
304  for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) {
305  int m = s->args[i];
306  if (m == 0) {
307  s->attributes = 0;
308  s->fg = DEFAULT_FG_COLOR;
309  s->bg = DEFAULT_BG_COLOR;
310  } else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
311  s->attributes |= 1 << (m - 1);
312  } else if (m >= 30 && m <= 37) {
313  s->fg = ansi_to_cga[m - 30];
314  } else if (m == 38 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
315  int index = s->args[i + 2];
316  s->fg = index < 16 ? ansi_to_cga[index] : index;
317  i += 2;
318  } else if (m == 39) {
320  } else if (m >= 40 && m <= 47) {
321  s->bg = ansi_to_cga[m - 40];
322  } else if (m == 48 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
323  int index = s->args[i + 2];
324  s->bg = index < 16 ? ansi_to_cga[index] : index;
325  i += 2;
326  } else if (m == 49) {
328  } else {
329  avpriv_request_sample(avctx, "Unsupported rendition parameter");
330  }
331  }
332  break;
333  case 'n': //Device Status Report
334  case 'R': //report current line and column
335  /* ignore */
336  break;
337  case 's': //Save Cursor Position
338  s->sx = s->x;
339  s->sy = s->y;
340  break;
341  case 'u': //Restore Cursor Position
342  s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH);
343  s->y = av_clip(s->sy, 0, avctx->height - s->font_height);
344  break;
345  default:
346  avpriv_request_sample(avctx, "Unknown escape code");
347  break;
348  }
349  s->x = av_clip(s->x, 0, avctx->width - FONT_WIDTH);
350  s->y = av_clip(s->y, 0, avctx->height - s->font_height);
351  return 0;
352 }
353 
354 static int decode_frame(AVCodecContext *avctx,
355  void *data, int *got_frame,
356  AVPacket *avpkt)
357 {
358  AnsiContext *s = avctx->priv_data;
359  uint8_t *buf = avpkt->data;
360  int buf_size = avpkt->size;
361  const uint8_t *buf_end = buf+buf_size;
362  int ret, i, count;
363 
364  if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
365  return ret;
366  if (!avctx->frame_number) {
367  for (i=0; i<avctx->height; i++)
368  memset(s->frame->data[0]+ i*s->frame->linesize[0], 0, avctx->width);
369  memset(s->frame->data[1], 0, AVPALETTE_SIZE);
370  }
371 
373  s->frame->palette_has_changed = 1;
374  set_palette((uint32_t *)s->frame->data[1]);
375  if (!s->first_frame) {
376  erase_screen(avctx);
377  s->first_frame = 1;
378  }
379 
380  while(buf < buf_end) {
381  switch(s->state) {
382  case STATE_NORMAL:
383  switch (buf[0]) {
384  case 0x00: //NUL
385  case 0x07: //BEL
386  case 0x1A: //SUB
387  /* ignore */
388  break;
389  case 0x08: //BS
390  s->x = FFMAX(s->x - 1, 0);
391  break;
392  case 0x09: //HT
393  i = s->x / FONT_WIDTH;
394  count = ((i + 8) & ~7) - i;
395  for (i = 0; i < count; i++)
396  draw_char(avctx, ' ');
397  break;
398  case 0x0A: //LF
399  hscroll(avctx);
400  case 0x0D: //CR
401  s->x = 0;
402  break;
403  case 0x0C: //FF
404  erase_screen(avctx);
405  break;
406  case 0x1B: //ESC
407  s->state = STATE_ESCAPE;
408  break;
409  default:
410  draw_char(avctx, buf[0]);
411  }
412  break;
413  case STATE_ESCAPE:
414  if (buf[0] == '[') {
415  s->state = STATE_CODE;
416  s->nb_args = 0;
417  s->args[0] = -1;
418  } else {
419  s->state = STATE_NORMAL;
420  draw_char(avctx, 0x1B);
421  continue;
422  }
423  break;
424  case STATE_CODE:
425  switch(buf[0]) {
426  case '0': case '1': case '2': case '3': case '4':
427  case '5': case '6': case '7': case '8': case '9':
428  if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553)
429  s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
430  break;
431  case ';':
432  s->nb_args++;
433  if (s->nb_args < MAX_NB_ARGS)
434  s->args[s->nb_args] = 0;
435  break;
436  case 'M':
437  s->state = STATE_MUSIC_PREAMBLE;
438  break;
439  case '=': case '?':
440  /* ignore */
441  break;
442  default:
443  if (s->nb_args > MAX_NB_ARGS)
444  av_log(avctx, AV_LOG_WARNING, "args overflow (%i)\n", s->nb_args);
445  if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] >= 0)
446  s->nb_args++;
447  if ((ret = execute_code(avctx, buf[0])) < 0)
448  return ret;
449  s->state = STATE_NORMAL;
450  }
451  break;
452  case STATE_MUSIC_PREAMBLE:
453  if (buf[0] == 0x0E || buf[0] == 0x1B)
454  s->state = STATE_NORMAL;
455  /* ignore music data */
456  break;
457  }
458  buf++;
459  }
460 
461  *got_frame = 1;
462  if ((ret = av_frame_ref(data, s->frame)) < 0)
463  return ret;
464  return buf_size;
465 }
466 
468 {
469  AnsiContext *s = avctx->priv_data;
470 
471  av_frame_free(&s->frame);
472  return 0;
473 }
474 
476  .name = "ansi",
477  .long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
478  .type = AVMEDIA_TYPE_VIDEO,
479  .id = AV_CODEC_ID_ANSI,
480  .priv_data_size = sizeof(AnsiContext),
481  .init = decode_init,
482  .close = decode_close,
483  .decode = decode_frame,
484  .capabilities = AV_CODEC_CAP_DR1,
485 };
static void draw_char(AVCodecContext *avctx, int c)
Draw character to screen.
Definition: ansi.c:160
#define FONT_WIDTH
Font width.
Definition: ansi.c:46
const char * s
Definition: avisynth_c.h:768
int x
x cursor position (pixels)
Definition: ansi.c:55
#define ATTR_REVERSE
Reverse (mode 7)
Definition: ansi.c:39
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
int bg
background color
Definition: ansi.c:63
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
#define ATTR_CONCEALED
Concealed (mode 8)
Definition: ansi.c:40
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
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:210
const char * g
Definition: vf_curves.c:112
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
int nb_args
number of arguments (may exceed MAX_NB_ARGS)
Definition: ansi.c:75
int size
Definition: avcodec.h:1602
const char * b
Definition: vf_curves.c:113
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1904
const uint8_t avpriv_vga16_font[4096]
#define DEFAULT_SCREEN_MODE
80x25
Definition: ansi.c:44
AVCodec.
Definition: avcodec.h:3601
static void erase_screen(AVCodecContext *avctx)
Definition: ansi.c:148
static int execute_code(AVCodecContext *avctx, int c)
Execute ANSI escape code.
Definition: ansi.c:187
static void hscroll(AVCodecContext *avctx)
Definition: ansi.c:119
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t
#define av_cold
Definition: attributes.h:82
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:145
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:73
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
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:385
#define height
uint8_t * data
Definition: avcodec.h:1601
CGA/EGA/VGA ROM data.
#define DEFAULT_BG_COLOR
Definition: ansi.c:43
static av_cold int decode_close(AVCodecContext *avctx)
Definition: ansi.c:467
#define av_log(a,...)
enum AnsiContext::@48 state
const uint8_t * font
font
Definition: ansi.c:59
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int sy
saved y cursor position (pixels)
Definition: ansi.c:58
const uint8_t avpriv_cga_font[2048]
Definition: xga_font_data.c:29
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:158
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
const char * r
Definition: vf_curves.c:111
static void erase_line(AVCodecContext *avctx, int xoffset, int xlength)
Definition: ansi.c:139
const char * name
Name of the codec implementation.
Definition: avcodec.h:3608
GLsizei count
Definition: opengl_enc.c:109
#define FFMAX(a, b)
Definition: common.h:94
reference-counted frame API
#define ATTR_BLINK
Blink/Bright-background (mode 5)
Definition: ansi.c:38
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: utils.c:996
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:258
#define FFMIN(a, b)
Definition: common.h:96
#define width
int width
picture width / height.
Definition: avcodec.h:1863
static av_cold int decode_init(AVCodecContext *avctx)
Definition: ansi.c:78
#define ATTR_BOLD
Bold/Bright-foreground (mode 1)
Definition: ansi.c:35
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
Libavcodec external API header.
int font_height
font height
Definition: ansi.c:60
int args[MAX_NB_ARGS]
Definition: ansi.c:74
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:215
main external API structure.
Definition: avcodec.h:1676
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: utils.c:947
void * buf
Definition: avisynth_c.h:690
int index
Definition: gxfenc.c:89
int palette_has_changed
Tell user application that palette has changed from previous frame.
Definition: frame.h:332
int fg
foreground color
Definition: ansi.c:62
static const uint8_t ansi_to_cga[16]
map ansi color index to cga palette index
Definition: ansi.c:49
#define GRAY(x)
static void set_palette(uint32_t *pal)
Definition: ansi.c:104
const uint32_t ff_cga_palette[16]
Definition: cga_data.c:30
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:495
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:198
int sx
saved x cursor position (pixels)
Definition: ansi.c:57
common internal api header.
common internal and external API header
AVFrame * frame
Definition: ansi.c:54
int y
y cursor position (pixels)
Definition: ansi.c:56
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: ansi.c:354
int first_frame
Definition: ansi.c:64
void * priv_data
Definition: avcodec.h:1718
static AVCodec * c
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:2469
#define MAX_NB_ARGS
Definition: ansi.c:73
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: ffmpeg.c:2045
#define DEFAULT_FG_COLOR
CGA color index.
Definition: ansi.c:42
#define FFSWAP(type, a, b)
Definition: common.h:99
int attributes
attribute flags
Definition: ansi.c:61
This structure stores compressed data.
Definition: avcodec.h:1578
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:1354
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959
CGA/EGA/VGA ROM font data.
AVCodec ff_ansi_decoder
Definition: ansi.c:475
#define COLOR(x)