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 "codec_internal.h"
25 #include "decode.h"
26 
27 #include "libavutil/attributes.h"
28 
29 /**
30  * @file
31  * @brief CD Graphics Video Decoder
32  * @author Michael Tison
33  * @see http://wiki.multimedia.cx/index.php?title=CD_Graphics
34  * @see http://www.ccs.neu.edu/home/bchafy/cdb/info/cdg
35  */
36 
37 /// default screen sizes
38 #define CDG_FULL_WIDTH 300
39 #define CDG_FULL_HEIGHT 216
40 #define CDG_DISPLAY_WIDTH 294
41 #define CDG_DISPLAY_HEIGHT 204
42 #define CDG_BORDER_WIDTH 6
43 #define CDG_BORDER_HEIGHT 12
44 
45 /// masks
46 #define CDG_COMMAND 0x09
47 #define CDG_MASK 0x3F
48 
49 /// instruction codes
50 #define CDG_INST_MEMORY_PRESET 1
51 #define CDG_INST_BORDER_PRESET 2
52 #define CDG_INST_TILE_BLOCK 6
53 #define CDG_INST_SCROLL_PRESET 20
54 #define CDG_INST_SCROLL_COPY 24
55 #define CDG_INST_TRANSPARENT_COL 28
56 #define CDG_INST_LOAD_PAL_LO 30
57 #define CDG_INST_LOAD_PAL_HIGH 31
58 #define CDG_INST_TILE_BLOCK_XOR 38
59 
60 /// data sizes
61 #define CDG_PACKET_SIZE 24
62 #define CDG_DATA_SIZE 16
63 #define CDG_TILE_HEIGHT 12
64 #define CDG_TILE_WIDTH 6
65 #define CDG_MINIMUM_PKT_SIZE 6
66 #define CDG_MINIMUM_SCROLL_SIZE 3
67 #define CDG_HEADER_SIZE 8
68 #define CDG_PALETTE_SIZE 16
69 
70 typedef struct CDGraphicsContext {
72  int hscroll;
73  int vscroll;
75  int cleared;
77 
79 {
80  CDGraphicsContext *cc = avctx->priv_data;
81 
82  cc->frame = av_frame_alloc();
83  if (!cc->frame)
84  return AVERROR(ENOMEM);
85 
86  for (int i = 0; i < CDG_PALETTE_SIZE; i++)
87  cc->alpha[i] = 0xFFU;
88 
89  avctx->pix_fmt = AV_PIX_FMT_PAL8;
91 }
92 
93 static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
94 {
95  ptrdiff_t lsize = cc->frame->linesize[0];
96  uint8_t *buf = cc->frame->data[0];
97  int color = data[0] & 0x0F;
98 
99  if (!(data[1] & 0x0F)) {
100  /// fill the top and bottom borders
101  for (int y = 0; y < CDG_BORDER_HEIGHT; y++)
102  memset(buf + y * lsize, color, cc->frame->width);
103  for (int y = CDG_FULL_HEIGHT-CDG_BORDER_HEIGHT; y < CDG_FULL_HEIGHT; y++)
104  memset(buf + y * lsize, color, cc->frame->width);
105 
106  /// fill the side borders
107  for (int y = CDG_BORDER_HEIGHT; y < CDG_FULL_HEIGHT - CDG_BORDER_HEIGHT; y++) {
108  memset(buf + y * lsize, color, CDG_BORDER_WIDTH);
109  memset(buf + CDG_FULL_WIDTH - CDG_BORDER_WIDTH + y * lsize,
111  }
112  }
113 }
114 
115 static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
116 {
117  uint8_t r, g, b;
118  uint16_t color;
119  int i;
120  int array_offset = low ? 0 : 8;
121  uint32_t *palette = (uint32_t *) cc->frame->data[1];
122 
123  for (i = 0; i < 8; i++) {
124  color = (data[2 * i] << 6) + (data[2 * i + 1] & 0x3F);
125  r = ((color >> 8) & 0x000F) * 17;
126  g = ((color >> 4) & 0x000F) * 17;
127  b = ((color ) & 0x000F) * 17;
128  palette[i + array_offset] = (uint32_t)cc->alpha[i + array_offset] << 24 | r << 16 | g << 8 | b;
129  }
130 }
131 
132 static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
133 {
134  unsigned ci, ri;
135  int color;
136  int x, y;
137  int ai;
138  ptrdiff_t stride = cc->frame->linesize[0];
139  uint8_t *buf = cc->frame->data[0];
140 
141  ri = (data[2] & 0x1F) * CDG_TILE_HEIGHT + cc->vscroll;
142  ci = (data[3] & 0x3F) * CDG_TILE_WIDTH + cc->hscroll;
143 
144  if (ri > (CDG_FULL_HEIGHT - CDG_TILE_HEIGHT))
145  return AVERROR(EINVAL);
146  if (ci > (CDG_FULL_WIDTH - CDG_TILE_WIDTH))
147  return AVERROR(EINVAL);
148 
149  for (y = 0; y < CDG_TILE_HEIGHT; y++) {
150  for (x = 0; x < CDG_TILE_WIDTH; x++) {
151  if (!((data[4 + y] >> (5 - x)) & 0x01))
152  color = data[0] & 0x0F;
153  else
154  color = data[1] & 0x0F;
155 
156  ai = ci + x + (stride * (ri + y));
157  if (b)
158  color ^= buf[ai];
159  buf[ai] = color;
160  }
161  }
162 
163  return 0;
164 }
165 
166 #define UP 2
167 #define DOWN 1
168 #define LEFT 2
169 #define RIGHT 1
170 
171 static void cdg_copy_rect_buf(int out_tl_x, int out_tl_y, uint8_t *out,
172  int in_tl_x, int in_tl_y, uint8_t *in,
173  int w, int h, int stride)
174 {
175  int y;
176 
177  in += in_tl_x + in_tl_y * stride;
178  out += out_tl_x + out_tl_y * stride;
179  for (y = 0; y < h; y++)
180  memcpy(out + y * stride, in + y * stride, w);
181 }
182 
183 static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out,
184  int color, int w, int h, int stride)
185 {
186  int y;
187 
188  for (y = tl_y; y < tl_y + h; y++)
189  memset(out + tl_x + y * stride, color, w);
190 }
191 
192 static void cdg_fill_wrapper(int out_tl_x, int out_tl_y, uint8_t *out,
193  int in_tl_x, int in_tl_y, uint8_t *in,
194  int color, int w, int h, int stride, int roll)
195 {
196  if (roll) {
197  cdg_copy_rect_buf(out_tl_x, out_tl_y, out, in_tl_x, in_tl_y,
198  in, w, h, stride);
199  } else {
200  cdg_fill_rect_preset(out_tl_x, out_tl_y, out, color, w, h, stride);
201  }
202 }
203 
204 static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
205  AVFrame *new_frame, int roll_over)
206 {
207  int color;
208  int hscmd, h_off, hinc, vscmd, v_off, vinc;
209  int y;
210  ptrdiff_t stride = cc->frame->linesize[0];
211  uint8_t *in = cc->frame->data[0];
212  uint8_t *out = new_frame->data[0];
213 
214  color = data[0] & 0x0F;
215  hscmd = (data[1] & 0x30) >> 4;
216  vscmd = (data[2] & 0x30) >> 4;
217 
218  h_off = FFMIN(data[1] & 0x07, CDG_BORDER_WIDTH - 1);
219  v_off = FFMIN(data[2] & 0x0F, CDG_BORDER_HEIGHT - 1);
220 
221  /// find the difference and save the offset for cdg_tile_block usage
222  hinc = h_off - cc->hscroll;
223  vinc = cc->vscroll - v_off;
224  cc->hscroll = h_off;
225  cc->vscroll = v_off;
226 
227  if (vscmd == UP)
228  vinc -= 12;
229  if (vscmd == DOWN)
230  vinc += 12;
231  if (hscmd == LEFT)
232  hinc -= 6;
233  if (hscmd == RIGHT)
234  hinc += 6;
235 
236  if (!hinc && !vinc)
237  return;
238 
239  memcpy(new_frame->data[1], cc->frame->data[1], CDG_PALETTE_SIZE * 4);
240 
241  for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
242  memcpy(out + FFMAX(0, hinc) + stride * y,
243  in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
244  FFABS(stride) - FFABS(hinc));
245 
246  if (vinc > 0)
247  cdg_fill_wrapper(0, 0, out,
248  0, CDG_FULL_HEIGHT - vinc, in, color,
249  FFABS(stride), vinc, stride, roll_over);
250  else if (vinc < 0)
252  0, 0, in, color,
253  FFABS(stride), -1 * vinc, stride, roll_over);
254 
255  if (hinc > 0)
256  cdg_fill_wrapper(0, 0, out,
257  CDG_FULL_WIDTH - hinc, 0, in, color,
258  hinc, CDG_FULL_HEIGHT, stride, roll_over);
259  else if (hinc < 0)
261  0, 0, in, color,
262  -1 * hinc, CDG_FULL_HEIGHT, stride, roll_over);
263 
264 }
265 
267  int *got_frame, AVPacket *avpkt)
268 {
269  GetByteContext gb;
270  int buf_size = avpkt->size;
271  int ret;
272  uint8_t command, inst;
273  uint8_t cdg_data[CDG_DATA_SIZE] = {0};
274  CDGraphicsContext *cc = avctx->priv_data;
275 
276  if (buf_size < CDG_MINIMUM_PKT_SIZE) {
277  av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
278  return AVERROR(EINVAL);
279  }
280  if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) {
281  av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n");
282  return AVERROR(EINVAL);
283  }
284 
285  bytestream2_init(&gb, avpkt->data, avpkt->size);
286 
287  if ((ret = ff_reget_buffer(avctx, cc->frame, 0)) < 0)
288  return ret;
289  if (!cc->cleared) {
290  for (int y = 0; y < avctx->height; y++)
291  memset(cc->frame->data[0] + y * cc->frame->linesize[0], 0, avctx->width);
292  memset(cc->frame->data[1], 0, AVPALETTE_SIZE);
293  cc->cleared = 1;
294  }
295 
296  command = bytestream2_get_byte(&gb);
297  inst = bytestream2_get_byte(&gb);
298  inst &= CDG_MASK;
299  bytestream2_skip(&gb, 2);
300  bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
301 
302  if ((command & CDG_MASK) == CDG_COMMAND) {
303  switch (inst) {
305  if (!(cdg_data[1] & 0x0F)) {
306  for (int y = 0; y < avctx->height; y++)
307  memset(cc->frame->data[0] + y * cc->frame->linesize[0],
308  cdg_data[0] & 0x0F, avctx->width);
309  }
310  break;
313  if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
314  av_log(avctx, AV_LOG_ERROR, "buffer too small for loading palette\n");
315  return AVERROR(EINVAL);
316  }
317 
318  cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);
319  break;
321  cdg_border_preset(cc, cdg_data);
322  break;
324  case CDG_INST_TILE_BLOCK:
325  if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
326  av_log(avctx, AV_LOG_ERROR, "buffer too small for drawing tile\n");
327  return AVERROR(EINVAL);
328  }
329 
330  ret = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);
331  if (ret) {
332  av_log(avctx, AV_LOG_ERROR, "tile is out of range\n");
333  return ret;
334  }
335  break;
338  if (buf_size - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {
339  av_log(avctx, AV_LOG_ERROR, "buffer too small for scrolling\n");
340  return AVERROR(EINVAL);
341  }
342 
343  if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
344  return ret;
345 
346  cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);
348  if (ret < 0)
349  return ret;
350  break;
352  for (int i = 0; i < CDG_PALETTE_SIZE; i++)
353  cc->alpha[i] = 255 - ((cdg_data[i] & 0x3f) << 2);
354  break;
355  default:
356  break;
357  }
358 
359  if (!frame->data[0]) {
360  ret = av_frame_ref(frame, cc->frame);
361  if (ret < 0)
362  return ret;
363  }
364  *got_frame = 1;
365  } else {
366  *got_frame = 0;
367  }
368 
369  return avpkt->size;
370 }
371 
373 {
374  CDGraphicsContext *cc = avctx->priv_data;
375 
376  if (!cc->frame->data[0])
377  return;
378 
379  for (int y = 0; y < avctx->height; y++)
380  memset(cc->frame->data[0] + y * cc->frame->linesize[0], 0, avctx->width);
381  if (!avctx->frame_num)
382  memset(cc->frame->data[1], 0, AVPALETTE_SIZE);
383 }
384 
386 {
387  CDGraphicsContext *cc = avctx->priv_data;
388 
389  av_frame_free(&cc->frame);
390 
391  return 0;
392 }
393 
395  .p.name = "cdgraphics",
396  CODEC_LONG_NAME("CD Graphics video"),
397  .p.type = AVMEDIA_TYPE_VIDEO,
398  .p.id = AV_CODEC_ID_CDGRAPHICS,
399  .priv_data_size = sizeof(CDGraphicsContext),
403  .flush = cdg_decode_flush,
404  .p.capabilities = AV_CODEC_CAP_DR1,
405 };
cdg_scroll
static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data, AVFrame *new_frame, int roll_over)
Definition: cdgraphics.c:204
r
const char * r
Definition: vf_curves.c:127
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
cdg_decode_frame
static int cdg_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: cdgraphics.c:266
out
FILE * out
Definition: movenc.c:55
color
Definition: vf_paletteuse.c:513
GetByteContext
Definition: bytestream.h:33
CDG_INST_SCROLL_PRESET
#define CDG_INST_SCROLL_PRESET
Definition: cdgraphics.c:53
CDG_DATA_SIZE
#define CDG_DATA_SIZE
Definition: cdgraphics.c:62
CDG_INST_LOAD_PAL_HIGH
#define CDG_INST_LOAD_PAL_HIGH
Definition: cdgraphics.c:57
CDGraphicsContext::alpha
uint8_t alpha[CDG_PALETTE_SIZE]
Definition: cdgraphics.c:74
CDG_MINIMUM_PKT_SIZE
#define CDG_MINIMUM_PKT_SIZE
Definition: cdgraphics.c:65
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
CDG_INST_TRANSPARENT_COL
#define CDG_INST_TRANSPARENT_COL
Definition: cdgraphics.c:55
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
AVFrame::width
int width
Definition: frame.h:499
w
uint8_t w
Definition: llviddspenc.c:38
AVPacket::data
uint8_t * data
Definition: packet.h:558
b
#define b
Definition: input.c:42
CDGraphicsContext::frame
AVFrame * frame
Definition: cdgraphics.c:71
data
const char data[16]
Definition: mxf.c:149
cdg_tile_block
static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
Definition: cdgraphics.c:132
FFCodec
Definition: codec_internal.h:127
CDG_TILE_WIDTH
#define CDG_TILE_WIDTH
Definition: cdgraphics.c:64
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
CDG_MASK
#define CDG_MASK
Definition: cdgraphics.c:47
CDG_INST_TILE_BLOCK_XOR
#define CDG_INST_TILE_BLOCK_XOR
Definition: cdgraphics.c:58
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:91
DOWN
#define DOWN
Definition: cdgraphics.c:167
CDG_PALETTE_SIZE
#define CDG_PALETTE_SIZE
Definition: cdgraphics.c:68
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
close
static av_cold void close(AVCodecParserContext *s)
Definition: apv_parser.c:135
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
CDG_FULL_HEIGHT
#define CDG_FULL_HEIGHT
Definition: cdgraphics.c:39
CDG_HEADER_SIZE
#define CDG_HEADER_SIZE
Definition: cdgraphics.c:67
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
cdg_border_preset
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
Definition: cdgraphics.c:93
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
av_cold
#define av_cold
Definition: attributes.h:90
cdg_decode_init
static av_cold int cdg_decode_init(AVCodecContext *avctx)
Definition: cdgraphics.c:78
CDG_BORDER_HEIGHT
#define CDG_BORDER_HEIGHT
Definition: cdgraphics.c:43
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:346
cdg_decode_flush
static av_cold void cdg_decode_flush(AVCodecContext *avctx)
Definition: cdgraphics.c:372
g
const char * g
Definition: vf_curves.c:128
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:411
CDGraphicsContext::vscroll
int vscroll
Definition: cdgraphics.c:73
decode.h
command
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_drawtext.c:1187
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:331
CDG_MINIMUM_SCROLL_SIZE
#define CDG_MINIMUM_SCROLL_SIZE
Definition: cdgraphics.c:66
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
CDG_FULL_WIDTH
#define CDG_FULL_WIDTH
default screen sizes
Definition: cdgraphics.c:38
ff_cdgraphics_decoder
const FFCodec ff_cdgraphics_decoder
Definition: cdgraphics.c:394
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:171
CDG_COMMAND
#define CDG_COMMAND
masks
Definition: cdgraphics.c:46
UP
#define UP
Definition: cdgraphics.c:166
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:115
cdg_decode_end
static av_cold int cdg_decode_end(AVCodecContext *avctx)
Definition: cdgraphics.c:385
AV_CODEC_ID_CDGRAPHICS
@ AV_CODEC_ID_CDGRAPHICS
Definition: codec_id.h:184
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1720
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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:559
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:278
codec_internal.h
RIGHT
#define RIGHT
Definition: cdgraphics.c:169
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
color
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:97
LEFT
#define LEFT
Definition: cdgraphics.c:168
attributes.h
CDG_INST_TILE_BLOCK
#define CDG_INST_TILE_BLOCK
Definition: cdgraphics.c:52
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
CDG_INST_BORDER_PRESET
#define CDG_INST_BORDER_PRESET
Definition: cdgraphics.c:51
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
CDG_INST_SCROLL_COPY
#define CDG_INST_SCROLL_COPY
Definition: cdgraphics.c:54
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCodecContext::height
int height
Definition: avcodec.h:592
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:631
avcodec.h
stride
#define stride
Definition: h264pred_template.c:536
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
AVCodecContext::frame_num
int64_t frame_num
Frame counter, set by libavcodec.
Definition: avcodec.h:1878
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:1840
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:265
CDGraphicsContext::hscroll
int hscroll
Definition: cdgraphics.c:72
CDG_BORDER_WIDTH
#define CDG_BORDER_WIDTH
Definition: cdgraphics.c:42
av_frame_replace
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
Definition: frame.c:376
AVCodecContext
main external API structure.
Definition: avcodec.h:431
CDG_TILE_HEIGHT
#define CDG_TILE_HEIGHT
Definition: cdgraphics.c:63
CDG_INST_MEMORY_PRESET
#define CDG_INST_MEMORY_PRESET
instruction codes
Definition: cdgraphics.c:50
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
CDGraphicsContext
Definition: cdgraphics.c:70
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:183
AVPacket
This structure stores compressed data.
Definition: packet.h:535
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:592
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:472
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
CDG_INST_LOAD_PAL_LO
#define CDG_INST_LOAD_PAL_LO
Definition: cdgraphics.c:56
CDGraphicsContext::cleared
int cleared
Definition: cdgraphics.c:75
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:192