X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fkmvc.c;h=56c1977254158614c22e272541465ffd08207539;hb=e5bcda6473a2d6984216004506374669501fcf3b;hp=ffe6a142e9721df54f3fe8ab2e52e7bd4749bbf0;hpb=3eea8edf618079e44719fe059ddd953b21ef1ba9;p=ffmpeg diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index ffe6a142e97..56c19772541 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -29,6 +29,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "decode.h" #include "internal.h" #include "libavutil/common.h" @@ -43,12 +44,12 @@ typedef struct KmvcContext { AVCodecContext *avctx; + GetByteContext g; + uint8_t *cur, *prev; int setpal; int palsize; uint32_t pal[MAX_PALSIZE]; - uint8_t *cur, *prev; uint8_t frm0[320 * 200], frm1[320 * 200]; - GetByteContext g; } KmvcContext; typedef struct BitBuf { @@ -268,14 +269,14 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, int i, ret; int header; int blocksize; - int pal_size; - const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); bytestream2_init(&ctx->g, avpkt->data, avpkt->size); if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; + frame->palette_has_changed = ff_copy_palette(ctx->pal, avpkt, avctx); + header = bytestream2_get_byte(&ctx->g); /* blocksize 127 is really palette change event */ @@ -304,13 +305,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, } } - if (pal && pal_size == AVPALETTE_SIZE) { - frame->palette_has_changed = 1; - memcpy(ctx->pal, pal, AVPALETTE_SIZE); - } else if (pal) { - av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); - } - if (ctx->setpal) { ctx->setpal = 0; frame->palette_has_changed = 1; @@ -351,13 +345,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, } /* flip buffers */ - if (ctx->cur == ctx->frm0) { - ctx->cur = ctx->frm1; - ctx->prev = ctx->frm0; - } else { - ctx->cur = ctx->frm0; - ctx->prev = ctx->frm1; - } + FFSWAP(uint8_t *, ctx->cur, ctx->prev); *got_frame = 1;