camera: allow to get size of JPEG after conversion
The member function `ImageProcessor::GetConvertedSize` is called by the
`ImageProcessor::ConvertFormat` every time when conversion is performed.
But for JPEG destination format it leads to error. It is proposed to add
the handling of the JPEG format with postponed size calculation.
Test: try to take a picture via camera with YUYV output format.
Change-Id: I1ec564e2434361c82b5d93348511116494249f06
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
diff --git a/modules/camera/3_4/arc/image_processor.cpp b/modules/camera/3_4/arc/image_processor.cpp
index f0fee91..7fb6219 100644
--- a/modules/camera/3_4/arc/image_processor.cpp
+++ b/modules/camera/3_4/arc/image_processor.cpp
@@ -85,6 +85,8 @@
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_RGB32:
return width * height * 4;
+ case V4L2_PIX_FMT_JPEG:
+ return 0; // For JPEG real size will be calculated after conversion.
default:
LOGF(ERROR) << "Pixel format " << FormatToString(fourcc)
<< " is unsupported.";
@@ -388,6 +390,9 @@
return false;
}
size_t buffer_length = compressor.GetCompressedImageSize();
+ if (out_frame->SetDataSize(buffer_length)) {
+ return false;
+ }
memcpy(out_frame->GetData(), compressor.GetCompressedImagePtr(),
buffer_length);
return true;