Merge "camera: allow to get size of JPEG after conversion"

am: 3664a25aa7

Change-Id: I4acc12c67e8f446dcc8ab6e9f585b77bd3ab0d70
This commit is contained in:
Sergii Piatakov 2019-01-08 17:39:36 -08:00 committed by android-build-merger
commit 18033cb5d5

View file

@ -85,6 +85,8 @@ size_t ImageProcessor::GetConvertedSize(int fourcc, uint32_t width,
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 @@ static bool ConvertToJpeg(const CameraMetadata& metadata,
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;