diff options
Diffstat (limited to 'libavcodec/bmpenc.c')
-rw-r--r-- | libavcodec/bmpenc.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index 0bbbb61315..1c40b13add 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -3,20 +3,20 @@ * Copyright (c) 2006, 2007 Michel Bardiaux * 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 */ @@ -24,6 +24,7 @@ #include "avcodec.h" #include "bytestream.h" #include "bmp.h" +#include <assert.h> #include "internal.h" static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF }; @@ -37,6 +38,9 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){ avctx->coded_frame = &s->picture; switch (avctx->pix_fmt) { + case PIX_FMT_BGRA: + avctx->bits_per_coded_sample = 32; + break; case PIX_FMT_BGR24: avctx->bits_per_coded_sample = 24; break; @@ -71,6 +75,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrame * const p = &s->picture; int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret; const uint32_t *pal = NULL; + uint32_t palette256[256]; int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB; int bit_count = avctx->bits_per_coded_sample; uint8_t *ptr, *buf; @@ -93,7 +98,10 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, case PIX_FMT_RGB4_BYTE: case PIX_FMT_BGR4_BYTE: case PIX_FMT_GRAY8: - ff_set_systematic_pal2((uint32_t*)p->data[1], avctx->pix_fmt); + assert(bit_count == 8); + ff_set_systematic_pal2(palette256, avctx->pix_fmt); + pal = palette256; + break; case PIX_FMT_PAL8: pal = (uint32_t *)p->data[1]; break; @@ -167,8 +175,8 @@ AVCodec ff_bmp_encoder = { .init = bmp_encode_init, .encode2 = bmp_encode_frame, .pix_fmts = (const enum PixelFormat[]){ - PIX_FMT_BGR24, - PIX_FMT_RGB555, PIX_FMT_RGB444, PIX_FMT_RGB565, + PIX_FMT_BGRA, PIX_FMT_BGR24, + PIX_FMT_RGB565, PIX_FMT_RGB555, PIX_FMT_RGB444, PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8, PIX_FMT_MONOBLACK, PIX_FMT_NONE}, |