summaryrefslogtreecommitdiff
path: root/src/media-thumb-internal.c
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-07-10 07:32:25 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-07-10 07:57:29 (GMT)
commitfadf003e720f369b533b726998a84f2154f3853b (patch)
tree76d77189596dbfbb104b1c7abd2f21faf3d8cab8 /src/media-thumb-internal.c
parent4cf66c08dc9082f757e56a37e465e51730a763f5 (diff)
downloadlibmedia-thumbnail-fadf003e720f369b533b726998a84f2154f3853b.zip
libmedia-thumbnail-fadf003e720f369b533b726998a84f2154f3853b.tar.gz
libmedia-thumbnail-fadf003e720f369b533b726998a84f2154f3853b.tar.bz2
Merge thumbnail create API when image typerefs/changes/82/137882/2
Change-Id: I14927754931071ef8d3d1307ddc334d5bc643541 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src/media-thumb-internal.c')
-rwxr-xr-xsrc/media-thumb-internal.c127
1 files changed, 11 insertions, 116 deletions
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index ed85c68..6526d62 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -638,6 +638,7 @@ int _media_thumb_decode_with_evas(const char *origin_path,
thumb_info->origin_height = height;
//thumb_dbg("origin width:%d, origin height:%d", width, height);
+ /* This case for only JPEG format.. JPEG can be partially processed.. */
if ((need_scale == 1) && (width * height > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
thumb_warn("This is too large image. so this's scale is going to be down");
evas_object_image_load_scale_down_set(source_img, 10);
@@ -777,10 +778,7 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info, int thumb_width, int
return err;
}
-int _media_thumb_agif(const char *origin_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
+int _media_thumb_agif(const char *origin_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
unsigned int *thumb = NULL;
@@ -828,10 +826,7 @@ int _media_thumb_agif(const char *origin_path,
return err;
}
-int _media_thumb_png(const char *origin_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
+int _media_thumb_general(const char *origin_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
@@ -844,59 +839,7 @@ int _media_thumb_png(const char *origin_path,
return err;
}
-int _media_thumb_bmp(const char *origin_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("decode_with_evas failed : %d", err);
- return err;
- }
-
- return err;
-}
-
-int _media_thumb_wbmp(const char *origin_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("decode_with_evas failed : %d", err);
- return err;
- }
-
- return err;
-}
-
-int _media_thumb_gif(const char *origin_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("decode_with_evas failed : %d", err);
- return err;
- }
-
- return err;
-}
-
-int _media_thumb_jpeg(const char *origin_path,
- const char *thumb_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
+int _media_thumb_jpeg(const char *origin_path, const char *thumb_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
int thumb_done = 0;
@@ -967,11 +910,7 @@ int _media_thumb_jpeg(const char *origin_path,
return err;
}
-int _media_thumb_image(const char *origin_path,
- const char *thumb_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
+int _media_thumb_image(const char *origin_path, const char *thumb_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
ImgCodecType image_type = 0;
@@ -979,7 +918,6 @@ int _media_thumb_image(const char *origin_path,
unsigned int origin_h = 0;
err = ImgGetImageInfoForThumb(origin_path, &image_type, &origin_w, &origin_h);
-
if (err != MS_MEDIA_ERR_NONE) {
thumb_warn("Getting image info is failed err: %d", err);
}
@@ -987,8 +925,7 @@ int _media_thumb_image(const char *origin_path,
thumb_info->origin_width = origin_w;
thumb_info->origin_height = origin_h;
- if ((image_type != IMG_CODEC_JPEG) &&
- (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
+ if ((image_type != IMG_CODEC_JPEG) && (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
thumb_warn("This original image is too big");
return MS_MEDIA_ERR_THUMB_TOO_BIG;
}
@@ -997,43 +934,9 @@ int _media_thumb_image(const char *origin_path,
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) {
- err = _media_thumb_png(origin_path, thumb_width, thumb_height, thumb_info);
- } else if (image_type == IMG_CODEC_GIF) {
- err = _media_thumb_gif(origin_path, thumb_width, thumb_height, thumb_info);
- } else if (image_type == IMG_CODEC_BMP) {
- err = _media_thumb_bmp(origin_path, thumb_width, thumb_height, thumb_info);
+ } else if (image_type == IMG_CODEC_PNG || image_type == IMG_CODEC_GIF || image_type == IMG_CODEC_BMP || image_type == IMG_CODEC_WBMP) {
+ err = _media_thumb_general(origin_path, thumb_width, thumb_height, thumb_info);
} else {
- char file_ext[10];
- err = _media_thumb_get_file_ext(origin_path, file_ext, sizeof(file_ext));
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_warn("_media_thumb_get_file_ext failed");
- } else {
- if (strcasecmp(file_ext, "wbmp") == 0) {
- image_type = IMG_CODEC_WBMP;
- int wbmp_width = 0;
- int wbmp_height = 0;
-
- err = _media_thumb_get_wh_with_evas(origin_path, &wbmp_width, &wbmp_height);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_get_wh_with_evas in WBMP : %d", err);
- return err;
- }
-
- if (wbmp_width * wbmp_height > THUMB_MAX_ALLOWED_MEM_FOR_THUMB) {
- thumb_warn("This original image is too big");
- return MS_MEDIA_ERR_THUMB_TOO_BIG;
- }
-
- thumb_info->origin_width = wbmp_width;
- thumb_info->origin_height = wbmp_height;
-
- err = _media_thumb_wbmp(origin_path, thumb_width, thumb_height, thumb_info);
-
- return err;
- }
- }
-
thumb_warn("Unsupported image type");
return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
}
@@ -1041,10 +944,7 @@ int _media_thumb_image(const char *origin_path,
return err;
}
-int _media_thumb_video(const char *origin_path,
- int thumb_width,
- int thumb_height,
- media_thumb_info *thumb_info)
+int _media_thumb_video(const char *origin_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
@@ -1212,8 +1112,7 @@ int _media_thumb_video(const char *origin_path,
return err;
}
-int _media_thumb_get_hash_name(const char *file_full_path,
- char *thumb_hash_path, size_t max_thumb_path, uid_t uid)
+int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid)
{
char *hash_name = NULL;
/*char *thumb_dir = NULL;*/
@@ -1268,11 +1167,7 @@ int _media_thumb_get_hash_name(const char *file_full_path,
}
-int _media_thumb_save_to_file_with_evas(unsigned char *data,
- int w,
- int h,
- int alpha,
- char *thumb_path)
+int _media_thumb_save_to_file_with_evas(unsigned char *data, int w, int h, int alpha, char *thumb_path)
{
Ecore_Evas *ee = ecore_evas_buffer_new(w, h);
if (ee == NULL) {