Commit 93abdbf2 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #12041 from mshabunin:fix-static-2

parents 391b9586 e0603bb4
...@@ -859,6 +859,13 @@ public: ...@@ -859,6 +859,13 @@ public:
*/ */
TermCriteria(int type, int maxCount, double epsilon); TermCriteria(int type, int maxCount, double epsilon);
inline bool isValid() const
{
const bool isCount = (type & COUNT) && maxCount > 0;
const bool isEps = (type & EPS) && !cvIsNaN(epsilon);
return isCount || isEps;
}
int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS
int maxCount; //!< the maximum number of iterations/elements int maxCount; //!< the maximum number of iterations/elements
double epsilon; //!< the desired accuracy double epsilon; //!< the desired accuracy
......
...@@ -629,7 +629,6 @@ CV_INLINE int cvIplDepth( int type ) ...@@ -629,7 +629,6 @@ CV_INLINE int cvIplDepth( int type )
#define CV_TYPE_NAME_MATND "opencv-nd-matrix" #define CV_TYPE_NAME_MATND "opencv-nd-matrix"
#define CV_MAX_DIM 32 #define CV_MAX_DIM 32
#define CV_MAX_DIM_HEAP 1024
/** /**
@deprecated consider using cv::Mat instead @deprecated consider using cv::Mat instead
......
...@@ -1725,8 +1725,8 @@ cvPtr1D( const CvArr* arr, int idx, int* _type ) ...@@ -1725,8 +1725,8 @@ cvPtr1D( const CvArr* arr, int idx, int* _type )
else else
{ {
int i, n = m->dims; int i, n = m->dims;
CV_DbgAssert( n <= CV_MAX_DIM_HEAP ); CV_DbgAssert( n <= CV_MAX_DIM );
int _idx[CV_MAX_DIM_HEAP]; int _idx[CV_MAX_DIM];
for( i = n - 1; i >= 0; i-- ) for( i = n - 1; i >= 0; i-- )
{ {
......
...@@ -302,7 +302,7 @@ static void* icvReadSparseMat( CvFileStorage* fs, CvFileNode* node ) ...@@ -302,7 +302,7 @@ static void* icvReadSparseMat( CvFileStorage* fs, CvFileNode* node )
CvFileNode* sizes_node; CvFileNode* sizes_node;
CvSeqReader reader; CvSeqReader reader;
CvSeq* elements; CvSeq* elements;
int sizes[CV_MAX_DIM_HEAP], dims, elem_type, cn; int sizes[CV_MAX_DIM], dims, elem_type, cn;
int i; int i;
sizes_node = cvGetFileNodeByName( fs, node, "sizes" ); sizes_node = cvGetFileNodeByName( fs, node, "sizes" );
...@@ -327,7 +327,7 @@ static void* icvReadSparseMat( CvFileStorage* fs, CvFileNode* node ) ...@@ -327,7 +327,7 @@ static void* icvReadSparseMat( CvFileStorage* fs, CvFileNode* node )
mat = cvCreateSparseMat( dims, sizes, elem_type ); mat = cvCreateSparseMat( dims, sizes, elem_type );
cn = CV_MAT_CN(elem_type); cn = CV_MAT_CN(elem_type);
int idx[CV_MAX_DIM_HEAP]; int idx[CV_MAX_DIM];
elements = data->data.seq; elements = data->data.seq;
cvStartReadRawData( fs, data, &reader ); cvStartReadRawData( fs, data, &reader );
......
...@@ -14,7 +14,7 @@ namespace cv { namespace dnn { ...@@ -14,7 +14,7 @@ namespace cv { namespace dnn {
class ResizeLayerImpl : public ResizeLayer class ResizeLayerImpl : public ResizeLayer
{ {
public: public:
ResizeLayerImpl(const LayerParams& params) : scaleWidth(0), scaleHeight(0) ResizeLayerImpl(const LayerParams& params) : zoomFactorWidth(0), zoomFactorHeight(0), scaleWidth(0), scaleHeight(0)
{ {
setParamsFrom(params); setParamsFrom(params);
outWidth = params.get<float>("width", 0); outWidth = params.get<float>("width", 0);
......
...@@ -4284,7 +4284,7 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst, ...@@ -4284,7 +4284,7 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst,
size_t src_step = _src.step(), src_offset = _src.offset(); size_t src_step = _src.step(), src_offset = _src.offset();
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
if (esz == 0 if (esz == 0 || src_step == 0
|| (src_offset % src_step) % esz != 0 || (src_offset % src_step) % esz != 0
|| (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F)) || (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F))
|| !(borderType == BORDER_CONSTANT || !(borderType == BORDER_CONSTANT
......
...@@ -370,6 +370,7 @@ static void cvUndistortPointsInternal( const CvMat* _src, CvMat* _dst, const CvM ...@@ -370,6 +370,7 @@ static void cvUndistortPointsInternal( const CvMat* _src, CvMat* _dst, const CvM
const CvMat* _distCoeffs, const CvMat* _distCoeffs,
const CvMat* matR, const CvMat* matP, cv::TermCriteria criteria) const CvMat* matR, const CvMat* matP, cv::TermCriteria criteria)
{ {
CV_Assert(criteria.isValid());
double A[3][3], RR[3][3], k[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0}; double A[3][3], RR[3][3], k[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
CvMat matA=cvMat(3, 3, CV_64F, A), _Dk; CvMat matA=cvMat(3, 3, CV_64F, A), _Dk;
CvMat _RR=cvMat(3, 3, CV_64F, RR); CvMat _RR=cvMat(3, 3, CV_64F, RR);
......
...@@ -158,8 +158,9 @@ public: ...@@ -158,8 +158,9 @@ public:
data.resize(size); 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()) if((m_pos == (data.size() - 1) && len > bits_free) || m_pos == data.size())
{ {
resize(int(2*data.size())); resize(int(2*data.size()));
...@@ -182,6 +183,12 @@ public: ...@@ -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() void finish()
{ {
if(bits_free == 32) if(bits_free == 32)
...@@ -1188,13 +1195,6 @@ public: ...@@ -1188,13 +1195,6 @@ public:
void operator()( const cv::Range& range ) const CV_OVERRIDE void operator()( const cv::Range& range ) const CV_OVERRIDE
{ {
const int CAT_TAB_SIZE = 4096; 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 x, y;
int i, j; int i, j;
...@@ -1300,8 +1300,8 @@ public: ...@@ -1300,8 +1300,8 @@ public:
int cat = cat_table[val + CAT_TAB_SIZE]; int cat = cat_table[val + CAT_TAB_SIZE];
//CV_Assert( cat <= 11 ); //CV_Assert( cat <= 11 );
JPUT_HUFF( cat, huff_dc_tab[is_chroma] ); output_buffer.put_val(cat, huff_dc_tab[is_chroma] );
JPUT_BITS( val - (val < 0 ? 1 : 0), cat ); output_buffer.put_bits( val - (val < 0 ? 1 : 0), cat );
} }
for( j = 1; j < 64; j++ ) for( j = 1; j < 64; j++ )
...@@ -1316,15 +1316,15 @@ public: ...@@ -1316,15 +1316,15 @@ public:
{ {
while( run >= 16 ) while( run >= 16 )
{ {
JPUT_HUFF( 0xF0, htable ); // encode 16 zeros output_buffer.put_val( 0xF0, htable ); // encode 16 zeros
run -= 16; run -= 16;
} }
{ {
int cat = cat_table[val + CAT_TAB_SIZE]; int cat = cat_table[val + CAT_TAB_SIZE];
//CV_Assert( cat <= 10 ); //CV_Assert( cat <= 10 );
JPUT_HUFF( cat + run*16, htable ); output_buffer.put_val( cat + run*16, htable );
JPUT_BITS( val - (val < 0 ? 1 : 0), cat ); output_buffer.put_bits( val - (val < 0 ? 1 : 0), cat );
} }
run = 0; run = 0;
...@@ -1333,7 +1333,7 @@ public: ...@@ -1333,7 +1333,7 @@ public:
if( run ) if( run )
{ {
JPUT_HUFF( 0x00, htable ); // encode EOB output_buffer.put_val( 0x00, htable ); // encode EOB
} }
} }
} }
......
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