37 #define ZMBV_KEYFRAME 1 38 #define ZMBV_DELTAPAL 2 84 int d, dx, dy, bw2, bh2;
93 for (i = 0; i < 768; i++)
98 src += ((c->
bx * c->
by * 2 + 3) & ~3);
101 for (y = 0; y < c->
height; y += c->
bh) {
103 for (x = 0; x < c->
width; x += c->
bw) {
107 dx = mvec[
block] >> 1;
108 dy = mvec[block + 1] >> 1;
115 tprev = prev + x + dx + dy * c->
width;
118 for (j = 0; j < bh2; j++) {
119 if (my + j < 0 || my + j >= c->
height) {
122 for (i = 0; i < bw2; i++) {
123 if (mx + i < 0 || mx + i >= c->
width)
135 for (j = 0; j < bh2; j++) {
136 for (i = 0; i < bw2; i++)
158 uint16_t *output, *
prev;
161 int d, dx, dy, bw2, bh2;
166 output = (uint16_t*)c->
cur;
167 prev = (uint16_t*)c->
prev;
170 src += ((c->
bx * c->
by * 2 + 3) & ~3);
173 for (y = 0; y < c->
height; y += c->
bh) {
175 for (x = 0; x < c->
width; x += c->
bw) {
176 uint16_t *
out, *tprev;
179 dx = mvec[
block] >> 1;
180 dy = mvec[block + 1] >> 1;
187 tprev = prev + x + dx + dy * c->
width;
190 for (j = 0; j < bh2; j++) {
191 if (my + j < 0 || my + j >= c->
height) {
192 memset(out, 0, bw2 * 2);
194 for (i = 0; i < bw2; i++) {
195 if (mx + i < 0 || mx + i >= c->
width)
207 for (j = 0; j < bh2; j++){
208 for (i = 0; i < bw2; i++) {
209 out[i] ^= *((uint16_t*)src);
225 #ifdef ZMBV_ENABLE_24BPP 236 int d, dx, dy, bw2, bh2;
245 stride = c->
width * 3;
247 src += ((c->
bx * c->
by * 2 + 3) & ~3);
250 for (y = 0; y < c->
height; y += c->
bh) {
252 for (x = 0; x < c->
width; x += c->
bw) {
256 dx = mvec[
block] >> 1;
257 dy = mvec[block + 1] >> 1;
263 out = output + x * 3;
264 tprev = prev + (x + dx) * 3 + dy * stride;
267 for (j = 0; j < bh2; j++) {
268 if (my + j < 0 || my + j >= c->
height) {
269 memset(out, 0, bw2 * 3);
271 for (i = 0; i < bw2; i++){
272 if (mx + i < 0 || mx + i >= c->
width) {
277 out[i * 3 + 0] = tprev[i * 3 + 0];
278 out[i * 3 + 1] = tprev[i * 3 + 1];
279 out[i * 3 + 2] = tprev[i * 3 + 2];
288 out = output + x * 3;
289 for (j = 0; j < bh2; j++) {
290 for (i = 0; i < bw2; i++) {
291 out[i * 3 + 0] ^= *src++;
292 out[i * 3 + 1] ^= *src++;
293 out[i * 3 + 2] ^= *src++;
299 output += stride * c->
bh;
300 prev += stride * c->
bh;
307 #endif //ZMBV_ENABLE_24BPP 316 uint32_t *output, *
prev;
319 int d, dx, dy, bw2, bh2;
324 output = (uint32_t*)c->
cur;
325 prev = (uint32_t*)c->
prev;
328 src += ((c->
bx * c->
by * 2 + 3) & ~3);
331 for (y = 0; y < c->
height; y += c->
bh) {
333 for (x = 0; x < c->
width; x += c->
bw) {
334 uint32_t *
out, *tprev;
337 dx = mvec[
block] >> 1;
338 dy = mvec[block + 1] >> 1;
345 tprev = prev + x + dx + dy * c->
width;
348 for (j = 0; j < bh2; j++) {
349 if (my + j < 0 || my + j >= c->
height) {
350 memset(out, 0, bw2 * 4);
352 for (i = 0; i < bw2; i++){
353 if (mx + i < 0 || mx + i >= c->
width)
365 for (j = 0; j < bh2; j++){
366 for (i = 0; i < bw2; i++) {
367 out[i] ^= *((uint32_t *) src);
392 memcpy(c->
pal, src, 768);
404 int buf_size = avpkt->
size;
408 int hi_ver, lo_ver, ret;
432 "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
434 if (hi_ver != 0 || lo_ver != 1) {
438 if (c->
bw == 0 || c->
bh == 0) {
459 #ifdef ZMBV_ENABLE_24BPP 465 #endif //ZMBV_ENABLE_24BPP 478 zret = inflateReset(&c->
zstream);
513 zret = inflate(&c->
zstream, Z_SYNC_FLUSH);
514 if (zret != Z_OK && zret != Z_STREAM_END) {
536 out = frame->
data[0];
540 for (j = 0; j < c->
height; j++) {
541 for (i = 0; i < c->
width; i++) {
542 out[i * 3 + 0] = c->
pal[(*src) * 3 + 0];
543 out[i * 3 + 1] = c->
pal[(*src) * 3 + 1];
544 out[i * 3 + 2] = c->
pal[(*src) * 3 + 2];
551 for (j = 0; j < c->
height; j++) {
552 for (i = 0; i < c->
width; i++) {
555 out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
556 out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
557 out[i * 3 + 2] = (tmp & 0x001F) << 3;
563 for (j = 0; j < c->
height; j++) {
564 for (i = 0; i < c->
width; i++) {
567 out[i * 3 + 0] = (tmp & 0xF800) >> 8;
568 out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
569 out[i * 3 + 2] = (tmp & 0x001F) << 3;
574 #ifdef ZMBV_ENABLE_24BPP 576 for (j = 0; j < c->
height; j++) {
577 memcpy(out, src, c->
width * 3);
582 #endif //ZMBV_ENABLE_24BPP 584 for (j = 0; j < c->
height; j++) {
585 for (i = 0; i < c->
width; i++) {
617 memset(&c->
zstream, 0,
sizeof(z_stream));
626 "Can't allocate decompression buffer.\n");
634 zret = inflateInit(&c->
zstream);
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
packed RGB 8:8:8, 24bpp, RGBRGB...
static int zmbv_decode_xor_32(ZmbvContext *c)
Decode XOR'ed frame - 32bpp version.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int(* decode_xor)(struct ZmbvContext *c)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold int decode_init(AVCodecContext *avctx)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int zmbv_decode_xor_8(ZmbvContext *c)
Decode XOR'ed frame - 8bpp version.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static av_cold int decode_end(AVCodecContext *avctx)
int(* decode_intra)(struct ZmbvContext *c)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
Libavcodec external API header.
static int zmbv_decode_xor_16(ZmbvContext *c)
Decode XOR'ed frame - 15bpp and 16bpp version.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
common internal and external API header
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static av_cold int init(AVCodecParserContext *s)
int key_frame
1 -> keyframe, 0-> not
static int zmbv_decode_intra(ZmbvContext *c)
Decode intraframe.
#define FFSWAP(type, a, b)
This structure stores compressed data.