X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqpeg.c;h=9513dd0ad3539144d96898e44017a4ae55dfeadf;hb=b6e8ff72ea055f40ee272a97bde3ff21b3ea6c27;hp=3c0d87e9398b2096ce8a1f067dd7d22812ddd2a4;hpb=fb8a82d20a4fa25419f7d87a9e9ee9b23372ed79;p=ffmpeg diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 3c0d87e9398..9513dd0ad35 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -2,35 +2,35 @@ * QPEG codec * Copyright (c) 2004 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 qpeg.c + * @file * QPEG codec. */ #include "avcodec.h" -#include "mpegvideo.h" typedef struct QpegContext{ AVCodecContext *avctx; AVFrame pic; uint8_t *refdata; + uint32_t pal[256]; } QpegContext; static void qpeg_decode_intra(const uint8_t *src, uint8_t *dst, int size, @@ -109,15 +109,15 @@ static void qpeg_decode_intra(const uint8_t *src, uint8_t *dst, int size, } } -static int qpeg_table_h[16] = +static const int qpeg_table_h[16] = { 0x00, 0x20, 0x20, 0x20, 0x18, 0x10, 0x10, 0x20, 0x10, 0x08, 0x18, 0x08, 0x08, 0x18, 0x10, 0x04}; -static int qpeg_table_w[16] = +static const int qpeg_table_w[16] = { 0x00, 0x20, 0x18, 0x08, 0x18, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x20, 0x08, 0x10, 0x18, 0x04}; /* Decodes delta frames */ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, int stride, int width, int height, - int delta, uint8_t *ctable, uint8_t *refdata) + int delta, const uint8_t *ctable, uint8_t *refdata) { int i, j; int code; @@ -249,19 +249,19 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, - const uint8_t *buf, int buf_size) + AVPacket *avpkt) { + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; QpegContext * const a = avctx->priv_data; AVFrame * const p= (AVFrame*)&a->pic; uint8_t* outdata; int delta; + const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); - if(p->data[0]) - avctx->release_buffer(avctx, p); - - p->reference= 0; - if(avctx->get_buffer(avctx, p) < 0){ - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + p->reference = 3; + if (avctx->reget_buffer(avctx, p) < 0) { + av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } outdata = a->pic.data[0]; @@ -273,11 +273,11 @@ static int decode_frame(AVCodecContext *avctx, } /* make the palette available on the way out */ - memcpy(a->pic.data[1], a->avctx->palctrl->palette, AVPALETTE_SIZE); - if (a->avctx->palctrl->palette_changed) { + if (pal) { a->pic.palette_has_changed = 1; - a->avctx->palctrl->palette_changed = 0; + memcpy(a->pal, pal, AVPALETTE_SIZE); } + memcpy(a->pic.data[1], a->pal, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = a->pic; @@ -285,18 +285,17 @@ static int decode_frame(AVCodecContext *avctx, return buf_size; } -static int decode_init(AVCodecContext *avctx){ +static av_cold int decode_init(AVCodecContext *avctx){ QpegContext * const a = avctx->priv_data; a->avctx = avctx; avctx->pix_fmt= PIX_FMT_PAL8; - a->pic.data[0] = NULL; a->refdata = av_malloc(avctx->width * avctx->height); return 0; } -static int decode_end(AVCodecContext *avctx){ +static av_cold int decode_end(AVCodecContext *avctx){ QpegContext * const a = avctx->priv_data; AVFrame * const p= (AVFrame*)&a->pic; @@ -307,14 +306,14 @@ static int decode_end(AVCodecContext *avctx){ return 0; } -AVCodec qpeg_decoder = { - "qpeg", - CODEC_TYPE_VIDEO, - CODEC_ID_QPEG, - sizeof(QpegContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, +AVCodec ff_qpeg_decoder = { + .name = "qpeg", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_QPEG, + .priv_data_size = sizeof(QpegContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, + .long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"), };