mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Merge pull request #24209 from alexlyulkov:al/fixed-mjpeg
Fixed bug with the last 4 bytes in MJPEG encoder
This commit is contained in:
commit
21fb10c6a3
@ -268,7 +268,7 @@ public:
|
|||||||
m_buffer_list[0].finish();
|
m_buffer_list[0].finish();
|
||||||
|
|
||||||
m_data_len = m_buffer_list[0].get_len();
|
m_data_len = m_buffer_list[0].get_len();
|
||||||
m_last_bit_len = m_buffer_list[0].get_bits_free() ? 32 - m_buffer_list[0].get_bits_free() : 0;
|
m_last_bit_len = 32 - m_buffer_list[0].get_bits_free();
|
||||||
|
|
||||||
return m_buffer_list[0].get_data();
|
return m_buffer_list[0].get_data();
|
||||||
}
|
}
|
||||||
@ -331,9 +331,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//bits == 0 means that last element shouldn't be used.
|
//bits == 0 means that last element shouldn't be used.
|
||||||
m_output_buffer[m_data_len++] = currval;
|
if (bits != 0) {
|
||||||
|
m_output_buffer[m_data_len++] = currval;
|
||||||
m_last_bit_len = -bits;
|
m_last_bit_len = -bits;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_last_bit_len = 32;
|
||||||
|
}
|
||||||
|
|
||||||
return &m_output_buffer[0];
|
return &m_output_buffer[0];
|
||||||
}
|
}
|
||||||
@ -1167,8 +1172,6 @@ public:
|
|||||||
fdct_qtab(_fdct_qtab),
|
fdct_qtab(_fdct_qtab),
|
||||||
cat_table(_cat_table)
|
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.
|
//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;
|
const int min_pixels_count = 96*96;
|
||||||
|
|
||||||
@ -1194,12 +1197,6 @@ public:
|
|||||||
|
|
||||||
stripes_count = std::min(stripes_count, max_stripes);
|
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);
|
m_buffer_list.allocate_buffers(stripes_count, (height*width*2)/stripes_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user