summaryrefslogtreecommitdiff
path: root/src
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 /src
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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/media-thumb-internal.c78
1 files changed, 62 insertions, 16 deletions
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);