diff options
author | Cho KyongHo <pullip.cho@samsung.com> | 2019-08-13 17:50:44 +0900 |
---|---|---|
committer | Cho KyongHo <pullip.cho@samsung.com> | 2020-02-20 21:34:34 -0800 |
commit | 8da348de51010dafbe2dd56980f9be12d8c109aa (patch) | |
tree | 8d035dcc43788a72893b0b7333c83f1acaabe88c /libhwjpeg/ExynosJpegEncoderForCamera.cpp | |
parent | 14df956ea07fdacd6ff0caab2673365564be3f2e (diff) |
libhwjpeg: refactor Set[Src|Dst]Image()
The LibScalerForJpeg is the thumbnail image generator for libhwjpeg and
the image and buffer types to LibScalerForJpeg does not vary.
Unnecessary flexibility increases the complexity of a module. So, we
should discard the support for userptr in SetDstImage().
In addition, LibScalerForJpeg requires unnecessary type casting to
libhwjpeg for SetSrcImage and SetDstImage for the historical reasion.
However, it is no longer needed because we can decide our API now.
Change-Id: Ie8eebc38bf4f09889cc001e673f128570fb642c1
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
Diffstat (limited to 'libhwjpeg/ExynosJpegEncoderForCamera.cpp')
-rw-r--r-- | libhwjpeg/ExynosJpegEncoderForCamera.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/libhwjpeg/ExynosJpegEncoderForCamera.cpp b/libhwjpeg/ExynosJpegEncoderForCamera.cpp index a05f70a..8d72eac 100644 --- a/libhwjpeg/ExynosJpegEncoderForCamera.cpp +++ b/libhwjpeg/ExynosJpegEncoderForCamera.cpp @@ -581,41 +581,36 @@ bool ExynosJpegEncoderForCamera::GenerateThumbnailImage() ALOGD("Generating thumbnail image: %dx%d -> %dx%d", main_width, main_height, m_nThumbWidth, m_nThumbHeight); - int len_srcbufs[3] = {0, 0, 0}; - void *srcbufs[3] = {NULL, NULL, NULL}; - int memtype; + bool okay = false; if (checkInBufType() == JPEG_BUF_TYPE_USER_PTR) { char *bufs[3]; + int len_srcbufs[3]; + if (getInBuf(bufs, len_srcbufs, 3) < 0) { ALOGE("Failed to retrieve the main image buffers"); return false; } - memtype = V4L2_MEMORY_USERPTR; - srcbufs[0] = reinterpret_cast<void *>(bufs[0]); - srcbufs[1] = reinterpret_cast<void *>(bufs[1]); - srcbufs[2] = reinterpret_cast<void *>(bufs[2]); + + okay = m_pLibScaler.SetSrcImage(main_width, main_height, v4l2Format, bufs); } else { // mainbuftype == JPEG_BUF_TYPE_DMA_BUF int bufs[3]; + int len_srcbufs[3]; + if (getInBuf(bufs, len_srcbufs, 3) < 0) { ALOGE("Failed to retrieve the main image buffers"); return false; } - memtype = V4L2_MEMORY_DMABUF; - srcbufs[0] = reinterpret_cast<void *>(bufs[0]); - srcbufs[1] = reinterpret_cast<void *>(bufs[1]); - srcbufs[2] = reinterpret_cast<void *>(bufs[2]); + okay = m_pLibScaler.SetSrcImage(main_width, main_height, v4l2Format, bufs); } - void *dstbuf[3] = {NULL, NULL, NULL}; - dstbuf[0] = reinterpret_cast<void *>(m_fdIONThumbImgBuffer); - - if (!m_pLibScaler.SetSrcImage(main_width, main_height, v4l2Format, srcbufs, memtype)) { + if (!okay) { ALOGE("Failed to configure the main image format to LibScalerForJpeg"); return false; } + if (!m_pLibScaler.SetDstImage(m_nThumbWidth, m_nThumbHeight, - GetThumbnailFormat(v4l2Format), dstbuf, V4L2_MEMORY_DMABUF)) { + GetThumbnailFormat(v4l2Format), m_fdIONThumbImgBuffer)) { ALOGE("Failed to configure the target image format to LibScalerForJpeg"); return false; } |