|
@@ -620,9 +620,18 @@ CImageBasis::CImageBasis(string _name, CImageBasis *_copyfrom)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (name == "tmpImage") {
|
|
if (name == "tmpImage") {
|
|
|
- rgb_image = static_cast<uint8_t*>(psram_reserve_shared_tmp_image_memory());
|
|
|
|
|
|
|
+ rgb_image = static_cast<uint8_t*>(psram_reserve_shared_tmp_image_memory(imageSize));
|
|
|
ownsSharedTempImageLease = (rgb_image != NULL);
|
|
ownsSharedTempImageLease = (rgb_image != NULL);
|
|
|
- memsize = (rgb_image != NULL) ? static_cast<int>(imageSize) : 0;
|
|
|
|
|
|
|
+ if (ownsSharedTempImageLease) {
|
|
|
|
|
+ memsize = static_cast<int>(imageSize);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // High-resolution camera frames can exceed the fixed shared workspace.
|
|
|
|
|
+ // Keep the frame in PSRAM heap rather than writing past the shared region.
|
|
|
|
|
+ rgb_image = static_cast<uint8_t*>(malloc_psram_heap(
|
|
|
|
|
+ std::string(TAG) + "->CImageBasis (" + name + " fallback)", imageSize,
|
|
|
|
|
+ MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
|
|
|
|
|
+ memsize = (rgb_image != NULL) ? static_cast<int>(imageSize) : 0;
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
rgb_image = static_cast<uint8_t*>(malloc_psram_heap(
|
|
rgb_image = static_cast<uint8_t*>(malloc_psram_heap(
|
|
|
std::string(TAG) + "->CImageBasis (" + name + ")", imageSize,
|
|
std::string(TAG) + "->CImageBasis (" + name + ")", imageSize,
|