Commit e2fe0ca8 authored by kalistratovag's avatar kalistratovag

Removing deadcode blocks, redudant variable & initializing all vars in constructor

Adding &31 to bit shift in order to silince coverity BAD_SHIFT defect

add default_stripes_count const
parent ca692b98
...@@ -433,7 +433,6 @@ private: ...@@ -433,7 +433,6 @@ private:
std::vector<unsigned> data; std::vector<unsigned> data;
int bits_free; int bits_free;
unsigned m_pos; unsigned m_pos;
bool m_is_full;
unsigned m_data_len; unsigned m_data_len;
}; };
...@@ -443,7 +442,7 @@ class mjpeg_buffer_keeper ...@@ -443,7 +442,7 @@ class mjpeg_buffer_keeper
public: public:
mjpeg_buffer_keeper() mjpeg_buffer_keeper()
{ {
m_last_bit_len = 0; reset();
} }
mjpeg_buffer& operator[](int i) mjpeg_buffer& operator[](int i)
...@@ -496,7 +495,7 @@ public: ...@@ -496,7 +495,7 @@ public:
} }
else else
{ {
memcpy(&m_output_buffer[current_pos], buffer.get_data(), sizeof(buffer.get_data()[0])*(buffer.get_len() -1 )); memcpy(&m_output_buffer[current_pos], buffer.get_data(), sizeof(buffer.get_data()[0])*(buffer.get_len() - 1 ));
m_data_len += buffer.get_len() - 1; m_data_len += buffer.get_len() - 1;
currval = buffer.get_data()[buffer.get_len() - 1]; currval = buffer.get_data()[buffer.get_len() - 1];
} }
...@@ -505,27 +504,20 @@ public: ...@@ -505,27 +504,20 @@ public:
{ {
for(unsigned i = 0; i < buffer.get_len() - 1; ++i) for(unsigned i = 0; i < buffer.get_len() - 1; ++i)
{ {
if( bits <= 0 ) currval |= ( (unsigned)buffer.get_data()[i] >> (31 & (-bits)) );
{
currval |= ((unsigned)buffer.get_data()[i] >> -bits);
m_output_buffer[m_data_len++] = currval; m_output_buffer[m_data_len++] = currval;
currval = (bits < 0) ? (buffer.get_data()[i] << (bits + 32)) : 0; currval = buffer.get_data()[i] << (bits + 32);
}
else
{
currval |= (buffer.get_data()[i] << bits);
}
} }
currval |= ((unsigned)buffer.get_data()[buffer.get_len() - 1] >> -bits); currval |= ( (unsigned)buffer.get_data()[buffer.get_len() - 1] >> (31 & (-bits)) );
if( (buffer.get_bits_free() == 32 ? 0 : buffer.get_bits_free()) <= -bits) if( buffer.get_bits_free() <= -bits)
{ {
m_output_buffer[m_data_len++] = currval; m_output_buffer[m_data_len++] = currval;
currval = (bits < 0) ? (buffer.get_data()[buffer.get_len() - 1] << (bits + 32)) : 0; currval = buffer.get_data()[buffer.get_len() - 1] << (bits + 32);
} }
} }
...@@ -1534,7 +1526,7 @@ public: ...@@ -1534,7 +1526,7 @@ public:
{ {
if(height*width > min_pixels_count) if(height*width > min_pixels_count)
{ {
stripes_count = 4; stripes_count = default_stripes_count;
} }
} }
else else
...@@ -1735,8 +1727,11 @@ private: ...@@ -1735,8 +1727,11 @@ private:
const short (&fdct_qtab)[2][64]; const short (&fdct_qtab)[2][64];
const uchar* cat_table; const uchar* cat_table;
int stripes_count; int stripes_count;
static const int default_stripes_count;
}; };
const int MjpegEncoder::default_stripes_count = 4;
void MotionJpegWriter::writeFrameData( const uchar* data, int step, int colorspace, int input_channels ) void MotionJpegWriter::writeFrameData( const uchar* data, int step, int colorspace, int input_channels )
{ {
//double total_cvt = 0, total_dct = 0; //double total_cvt = 0, total_dct = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment