diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2020-04-23 15:49:54 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2020-04-23 15:49:54 +0900 |
commit | c0f650b5d543dd07afaa98a5e04a42bfe6425e16 (patch) | |
tree | dbd2f81904911382fb10d2e218dd68622f0dc99f | |
parent | bfb2b810db4a5c35eee884de0d7fe6bdae3ef270 (diff) | |
download | libmedia-thumbnail-c0f650b5d543dd07afaa98a5e04a42bfe6425e16.tar.gz libmedia-thumbnail-c0f650b5d543dd07afaa98a5e04a42bfe6425e16.tar.bz2 libmedia-thumbnail-c0f650b5d543dd07afaa98a5e04a42bfe6425e16.zip |
Fix video thumbnail format issuesubmit/tizen/20200423.080104accepted/tizen/unified/20200423.161050
Change-Id: Ic80e0951622747c62d97bbba5370b3b935e0c8a9
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rwxr-xr-x | include/media-thumbnail.h | 2 | ||||
-rwxr-xr-x | server/thumb-server-internal.c | 2 | ||||
-rwxr-xr-x | src/media-thumbnail.c | 32 |
3 files changed, 29 insertions, 7 deletions
diff --git a/include/media-thumbnail.h b/include/media-thumbnail.h index b35426a..395855f 100755 --- a/include/media-thumbnail.h +++ b/include/media-thumbnail.h @@ -44,7 +44,7 @@ int thumbnail_request_cancel_media(unsigned int request_id); int thumbnail_request_cancel_raw_data(int request_id); int create_video_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path, bool auto_rotate); -int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height, bool auto_rotate); +int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height, bool auto_rotate, bool is_server_request); int create_image_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path, bool auto_rotate); int create_image_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height); diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c index bd43605..4f1e5f9 100755 --- a/server/thumb-server-internal.c +++ b/server/thumb-server-internal.c @@ -78,7 +78,7 @@ static int __thumbnail_get_raw_data(const char *origin_path, unsigned int *width if (file_type == THUMB_IMAGE_TYPE) { err = create_image_thumbnail_to_buffer(origin_path, *width, *height, data, size, width, height); } else if (file_type == THUMB_VIDEO_TYPE) { - err = create_video_thumbnail_to_buffer(origin_path, *width, *height, data, size, width, height, true); + err = create_video_thumbnail_to_buffer(origin_path, *width, *height, data, size, width, height, true, true); } else { thumb_err("invalid file type"); return MS_MEDIA_ERR_THUMB_UNSUPPORTED; diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c index f5d1326..03bbda9 100755 --- a/src/media-thumbnail.c +++ b/src/media-thumbnail.c @@ -447,7 +447,15 @@ int create_video_thumbnail_to_file(const char *path, unsigned int width, unsigne return err; } -int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height, bool auto_rotate) +int create_video_thumbnail_to_buffer(const char *path, + unsigned int width, + unsigned int height, + unsigned char **thumb_buffer, + size_t *thumb_size, + unsigned int *thumb_width, + unsigned int *thumb_height, + bool auto_rotate, + bool is_server_request) { int err = MS_MEDIA_ERR_NONE; int video_track_num = 0; @@ -457,6 +465,7 @@ int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsig size_t frame_size = 0; mm_util_image_h img = NULL; mm_util_magick_rotate_type rot_type = MM_UTIL_ROTATE_NUM; + mm_util_image_h convert_img = NULL; err = __check_parameter_validity_for_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height); thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid parameter"); @@ -471,11 +480,24 @@ int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsig //Extract thumbnail err = __get_video_thumb_to_buffer(video_w, video_h, frame, frame_size, rot_type, width, height, &img); - if (err == MS_MEDIA_ERR_NONE) - err = mm_image_get_image(img, thumb_width, thumb_height, NULL, thumb_buffer, thumb_size); - - mm_image_destroy_image(img); g_free(frame); + if (err != MS_MEDIA_ERR_NONE) + return err; + + if (is_server_request) { + err = mm_util_convert_B_B(img, MM_UTIL_COLOR_BGRA, &convert_img); + mm_image_destroy_image(img); + if (err != MM_UTIL_ERROR_NONE) { + thumb_err("mm_util_convert_B_B failed"); + return MS_MEDIA_ERR_INTERNAL; + } + + err = mm_image_get_image(convert_img, thumb_width, thumb_height, NULL, thumb_buffer, thumb_size); + mm_image_destroy_image(convert_img); + } else { + err = mm_image_get_image(img, thumb_width, thumb_height, NULL, thumb_buffer, thumb_size); + mm_image_destroy_image(img); + } return err; } |