diff options
author | Cho KyongHo <pullip.cho@samsung.com> | 2019-08-14 20:48:42 +0900 |
---|---|---|
committer | Cho KyongHo <pullip.cho@samsung.com> | 2020-02-20 21:34:34 -0800 |
commit | 376a9251edbb8fd8ff6d1bd9055499dd36ae06b6 (patch) | |
tree | a9a179c2527e9fb968d2926cf717f1e52ffc3835 /libhwjpeg/ExynosJpegEncoderForCamera.cpp | |
parent | 01ca34c1bb0969c968e2ab109675243c097045d7 (diff) |
libhwjpeg: introduce polymorphic thumbnail scaler
LibScalerForJpeg is the only thumbnail scaler implemented with the
legacy V4L2 MSCL driver. But we may need to use another types of
thumbnail scaler that runs with different H/W or different API.
Therefore abstract calss, ThumbnailScaler is introduced and the
concrete object of the thumbnail scaler is created with
ThumbnailScaler::createInstance(). All the implementation details
and differences between products are handled in createInstance().
Change-Id: Ibef2693ca6ea9e23f8993c9e525e58ac54a22333
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
Diffstat (limited to 'libhwjpeg/ExynosJpegEncoderForCamera.cpp')
-rw-r--r-- | libhwjpeg/ExynosJpegEncoderForCamera.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/libhwjpeg/ExynosJpegEncoderForCamera.cpp b/libhwjpeg/ExynosJpegEncoderForCamera.cpp index 39e877e..ed09cb8 100644 --- a/libhwjpeg/ExynosJpegEncoderForCamera.cpp +++ b/libhwjpeg/ExynosJpegEncoderForCamera.cpp @@ -27,7 +27,7 @@ #include "hwjpeg-internal.h" #include "AppMarkerWriter.h" -#include "LibScalerForJpeg.h" +#include "ThumbnailScaler.h" #include "IFDWriter.h" // Data length written by H/W without the scan data. @@ -105,6 +105,8 @@ ExynosJpegEncoderForCamera::ExynosJpegEncoderForCamera(bool bBTBComp) m_extraInfo.appInfo = m_appInfo; + mThumbnailScaler.reset(ThumbnailScaler::createInstance()); + ALOGD("ExynosJpegEncoderForCamera Created: %p, ION %d", this, m_fdIONClient); } @@ -581,42 +583,47 @@ bool ExynosJpegEncoderForCamera::GenerateThumbnailImage() ALOGD("Generating thumbnail image: %dx%d -> %dx%d", main_width, main_height, m_nThumbWidth, m_nThumbHeight); - if (!m_pLibScaler.SetSrcImage(main_width, main_height, v4l2Format)) { - ALOGE("Failed to configure the main image format to LibScalerForJpeg"); + if (!mThumbnailScaler) { + ALOGE("Thumbnail scaler is not prepared"); + return false; + } + + if (!mThumbnailScaler->SetSrcImage(main_width, main_height, v4l2Format)) { + ALOGE("Failed to configure the main image to the thumbnail scaler"); return false; } - if (!m_pLibScaler.SetDstImage(m_nThumbWidth, m_nThumbHeight, GetThumbnailFormat(v4l2Format))) { - ALOGE("Failed to configure the target image format to LibScalerForJpeg"); + if (!mThumbnailScaler->SetDstImage(m_nThumbWidth, m_nThumbHeight, GetThumbnailFormat(v4l2Format))) { + ALOGE("Failed to configure the target image to the thumbnail scaler"); return false; } bool okay = false; if (checkInBufType() == JPEG_BUF_TYPE_USER_PTR) { - char *bufs[SCALER_MAX_PLANES]; - int len_srcbufs[SCALER_MAX_PLANES]; + char *bufs[ThumbnailScaler::SCALER_MAX_PLANES]; + int len_srcbufs[ThumbnailScaler::SCALER_MAX_PLANES]; - if (getInBuf(bufs, len_srcbufs, SCALER_MAX_PLANES) < 0) { + if (getInBuf(bufs, len_srcbufs, ThumbnailScaler::SCALER_MAX_PLANES) < 0) { ALOGE("Failed to retrieve the main image buffers"); return false; } - okay = m_pLibScaler.RunStream(bufs, len_srcbufs, m_fdIONThumbImgBuffer, m_szIONThumbImgBuffer); + okay = mThumbnailScaler->RunStream(bufs, len_srcbufs, m_fdIONThumbImgBuffer, m_szIONThumbImgBuffer); } else { // mainbuftype == JPEG_BUF_TYPE_DMA_BUF - int bufs[SCALER_MAX_PLANES]; - int len_srcbufs[SCALER_MAX_PLANES]; + int bufs[ThumbnailScaler::SCALER_MAX_PLANES]; + int len_srcbufs[ThumbnailScaler::SCALER_MAX_PLANES]; - if (getInBuf(bufs, len_srcbufs, SCALER_MAX_PLANES) < 0) { + if (getInBuf(bufs, len_srcbufs, ThumbnailScaler::SCALER_MAX_PLANES) < 0) { ALOGE("Failed to retrieve the main image buffers"); return false; } - okay = m_pLibScaler.RunStream(bufs, len_srcbufs, m_fdIONThumbImgBuffer, m_szIONThumbImgBuffer); + okay = mThumbnailScaler->RunStream(bufs, len_srcbufs, m_fdIONThumbImgBuffer, m_szIONThumbImgBuffer); } if (!okay) { - ALOGE("Failed to convert the main image to thumbnail with LibScalerForJpeg"); + ALOGE("Failed to convert the main image to thumbnail with the thumbnail scaler"); return false; } |