diff --git a/modules/videoio/src/cap_mjpeg_encoder.cpp b/modules/videoio/src/cap_mjpeg_encoder.cpp index 0503f2f94d..0e7cc7d279 100644 --- a/modules/videoio/src/cap_mjpeg_encoder.cpp +++ b/modules/videoio/src/cap_mjpeg_encoder.cpp @@ -384,7 +384,7 @@ public: } else { - data[m_pos] |= (tempval << bits_free); + data[m_pos] |= (bits_free == 32) ? tempval : (tempval << bits_free); } }