Browse Source

bmp: fix some 1bit samples.

<= 8bpp BMP images always have palette.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
tags/n0.9
Carl Eugen Hoyos Anton Khirnov 13 years ago
parent
commit
1e92d58e44
1 changed files with 18 additions and 4 deletions
  1. +18
    -4
      libavcodec/bmp.c

+ 18
- 4
libavcodec/bmp.c View File

@@ -171,17 +171,15 @@ static int bmp_decode_frame(AVCodecContext *avctx,
else else
avctx->pix_fmt = PIX_FMT_GRAY8; avctx->pix_fmt = PIX_FMT_GRAY8;
break; break;
case 1:
case 4: case 4:
if(hsize - ihsize - 14 > 0){ if(hsize - ihsize - 14 > 0){
avctx->pix_fmt = PIX_FMT_PAL8; avctx->pix_fmt = PIX_FMT_PAL8;
}else{ }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; return -1;
} }
break; break;
case 1:
avctx->pix_fmt = PIX_FMT_MONOBLACK;
break;
default: default:
av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
return -1; return -1;
@@ -265,6 +263,22 @@ static int bmp_decode_frame(AVCodecContext *avctx,
}else{ }else{
switch(depth){ switch(depth){
case 1: 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 8:
case 24: case 24:
for(i = 0; i < avctx->height; i++){ for(i = 0; i < avctx->height; i++){


Loading…
Cancel
Save