| 221 | \****************************************************************************************/ |
| 222 | |
| 223 | CV_IMPL CvMatND* |
| 224 | cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, |
| 225 | int type, void* data ) |
| 226 | { |
| 227 | type = CV_MAT_TYPE(type); |
| 228 | int64 step = CV_ELEM_SIZE(type); |
| 229 | |
| 230 | if( !mat ) |
| 231 | CV_Error( CV_StsNullPtr, "NULL matrix header pointer" ); |
| 232 | |
| 233 | if( step == 0 ) |
| 234 | CV_Error( CV_StsUnsupportedFormat, "invalid array data type" ); |
| 235 | |
| 236 | if( !sizes ) |
| 237 | CV_Error( CV_StsNullPtr, "NULL <sizes> pointer" ); |
| 238 | |
| 239 | if( dims <= 0 || dims > CV_MAX_DIM ) |
| 240 | CV_Error( CV_StsOutOfRange, |
| 241 | "non-positive or too large number of dimensions" ); |
| 242 | |
| 243 | for( int i = dims - 1; i >= 0; i-- ) |
| 244 | { |
| 245 | if( sizes[i] < 0 ) |
| 246 | CV_Error( CV_StsBadSize, "one of dimesion sizes is non-positive" ); |
| 247 | mat->dim[i].size = sizes[i]; |
| 248 | if( step > INT_MAX ) |
| 249 | CV_Error( CV_StsOutOfRange, "The array is too big" ); |
| 250 | mat->dim[i].step = (int)step; |
| 251 | step *= sizes[i]; |
| 252 | } |
| 253 | |
| 254 | mat->type = CV_MATND_MAGIC_VAL | (step <= INT_MAX ? CV_MAT_CONT_FLAG : 0) | type; |
| 255 | mat->dims = dims; |
| 256 | mat->data.ptr = (uchar*)data; |
| 257 | mat->refcount = 0; |
| 258 | mat->hdr_refcount = 0; |
| 259 | return mat; |
| 260 | } |
| 261 | |
| 262 | |
| 263 | // Creates CvMatND and underlying data |
no outgoing calls
no test coverage detected