From 6e9b1f4ba74787bdea06b43ef31b2565e62525a2 Mon Sep 17 00:00:00 2001 From: Dmytro Dragan Date: Tue, 27 Sep 2016 14:16:20 +0300 Subject: [PATCH] TizenRefApp-7293 Get rid of image_util_encode_jpeg() usage Change-Id: Ia41efe8df7addfcdc8d80c44572c3be2a047cbb0 Signed-off-by: Dmytro Dragan --- src/Common/Utils/src/MediaUtils.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Common/Utils/src/MediaUtils.cpp b/src/Common/Utils/src/MediaUtils.cpp index a58a7a5..e0468eb 100644 --- a/src/Common/Utils/src/MediaUtils.cpp +++ b/src/Common/Utils/src/MediaUtils.cpp @@ -146,10 +146,31 @@ bool MediaUtils::getVideoFrame(const std::string &videoFilePath, const std::stri if(thumbnail) { const int quality = 90; // JPEG image quality(1 ~ 100) - int ret = image_util_encode_jpeg((unsigned char *)thumbnail, videoW, videoH, IMAGE_UTIL_COLORSPACE_RGB888, quality, imageFilePath.c_str()); + image_util_encode_h encode_h = {}; + bool isOk = false; + isOk = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h) == IMAGE_UTIL_ERROR_NONE; + if(!isOk) + { + free(thumbnail); + return false; + } + + isOk &= image_util_encode_set_resolution(encode_h, videoW, videoH) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGB888) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_quality(encode_h, quality) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_input_buffer(encode_h, (unsigned char *)thumbnail) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_output_path(encode_h, imageFilePath.c_str()) == IMAGE_UTIL_ERROR_NONE; + if(!isOk) + { + image_util_encode_destroy(encode_h); + free(thumbnail); + return false; + } + + isOk = image_util_encode_run(encode_h, nullptr) == IMAGE_UTIL_ERROR_NONE; + image_util_encode_destroy(encode_h); free(thumbnail); - return ret == IMAGE_UTIL_ERROR_NONE; - + return isOk; } return false; } -- 2.7.4