fixed mjpeg encoder so that libjpeg-based decoder does not complain on extra bytes in the end of stream
This commit is contained in:
parent
dcf177e372
commit
d825b7ee9a
@ -552,11 +552,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
|
||||
}
|
||||
|
||||
|
||||
static Ptr<IVideoCapture> IVideoCapture_create(const String&)
|
||||
static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
|
||||
{
|
||||
Ptr<IVideoCapture> capture;
|
||||
|
||||
//capture = createMotionJpegCapture(filename);
|
||||
capture = createMotionJpegCapture(filename);
|
||||
if (capture && capture->isOpened())
|
||||
{
|
||||
return capture;
|
||||
|
@ -248,6 +248,25 @@ public:
|
||||
writeBlock();
|
||||
}
|
||||
|
||||
void jflush(unsigned currval, int bitIdx)
|
||||
{
|
||||
uchar v;
|
||||
uchar* ptr = m_current;
|
||||
currval |= (1 << bitIdx)-1;
|
||||
while( bitIdx < 32 )
|
||||
{
|
||||
v = (uchar)(currval >> 24);
|
||||
*ptr++ = v;
|
||||
if( v == 255 )
|
||||
*ptr++ = 0;
|
||||
currval <<= 8;
|
||||
bitIdx += 8;
|
||||
}
|
||||
m_current = ptr;
|
||||
if( m_current >= m_end )
|
||||
writeBlock();
|
||||
}
|
||||
|
||||
static bool createEncodeHuffmanTable( const int* src, unsigned* table, int max_size )
|
||||
{
|
||||
int i, k;
|
||||
@ -1440,7 +1459,7 @@ void MotionJpegWriter::writeFrameData( const uchar* data, int step, int colorspa
|
||||
}
|
||||
|
||||
// Flush
|
||||
JPUT_BITS((unsigned)-1, bit_idx & 31);
|
||||
strm.jflush(currval, bit_idx);
|
||||
strm.jputShort( 0xFFD9 ); // EOI marker
|
||||
/*printf("total dct = %.1fms, total cvt = %.1fms\n",
|
||||
total_dct*1000./cv::getTickFrequency(),
|
||||
|
Loading…
Reference in New Issue
Block a user