diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index cb0364c56e8cc045239a0960ab060b884ae4885f..1ab71126275cb19e8d0c221f211cbaed38dce318 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -94,8 +94,11 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
             return AVERROR(ENOMEM);
         if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
             avpriv_set_systematic_pal2((uint32_t*)context->palette->data, avctx->pix_fmt);
-        else
+        else {
             memset(context->palette->data, 0, AVPALETTE_SIZE);
+            if (avctx->bits_per_coded_sample == 1)
+                memset(context->palette->data, 0xff, 4);
+        }
     }
 
     if ((avctx->extradata_size >= 9 &&