summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-06-07 06:46:18 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-06-08 05:08:18 (GMT)
commit75c4bd5f2433f484a974b913d9e58cf5f5cdb187 (patch)
treef540a33e9b4d0e47f670ae93a51fa9890fdc9598
parent34ed08a8f899bffe2f9b27b4bd2e6e180650e61c (diff)
downloadlibmedia-thumbnail-75c4bd5f2433f484a974b913d9e58cf5f5cdb187.zip
libmedia-thumbnail-75c4bd5f2433f484a974b913d9e58cf5f5cdb187.tar.gz
libmedia-thumbnail-75c4bd5f2433f484a974b913d9e58cf5f5cdb187.tar.bz2
Remove format enum and related API Remove unused codes Merge same logics Change-Id: I1e44585955eb1698d2aa5901f2e1969d831de6c7 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/include/thumb-server-internal.h2
-rwxr-xr-xserver/thumb-server-internal.c73
-rwxr-xr-xsrc/include/media-thumb-internal.h2
-rwxr-xr-xsrc/include/util/media-thumb-util.h5
-rwxr-xr-xsrc/media-thumb-internal.c355
-rwxr-xr-xtest/test-thumb.c4
7 files changed, 55 insertions, 388 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 6495587..3465e78 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -1,6 +1,6 @@
Name: libmedia-thumbnail
Summary: Media thumbnail service library for multimedia applications
-Version: 0.2.7
+Version: 0.2.8
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0 and PD
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
index 3dedd77..6ec539a 100755
--- a/server/include/thumb-server-internal.h
+++ b/server/include/thumb-server-internal.h
@@ -43,7 +43,6 @@ gboolean _thumb_server_prepare_socket(int *sock_fd);
gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpointer data);
int _thumbnail_get_data(const char *origin_path,
- media_thumb_format format,
char *thumb_path,
unsigned char **data,
int *size,
@@ -55,7 +54,6 @@ int _thumbnail_get_data(const char *origin_path,
bool *is_saved);
int _thumbnail_get_raw_data(const char *origin_path,
- media_thumb_format format,
int *width,
int *height,
unsigned char **data,
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index dc921d6..58c8c76 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -78,20 +78,15 @@ int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
{
int err = MS_MEDIA_ERR_NONE;
- err = _media_thumb_process(req_msg, res_msg);
- if (err != MS_MEDIA_ERR_NONE)
- thumb_warn("_media_thumb_process is failed: %d", err);
-
- return err;
-}
-
-static int __thumb_daemon_process_job_raw(thumbMsg *req_msg, thumbMsg *res_msg)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = _media_thumb_process_raw(req_msg, res_msg);
- if (err != MS_MEDIA_ERR_NONE)
- thumb_warn("_media_thumb_process_raw is failed: %d", err);
+ if (req_msg->msg_type == THUMB_REQUEST_RAW_DATA) {
+ err = _media_thumb_process_raw(req_msg, res_msg);
+ if (err != MS_MEDIA_ERR_NONE)
+ thumb_warn("_media_thumb_process_raw is failed: %d", err);
+ } else {
+ err = _media_thumb_process(req_msg, res_msg);
+ if (err != MS_MEDIA_ERR_NONE)
+ thumb_warn("_media_thumb_process is failed: %d", err);
+ }
return err;
}
@@ -146,13 +141,8 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
thumb_warn_slog("Received [%d] %s(%d) from PID(%d)", recv_msg.msg_type, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid);
- if (recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
- __thumb_daemon_process_job_raw(&recv_msg, &res_msg);
- } else if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
- thumb_warn("received KILL msg from thumbnail agent.");
- } else {
+ if (recv_msg.msg_type != THUMB_REQUEST_KILL_SERVER)
_thumb_daemon_process_job(&recv_msg, &res_msg);
- }
if (res_msg.msg_type == 0)
res_msg.msg_type = recv_msg.msg_type;
@@ -186,9 +176,9 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
block_size = THUMB_BLOCK_SIZE;
}
}
- if (buf_size == 0) {
- thumb_dbg_slog("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path);
- }
+
+ thumb_dbg_slog("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path);
+
SAFE_FREE(buf);
SAFE_FREE(res_msg.thumb_data);
@@ -277,7 +267,6 @@ gboolean _thumb_server_prepare_socket(int *sock_fd)
}
int _thumbnail_get_data(const char *origin_path,
- media_thumb_format format,
char *thumb_path,
unsigned char **data,
int *size,
@@ -292,23 +281,16 @@ int _thumbnail_get_data(const char *origin_path,
int thumb_width = -1;
int thumb_height = -1;
- if (origin_path == NULL || size == NULL
- || width == NULL || height == NULL) {
+ if (origin_path == NULL || size == NULL || width == NULL || height == NULL) {
thumb_err("Invalid parameter");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) {
- thumb_err("parameter format is invalid");
+ if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ thumb_err("Original path (%s) does not exist", origin_path);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- if (!g_file_test
- (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
- thumb_err("Original path (%s) does not exist", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
thumb_dbg("Origin path : %s", origin_path);
int file_type = THUMB_NONE_TYPE;
@@ -324,13 +306,13 @@ int _thumbnail_get_data(const char *origin_path,
thumb_info.is_raw = FALSE;
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info);
+ err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, &thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_image failed");
return err;
}
} else if (file_type == THUMB_VIDEO_TYPE) {
- err = _media_thumb_video(origin_path, thumb_width, thumb_height, format, &thumb_info);
+ err = _media_thumb_video(origin_path, thumb_width, thumb_height, &thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_image failed");
return err;
@@ -355,7 +337,6 @@ int _thumbnail_get_data(const char *origin_path,
}
int _thumbnail_get_raw_data(const char *origin_path,
- media_thumb_format format,
int *width,
int *height,
unsigned char **data,
@@ -371,11 +352,6 @@ int _thumbnail_get_raw_data(const char *origin_path,
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) {
- thumb_err("parameter format is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("Original path (%s) does not exist", origin_path);
return MS_MEDIA_ERR_INVALID_PARAMETER;
@@ -389,13 +365,13 @@ int _thumbnail_get_raw_data(const char *origin_path,
thumb_info.is_raw = TRUE;
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info);
+ err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, &thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_image failed");
return err;
}
} else if (file_type == THUMB_VIDEO_TYPE) {
- err = _media_thumb_video(origin_path, thumb_width, thumb_height, format, &thumb_info);
+ err = _media_thumb_video(origin_path, thumb_width, thumb_height, &thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_image failed");
return err;
@@ -435,8 +411,6 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
int msg_type = req_msg->msg_type;
const char *origin_path = req_msg->org_path;
-
- media_thumb_format thumb_format = MEDIA_THUMB_BGRA;
thumb_w = req_msg->thumb_width;
thumb_h = req_msg->thumb_height;
thumb_path = res_msg->dst_path;
@@ -488,7 +462,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
_media_thumb_remove_file(thumb_path);
}
- err = _thumbnail_get_data(origin_path, thumb_format, thumb_path, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, &is_saved);
+ err = _thumbnail_get_data(origin_path, thumb_path, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, &is_saved);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_thumbnail_get_data failed - %d", err);
SAFE_FREE(data);
@@ -584,14 +558,11 @@ _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg)
}
const char *origin_path = req_msg->org_path;
-
- media_thumb_format thumb_format = MEDIA_THUMB_BGRA;
thumb_w = req_msg->thumb_width;
thumb_h = req_msg->thumb_height;
res_msg->status = MS_MEDIA_ERR_NONE;
- err = _thumbnail_get_raw_data(origin_path, thumb_format, &thumb_w, &thumb_h, &data, &thumb_size);
-
+ err = _thumbnail_get_raw_data(origin_path, &thumb_w, &thumb_h, &data, &thumb_size);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_thumbnail_get_data failed - %d", err);
res_msg->status = err;
diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h
index da9165b..6d0d5e6 100755
--- a/src/include/media-thumb-internal.h
+++ b/src/include/media-thumb-internal.h
@@ -74,13 +74,11 @@ int _media_thumb_image(const char *origin_path,
const char *thumb_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
media_thumb_info *thumb_info);
int _media_thumb_video(const char *origin_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
media_thumb_info *thumb_info);
int _media_thumb_get_hash_name(const char *file_full_path,
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
index f3771bc..4b9c74b 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -29,11 +29,6 @@
else { src = malloc(size); if (src) memset(src, 0x0, size); } }
#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
-typedef enum {
- MEDIA_THUMB_BGRA, /* BGRA, especially provided for evas users */
- MEDIA_THUMB_RGB888, /* RGB888 */
-} media_thumb_format;
-
#define THUMB_NONE_TYPE -1 /* None */
#define THUMB_IMAGE_TYPE 0 /* Image */
#define THUMB_VIDEO_TYPE 1 /* Video */
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index ecd7d8e..540ea0b 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -46,8 +46,6 @@
#include <sys/stat.h>
#define MEDIA_THUMB_ROUND_UP_8(num) (((num)+7)&~7)
-/* performance enhanced to make thumbnail */
-#define THUMB_PERFORMANCE_ENHANCED 1
int _media_thumb_resize_data(unsigned char *src_data,
int src_width,
@@ -57,20 +55,16 @@ int _media_thumb_resize_data(unsigned char *src_data,
int dst_width,
int dst_height);
-#if THUMB_PERFORMANCE_ENHANCED
int _media_thumb_convert_video(const unsigned char *src_data, const int src_size,
unsigned char **dst_data,
unsigned int *buf_size,
int width,
- int height,
- mm_util_img_format src_format,
- mm_util_img_format dst_format)
+ int height)
{
int err = MS_MEDIA_ERR_NONE;
+ int i = 0, j;
- thumb_dbg("src format:%d, dst format:%d", src_format, dst_format);
-
- if (mm_util_get_image_size(dst_format, width, height, buf_size) < 0) {
+ if (mm_util_get_image_size(MM_UTIL_IMG_FMT_BGRA8888, width, height, buf_size) < 0) {
thumb_err("mm_util_get_image_size failed");
return MS_MEDIA_ERR_INTERNAL;
}
@@ -78,36 +72,16 @@ int _media_thumb_convert_video(const unsigned char *src_data, const int src_size
thumb_dbg("mm_util_get_image_size : %d", *buf_size);
*dst_data = (unsigned char *)malloc(*buf_size);
-
if (*dst_data == NULL) {
thumb_err("Failed to allocate memory");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- if (src_format == MM_UTIL_IMG_FMT_RGB888 &&
- dst_format == MM_UTIL_IMG_FMT_BGRA8888) {
-
- int i = 0, j;
- for (j = 0; ((j < src_size) && (i < *buf_size)); j += 3) {
- (*dst_data)[i++] = (src_data[j + 2]);
- (*dst_data)[i++] = (src_data[j + 1]);
- (*dst_data)[i++] = (src_data[j]);
- (*dst_data)[i++] = 0x0;
- }
-
- } else {
- err = mm_util_convert_colorspace(src_data,
- width,
- height,
- src_format,
- *dst_data,
- dst_format);
-
- if (err < 0) {
- thumb_err("Failed to change from rgb888 to argb8888 %d", err);
- SAFE_FREE(*dst_data);
- return MS_MEDIA_ERR_INTERNAL;
- }
+ for (j = 0; ((j < src_size) && (i < *buf_size)); j += 3) {
+ (*dst_data)[i++] = (src_data[j + 2]);
+ (*dst_data)[i++] = (src_data[j + 1]);
+ (*dst_data)[i++] = (src_data[j]);
+ (*dst_data)[i++] = 0x0;
}
thumb_dbg("_media_thumb_convert_video success");
@@ -305,7 +279,6 @@ int _media_thumb_rotate_thumb(unsigned char *data, int size, int *width, int *he
thumb_dbg("_media_thumb_rotate_thumb success");
return MS_MEDIA_ERR_NONE;
}
-#endif
int _media_thumb_get_proper_thumb_size(int orig_w, int orig_h,
int *thumb_w, int *thumb_h)
@@ -549,7 +522,6 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
thumb_width = decoded.width;
thumb_height = decoded.height;
-#if THUMB_PERFORMANCE_ENHANCED
int rot_type = MM_UTIL_ROTATE_0;
if (orientation == ROT_90) {
rot_type = MM_UTIL_ROTATE_90;
@@ -569,65 +541,6 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
thumb_info->size = decoded.size;
thumb_info->width = decoded.width;
thumb_info->height = decoded.height;
-#else
- /* Start to decode to rotate */
- unsigned char *rotated = NULL;
- unsigned int r_w = decoded.height;
- unsigned int r_h = decoded.width;
- unsigned int r_size = 0;
- mm_util_img_rotate_type rot_type = MM_UTIL_ROTATE_0;
-
- int i, rotate_cnt = 0;
-
- rot_type = MM_UTIL_ROTATE_90;
- if (orientation == ROT_90) {
- rotate_cnt = 1;
- } else if (orientation == ROT_180) {
- rotate_cnt = 2;
- } else if (orientation == ROT_270) {
- rotate_cnt = 3;
- }
-
- for (i = 0; i < rotate_cnt; i++) {
- if (i == 1) {
- r_w = decoded.width;
- r_h = decoded.height;
- }
-
- err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, r_w, r_h, &r_size);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("mm_util_get_image_size failed : %d", err);
- SAFE_FREE(decoded.data);
- return err;
- }
-
- rotated = (unsigned char *)malloc(r_size);
- err = mm_util_rotate_image(decoded.data, decoded.width, decoded.height,
- MM_UTIL_IMG_FMT_RGB888,
- rotated, &r_w, &r_h,
- rot_type);
-
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("mm_util_rotate_image failed : %d", err);
- SAFE_FREE(decoded.data);
- SAFE_FREE(rotated);
- return err;
- } else {
- thumb_err("mm_util_rotate_image succeed");
- }
-
- SAFE_FREE(decoded.data);
- decoded.data = rotated;
- decoded.width = r_w;
- decoded.height = r_h;
- }
-
- //thumb_dbg("Width : %d, Height : %d", r_w, r_h);
- thumb_info->data = rotated;
- thumb_info->size = r_size;
- thumb_info->width = r_w;
- thumb_info->height = r_h;
-#endif
} else {
/*in this case, just write raw data in file */
thumb_dbg_slog("Thumb is :%s", thumb_path);
@@ -890,32 +803,15 @@ int _media_thumb_decode_with_evas(const char *origin_path,
return err;
}
-mm_util_img_format _media_thumb_get_format(media_thumb_format src_format)
-{
- switch (src_format) {
- case MEDIA_THUMB_BGRA:
- return MM_UTIL_IMG_FMT_BGRA8888;
- case MEDIA_THUMB_RGB888:
- return MM_UTIL_IMG_FMT_RGB888;
- default:
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-}
-
-int _media_thumb_convert_data(media_thumb_info *thumb_info,
- int thumb_width,
- int thumb_height,
- mm_util_img_format src_format,
- mm_util_img_format dst_format)
+int _media_thumb_convert_data(media_thumb_info *thumb_info, int thumb_width, int thumb_height)
{
int err = MS_MEDIA_ERR_NONE;
unsigned int buf_size = 0;
unsigned char *src_data = thumb_info->data;
unsigned char *dst_data = NULL;
+ int i = 0, j;
- thumb_dbg("src format:%d, dst format:%d", src_format, dst_format);
-
- if (mm_util_get_image_size(dst_format, thumb_width, thumb_height, &buf_size) < 0) {
+ if (mm_util_get_image_size(MM_UTIL_IMG_FMT_BGRA8888, thumb_width, thumb_height, &buf_size) < 0) {
thumb_err("mm_util_get_image_size failed");
return MS_MEDIA_ERR_INTERNAL;
}
@@ -923,37 +819,16 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info,
thumb_dbg("mm_util_get_image_size : %d", buf_size);
dst_data = (unsigned char *)malloc(buf_size);
-
if (dst_data == NULL) {
thumb_err("Failed to allocate memory");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- if (src_format == MM_UTIL_IMG_FMT_RGB888 &&
- dst_format == MM_UTIL_IMG_FMT_BGRA8888) {
-
- int i = 0, j;
- for (j = 0; j < thumb_width * 3 * thumb_height;
- j += 3) {
- dst_data[i++] = (src_data[j + 2]);
- dst_data[i++] = (src_data[j + 1]);
- dst_data[i++] = (src_data[j]);
- dst_data[i++] = 0x0;
- }
-
- } else {
- err = mm_util_convert_colorspace(src_data,
- thumb_width,
- thumb_height,
- src_format,
- dst_data,
- dst_format);
-
- if (err < 0) {
- thumb_err("Failed to change from rgb888 to argb8888 %d", err);
- SAFE_FREE(dst_data);
- return MS_MEDIA_ERR_INTERNAL;
- }
+ for (j = 0; j < thumb_width * 3 * thumb_height; j += 3) {
+ dst_data[i++] = (src_data[j + 2]);
+ dst_data[i++] = (src_data[j + 1]);
+ dst_data[i++] = (src_data[j]);
+ dst_data[i++] = 0x0;
}
SAFE_FREE(thumb_info->data);
@@ -965,48 +840,11 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info,
return err;
}
-int _media_thumb_convert_format(media_thumb_info *thumb_info,
- media_thumb_format src_format,
- media_thumb_format dst_format)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- if (src_format == dst_format) {
- //thumb_dbg("src_format == dst_format");
- return err;
- }
-
- mm_util_img_format src_mm_format;
- mm_util_img_format dst_mm_format;
-
- src_mm_format = _media_thumb_get_format(src_format);
- dst_mm_format = _media_thumb_get_format(dst_format);
-
- if ((int)src_mm_format == -1 || (int)dst_mm_format == -1) {
- thumb_err("Format is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- err = _media_thumb_convert_data(thumb_info,
- thumb_info->width,
- thumb_info->height,
- src_mm_format,
- dst_mm_format);
-
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("media_thumb_convert_format failed : %d", err);
- return err;
- }
-
- return err;
-}
-
int _media_thumb_agif(const char *origin_path,
int image_width,
int image_height,
int thumb_width,
int thumb_height,
- media_thumb_format format,
media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
@@ -1042,9 +880,9 @@ int _media_thumb_agif(const char *origin_path,
SAFE_FREE(thumb);
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
+ err = _media_thumb_convert_data(thumb_info, thumb_info->width, thumb_info->height);
if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
+ thumb_err("_media_thumb_convert_data falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
@@ -1055,96 +893,64 @@ int _media_thumb_agif(const char *origin_path,
int _media_thumb_png(const char *origin_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
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);
+ 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;
}
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_BGRA, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
-
return err;
}
int _media_thumb_bmp(const char *origin_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
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);
+ 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;
}
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_BGRA, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
-
return err;
}
int _media_thumb_wbmp(const char *origin_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
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);
+ 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;
}
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_BGRA, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
-
return err;
}
int _media_thumb_gif(const char *origin_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
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);
+ 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;
}
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_BGRA, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
-
return err;
}
@@ -1152,7 +958,6 @@ int _media_thumb_jpeg(const char *origin_path,
const char *thumb_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
@@ -1167,14 +972,12 @@ int _media_thumb_jpeg(const char *origin_path,
if (ed) {
/* First, Get orientation from exif */
err = _media_thumb_get_exif_info(ed, NULL, 0, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
-
if (err != MS_MEDIA_ERR_NONE) {
thumb_warn("_media_thumb_get_exif_info failed");
}
/* Second, Get thumb from exif */
err = _media_thumb_get_thumb_from_exif(ed, origin_path, thumb_path, orientation, thumb_width, thumb_height, thumb_info);
-
if (err != MS_MEDIA_ERR_NONE) {
thumb_dbg("_media_thumb_get_thumb_from_exif failed");
} else {
@@ -1193,14 +996,7 @@ int _media_thumb_jpeg(const char *origin_path,
}
if (thumb_info->is_saved == FALSE) {
- mm_util_img_format dst_format = _media_thumb_get_format(format);
-
- err = _media_thumb_convert_data(thumb_info,
- thumb_info->width,
- thumb_info->height,
- MM_UTIL_IMG_FMT_RGB888,
- dst_format);
-
+ err = _media_thumb_convert_data(thumb_info, thumb_info->width, thumb_info->height);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_data failed : %d", err);
exif_data_unref(ed);
@@ -1224,18 +1020,10 @@ int _media_thumb_jpeg(const char *origin_path,
if (!thumb_done) {
err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, orientation);
-
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("decode_with_evas failed : %d", err);
return err;
}
-
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_BGRA, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
}
return err;
@@ -1245,7 +1033,6 @@ int _media_thumb_image(const char *origin_path,
const char *thumb_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
@@ -1269,15 +1056,15 @@ 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, format, thumb_info);
+ err = _media_thumb_agif(origin_path, origin_w, origin_h, 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, format, thumb_info);
+ 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, format, thumb_info);
+ 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, format, thumb_info);
+ 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, format, thumb_info);
+ err = _media_thumb_bmp(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));
@@ -1303,7 +1090,7 @@ int _media_thumb_image(const char *origin_path,
thumb_info->origin_width = wbmp_width;
thumb_info->origin_height = wbmp_height;
- err = _media_thumb_wbmp(origin_path, thumb_width, thumb_height, format, thumb_info);
+ err = _media_thumb_wbmp(origin_path, thumb_width, thumb_height, thumb_info);
return err;
}
@@ -1319,7 +1106,6 @@ int _media_thumb_image(const char *origin_path,
int _media_thumb_video(const char *origin_path,
int thumb_width,
int thumb_height,
- media_thumb_format format,
media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
@@ -1404,7 +1190,6 @@ int _media_thumb_video(const char *origin_path,
/* MMF api handle both normal and DRM video */
if (video_track_num > 0 || is_drm) {
-
err = mm_file_get_attrs(content, &err_msg,
MM_FILE_CONTENT_VIDEO_WIDTH,
&width,
@@ -1436,10 +1221,10 @@ int _media_thumb_video(const char *origin_path,
thumb_info->origin_height = height;
err = _media_thumb_get_proper_thumb_size(width, height, &thumb_width, &thumb_height);
-#if THUMB_PERFORMANCE_ENHANCED
+
unsigned int new_size = 0;
unsigned char *new_frame = NULL;
- err = _media_thumb_convert_video(frame, size, &new_frame, &new_size, width, height, MM_UTIL_IMG_FMT_RGB888, MM_UTIL_IMG_FMT_BGRA8888);
+ err = _media_thumb_convert_video(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);
@@ -1478,84 +1263,6 @@ int _media_thumb_video(const char *origin_path,
return err;
}
}
-#else
- if (width > thumb_width || height > thumb_height) {
- err = _media_thumb_resize_data(frame,
- width,
- height,
- MM_UTIL_IMG_FMT_RGB888,
- thumb_info,
- thumb_width,
- thumb_height);
-
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_resize_data failed - %d", err);
- SAFE_FREE(thumb_info->data);
- mm_file_destroy_content_attrs(content);
- return err;
- }
- } else {
- thumb_info->size = size;
- thumb_info->width = width;
- thumb_info->height = height;
- thumb_info->data = malloc(size);
- if (thumb_info->data == NULL) {
- thumb_err("memory allcation failed");
- mm_file_destroy_content_attrs(content);
- return MS_MEDIA_ERR_OUT_OF_MEMORY;
- }
- memcpy(thumb_info->data, frame, size);
- }
-
- mm_file_destroy_content_attrs(content);
- if (rot_type == MM_UTIL_ROTATE_90 || rot_type == MM_UTIL_ROTATE_180 || rot_type == MM_UTIL_ROTATE_270) {
- /* Start to decode to rotate */
- unsigned char *rotated = NULL;
- unsigned int r_w = thumb_info->height;
- unsigned int r_h = thumb_info->width;
- unsigned int r_size = 0;
-
- if (rot_type == MM_UTIL_ROTATE_180) {
- r_w = thumb_info->width;
- r_h = thumb_info->height;
- }
-
- err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, r_w, r_h, &r_size);
- if (err != FILEINFO_ERROR_NONE) {
- thumb_err("mm_util_get_image_size failed : %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
-
- //thumb_dbg("Size of Rotated : %d", r_size);
- rotated = (unsigned char *)malloc(r_size);
- err = mm_util_rotate_image(thumb_info->data, thumb_info->width, thumb_info->height,
- MM_UTIL_IMG_FMT_RGB888,
- rotated, &r_w, &r_h,
- rot_type);
-
- if (err != FILEINFO_ERROR_NONE) {
- thumb_err("mm_util_rotate_image failed : %d", err);
- SAFE_FREE(thumb_info->data);
- SAFE_FREE(rotated);
- return err;
- } else {
- thumb_dbg("mm_util_rotate_image succeed");
- }
-
- SAFE_FREE(thumb_info->data);
- thumb_info->data = rotated;
- thumb_info->size = r_size;
- thumb_info->width = r_w;
- thumb_info->height = r_h;
- }
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
-#endif
} else {
thumb_dbg("no contents information");
frame = NULL;
diff --git a/test/test-thumb.c b/test/test-thumb.c
index d07ac7e..6ab7657 100755
--- a/test/test-thumb.c
+++ b/test/test-thumb.c
@@ -134,14 +134,12 @@ int main(int argc, char *argv[])
bool is_saved = FALSE;
char *thumb_path = "thumbnail_path.jpg";
- media_thumb_format thumb_format = MEDIA_THUMB_BGRA;
- //media_thumb_format thumb_format = MEDIA_THUMB_RGB888;
int is_bgra = 1;
//int is_bgra = 0;
//long start = thumb_get_debug_time();
- err = _thumbnail_get_data(origin_path, thumb_format, thumb_path, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, &is_saved);
+ err = _thumbnail_get_data(origin_path, thumb_path, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, &is_saved);
if (err < 0) {
printf("_thumbnail_get_data failed - %d\n", err);
return -1;