FFmpeg
cdgraphics.c
Go to the documentation of this file.
1 /*
2  * CD Graphics Video Decoder
3  * Copyright (c) 2009 Michael Tison
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 #include "avcodec.h"
23 #include "bytestream.h"
24 #include "internal.h"
25 
26 /**
27  * @file
28  * @brief CD Graphics Video Decoder
29  * @author Michael Tison
30  * @see http://wiki.multimedia.cx/index.php?title=CD_Graphics
31  * @see http://www.ccs.neu.edu/home/bchafy/cdb/info/cdg
32  */
33 
34 /// default screen sizes
35 #define CDG_FULL_WIDTH 300
36 #define CDG_FULL_HEIGHT 216
37 #define CDG_DISPLAY_WIDTH 294
38 #define CDG_DISPLAY_HEIGHT 204
39 #define CDG_BORDER_WIDTH 6
40 #define CDG_BORDER_HEIGHT 12
41 
42 /// masks
43 #define CDG_COMMAND 0x09
44 #define CDG_MASK 0x3F
45 
46 /// instruction codes
47 #define CDG_INST_MEMORY_PRESET 1
48 #define CDG_INST_BORDER_PRESET 2
49 #define CDG_INST_TILE_BLOCK 6
50 #define CDG_INST_SCROLL_PRESET 20
51 #define CDG_INST_SCROLL_COPY 24
52 #define CDG_INST_TRANSPARENT_COL 28
53 #define CDG_INST_LOAD_PAL_LO 30
54 #define CDG_INST_LOAD_PAL_HIGH 31
55 #define CDG_INST_TILE_BLOCK_XOR 38
56 
57 /// data sizes
58 #define CDG_PACKET_SIZE 24
59 #define CDG_DATA_SIZE 16
60 #define CDG_TILE_HEIGHT 12
61 #define CDG_TILE_WIDTH 6
62 #define CDG_MINIMUM_PKT_SIZE 6
63 #define CDG_MINIMUM_SCROLL_SIZE 3
64 #define CDG_HEADER_SIZE 8
65 #define CDG_PALETTE_SIZE 16
66 
67 typedef struct CDGraphicsContext {
69  int hscroll;
70  int vscroll;
72  int cleared;
74 
76 {
77  CDGraphicsContext *cc = avctx->priv_data;
78 
79  cc->frame = av_frame_alloc();
80  if (!cc->frame)
81  return AVERROR(ENOMEM);
82 
83  for (int i = 0; i < CDG_PALETTE_SIZE; i++)
84  cc->alpha[i] = 0xFFU;
85 
86  avctx->pix_fmt = AV_PIX_FMT_PAL8;
88 }
89 
90 static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
91 {
92  int y;
93  int lsize = cc->frame->linesize[0];
94  uint8_t *buf = cc->frame->data[0];
95  int color = data[0] & 0x0F;
96 
97  if (!(data[1] & 0x0F)) {
98  /// fill the top and bottom borders
99  memset(buf, color, CDG_BORDER_HEIGHT * lsize);
100  memset(buf + (CDG_FULL_HEIGHT - CDG_BORDER_HEIGHT) * lsize,
101  color, CDG_BORDER_HEIGHT * lsize);
102 
103  /// fill the side borders
104  for (y = CDG_BORDER_HEIGHT; y < CDG_FULL_HEIGHT - CDG_BORDER_HEIGHT; y++) {
105  memset(buf + y * lsize, color, CDG_BORDER_WIDTH);
106  memset(buf + CDG_FULL_WIDTH - CDG_BORDER_WIDTH + y * lsize,
108  }
109  }
110 }
111 
112 static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
113 {
114  uint8_t r, g, b;
115  uint16_t color;
116  int i;
117  int array_offset = low ? 0 : 8;
118  uint32_t *palette = (uint32_t *) cc->frame->data[1];
119 
120  for (i = 0; i < 8; i++) {
121  color = (data[2 * i] << 6) + (data[2 * i + 1] & 0x3F);
122  r = ((color >> 8) & 0x000F) * 17;
123  g = ((color >> 4) & 0x000F) * 17;
124  b = ((color ) & 0x000F) * 17;
125  palette[i + array_offset] = (uint32_t)cc->alpha[i + array_offset] << 24 | r << 16 | g << 8 | b;
126  }
127  cc->frame->palette_has_changed = 1;
128 }
129 
130 static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
131 {
132  unsigned ci, ri;
133  int color;
134  int x, y;
135  int ai;
136  int stride = cc->frame->linesize[0];
137  uint8_t *buf = cc->frame->data[0];
138 
139  ri = (data[2] & 0x1F) * CDG_TILE_HEIGHT + cc->vscroll;
140  ci = (data[3] & 0x3F) * CDG_TILE_WIDTH + cc->hscroll;
141 
142  if (ri > (CDG_FULL_HEIGHT - CDG_TILE_HEIGHT))
143  return AVERROR(EINVAL);
144  if (ci > (CDG_FULL_WIDTH - CDG_TILE_WIDTH))
145  return AVERROR(EINVAL);
146 
147  for (y = 0; y < CDG_TILE_HEIGHT; y++) {
148  for (x = 0; x < CDG_TILE_WIDTH; x++) {
149  if (!((data[4 + y] >> (5 - x)) & 0x01))
150  color = data[0] & 0x0F;
151  else
152  color = data[1] & 0x0F;
153 
154  ai = ci + x + (stride * (ri + y));
155  if (b)
156  color ^= buf[ai];
157  buf[ai] = color;
158  }
159  }
160 
161  return 0;
162 }
163 
164 #define UP 2
165 #define DOWN 1
166 #define LEFT 2
167 #define RIGHT 1
168 
169 static void cdg_copy_rect_buf(int out_tl_x, int out_tl_y, uint8_t *out,
170  int in_tl_x, int in_tl_y, uint8_t *in,
171  int w, int h, int stride)
172 {
173  int y;
174 
175  in += in_tl_x + in_tl_y * stride;
176  out += out_tl_x + out_tl_y * stride;
177  for (y = 0; y < h; y++)
178  memcpy(out + y * stride, in + y * stride, w);
179 }
180 
181 static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out,
182  int color, int w, int h, int stride)
183 {
184  int y;
185 
186  for (y = tl_y; y < tl_y + h; y++)
187  memset(out + tl_x + y * stride, color, w);
188 }
189 
190 static void cdg_fill_wrapper(int out_tl_x, int out_tl_y, uint8_t *out,
191  int in_tl_x, int in_tl_y, uint8_t *in,
192  int color, int w, int h, int stride, int roll)
193 {
194  if (roll) {
195  cdg_copy_rect_buf(out_tl_x, out_tl_y, out, in_tl_x, in_tl_y,
196  in, w, h, stride);
197  } else {
198  cdg_fill_rect_preset(out_tl_x, out_tl_y, out, color, w, h, stride);
199  }
200 }
201 
202 static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
203  AVFrame *new_frame, int roll_over)
204 {
205  int color;
206  int hscmd, h_off, hinc, vscmd, v_off, vinc;
207  int y;
208  int stride = cc->frame->linesize[0];
209  uint8_t *in = cc->frame->data[0];
210  uint8_t *out = new_frame->data[0];
211 
212  color = data[0] & 0x0F;
213  hscmd = (data[1] & 0x30) >> 4;
214  vscmd = (data[2] & 0x30) >> 4;
215 
216  h_off = FFMIN(data[1] & 0x07, CDG_BORDER_WIDTH - 1);
217  v_off = FFMIN(data[2] & 0x0F, CDG_BORDER_HEIGHT - 1);
218 
219  /// find the difference and save the offset for cdg_tile_block usage
220  hinc = h_off - cc->hscroll;
221  vinc = cc->vscroll - v_off;
222  cc->hscroll = h_off;
223  cc->vscroll = v_off;
224 
225  if (vscmd == UP)
226  vinc -= 12;
227  if (vscmd == DOWN)
228  vinc += 12;
229  if (hscmd == LEFT)
230  hinc -= 6;
231  if (hscmd == RIGHT)
232  hinc += 6;
233 
234  if (!hinc && !vinc)
235  return;
236 
237  memcpy(new_frame->data[1], cc->frame->data[1], CDG_PALETTE_SIZE * 4);
238 
239  for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
240  memcpy(out + FFMAX(0, hinc) + stride * y,
241  in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
242  FFMIN(stride + hinc, stride));
243 
244  if (vinc > 0)
245  cdg_fill_wrapper(0, 0, out,
246  0, CDG_FULL_HEIGHT - vinc, in, color,
247  stride, vinc, stride, roll_over);
248  else if (vinc < 0)
250  0, 0, in, color,
251  stride, -1 * vinc, stride, roll_over);
252 
253  if (hinc > 0)
254  cdg_fill_wrapper(0, 0, out,
255  CDG_FULL_WIDTH - hinc, 0, in, color,
256  hinc, CDG_FULL_HEIGHT, stride, roll_over);
257  else if (hinc < 0)
259  0, 0, in, color,
260  -1 * hinc, CDG_FULL_HEIGHT, stride, roll_over);
261 
262 }
263 
265  void *data, int *got_frame, AVPacket *avpkt)
266 {
267  GetByteContext gb;
268  int buf_size = avpkt->size;
269  int ret;
270  uint8_t command, inst;
271  uint8_t cdg_data[CDG_DATA_SIZE] = {0};
272  AVFrame *frame = data;
273  CDGraphicsContext *cc = avctx->priv_data;
274 
275  if (buf_size < CDG_MINIMUM_PKT_SIZE) {
276  av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
277  return AVERROR(EINVAL);
278  }
279  if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) {
280  av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n");
281  return AVERROR(EINVAL);
282  }
283 
284  bytestream2_init(&gb, avpkt->data, avpkt->size);
285 
286  if ((ret = ff_reget_buffer(avctx, cc->frame, 0)) < 0)
287  return ret;
288  if (!cc->cleared) {
289  memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height);
290  memset(cc->frame->data[1], 0, AVPALETTE_SIZE);
291  cc->cleared = 1;
292  }
293 
294  command = bytestream2_get_byte(&gb);
295  inst = bytestream2_get_byte(&gb);
296  inst &= CDG_MASK;
297  bytestream2_skip(&gb, 2);
298  bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
299 
300  if ((command & CDG_MASK) == CDG_COMMAND) {
301  switch (inst) {
303  if (!(cdg_data[1] & 0x0F))
304  memset(cc->frame->data[0], cdg_data[0] & 0x0F,
305  cc->frame->linesize[0] * CDG_FULL_HEIGHT);
306  break;
309  if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
310  av_log(avctx, AV_LOG_ERROR, "buffer too small for loading palette\n");
311  return AVERROR(EINVAL);
312  }
313 
314  cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);
315  break;
317  cdg_border_preset(cc, cdg_data);
318  break;
320  case CDG_INST_TILE_BLOCK:
321  if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
322  av_log(avctx, AV_LOG_ERROR, "buffer too small for drawing tile\n");
323  return AVERROR(EINVAL);
324  }
325 
326  ret = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);
327  if (ret) {
328  av_log(avctx, AV_LOG_ERROR, "tile is out of range\n");
329  return ret;
330  }
331  break;
334  if (buf_size - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {
335  av_log(avctx, AV_LOG_ERROR, "buffer too small for scrolling\n");
336  return AVERROR(EINVAL);
337  }
338 
339  if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
340  return ret;
341 
342  cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);
343  av_frame_unref(cc->frame);
344  ret = av_frame_ref(cc->frame, frame);
345  if (ret < 0)
346  return ret;
347  break;
349  for (int i = 0; i < CDG_PALETTE_SIZE; i++)
350  cc->alpha[i] = 255 - ((cdg_data[i] & 0x3f) << 2);
351  break;
352  default:
353  break;
354  }
355 
356  if (!frame->data[0]) {
357  ret = av_frame_ref(frame, cc->frame);
358  if (ret < 0)
359  return ret;
360  }
361  *got_frame = 1;
362  } else {
363  *got_frame = 0;
364  }
365 
366  return avpkt->size;
367 }
368 
369 static void cdg_decode_flush(AVCodecContext *avctx)
370 {
371  CDGraphicsContext *cc = avctx->priv_data;
372 
373  if (!cc->frame->data[0])
374  return;
375 
376  memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height);
377  if (!avctx->frame_number)
378  memset(cc->frame->data[1], 0, AVPALETTE_SIZE);
379 }
380 
382 {
383  CDGraphicsContext *cc = avctx->priv_data;
384 
385  av_frame_free(&cc->frame);
386 
387  return 0;
388 }
389 
391  .name = "cdgraphics",
392  .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"),
393  .type = AVMEDIA_TYPE_VIDEO,
395  .priv_data_size = sizeof(CDGraphicsContext),
397  .close = cdg_decode_end,
400  .capabilities = AV_CODEC_CAP_DR1,
401  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
402 };
cdg_scroll
static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data, AVFrame *new_frame, int roll_over)
Definition: cdgraphics.c:202
AVCodec
AVCodec.
Definition: codec.h:202
stride
int stride
Definition: mace.c:144
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:42
r
const char * r
Definition: vf_curves.c:116
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
out
FILE * out
Definition: movenc.c:54
color
Definition: vf_paletteuse.c:599
GetByteContext
Definition: bytestream.h:33
CDG_INST_SCROLL_PRESET
#define CDG_INST_SCROLL_PRESET
Definition: cdgraphics.c:50
CDG_DATA_SIZE
#define CDG_DATA_SIZE
Definition: cdgraphics.c:59
CDG_INST_LOAD_PAL_HIGH
#define CDG_INST_LOAD_PAL_HIGH
Definition: cdgraphics.c:54
CDGraphicsContext::alpha
uint8_t alpha[CDG_PALETTE_SIZE]
Definition: cdgraphics.c:71
CDG_MINIMUM_PKT_SIZE
#define CDG_MINIMUM_PKT_SIZE
Definition: cdgraphics.c:62
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
CDG_INST_TRANSPARENT_COL
#define CDG_INST_TRANSPARENT_COL
Definition: cdgraphics.c:52
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
w
uint8_t w
Definition: llviddspenc.c:38
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:373
b
#define b
Definition: input.c:40
CDGraphicsContext::frame
AVFrame * frame
Definition: cdgraphics.c:68
data
const char data[16]
Definition: mxf.c:143
cdg_tile_block
static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
Definition: cdgraphics.c:130
CDG_TILE_WIDTH
#define CDG_TILE_WIDTH
Definition: cdgraphics.c:61
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
CDG_MASK
#define CDG_MASK
Definition: cdgraphics.c:44
CDG_INST_TILE_BLOCK_XOR
#define CDG_INST_TILE_BLOCK_XOR
Definition: cdgraphics.c:55
DOWN
#define DOWN
Definition: cdgraphics.c:165
CDG_PALETTE_SIZE
#define CDG_PALETTE_SIZE
Definition: cdgraphics.c:65
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
init
static int init
Definition: av_tx.c:47
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
CDG_FULL_HEIGHT
#define CDG_FULL_HEIGHT
Definition: cdgraphics.c:36
CDG_HEADER_SIZE
#define CDG_HEADER_SIZE
Definition: cdgraphics.c:64
cdg_decode_flush
static void cdg_decode_flush(AVCodecContext *avctx)
Definition: cdgraphics.c:369
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:97
cdg_border_preset
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
Definition: cdgraphics.c:90
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
cdg_decode_init
static av_cold int cdg_decode_init(AVCodecContext *avctx)
Definition: cdgraphics.c:75
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
CDG_BORDER_HEIGHT
#define CDG_BORDER_HEIGHT
Definition: cdgraphics.c:40
g
const char * g
Definition: vf_curves.c:117
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:361
CDGraphicsContext::vscroll
int vscroll
Definition: cdgraphics.c:70
command
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_drawtext.c:906
CDG_MINIMUM_SCROLL_SIZE
#define CDG_MINIMUM_SCROLL_SIZE
Definition: cdgraphics.c:63
CDG_FULL_WIDTH
#define CDG_FULL_WIDTH
default screen sizes
Definition: cdgraphics.c:35
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:593
cdg_copy_rect_buf
static void cdg_copy_rect_buf(int out_tl_x, int out_tl_y, uint8_t *out, int in_tl_x, int in_tl_y, uint8_t *in, int w, int h, int stride)
Definition: cdgraphics.c:169
CDG_COMMAND
#define CDG_COMMAND
masks
Definition: cdgraphics.c:43
UP
#define UP
Definition: cdgraphics.c:164
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
bytestream2_get_buffer
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
cdg_load_palette
static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
Definition: cdgraphics.c:112
cdg_decode_end
static av_cold int cdg_decode_end(AVCodecContext *avctx)
Definition: cdgraphics.c:381
AV_CODEC_ID_CDGRAPHICS
@ AV_CODEC_ID_CDGRAPHICS
Definition: codec_id.h:182
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1652
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:374
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:117
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:325
RIGHT
#define RIGHT
Definition: cdgraphics.c:167
color
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:92
LEFT
#define LEFT
Definition: cdgraphics.c:166
ff_cdgraphics_decoder
const AVCodec ff_cdgraphics_decoder
Definition: cdgraphics.c:390
CDG_INST_TILE_BLOCK
#define CDG_INST_TILE_BLOCK
Definition: cdgraphics.c:49
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
CDG_INST_BORDER_PRESET
#define CDG_INST_BORDER_PRESET
Definition: cdgraphics.c:48
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:435
CDG_INST_SCROLL_COPY
#define CDG_INST_SCROLL_COPY
Definition: cdgraphics.c:51
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:209
AVCodecContext::height
int height
Definition: avcodec.h:556
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:593
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ff_reget_buffer
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.
Definition: decode.c:1759
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
CDGraphicsContext::hscroll
int hscroll
Definition: cdgraphics.c:69
CDG_BORDER_WIDTH
#define CDG_BORDER_WIDTH
Definition: cdgraphics.c:39
AVCodecContext
main external API structure.
Definition: avcodec.h:383
cdg_decode_frame
static int cdg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: cdgraphics.c:264
AVFrame::palette_has_changed
int palette_has_changed
Tell user application that palette has changed from previous frame.
Definition: frame.h:479
CDG_TILE_HEIGHT
#define CDG_TILE_HEIGHT
Definition: cdgraphics.c:60
CDG_INST_MEMORY_PRESET
#define CDG_INST_MEMORY_PRESET
instruction codes
Definition: cdgraphics.c:47
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:86
CDGraphicsContext
Definition: cdgraphics.c:67
AVCodecContext::frame_number
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:1023
cdg_fill_rect_preset
static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out, int color, int w, int h, int stride)
Definition: cdgraphics.c:181
AVPacket
This structure stores compressed data.
Definition: packet.h:350
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:410
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
h
h
Definition: vp9dsp_template.c:2038
CDG_INST_LOAD_PAL_LO
#define CDG_INST_LOAD_PAL_LO
Definition: cdgraphics.c:53
CDGraphicsContext::cleared
int cleared
Definition: cdgraphics.c:72
cdg_fill_wrapper
static void cdg_fill_wrapper(int out_tl_x, int out_tl_y, uint8_t *out, int in_tl_x, int in_tl_y, uint8_t *in, int color, int w, int h, int stride, int roll)
Definition: cdgraphics.c:190