]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bmp.c
mpegaudiodec: move imdct and windowing function to mpegaudiodsp
[ffmpeg] / libavcodec / bmp.c
index b7fee130bc3ebbeb45d06906f99270a0e3398311..f438d10613a3b9e0e3be2226d8c2008f79103eee 100644 (file)
@@ -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++){
@@ -336,14 +350,13 @@ static av_cold int bmp_decode_end(AVCodecContext *avctx)
 }
 
 AVCodec ff_bmp_decoder = {
-    "bmp",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_BMP,
-    sizeof(BMPContext),
-    bmp_decode_init,
-    NULL,
-    bmp_decode_end,
-    bmp_decode_frame,
-    CODEC_CAP_DR1,
+    .name           = "bmp",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_BMP,
+    .priv_data_size = sizeof(BMPContext),
+    .init           = bmp_decode_init,
+    .close          = bmp_decode_end,
+    .decode         = bmp_decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("BMP image"),
 };