diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index e6e27042fd6dc3eb7b90f09e751186a24189bc24..4412b68b2c66a92e5a7cc835c23545d48fbb2f72 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -201,7 +201,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
         case NAL_SLICE:
         case NAL_IDR_SLICE:
             // Do not walk the whole buffer just to decode slice header
-            if (state & 0x1f == NAL_IDR_SLICE || (state >> 5) & 0x3 == 0) {
+            if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
                 /* IDR or disposable slice
                  * No need to decode many bytes because MMCOs shall not be present. */
                 if (src_length > 60)