35 #define KMVC_KEYFRAME 0x80 36 #define KMVC_PALETTE 0x40 37 #define KMVC_METHOD 0x0F 38 #define MAX_PALSIZE 256 59 #define BLK(data, x, y) data[av_clip((x) + (y) * 320, 0, 320 * 200 -1)] 61 #define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g); 63 #define kmvc_getbit(bb, g, res) {\ 65 if (bb.bitbuf & (1 << bb.bits)) res = 1; \ 68 bb.bitbuf = bytestream2_get_byte(g); \ 79 int l0x, l1x, l0y, l1y;
84 for (by = 0; by < h; by += 8)
85 for (bx = 0; bx < w; bx += 8) {
92 val = bytestream2_get_byte(&ctx->
g);
93 for (i = 0; i < 64; i++)
94 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
96 for (i = 0; i < 4; i++) {
97 l0x = bx + (i & 1) * 4;
98 l0y = by + (i & 2) * 2;
103 val = bytestream2_get_byte(&ctx->
g);
104 for (j = 0; j < 16; j++)
105 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
107 val = bytestream2_get_byte(&ctx->
g);
110 for (j = 0; j < 16; j++)
111 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
112 BLK(ctx->
cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
115 for (j = 0; j < 4; j++) {
116 l1x = l0x + (j & 1) * 2;
122 val = bytestream2_get_byte(&ctx->
g);
123 BLK(ctx->
cur, l1x, l1y) = val;
124 BLK(ctx->
cur, l1x + 1, l1y) = val;
125 BLK(ctx->
cur, l1x, l1y + 1) = val;
126 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
128 val = bytestream2_get_byte(&ctx->
g);
131 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
cur, l1x - mx, l1y - my);
132 BLK(ctx->
cur, l1x + 1, l1y) =
133 BLK(ctx->
cur, l1x + 1 - mx, l1y - my);
134 BLK(ctx->
cur, l1x, l1y + 1) =
135 BLK(ctx->
cur, l1x - mx, l1y + 1 - my);
136 BLK(ctx->
cur, l1x + 1, l1y + 1) =
137 BLK(ctx->
cur, l1x + 1 - mx, l1y + 1 - my);
140 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
141 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
142 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
143 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
160 int l0x, l1x, l0y, l1y;
165 for (by = 0; by < h; by += 8)
166 for (bx = 0; bx < w; bx += 8) {
175 val = bytestream2_get_byte(&ctx->
g);
176 for (i = 0; i < 64; i++)
177 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
179 for (i = 0; i < 64; i++)
180 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
181 BLK(ctx->
prev, bx + (i & 0x7), by + (i >> 3));
188 for (i = 0; i < 4; i++) {
189 l0x = bx + (i & 1) * 4;
190 l0y = by + (i & 2) * 2;
195 val = bytestream2_get_byte(&ctx->
g);
196 for (j = 0; j < 16; j++)
197 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
199 val = bytestream2_get_byte(&ctx->
g);
200 mx = (val & 0xF) - 8;
202 for (j = 0; j < 16; j++)
203 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
204 BLK(ctx->
prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
207 for (j = 0; j < 4; j++) {
208 l1x = l0x + (j & 1) * 2;
214 val = bytestream2_get_byte(&ctx->
g);
215 BLK(ctx->
cur, l1x, l1y) = val;
216 BLK(ctx->
cur, l1x + 1, l1y) = val;
217 BLK(ctx->
cur, l1x, l1y + 1) = val;
218 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
220 val = bytestream2_get_byte(&ctx->
g);
221 mx = (val & 0xF) - 8;
223 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
prev, l1x + mx, l1y + my);
224 BLK(ctx->
cur, l1x + 1, l1y) =
225 BLK(ctx->
prev, l1x + 1 + mx, l1y + my);
226 BLK(ctx->
cur, l1x, l1y + 1) =
227 BLK(ctx->
prev, l1x + mx, l1y + 1 + my);
228 BLK(ctx->
cur, l1x + 1, l1y + 1) =
229 BLK(ctx->
prev, l1x + 1 + mx, l1y + 1 + my);
232 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
233 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
234 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
235 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
264 header = bytestream2_get_byte(&ctx->
g);
267 if (bytestream2_peek_byte(&ctx->
g) == 127) {
269 for (i = 0; i < 127; i++) {
270 ctx->
pal[i + (header & 0x81)] = bytestream2_get_be24(&ctx->
g);
287 for (i = 1; i <= ctx->
palsize; i++) {
288 ctx->
pal[i] = bytestream2_get_be24(&ctx->
g);
303 memcpy(frame->
data[1], ctx->
pal, 1024);
305 blocksize = bytestream2_get_byte(&ctx->
g);
307 if (blocksize != 8 && blocksize != 127) {
311 memset(ctx->
cur, 0, 320 * 200);
315 memcpy(ctx->
cur, ctx->
prev, 320 * 200);
328 out = frame->
data[0];
330 for (i = 0; i < avctx->
height; i++) {
331 memcpy(out, src, avctx->
width);
371 for (i = 0; i < 256; i++) {
372 c->
pal[i] = i * 0x10101;
377 "Extradata missing, decoding may not work properly...\n");
389 for (i = 0; i < 256; i++) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
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)
8 bit with PIX_FMT_RGB32 palette
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int kmvc_decode_intra_8x8(KmvcContext *ctx, int w, int h)
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)
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.
int width
picture width / height.
#define kmvc_getbit(bb, g, res)
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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
static av_cold int init(AVCodecParserContext *s)
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
uint32_t pal[MAX_PALSIZE]
This structure stores compressed data.