diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index df1ce1e2b83c3a16e54d4973767048109cda9e55..6b1a03b9c8244696564a6008a92ceb77a8e8ccd2 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1272,7 +1272,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
     }
 
     if (!Al) {
-        s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
+        s->coefs_finished[c] |= (2ULL << se) - (1ULL << ss);
         last_scan = !~s->coefs_finished[c];
     }