diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index 8c554c41c57029be14b0db9004ee49d38302949c..b6fe0534ef043d6ef1abb43f8244b2f4141eccb3 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -83,6 +83,14 @@ static int raw_init_decoder(AVCodecContext *avctx)
 
     if (avctx->codec_tag)
         avctx->pix_fmt = findPixelFormat(avctx->codec_tag);
+    else if (avctx->bits_per_sample){
+        switch(avctx->bits_per_sample){
+        case 15: avctx->pix_fmt= PIX_FMT_RGB555; break;
+        case 16: avctx->pix_fmt= PIX_FMT_RGB565; break;
+        case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break;
+        case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break;
+        }
+    }
     
     context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
     context->buffer = av_malloc(context->length);
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 1c477606271c4f20d6d4196cc031462da1a1b83e..1306efeb2d542e744955864a9209472321598cc2 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -164,6 +164,7 @@ const CodecTag codec_bmp_tags[] = {
     { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
     { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
     { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
+    { CODEC_ID_RAWVIDEO, 0 },
     { 0, 0 },
 };