From 0bc5140b17087776d48b640d24462d0057e973a5 Mon Sep 17 00:00:00 2001 From: Marina Kolpakova Date: Fri, 16 Mar 2012 14:11:39 +0000 Subject: [PATCH] allocate CPU memory if Tegra GPU allocator failed. --- modules/core/src/matrix.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index cf1bbfe..1c93f9e 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -217,8 +217,23 @@ void Mat::create(int d, const int* _sizes, int _type) } else { +#ifdef HAVE_TGPU + try + { + allocator->allocate(dims, size, _type, refcount, datastart, data, step.p); + CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); + }catch(...) + { + allocator = 0; + size_t total = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount)); + data = datastart = (uchar*)fastMalloc(total + (int)sizeof(*refcount)); + refcount = (int*)(data + total); + *refcount = 1; + } +#else allocator->allocate(dims, size, _type, refcount, datastart, data, step.p); CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); +#endif } } -- 2.7.4