diff options
Diffstat (limited to 'libavcodec/pcxenc.c')
-rw-r--r-- | libavcodec/pcxenc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 865d7bdbd3..5edb2623b1 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -2,20 +2,20 @@ * PC Paintbrush PCX (.pcx) image encoder * Copyright (c) 2009 Daniel Verkamp <daniel at drv.nu> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg 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. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -28,6 +28,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "libavutil/imgutils.h" #include "internal.h" typedef struct PCXContext { @@ -106,6 +107,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int bpp, nplanes, i, y, line_bytes, written, ret, max_pkt_size; const uint32_t *pal = NULL; + uint32_t palette256[256]; const uint8_t *src; *pict = *frame; @@ -127,6 +129,11 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, case PIX_FMT_RGB4_BYTE: case PIX_FMT_BGR4_BYTE: case PIX_FMT_GRAY8: + bpp = 8; + nplanes = 1; + ff_set_systematic_pal2(palette256, avctx->pix_fmt); + pal = palette256; + break; case PIX_FMT_PAL8: bpp = 8; nplanes = 1; @@ -146,10 +153,8 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, line_bytes = (line_bytes + 1) & ~1; max_pkt_size = 128 + avctx->height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0); - if ((ret = ff_alloc_packet(pkt, max_pkt_size)) < 0) { - av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", max_pkt_size); + if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0) return ret; - } buf = pkt->data; buf_end = pkt->data + pkt->size; |