mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Fixed several issues found by static analysis tools
This commit is contained in:
@@ -158,8 +158,9 @@ public:
|
||||
data.resize(size);
|
||||
}
|
||||
|
||||
void put(unsigned bits, int len)
|
||||
inline void put_bits(unsigned bits, int len)
|
||||
{
|
||||
CV_Assert(len >=0 && len < 32);
|
||||
if((m_pos == (data.size() - 1) && len > bits_free) || m_pos == data.size())
|
||||
{
|
||||
resize(int(2*data.size()));
|
||||
@@ -182,6 +183,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline void put_val(int val, const unsigned * table)
|
||||
{
|
||||
unsigned code = table[(val) + 2];
|
||||
put_bits(code >> 8, (int)(code & 255));
|
||||
}
|
||||
|
||||
void finish()
|
||||
{
|
||||
if(bits_free == 32)
|
||||
@@ -1188,13 +1195,6 @@ public:
|
||||
void operator()( const cv::Range& range ) const CV_OVERRIDE
|
||||
{
|
||||
const int CAT_TAB_SIZE = 4096;
|
||||
unsigned code = 0;
|
||||
|
||||
#define JPUT_BITS(val, bits) output_buffer.put(val, bits)
|
||||
|
||||
#define JPUT_HUFF(val, table) \
|
||||
code = table[(val) + 2]; \
|
||||
JPUT_BITS(code >> 8, (int)(code & 255))
|
||||
|
||||
int x, y;
|
||||
int i, j;
|
||||
@@ -1300,8 +1300,8 @@ public:
|
||||
int cat = cat_table[val + CAT_TAB_SIZE];
|
||||
|
||||
//CV_Assert( cat <= 11 );
|
||||
JPUT_HUFF( cat, huff_dc_tab[is_chroma] );
|
||||
JPUT_BITS( val - (val < 0 ? 1 : 0), cat );
|
||||
output_buffer.put_val(cat, huff_dc_tab[is_chroma] );
|
||||
output_buffer.put_bits( val - (val < 0 ? 1 : 0), cat );
|
||||
}
|
||||
|
||||
for( j = 1; j < 64; j++ )
|
||||
@@ -1316,15 +1316,15 @@ public:
|
||||
{
|
||||
while( run >= 16 )
|
||||
{
|
||||
JPUT_HUFF( 0xF0, htable ); // encode 16 zeros
|
||||
output_buffer.put_val( 0xF0, htable ); // encode 16 zeros
|
||||
run -= 16;
|
||||
}
|
||||
|
||||
{
|
||||
int cat = cat_table[val + CAT_TAB_SIZE];
|
||||
//CV_Assert( cat <= 10 );
|
||||
JPUT_HUFF( cat + run*16, htable );
|
||||
JPUT_BITS( val - (val < 0 ? 1 : 0), cat );
|
||||
output_buffer.put_val( cat + run*16, htable );
|
||||
output_buffer.put_bits( val - (val < 0 ? 1 : 0), cat );
|
||||
}
|
||||
|
||||
run = 0;
|
||||
@@ -1333,7 +1333,7 @@ public:
|
||||
|
||||
if( run )
|
||||
{
|
||||
JPUT_HUFF( 0x00, htable ); // encode EOB
|
||||
output_buffer.put_val( 0x00, htable ); // encode EOB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user