summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminje.ahn <minje.ahn@samsung.com>2022-09-05 09:53:44 +0900
committerminje.ahn <minje.ahn@samsung.com>2022-09-05 11:20:26 +0900
commit828c4897c3dc1ee4b63d6872cd9aeb11514b3137 (patch)
treed0ff521d550a91d89fed35f7edaf157c03ae8e58
parenta0c88b8cf4d00b26ed61f80ed36faa08fa740f4c (diff)
downloadlibmedia-thumbnail-828c4897c3dc1ee4b63d6872cd9aeb11514b3137.tar.gz
libmedia-thumbnail-828c4897c3dc1ee4b63d6872cd9aeb11514b3137.tar.bz2
libmedia-thumbnail-828c4897c3dc1ee4b63d6872cd9aeb11514b3137.zip
Change-Id: I4003386f70581c0796929e0442701fb00244f50d Signed-off-by: minje.ahn <minje.ahn@samsung.com>
-rwxr-xr-xsrc/media-thumbnail.c47
1 files changed, 10 insertions, 37 deletions
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index bcff8a2..5d21169 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -173,10 +173,7 @@ static int __get_video_thumb_to_file(unsigned int width, unsigned int height, vo
thumb_retvm_if(!thumb_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid thumb_path");
__media_thumb_get_proper_thumb_size(width, height, &thumb_w, &thumb_h);
- if (thumb_w == 0 || thumb_h == 0) {
- thumb_err("Failed to get thumb size");
- return MS_MEDIA_ERR_INTERNAL;
- }
+ thumb_retv_if(thumb_w == 0 || thumb_h == 0, MS_MEDIA_ERR_INTERNAL);
err = mm_image_create_image(width, height, MM_UTIL_COLOR_RGB24, (unsigned char *)frame, frame_size, &img);
thumb_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to mm_image_create_image [%d]", err);
@@ -202,54 +199,30 @@ static int __get_video_thumb_to_file(unsigned int width, unsigned int height, vo
ERROR:
mm_image_destroy_image(img);
mm_image_destroy_image(resize_img);
- if (err == MS_MEDIA_ERR_NONE)
- return err;
- return MS_MEDIA_ERR_INTERNAL;
+ return (err == MM_UTIL_ERROR_NONE) ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_INTERNAL;
}
-static int __get_video_thumb_to_buffer(unsigned int width, unsigned int height, void *frame, size_t frame_size, mm_util_rotate_type_e rot_type, unsigned int thumb_width, unsigned int thumb_height, mm_util_image_h *dst_img)
+static int __get_video_thumb_to_buffer(unsigned int width, unsigned int height, void *frame, size_t frame_size, unsigned int thumb_width, unsigned int thumb_height, mm_util_image_h *dst_img)
{
int err = MS_MEDIA_ERR_NONE;
mm_util_image_h img = NULL;
- mm_util_image_h resize_img = NULL;
unsigned int thumb_w = thumb_width;
unsigned int thumb_h = thumb_height;
__media_thumb_get_proper_thumb_size(width, height, &thumb_w, &thumb_h);
- if (thumb_w == 0 || thumb_h == 0) {
- thumb_err("Failed to get thumb size");
- return MS_MEDIA_ERR_INTERNAL;
- }
+ thumb_retv_if(thumb_w == 0 || thumb_h == 0, MS_MEDIA_ERR_INTERNAL);
err = mm_image_create_image(width, height, MM_UTIL_COLOR_RGB24, (unsigned char *)frame, frame_size, &img);
thumb_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to mm_image_create_image [%d]", err);
- if (width > thumb_w || height > thumb_h) {
- if (rot_type != MM_UTIL_ROTATE_0) {
- err = mm_util_resize_B_B(img, thumb_w, thumb_h, &resize_img);
- if (err != MM_UTIL_ERROR_NONE)
- goto ERROR;
-
- err = mm_util_rotate_B_B(resize_img, rot_type, dst_img);
-
- } else {
- err = mm_util_resize_B_B(img, thumb_w, thumb_h, dst_img);
- }
- } else {
- if (rot_type != MM_UTIL_ROTATE_0)
- err = mm_util_rotate_B_B(img, rot_type, dst_img);
- else
- err = mm_image_clone_image(img, dst_img);
- }
-
-ERROR:
+ if (width > thumb_w || height > thumb_h)
+ err = mm_util_resize_B_B(img, thumb_w, thumb_h, dst_img);
+ else
+ err = mm_image_clone_image(img, dst_img);
mm_image_destroy_image(img);
- mm_image_destroy_image(resize_img);
- if (err != MS_MEDIA_ERR_NONE)
- return MS_MEDIA_ERR_INTERNAL;
- return MS_MEDIA_ERR_NONE;
+ return (err == MM_UTIL_ERROR_NONE) ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_INTERNAL;
}
static int __check_path_validity(const char *path)
@@ -374,7 +347,7 @@ int create_video_thumbnail_to_buffer(const char *path,
thumb_retvm_if(video_track_num == 0, MM_UTIL_ERROR_NONE, "No video track");
//Extract thumbnail
- err = __get_video_thumb_to_buffer(video_w, video_h, frame, frame_size, MM_UTIL_ROTATE_0, width, height, &img);
+ err = __get_video_thumb_to_buffer(video_w, video_h, frame, frame_size, width, height, &img);
g_free(frame);
if (err != MS_MEDIA_ERR_NONE)
return err;