34 #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
43 #define CDG_COMMAND 0x09
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_LOAD_PAL_LO 30
53 #define CDG_INST_LOAD_PAL_HIGH 31
54 #define CDG_INST_TILE_BLOCK_XOR 38
57 #define CDG_PACKET_SIZE 24
58 #define CDG_DATA_SIZE 16
59 #define CDG_TILE_HEIGHT 12
60 #define CDG_TILE_WIDTH 6
61 #define CDG_MINIMUM_PKT_SIZE 6
62 #define CDG_MINIMUM_SCROLL_SIZE 3
63 #define CDG_HEADER_SIZE 8
64 #define CDG_PALETTE_SIZE 16
100 int color = data[0] & 0x0F;
102 if (!(data[1] & 0x0F)) {
122 int array_offset = low ? 0 : 8;
123 uint32_t *palette = (uint32_t *) cc->
frame.
data[1];
125 for (i = 0; i < 8; i++) {
126 color = (data[2 * i] << 6) + (data[2 * i + 1] & 0x3F);
127 r = ((color >> 8) & 0x000F) * 17;
128 g = ((color >> 4) & 0x000F) * 17;
129 b = ((
color ) & 0x000F) * 17;
130 palette[i + array_offset] = r << 16 | g << 8 |
b;
154 if (!((data[4 + y] >> (5 - x)) & 0x01))
155 color = data[0] & 0x0F;
157 color = data[1] & 0x0F;
159 ai = ci + x + (stride * (ri + y));
175 int in_tl_x,
int in_tl_y,
uint8_t *in,
180 in += in_tl_x + in_tl_y *
stride;
181 out += out_tl_x + out_tl_y *
stride;
182 for (y = 0; y < h; y++)
183 memcpy(out + y * stride, in + y * stride, w);
191 for (y = tl_y; y < tl_y + h; y++)
192 memset(out + tl_x + y * stride, color, w);
196 int in_tl_x,
int in_tl_y,
uint8_t *in,
208 AVFrame *new_frame,
int roll_over)
211 int hscmd, h_off, hinc, vscmd, v_off, vinc;
217 color = data[0] & 0x0F;
218 hscmd = (data[1] & 0x30) >> 4;
219 vscmd = (data[2] & 0x30) >> 4;
245 memcpy(out +
FFMAX(0, hinc) + stride * y,
246 in +
FFMAX(0, hinc) - hinc + (y - vinc) * stride,
247 FFMIN(stride + hinc, stride));
252 stride, vinc, stride, roll_over);
256 stride, -1 * vinc, stride, roll_over);
273 int buf_size = avpkt->
size;
291 command = bytestream_get_byte(&buf);
292 inst = bytestream_get_byte(&buf);
300 if (!(cdg_data[1] & 0x0F))
301 memset(cc->
frame.
data[0], cdg_data[0] & 0x0F,
345 cc->
frame = new_frame;
372 .
name =
"cdgraphics",
#define CDG_BORDER_HEIGHT
This structure describes decoded (raw) audio or video data.
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
#define CDG_INST_LOAD_PAL_HIGH
#define CDG_INST_SCROLL_PRESET
static void cdg_init_frame(AVFrame *frame)
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
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)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
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)
8 bit with PIX_FMT_RGB32 palette
static int init(AVCodecParserContext *s)
#define FF_BUFFER_HINTS_READABLE
static av_cold int cdg_decode_init(AVCodecContext *avctx)
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#define CDG_MINIMUM_PKT_SIZE
static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out, int color, int w, int h, int stride)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define CDG_INST_BORDER_PRESET
static av_cold int cdg_decode_end(AVCodecContext *avctx)
#define CDG_INST_TILE_BLOCK
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define CDG_FULL_WIDTH
default screen sizes
static int cdg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int width
picture width / height.
#define CDG_INST_MEMORY_PRESET
instruction codes
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data, AVFrame *new_frame, int roll_over)
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
AVCodec ff_cdgraphics_decoder
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define CDG_INST_LOAD_PAL_LO
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
int palette_has_changed
Tell user application that palette has changed from previous frame.
#define FF_BUFFER_HINTS_REUSABLE
#define FF_BUFFER_HINTS_PRESERVE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define CDG_INST_TILE_BLOCK_XOR
common internal api header.
static const uint8_t color[]
struct CDGraphicsContext CDGraphicsContext
#define FF_BUFFER_HINTS_VALID
#define CDG_INST_SCROLL_COPY
This structure stores compressed data.
#define CDG_MINIMUM_SCROLL_SIZE