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);
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)
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;