mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #12570 from alalek:drop_usrtype1
* core: drop usage of CV_USRTYPE1 in OpenCV avoid OpenCV crashes due size change CV_ELEM_SIZE(CV_USRTYPE1): 8 -> 2 * ! fix persistence internal types
This commit is contained in:
committed by
GitHub
parent
861415133e
commit
5fb0f34e8a
@@ -515,11 +515,13 @@ void make_write_struct_delayed( CvFileStorage* fs, const char* key, int struct_f
|
||||
fs->is_write_struct_delayed = true;
|
||||
}
|
||||
|
||||
// FIXIT: conflict with 8UC8 (replacement for CV_USRTYPE1)
|
||||
static const char symbols[9] = "ucwsifdr";
|
||||
|
||||
char icvTypeSymbol(int depth)
|
||||
static char icvTypeSymbol(int depth)
|
||||
{
|
||||
CV_Assert(depth >=0 && depth < 9);
|
||||
CV_StaticAssert(CV_64F == 6, "");
|
||||
CV_Assert(depth >=0 && depth <= CV_64F);
|
||||
return symbols[depth];
|
||||
}
|
||||
|
||||
@@ -528,13 +530,17 @@ static int icvSymbolToType(char c)
|
||||
const char* pos = strchr( symbols, c );
|
||||
if( !pos )
|
||||
CV_Error( CV_StsBadArg, "Invalid data type specification" );
|
||||
if (c == 'r')
|
||||
return CV_SEQ_ELTYPE_PTR;
|
||||
return static_cast<int>(pos - symbols);
|
||||
}
|
||||
|
||||
char* icvEncodeFormat( int elem_type, char* dt )
|
||||
char* icvEncodeFormat(int elem_type, char* dt)
|
||||
{
|
||||
sprintf( dt, "%d%c", CV_MAT_CN(elem_type), icvTypeSymbol(CV_MAT_DEPTH(elem_type)) );
|
||||
return dt + ( dt[2] == '\0' && dt[0] == '1' );
|
||||
int cn = (elem_type == CV_SEQ_ELTYPE_PTR/*CV_USRTYPE1*/) ? 1 : CV_MAT_CN(elem_type);
|
||||
char symbol = (elem_type == CV_SEQ_ELTYPE_PTR/*CV_USRTYPE1*/) ? 'r' : icvTypeSymbol(CV_MAT_DEPTH(elem_type));
|
||||
sprintf(dt, "%d%c", cn, symbol);
|
||||
return dt + (cn == 1 ? 1 : 0);
|
||||
}
|
||||
|
||||
int icvDecodeFormat( const char* dt, int* fmt_pairs, int max_len )
|
||||
|
||||
Reference in New Issue
Block a user