From 033c47246776bcf23ce24d5328f8b7f17162bdaf Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Mon, 28 Aug 2017 10:16:59 +0900 Subject: Remove dependency of mmutil-jpeg. Use capi-media-image-util instead Change-Id: Ifdf3ec27e60e4e4b4d4e34b5a8eac370524024d1 --- src/media-thumb-internal.c | 78 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 16 deletions(-) (limited to 'src') 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 #include -#include #include #include #include @@ -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); -- cgit v1.2.3