diff --git a/modules/videoio/src/cap_mjpeg_encoder.cpp b/modules/videoio/src/cap_mjpeg_encoder.cpp index 7f4c8a6e9d..96ec488bc0 100644 --- a/modules/videoio/src/cap_mjpeg_encoder.cpp +++ b/modules/videoio/src/cap_mjpeg_encoder.cpp @@ -1167,6 +1167,8 @@ public: fdct_qtab(_fdct_qtab), cat_table(_cat_table) { +#if 0 // disable parallel processing due to buffer overrun bug: https://github.com/opencv/opencv/issues/19634 + //empirically found value. if number of pixels is less than that value there is no sense to parallelize it. const int min_pixels_count = 96*96; @@ -1176,6 +1178,7 @@ public: { if(height*width > min_pixels_count) { + const int default_stripes_count = 4; stripes_count = default_stripes_count; } } @@ -1191,6 +1194,12 @@ public: stripes_count = std::min(stripes_count, max_stripes); +#else + if (nstripes > 1) + CV_LOG_ONCE_WARNING(NULL, "VIDEOIO/MJPEG: parallel processing is disabled: https://github.com/opencv/opencv/issues/19634"); + stripes_count = 1; +#endif + m_buffer_list.allocate_buffers(stripes_count, (height*width*2)/stripes_count); } @@ -1370,11 +1379,8 @@ private: const short (&fdct_qtab)[2][64]; const uchar* cat_table; int stripes_count; - static const int default_stripes_count; }; -const int MjpegEncoder::default_stripes_count = 4; - void MotionJpegWriter::writeFrameData( const uchar* data, int step, int colorspace, int input_channels ) { //double total_cvt = 0, total_dct = 0;