35 #define KMVC_KEYFRAME 0x80
36 #define KMVC_PALETTE 0x40
37 #define KMVC_METHOD 0x0F
38 #define MAX_PALSIZE 256
60 #define BLK(data, x, y) data[av_clip((x) + (y) * 320, 0, 320 * 200 -1)]
62 #define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
64 #define kmvc_getbit(bb, g, res) {\
66 if (bb.bitbuf & (1 << bb.bits)) res = 1; \
69 bb.bitbuf = bytestream2_get_byte(g); \
80 int l0x, l1x, l0y, l1y;
85 for (by = 0; by < h; by += 8)
86 for (bx = 0; bx < w; bx += 8) {
93 val = bytestream2_get_byte(&ctx->
g);
94 for (i = 0; i < 64; i++)
95 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
97 for (i = 0; i < 4; i++) {
98 l0x = bx + (i & 1) * 4;
99 l0y = by + (i & 2) * 2;
104 val = bytestream2_get_byte(&ctx->
g);
105 for (j = 0; j < 16; j++)
106 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
108 val = bytestream2_get_byte(&ctx->
g);
111 for (j = 0; j < 16; j++)
112 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
113 BLK(ctx->
cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
116 for (j = 0; j < 4; j++) {
117 l1x = l0x + (j & 1) * 2;
123 val = bytestream2_get_byte(&ctx->
g);
124 BLK(ctx->
cur, l1x, l1y) = val;
125 BLK(ctx->
cur, l1x + 1, l1y) = val;
126 BLK(ctx->
cur, l1x, l1y + 1) = val;
127 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
129 val = bytestream2_get_byte(&ctx->
g);
132 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
cur, l1x - mx, l1y - my);
133 BLK(ctx->
cur, l1x + 1, l1y) =
134 BLK(ctx->
cur, l1x + 1 - mx, l1y - my);
135 BLK(ctx->
cur, l1x, l1y + 1) =
136 BLK(ctx->
cur, l1x - mx, l1y + 1 - my);
137 BLK(ctx->
cur, l1x + 1, l1y + 1) =
138 BLK(ctx->
cur, l1x + 1 - mx, l1y + 1 - my);
141 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
142 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
143 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
144 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
161 int l0x, l1x, l0y, l1y;
166 for (by = 0; by < h; by += 8)
167 for (bx = 0; bx < w; bx += 8) {
176 val = bytestream2_get_byte(&ctx->
g);
177 for (i = 0; i < 64; i++)
178 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
180 for (i = 0; i < 64; i++)
181 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
182 BLK(ctx->
prev, bx + (i & 0x7), by + (i >> 3));
189 for (i = 0; i < 4; i++) {
190 l0x = bx + (i & 1) * 4;
191 l0y = by + (i & 2) * 2;
196 val = bytestream2_get_byte(&ctx->
g);
197 for (j = 0; j < 16; j++)
198 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
200 val = bytestream2_get_byte(&ctx->
g);
201 mx = (val & 0xF) - 8;
203 for (j = 0; j < 16; j++)
204 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
205 BLK(ctx->
prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
208 for (j = 0; j < 4; j++) {
209 l1x = l0x + (j & 1) * 2;
215 val = bytestream2_get_byte(&ctx->
g);
216 BLK(ctx->
cur, l1x, l1y) = val;
217 BLK(ctx->
cur, l1x + 1, l1y) = val;
218 BLK(ctx->
cur, l1x, l1y + 1) = val;
219 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
221 val = bytestream2_get_byte(&ctx->
g);
222 mx = (val & 0xF) - 8;
224 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
prev, l1x + mx, l1y + my);
225 BLK(ctx->
cur, l1x + 1, l1y) =
226 BLK(ctx->
prev, l1x + 1 + mx, l1y + my);
227 BLK(ctx->
cur, l1x, l1y + 1) =
228 BLK(ctx->
prev, l1x + mx, l1y + 1 + my);
229 BLK(ctx->
cur, l1x + 1, l1y + 1) =
230 BLK(ctx->
prev, l1x + 1 + mx, l1y + 1 + my);
233 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
234 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
235 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
236 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
267 header = bytestream2_get_byte(&ctx->
g);
270 if (bytestream2_peek_byte(&ctx->
g) == 127) {
272 for (i = 0; i < 127; i++) {
273 ctx->
pal[i + (header & 0x81)] = bytestream2_get_be24(&ctx->
g);
290 for (i = 1; i <= ctx->
palsize; i++) {
291 ctx->
pal[i] = bytestream2_get_be24(&ctx->
g);
308 blocksize = bytestream2_get_byte(&ctx->
g);
310 if (blocksize != 8 && blocksize != 127) {
314 memset(ctx->
cur, 0, 320 * 200);
318 memcpy(ctx->
cur, ctx->
prev, 320 * 200);
333 for (i = 0; i < avctx->
height; i++) {
334 memcpy(out, src, avctx->
width);
375 for (i = 0; i < 256; i++) {
376 c->
pal[i] = i * 0x10101;
380 av_log(
NULL, 0,
"Extradata missing, decoding may not work properly...\n");
392 for (i = 0; i < 256; i++) {
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_BUFFER_HINTS_VALID
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.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int kmvc_decode_inter_8x8(KmvcContext *ctx, int w, int h)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int kmvc_decode_intra_8x8(KmvcContext *ctx, int w, int h)
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.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
struct KmvcContext KmvcContext
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define kmvc_init_getbits(bb, g)
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
#define kmvc_getbit(bb, g, res)
struct AVFrame AVFrame
Audio Video Frame.
static av_cold int decode_init(AVCodecContext *avctx)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int palette_has_changed
Tell user application that palette has changed from previous frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
common internal and external API header
8 bit with PIX_FMT_RGB32 palette
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
uint32_t pal[MAX_PALSIZE]