|
|
|
@ -42,6 +42,7 @@ |
|
|
|
|
|
|
|
|
|
#include "precomp.hpp" |
|
|
|
|
#include "bitstrm.hpp" |
|
|
|
|
#include "utils.hpp" |
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
@ -165,7 +166,7 @@ void RBaseStream::release() |
|
|
|
|
|
|
|
|
|
void RBaseStream::setPos( int pos ) |
|
|
|
|
{ |
|
|
|
|
assert( isOpened() && pos >= 0 ); |
|
|
|
|
CV_Assert(isOpened() && pos >= 0); |
|
|
|
|
|
|
|
|
|
if( !m_file ) |
|
|
|
|
{ |
|
|
|
@ -182,14 +183,19 @@ void RBaseStream::setPos( int pos ) |
|
|
|
|
|
|
|
|
|
int RBaseStream::getPos() |
|
|
|
|
{ |
|
|
|
|
assert( isOpened() ); |
|
|
|
|
return m_block_pos + (int)(m_current - m_start); |
|
|
|
|
CV_Assert(isOpened()); |
|
|
|
|
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 ) |
|
|
|
|
{ |
|
|
|
|
assert( bytes >= 0 ); |
|
|
|
|
CV_Assert(bytes >= 0); |
|
|
|
|
uchar* old = m_current; |
|
|
|
|
m_current += bytes; |
|
|
|
|
CV_Assert(m_current >= old); // overflow check
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///////////////////////// RLByteStream ////////////////////////////
|
|
|
|
@ -221,7 +227,7 @@ int RLByteStream::getBytes( void* buffer, int count ) |
|
|
|
|
{ |
|
|
|
|
uchar* data = (uchar*)buffer; |
|
|
|
|
int readed = 0; |
|
|
|
|
assert( count >= 0 ); |
|
|
|
|
CV_Assert(count >= 0); |
|
|
|
|
|
|
|
|
|
while( count > 0 ) |
|
|
|
|
{ |
|
|
|
@ -373,7 +379,7 @@ void WBaseStream::writeBlock() |
|
|
|
|
{ |
|
|
|
|
int size = (int)(m_current - m_start); |
|
|
|
|
|
|
|
|
|
assert( isOpened() ); |
|
|
|
|
CV_Assert(isOpened()); |
|
|
|
|
if( size == 0 ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
@ -444,7 +450,7 @@ void WBaseStream::release() |
|
|
|
|
|
|
|
|
|
int WBaseStream::getPos() |
|
|
|
|
{ |
|
|
|
|
assert( isOpened() ); |
|
|
|
|
CV_Assert(isOpened()); |
|
|
|
|
return m_block_pos + (int)(m_current - m_start); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -467,7 +473,7 @@ void WLByteStream::putBytes( const void* buffer, int count ) |
|
|
|
|
{ |
|
|
|
|
uchar* data = (uchar*)buffer; |
|
|
|
|
|
|
|
|
|
assert( data && m_current && count >= 0 ); |
|
|
|
|
CV_Assert(data && m_current && count >= 0); |
|
|
|
|
|
|
|
|
|
while( count ) |
|
|
|
|
{ |
|
|
|
|