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
46#define CDG_COMMAND 0x09
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
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
99 if (!(
data[1] & 0x0F)) {
120 int array_offset = low ? 0 : 8;
121 uint32_t *palette = (uint32_t *) cc->
frame->
data[1];
123 for (
i = 0;
i < 8;
i++) {
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;
151 if (!((
data[4 + y] >> (5 - x)) & 0x01))
156 ai = ci + x + (
stride * (ri + y));
172 int in_tl_x,
int in_tl_y, uint8_t *in,
177 in += in_tl_x + in_tl_y *
stride;
179 for (y = 0; y <
h; y++)
188 for (y = tl_y; y < tl_y +
h; y++)
193 int in_tl_x,
int in_tl_y, uint8_t *in,
205 AVFrame *new_frame,
int roll_over)
208 int hscmd, h_off, hinc, vscmd, v_off, vinc;
212 uint8_t *
out = new_frame->
data[0];
215 hscmd = (
data[1] & 0x30) >> 4;
216 vscmd = (
data[2] & 0x30) >> 4;
270 int buf_size = avpkt->
size;
290 for (
int y = 0; y < avctx->
height; y++)
296 command = bytestream2_get_byte(&gb);
297 inst = bytestream2_get_byte(&gb);
305 if (!(cdg_data[1] & 0x0F)) {
306 for (
int y = 0; y < avctx->
height; y++)
308 cdg_data[0] & 0x0F, avctx->
width);
353 cc->
alpha[
i] = 255 - ((cdg_data[
i] & 0x3f) << 2);
359 if (!
frame->data[0]) {
379 for (
int y = 0; y < avctx->
height; y++)
395 .p.name =
"cdgraphics",
const FFCodec ff_cdgraphics_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define i(width, name, range_min, range_max)
#define CDG_INST_SCROLL_COPY
#define CDG_INST_TILE_BLOCK_XOR
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)
#define CDG_INST_LOAD_PAL_HIGH
#define CDG_INST_LOAD_PAL_LO
static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data, AVFrame *new_frame, int roll_over)
static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out, int color, int w, int h, int stride)
#define CDG_INST_TRANSPARENT_COL
static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
static av_cold int cdg_decode_init(AVCodecContext *avctx)
#define CDG_MINIMUM_SCROLL_SIZE
static int cdg_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
#define CDG_INST_SCROLL_PRESET
#define CDG_FULL_WIDTH
default screen sizes
static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
#define CDG_INST_BORDER_PRESET
#define CDG_INST_MEMORY_PRESET
instruction codes
static av_cold void cdg_decode_flush(AVCodecContext *avctx)
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
#define CDG_INST_TILE_BLOCK
static av_cold int cdg_decode_end(AVCodecContext *avctx)
#define CDG_BORDER_HEIGHT
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)
#define CDG_MINIMUM_PKT_SIZE
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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)
#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.
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
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_ERROR
Something went wrong and cannot losslessly be recovered.
Macro definitions for various function/variable attributes.
@ 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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.
uint8_t alpha[CDG_PALETTE_SIZE]
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)