summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaejeong Kim <backto.kim@samsung.com>2017-08-28 01:16:59 (GMT)
committerHaejeong Kim <backto.kim@samsung.com>2017-08-28 01:16:59 (GMT)
commit033c47246776bcf23ce24d5328f8b7f17162bdaf (patch)
tree687dbfb4c7e25261ed4b441e0573c93b6e561c3a
parent8cf4bc44c2593b47725f293a2f834eea9c994d2d (diff)
downloadlibmedia-thumbnail-033c47246776bcf23ce24d5328f8b7f17162bdaf.zip
libmedia-thumbnail-033c47246776bcf23ce24d5328f8b7f17162bdaf.tar.gz
libmedia-thumbnail-033c47246776bcf23ce24d5328f8b7f17162bdaf.tar.bz2
Remove dependency of mmutil-jpeg. Use capi-media-image-util insteadsubmit/tizen/20170828.073653accepted/tizen/unified/20170829.053211refs/changes/89/146289/1
Change-Id: Ifdf3ec27e60e4e4b4d4e34b5a8eac370524024d1
-rwxr-xr-xCMakeLists.txt2
-rw-r--r--packaging/libmedia-thumbnail.spec1
-rwxr-xr-xserver/CMakeLists.txt2
-rwxr-xr-xsrc/media-thumb-internal.c78
-rw-r--r--test/CMakeLists.txt2
5 files changed, 65 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f405d5d..6eb775a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/codec ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/ipc ${CMAKE_SOURCE_DIR}/server/include ${CMAKE_SOURCE_DIR}/md5)
INCLUDE(FindPkgConfig)
- pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 mm-fileinfo aul libexif ecore-evas evas capi-media-image-util mmutil-jpeg libmedia-utils libtzplatform-config db-util)
+ pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 mm-fileinfo aul libexif ecore-evas evas capi-media-image-util libmedia-utils libtzplatform-config db-util)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index d2c53e4..27a0c47 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -14,7 +14,6 @@ BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(mm-fileinfo)
BuildRequires: pkgconfig(capi-media-image-util)
-BuildRequires: pkgconfig(mmutil-jpeg)
BuildRequires: pkgconfig(libexif)
BuildRequires: pkgconfig(evas)
BuildRequires: pkgconfig(ecore)
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
index 1493bb5..35f14a8 100755
--- a/server/CMakeLists.txt
+++ b/server/CMakeLists.txt
@@ -5,7 +5,7 @@ SET(THUMB-SERVER
thumb-server-internal.c)
INCLUDE(FindPkgConfig)
- pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo aul libexif ecore-evas evas mmutil-jpeg libmedia-utils libtzplatform-config)
+ pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo aul libexif ecore-evas evas libmedia-utils libtzplatform-config)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index 1f09570..f9ad343 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -38,7 +38,6 @@
#include <unistd.h>
#include <mm_file.h>
-#include <mm_util_jpeg.h>
#include <image_util.h>
#include <Evas.h>
#include <Ecore_Evas.h>
@@ -218,9 +217,9 @@ int _media_thumb_rotate_argb(unsigned char *source, const unsigned int size, int
int width = 0, height = 0;
unsigned char *temp_buf = NULL;
- if (format == MM_UTIL_JPEG_FMT_BGRA8888) {
+ if (format == IMAGE_UTIL_COLORSPACE_BGRA8888) {
dpp = 4;
- } else if (format == MM_UTIL_JPEG_FMT_RGB888) {
+ } else if (format == IMAGE_UTIL_COLORSPACE_RGB888) {
dpp = 3;
} else {
thumb_err("Invalid parameter");
@@ -479,6 +478,55 @@ static int _media_thumb_get_data_from_exif(ExifData *ed,
return MS_MEDIA_ERR_NONE;
}
+static int __media_thumb_decode_jpeg(unsigned char *src, unsigned long long size, image_util_colorspace_e colorspace, unsigned char **dst, unsigned long *width, unsigned long *height, unsigned long long *dst_size)
+{
+ int err = IMAGE_UTIL_ERROR_NONE;
+ image_util_decode_h decoder = NULL;
+
+ err = image_util_decode_create(&decoder);
+ if (err != IMAGE_UTIL_ERROR_NONE) {
+ thumb_err("image_util_decode_create failed! (%d)", err);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ err = image_util_decode_set_input_buffer(decoder, src, size);
+ if (err != IMAGE_UTIL_ERROR_NONE) {
+ thumb_err("image_util_decode_set_input_buffer failed! (%d)", err);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ err = image_util_decode_set_colorspace(decoder, colorspace);
+ if (err != IMAGE_UTIL_ERROR_NONE) {
+ thumb_err("image_util_decode_set_colorspace failed! (%d)", err);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ err = image_util_decode_set_output_buffer(decoder, dst);
+ if (err != IMAGE_UTIL_ERROR_NONE) {
+ thumb_err("image_util_decode_set_output_buffer failed! (%d)", err);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ err = image_util_decode_run(decoder, width, height, dst_size);
+ if (err != IMAGE_UTIL_ERROR_NONE) {
+ thumb_err("image_util_decode_run failed! (%d)", err);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ err = image_util_decode_destroy(decoder);
+ if (err != IMAGE_UTIL_ERROR_NONE) {
+ thumb_err("image_util_decode_destroy failed! (%d)", err);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+
int _media_thumb_get_thumb_from_exif(ExifData *ed,
const char *file_full_path,
const char *thumb_path,
@@ -491,11 +539,12 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
int size = 0;
int thumb_width = 0;
int thumb_height = 0;
+ unsigned long long thumb_size = 0;
+ unsigned char *raw_image = NULL;
int origin_width = 0;
int origin_height = 0;
void *thumb = NULL;
bool is_rotated = (orientation == ROT_90 || orientation == ROT_180 || orientation == ROT_270) ? TRUE : FALSE;
- mm_util_jpeg_yuv_data decoded = {0,};
if (ed == NULL) {
return MS_MEDIA_ERR_INVALID_PARAMETER;
@@ -526,16 +575,13 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
}
if (is_rotated) {
- err = mm_util_decode_from_jpeg_memory(&decoded, thumb, (unsigned int)size, MM_UTIL_JPEG_FMT_RGB888);
+ err = __media_thumb_decode_jpeg(thumb, size, IMAGE_UTIL_COLORSPACE_RGB888, &raw_image, (unsigned long *)&thumb_width, (unsigned long *)&thumb_height, &thumb_size);
SAFE_FREE(thumb);
if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("mm_util_decode_from_jpeg_turbo_memory failed : %d", err);
+ thumb_err("__media_thumb_decode_jpeg failed : %d", err);
return err;
}
- thumb_width = decoded.width;
- thumb_height = decoded.height;
-
int rot_type = IMAGE_UTIL_ROTATION_NONE;
if (orientation == ROT_90) {
rot_type = IMAGE_UTIL_ROTATION_90;
@@ -544,17 +590,17 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
} else if (orientation == ROT_270) {
rot_type = IMAGE_UTIL_ROTATION_270;
}
- err = _media_thumb_rotate_thumb(decoded.data, decoded.size, &(decoded.width), &(decoded.height), rot_type, MM_UTIL_JPEG_FMT_RGB888);
+ err = _media_thumb_rotate_thumb(raw_image, thumb_size, &thumb_width, &thumb_height, rot_type, IMAGE_UTIL_COLORSPACE_RGB888);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_rotate_thumb falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- //thumb_dbg("Width : %d, Height : %d", decoded.width, decoded.height);
- thumb_info->data = decoded.data;
- thumb_info->size = decoded.size;
- thumb_info->width = decoded.width;
- thumb_info->height = decoded.height;
+
+ thumb_info->data = raw_image;
+ thumb_info->size = thumb_size;
+ thumb_info->width = thumb_width;
+ thumb_info->height = thumb_height;
} else {
/*in this case, just write raw data in file */
thumb_dbg_slog("Thumb is :%s", thumb_path);
@@ -1118,7 +1164,7 @@ int _media_thumb_video(const char *origin_path, int thumb_width, int thumb_heigh
SAFE_FREE(new_frame);
if (rot_type == IMAGE_UTIL_ROTATION_90 || rot_type == IMAGE_UTIL_ROTATION_180 || rot_type == IMAGE_UTIL_ROTATION_270) {
- err = _media_thumb_rotate_thumb(thumb_info->data, thumb_info->size, &(thumb_info->width), &(thumb_info->height), rot_type, MM_UTIL_JPEG_FMT_BGRA8888);
+ err = _media_thumb_rotate_thumb(thumb_info->data, thumb_info->size, &(thumb_info->width), &(thumb_info->height), rot_type, IMAGE_UTIL_COLORSPACE_BGRA8888);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_rotate_thumb falied: %d", err);
SAFE_FREE(thumb_info->data);
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 20f7d4e..51c570d 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,7 +1,7 @@
SET(TEST-THUMB "test-thumb.c")
INCLUDE(FindPkgConfig)
- pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo aul libexif ecore-evas evas mmutil-jpeg libmedia-utils libtzplatform-config)
+ pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo aul libexif ecore-evas evas libmedia-utils libtzplatform-config)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")