summaryrefslogtreecommitdiff
path: root/src/media-thumb-internal.c
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-06-19 03:55:54 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-06-19 04:31:25 (GMT)
commitb5bedb7541d78fd966e025266a6fadc3e3e0fd2d (patch)
treeba338a9726ee9fe50b55416979930da1aafa0ba3 /src/media-thumb-internal.c
parent75c4bd5f2433f484a974b913d9e58cf5f5cdb187 (diff)
downloadlibmedia-thumbnail-b5bedb7541d78fd966e025266a6fadc3e3e0fd2d.zip
libmedia-thumbnail-b5bedb7541d78fd966e025266a6fadc3e3e0fd2d.tar.gz
libmedia-thumbnail-b5bedb7541d78fd966e025266a6fadc3e3e0fd2d.tar.bz2
Remove image-util dependencyrefs/changes/04/134504/5
Remove image-util dependency when create agif thumbnail Change-Id: Ie6a96e8b5132e4b6be0e86b7cf23e4c29aba65c1 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src/media-thumb-internal.c')
-rwxr-xr-xsrc/media-thumb-internal.c112
1 files changed, 25 insertions, 87 deletions
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index 540ea0b..9debe27 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -47,15 +47,7 @@
#define MEDIA_THUMB_ROUND_UP_8(num) (((num)+7)&~7)
-int _media_thumb_resize_data(unsigned char *src_data,
- int src_width,
- int src_height,
- mm_util_img_format src_format,
- media_thumb_info *thumb_info,
- int dst_width,
- int dst_height);
-
-int _media_thumb_convert_video(const unsigned char *src_data, const int src_size,
+int _media_thumb_rgb_to_argb(const unsigned char *src_data, const int src_size,
unsigned char **dst_data,
unsigned int *buf_size,
int width,
@@ -84,14 +76,12 @@ int _media_thumb_convert_video(const unsigned char *src_data, const int src_size
(*dst_data)[i++] = 0x0;
}
- thumb_dbg("_media_thumb_convert_video success");
+ thumb_dbg("_media_thumb_rgb_to_argb success");
return err;
}
-int _media_thumb_resize_video_with_evas(const void *image,
- int thumb_width, int thumb_height,
- media_thumb_info *thumb_info)
+int _media_thumb_resize_with_evas(const void *image, int thumb_width, int thumb_height, media_thumb_info *thumb_info)
{
Ecore_Evas *resize_img_ee;
@@ -202,7 +192,7 @@ int _media_thumb_resize_video_with_evas(const void *image,
ecore_evas_free(target_ee);
ecore_evas_free(resize_img_ee);
- thumb_dbg("_media_thumb_resize_video_with_evas success");
+ thumb_dbg("_media_thumb_resize_with_evas success");
return MS_MEDIA_ERR_NONE;
}
@@ -578,59 +568,6 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
return err;
}
-int _media_thumb_resize_data(unsigned char *src_data,
- int src_width,
- int src_height,
- mm_util_img_format src_format,
- media_thumb_info *thumb_info,
- int dst_width,
- int dst_height)
-{
- int thumb_width = dst_width;
- int thumb_height = dst_height;
- unsigned int buf_size = 0;
-
- if (mm_util_get_image_size(src_format, thumb_width, thumb_height, &buf_size) < 0) {
- thumb_err("Failed to get buffer size");
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- thumb_dbg("mm_util_get_image_size : %d", buf_size);
-
- unsigned char *dst = (unsigned char *)malloc(buf_size);
-
- if (dst == NULL) {
- thumb_err("malloc fails");
- return MS_MEDIA_ERR_OUT_OF_MEMORY;
- }
-
- if (mm_util_resize_image((unsigned char *)src_data, src_width,
- src_height, src_format,
- dst, (unsigned int *)&thumb_width,
- (unsigned int *)&thumb_height) < 0) {
- thumb_err("Failed to resize the thumbnails");
-
- SAFE_FREE(dst);
-
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- thumb_info->size = buf_size;
- thumb_info->width = thumb_width;
- thumb_info->height = thumb_height;
- thumb_info->data = malloc(buf_size);
- if (thumb_info->data != NULL) {
- memcpy(thumb_info->data, dst, buf_size);
- } else {
- thumb_err("malloc fails");
- SAFE_FREE(dst);
- return MS_MEDIA_ERR_OUT_OF_MEMORY;
- }
- SAFE_FREE(dst);
-
- return MS_MEDIA_ERR_NONE;
-}
-
int _media_thumb_get_wh_with_evas(const char *origin_path, int *width, int *height)
{
/* using evas to get w/h */
@@ -841,22 +778,29 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info, int thumb_width, int
}
int _media_thumb_agif(const char *origin_path,
- int image_width,
- int image_height,
int thumb_width,
int thumb_height,
media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
unsigned int *thumb = NULL;
+ unsigned char *dst_image = NULL;
+ unsigned int dst_size = 0;
+ unsigned int thumb_size = 0;
- thumb = ImgGetFirstFrameAGIFAtSize(origin_path, image_width, image_height);
-
+ thumb = ImgGetFirstFrameAGIFAtSize(origin_path, thumb_info->origin_width, thumb_info->origin_height);
if (!thumb) {
thumb_err("Frame data is NULL!!");
return MS_MEDIA_ERR_INTERNAL;
}
+ err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, thumb_info->origin_width, thumb_info->origin_height, &thumb_size);
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("mm_util_get_image_size failed: %d", err);
+ SAFE_FREE(thumb);
+ return err;
+ }
+
err = _media_thumb_get_proper_thumb_size(thumb_info->origin_width, thumb_info->origin_height, &thumb_width, &thumb_height);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
@@ -864,29 +808,23 @@ int _media_thumb_agif(const char *origin_path,
return err;
}
- err = _media_thumb_resize_data((unsigned char *)thumb,
- image_width,
- image_height,
- MM_UTIL_IMG_FMT_RGB888,
- thumb_info,
- thumb_width,
- thumb_height);
-
+ err = _media_thumb_rgb_to_argb((unsigned char *) thumb, thumb_size, &dst_image, &dst_size, thumb_info->origin_width, thumb_info->origin_height);
if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_resize_data failed: %d", err);
+ thumb_err("_media_thumb_convert_data falied: %d", err);
SAFE_FREE(thumb);
return err;
}
- SAFE_FREE(thumb);
-
- err = _media_thumb_convert_data(thumb_info, thumb_info->width, thumb_info->height);
+ err = _media_thumb_resize_with_evas(dst_image, thumb_width, thumb_height, thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_data falied: %d", err);
+ thumb_err("_media_thumb_resize_data failed: %d", err);
SAFE_FREE(thumb_info->data);
+ SAFE_FREE(thumb);
return err;
}
+ SAFE_FREE(thumb);
+
return err;
}
@@ -1056,7 +994,7 @@ int _media_thumb_image(const char *origin_path,
}
if (image_type == IMG_CODEC_AGIF) {
- err = _media_thumb_agif(origin_path, origin_w, origin_h, thumb_width, thumb_height, thumb_info);
+ err = _media_thumb_agif(origin_path, thumb_width, thumb_height, thumb_info);
} else if (image_type == IMG_CODEC_JPEG) {
err = _media_thumb_jpeg(origin_path, thumb_path, thumb_width, thumb_height, thumb_info);
} else if (image_type == IMG_CODEC_PNG) {
@@ -1224,7 +1162,7 @@ int _media_thumb_video(const char *origin_path,
unsigned int new_size = 0;
unsigned char *new_frame = NULL;
- err = _media_thumb_convert_video(frame, size, &new_frame, &new_size, width, height);
+ err = _media_thumb_rgb_to_argb(frame, size, &new_frame, &new_size, width, height);
if ((err != MS_MEDIA_ERR_NONE) || (new_frame == NULL)) {
thumb_err("_media_thumb_convert_video falied: %d", err);
mm_file_destroy_content_attrs(content);
@@ -1235,7 +1173,7 @@ int _media_thumb_video(const char *origin_path,
thumb_dbg("original size - width:%d, height:%d", width, height);
thumb_dbg("proper thumb size - width:%d, height:%d", thumb_width, thumb_height);
if (width > thumb_width || height > thumb_height) {
- err = _media_thumb_resize_video_with_evas(new_frame, thumb_width, thumb_height, thumb_info);
+ err = _media_thumb_resize_with_evas(new_frame, thumb_width, thumb_height, thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_resize_video_with_evas falied: %d", err);
SAFE_FREE(new_frame);