X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fkmvc.c;h=07ca19479b60e6c3883f5146151bbcfa2dda07b0;hb=24adf7832b8370f3c1febbef6c686f574d360d32;hp=30939ab411e3e9db1f3c0f68025d4a7f27354c11;hpb=bad5537e2c2caeb5deb1ff9d771ea01058b8010c;p=ffmpeg diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 30939ab411e..07ca19479b6 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -2,25 +2,25 @@ * KMVC decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** - * @file libavcodec/kmvc.c + * @file * Karl Morton's Video Codec decoder */ @@ -224,14 +224,16 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, } } -static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t * buf, - int buf_size) +static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; KmvcContext *const ctx = avctx->priv_data; uint8_t *out, *src; int i; int header; int blocksize; + const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (ctx->pic.data[0]) avctx->release_buffer(avctx, &ctx->pic); @@ -257,17 +259,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, cons if (header & KMVC_KEYFRAME) { ctx->pic.key_frame = 1; - ctx->pic.pict_type = FF_I_TYPE; + ctx->pic.pict_type = AV_PICTURE_TYPE_I; } else { ctx->pic.key_frame = 0; - ctx->pic.pict_type = FF_P_TYPE; - } - - /* if palette has been changed, copy it from palctrl */ - if (ctx->avctx->palctrl && ctx->avctx->palctrl->palette_changed) { - memcpy(ctx->pal, ctx->avctx->palctrl->palette, AVPALETTE_SIZE); - ctx->setpal = 1; - ctx->avctx->palctrl->palette_changed = 0; + ctx->pic.pict_type = AV_PICTURE_TYPE_P; } if (header & KMVC_PALETTE) { @@ -278,6 +273,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, cons } } + if (pal) { + ctx->pic.palette_has_changed = 1; + memcpy(ctx->pal, pal, AVPALETTE_SIZE); + } + if (ctx->setpal) { ctx->setpal = 0; ctx->pic.palette_has_changed = 1; @@ -345,8 +345,6 @@ static av_cold int decode_init(AVCodecContext * avctx) c->avctx = avctx; - c->pic.data[0] = NULL; - if (avctx->width > 320 || avctx->height > 200) { av_log(avctx, AV_LOG_ERROR, "KMVC supports frames <= 320x200\n"); return -1; @@ -375,9 +373,6 @@ static av_cold int decode_init(AVCodecContext * avctx) src += 4; } c->setpal = 1; - if (c->avctx->palctrl) { - c->avctx->palctrl->palette_changed = 0; - } } avctx->pix_fmt = PIX_FMT_PAL8; @@ -402,14 +397,14 @@ static av_cold int decode_end(AVCodecContext * avctx) return 0; } -AVCodec kmvc_decoder = { - "kmvc", - CODEC_TYPE_VIDEO, - CODEC_ID_KMVC, - sizeof(KmvcContext), - decode_init, - NULL, - decode_end, - decode_frame, +AVCodec ff_kmvc_decoder = { + .name = "kmvc", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_KMVC, + .priv_data_size = sizeof(KmvcContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"), };