summaryrefslogtreecommitdiff
path: root/libhwjpeg/LibScalerForJpeg.cpp
diff options
context:
space:
mode:
authorCho KyongHo <pullip.cho@samsung.com>2019-08-13 17:50:44 +0900
committerCho KyongHo <pullip.cho@samsung.com>2020-02-20 21:34:34 -0800
commit8da348de51010dafbe2dd56980f9be12d8c109aa (patch)
tree8d035dcc43788a72893b0b7333c83f1acaabe88c /libhwjpeg/LibScalerForJpeg.cpp
parent14df956ea07fdacd6ff0caab2673365564be3f2e (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/LibScalerForJpeg.cpp')
-rw-r--r--libhwjpeg/LibScalerForJpeg.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/libhwjpeg/LibScalerForJpeg.cpp b/libhwjpeg/LibScalerForJpeg.cpp
index 90f5079..21e8e88 100644
--- a/libhwjpeg/LibScalerForJpeg.cpp
+++ b/libhwjpeg/LibScalerForJpeg.cpp
@@ -59,19 +59,17 @@ LibScalerForJpeg::~LibScalerForJpeg()
bool LibScalerForJpeg::SetImage(
v4l2_format &m_fmt, v4l2_buffer &m_buf, v4l2_plane m_planes[SCALER_MAX_PLANES],
- unsigned int width, unsigned int height, unsigned int v4l2_format,
- void *addrs[SCALER_MAX_PLANES], int mem_type)
+ unsigned int width, unsigned int height, unsigned int v4l2_format, unsigned int memtype)
{
/* Format information update*/
if ((m_needReqbuf == true) ||
(m_fmt.fmt.pix_mp.pixelformat != v4l2_format ||
m_fmt.fmt.pix_mp.width != width ||
m_fmt.fmt.pix_mp.height != height ||
- m_buf.memory != static_cast<v4l2_memory>(mem_type))) {
+ m_buf.memory != memtype)) {
m_fmt.fmt.pix_mp.pixelformat = v4l2_format;
m_fmt.fmt.pix_mp.width = width;
m_fmt.fmt.pix_mp.height = height;
- m_buf.memory = static_cast<v4l2_memory>(mem_type);
// The driver returns the number and length of planes through TRY_FMT.
if (ioctl(m_fdScaler, VIDIOC_TRY_FMT, &m_fmt) < 0) {
@@ -85,19 +83,44 @@ bool LibScalerForJpeg::SetImage(
/* Buffer information update*/
m_buf.index = 0;
m_buf.length = m_fmt.fmt.pix_mp.num_planes;
+ m_buf.memory = memtype;
for (unsigned long i = 0; i < m_buf.length; i++) {
m_planes[i].length = m_fmt.fmt.pix_mp.plane_fmt[i].sizeimage;
m_planes[i].bytesused = m_planes[i].length;
- if (m_buf.memory == V4L2_MEMORY_DMABUF)
- m_planes[i].m.fd = static_cast<__s32>(reinterpret_cast<long>(addrs[i]));
- else
- m_planes[i].m.userptr = reinterpret_cast<unsigned long>(addrs[i]);
}
return true;
}
+bool LibScalerForJpeg::SetImage(
+ v4l2_format &m_fmt, v4l2_buffer &m_buf, v4l2_plane m_planes[SCALER_MAX_PLANES],
+ unsigned int width, unsigned int height, unsigned int v4l2_format,
+ int buf[SCALER_MAX_PLANES])
+{
+ if (!SetImage(m_fmt, m_buf, m_planes, width, height, v4l2_format, V4L2_MEMORY_DMABUF))
+ return false;
+
+ for (unsigned long i = 0; i < m_buf.length; i++)
+ m_planes[i].m.fd = buf[i];
+
+ return true;
+}
+
+bool LibScalerForJpeg::SetImage(
+ v4l2_format &m_fmt, v4l2_buffer &m_buf, v4l2_plane m_planes[SCALER_MAX_PLANES],
+ unsigned int width, unsigned int height, unsigned int v4l2_format,
+ char *addrs[SCALER_MAX_PLANES])
+{
+ SetImage(m_fmt, m_buf, m_planes, width, height, v4l2_format, V4L2_MEMORY_USERPTR);
+ return false;
+
+ for (unsigned long i = 0; i < m_buf.length; i++)
+ m_planes[i].m.userptr = reinterpret_cast<unsigned long>(addrs[i]);
+
+ return true;
+}
+
bool LibScalerForJpeg::SetFormat()
{
if (ioctl(m_fdScaler, VIDIOC_S_FMT, &m_srcFmt) < 0) {