diff options
Diffstat (limited to 'libavcodec/bmp.c')
-rw-r--r-- | libavcodec/bmp.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 21ebeec694..22973aa52d 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -2,20 +2,20 @@ * BMP image format decoder * Copyright (c) 2005 Mans Rullgard * - * 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 */ @@ -171,17 +171,15 @@ static int bmp_decode_frame(AVCodecContext *avctx, else avctx->pix_fmt = PIX_FMT_GRAY8; break; + case 1: case 4: if(hsize - ihsize - 14 > 0){ avctx->pix_fmt = PIX_FMT_PAL8; }else{ - av_log(avctx, AV_LOG_ERROR, "Unknown palette for 16-colour BMP\n"); + av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth); return -1; } break; - case 1: - avctx->pix_fmt = PIX_FMT_MONOBLACK; - break; default: av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); return -1; @@ -245,7 +243,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, buf = buf0 + 14 + ihsize; //palette location if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry for(i = 0; i < colors; i++) - ((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf); + ((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf); }else{ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf); @@ -265,6 +263,22 @@ static int bmp_decode_frame(AVCodecContext *avctx, }else{ switch(depth){ case 1: + for(i = 0; i < avctx->height; i++){ + int j; + for(j = 0; j < n; j++){ + ptr[j*8+0] = buf[j] >> 7; + ptr[j*8+1] = (buf[j] >> 6) & 1; + ptr[j*8+2] = (buf[j] >> 5) & 1; + ptr[j*8+3] = (buf[j] >> 4) & 1; + ptr[j*8+4] = (buf[j] >> 3) & 1; + ptr[j*8+5] = (buf[j] >> 2) & 1; + ptr[j*8+6] = (buf[j] >> 1) & 1; + ptr[j*8+7] = buf[j] & 1; + } + buf += n; + ptr += linesize; + } + break; case 8: case 24: for(i = 0; i < avctx->height; i++){ |