diff --git a/libavcodec/bitstream_filter.c b/libavcodec/bitstream_filter.c
index e4be773c6e682dd7a7201ec6a04d40c59b79caa1..b52acf60a2d4a591d31f29f66c0fa4189e7d06c1 100644
--- a/libavcodec/bitstream_filter.c
+++ b/libavcodec/bitstream_filter.c
@@ -238,8 +238,10 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext
         if(lsf){
             FFSWAP(int, p[1], p[2]);
             header |= (p[1] & 0xC0)>>2;
+            p[1] &= 0x3F;
         }else{
             header |= p[1] & 0x30;
+            p[1] &= 0xCF;
         }
     }