Commit 6090ac1d authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Michael Niedermayer

avcodec/zmbv: Call decode_intra directly

zmbv has only one function for decoding intra frames, namely
decode_intra; and yet up until now it has been called via a function
pointer. This has been changed.

This also removes spec-incompliant conversions between function pointers
and pointers of type void * and thereby fixes the warning "ISO C forbids
assignment between function pointer and ‘void *’" that GCC emits with
the -pedantic option.
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 2c78a76c
...@@ -69,8 +69,8 @@ typedef struct ZmbvContext { ...@@ -69,8 +69,8 @@ typedef struct ZmbvContext {
int stride; int stride;
int bw, bh, bx, by; int bw, bh, bx, by;
int decomp_len; int decomp_len;
int got_keyframe;
z_stream zstream; z_stream zstream;
int (*decode_intra)(struct ZmbvContext *c);
int (*decode_xor)(struct ZmbvContext *c); int (*decode_xor)(struct ZmbvContext *c);
} ZmbvContext; } ZmbvContext;
...@@ -425,8 +425,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -425,8 +425,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
c->flags = buf[0]; c->flags = buf[0];
buf++; len--; buf++; len--;
if (c->flags & ZMBV_KEYFRAME) { if (c->flags & ZMBV_KEYFRAME) {
void *decode_intra = NULL; c->got_keyframe = 0;
c->decode_intra= NULL;
if (len < 6) if (len < 6)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -436,7 +435,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -436,7 +435,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
c->fmt = buf[3]; c->fmt = buf[3];
c->bw = buf[4]; c->bw = buf[4];
c->bh = buf[5]; c->bh = buf[5];
c->decode_intra = NULL;
c->decode_xor = NULL; c->decode_xor = NULL;
buf += 6; buf += 6;
...@@ -460,7 +458,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -460,7 +458,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
switch (c->fmt) { switch (c->fmt) {
case ZMBV_FMT_8BPP: case ZMBV_FMT_8BPP:
c->bpp = 8; c->bpp = 8;
decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_8; c->decode_xor = zmbv_decode_xor_8;
avctx->pix_fmt = AV_PIX_FMT_PAL8; avctx->pix_fmt = AV_PIX_FMT_PAL8;
c->stride = c->width; c->stride = c->width;
...@@ -468,7 +465,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -468,7 +465,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
case ZMBV_FMT_15BPP: case ZMBV_FMT_15BPP:
case ZMBV_FMT_16BPP: case ZMBV_FMT_16BPP:
c->bpp = 16; c->bpp = 16;
decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_16; c->decode_xor = zmbv_decode_xor_16;
if (c->fmt == ZMBV_FMT_15BPP) if (c->fmt == ZMBV_FMT_15BPP)
avctx->pix_fmt = AV_PIX_FMT_RGB555LE; avctx->pix_fmt = AV_PIX_FMT_RGB555LE;
...@@ -479,7 +475,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -479,7 +475,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
#ifdef ZMBV_ENABLE_24BPP #ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP: case ZMBV_FMT_24BPP:
c->bpp = 24; c->bpp = 24;
decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_24; c->decode_xor = zmbv_decode_xor_24;
avctx->pix_fmt = AV_PIX_FMT_BGR24; avctx->pix_fmt = AV_PIX_FMT_BGR24;
c->stride = c->width * 3; c->stride = c->width * 3;
...@@ -487,7 +482,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -487,7 +482,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
#endif //ZMBV_ENABLE_24BPP #endif //ZMBV_ENABLE_24BPP
case ZMBV_FMT_32BPP: case ZMBV_FMT_32BPP:
c->bpp = 32; c->bpp = 32;
decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_32; c->decode_xor = zmbv_decode_xor_32;
avctx->pix_fmt = AV_PIX_FMT_BGR0; avctx->pix_fmt = AV_PIX_FMT_BGR0;
c->stride = c->width * 4; c->stride = c->width * 4;
...@@ -517,7 +511,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -517,7 +511,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
} }
memset(c->cur, 0, avctx->width * avctx->height * (c->bpp / 8)); memset(c->cur, 0, avctx->width * avctx->height * (c->bpp / 8));
memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8)); memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
c->decode_intra= decode_intra; c->got_keyframe = 1;
} }
if (c->flags & ZMBV_KEYFRAME) { if (c->flags & ZMBV_KEYFRAME) {
expected_size = avctx->width * avctx->height * (c->bpp / 8); expected_size = avctx->width * avctx->height * (c->bpp / 8);
...@@ -528,7 +522,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -528,7 +522,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
(c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME))) (c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME)))
expected_size += 768; expected_size += 768;
if (!c->decode_intra) { if (!c->got_keyframe) {
av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n"); av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -564,7 +558,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -564,7 +558,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (c->flags & ZMBV_KEYFRAME) { if (c->flags & ZMBV_KEYFRAME) {
frame->key_frame = 1; frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I; frame->pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c); zmbv_decode_intra(c);
} else { } else {
frame->key_frame = 0; frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P; frame->pict_type = AV_PICTURE_TYPE_P;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment