|
|
@ -42,6 +42,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "precomp.hpp" |
|
|
|
#include "precomp.hpp" |
|
|
|
#include "bitstrm.hpp" |
|
|
|
#include "bitstrm.hpp" |
|
|
|
|
|
|
|
#include "utils.hpp" |
|
|
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
namespace cv |
|
|
|
{ |
|
|
|
{ |
|
|
@ -164,7 +165,7 @@ void RBaseStream::release() |
|
|
|
|
|
|
|
|
|
|
|
void RBaseStream::setPos( int pos ) |
|
|
|
void RBaseStream::setPos( int pos ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert( isOpened() && pos >= 0 ); |
|
|
|
CV_Assert(isOpened() && pos >= 0); |
|
|
|
|
|
|
|
|
|
|
|
if( !m_file ) |
|
|
|
if( !m_file ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -181,14 +182,19 @@ void RBaseStream::setPos( int pos ) |
|
|
|
|
|
|
|
|
|
|
|
int RBaseStream::getPos() |
|
|
|
int RBaseStream::getPos() |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert( isOpened() ); |
|
|
|
CV_Assert(isOpened()); |
|
|
|
return m_block_pos + (int)(m_current - m_start); |
|
|
|
int pos = validateToInt((m_current - m_start) + m_block_pos); |
|
|
|
|
|
|
|
CV_Assert(pos >= m_block_pos); // overflow check
|
|
|
|
|
|
|
|
CV_Assert(pos >= 0); // overflow check
|
|
|
|
|
|
|
|
return pos; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RBaseStream::skip( int bytes ) |
|
|
|
void RBaseStream::skip( int bytes ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert( bytes >= 0 ); |
|
|
|
CV_Assert(bytes >= 0); |
|
|
|
|
|
|
|
uchar* old = m_current; |
|
|
|
m_current += bytes; |
|
|
|
m_current += bytes; |
|
|
|
|
|
|
|
CV_Assert(m_current >= old); // overflow check
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///////////////////////// RLByteStream ////////////////////////////
|
|
|
|
///////////////////////// RLByteStream ////////////////////////////
|
|
|
@ -220,7 +226,7 @@ int RLByteStream::getBytes( void* buffer, int count ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uchar* data = (uchar*)buffer; |
|
|
|
uchar* data = (uchar*)buffer; |
|
|
|
int readed = 0; |
|
|
|
int readed = 0; |
|
|
|
assert( count >= 0 ); |
|
|
|
CV_Assert(count >= 0); |
|
|
|
|
|
|
|
|
|
|
|
while( count > 0 ) |
|
|
|
while( count > 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -371,7 +377,7 @@ void WBaseStream::writeBlock() |
|
|
|
{ |
|
|
|
{ |
|
|
|
int size = (int)(m_current - m_start); |
|
|
|
int size = (int)(m_current - m_start); |
|
|
|
|
|
|
|
|
|
|
|
assert( isOpened() ); |
|
|
|
CV_Assert(isOpened()); |
|
|
|
if( size == 0 ) |
|
|
|
if( size == 0 ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -442,7 +448,7 @@ void WBaseStream::release() |
|
|
|
|
|
|
|
|
|
|
|
int WBaseStream::getPos() |
|
|
|
int WBaseStream::getPos() |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert( isOpened() ); |
|
|
|
CV_Assert(isOpened()); |
|
|
|
return m_block_pos + (int)(m_current - m_start); |
|
|
|
return m_block_pos + (int)(m_current - m_start); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -465,7 +471,7 @@ void WLByteStream::putBytes( const void* buffer, int count ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uchar* data = (uchar*)buffer; |
|
|
|
uchar* data = (uchar*)buffer; |
|
|
|
|
|
|
|
|
|
|
|
assert( data && m_current && count >= 0 ); |
|
|
|
CV_Assert(data && m_current && count >= 0); |
|
|
|
|
|
|
|
|
|
|
|
while( count ) |
|
|
|
while( count ) |
|
|
|
{ |
|
|
|
{ |
|
|
|