[FFmpeg-cvslog] bmp: fix some 1bit samples.

Carl Eugen Hoyos git at videolan.org
Mon Dec 5 00:43:09 CET 2011


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Thu Nov 10 23:07:27 2011 +0100| [1e92d58e444e482948c06bd968e99beb214f1735] | committer: Anton Khirnov

bmp: fix some 1bit samples.

<= 8bpp BMP images always have palette.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1e92d58e444e482948c06bd968e99beb214f1735
---

 libavcodec/bmp.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 21ebeec..f438d106 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -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;
@@ -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++){



More information about the ffmpeg-cvslog mailing list