summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/media-thumb-internal.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index ddba747..bed7cd6 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -316,6 +316,7 @@ int _media_thumb_video(const char *origin_path, const char *thumb_path, unsigned
unsigned int width = 0;
unsigned int height = 0;
mm_util_image_h dst_img = NULL;
+ mm_util_image_h convert_img = NULL;
unsigned char *buf = NULL;
size_t size = 0;
mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
@@ -328,25 +329,29 @@ int _media_thumb_video(const char *origin_path, const char *thumb_path, unsigned
if (STRING_VALID(thumb_path)) {
err = __get_video_thumb(width, height, frame, size, rot_type, thumb_path, thumb_width, thumb_height, NULL);
-
+ SAFE_FREE(frame);
} else if (thumb_info) {
err = __get_video_thumb(width, height, frame, size, rot_type, NULL, thumb_width, thumb_height, &dst_img);
- if (err == MS_MEDIA_ERR_NONE) {
- err = mm_image_get_image(dst_img, &width, &height, &format, &buf, &size);
- thumb_info->data = buf;
- thumb_info->size = size;
- thumb_info->width = width;
- thumb_info->height = height;
- }
+ SAFE_FREE(frame);
+ thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "__get_video_thumb failed");
+ /* Convert rgb to bgra */
+ err = mm_util_convert_B_B(dst_img, MM_UTIL_COLOR_BGRA, &convert_img);
mm_image_destroy_image(dst_img);
+ thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "mm_util_convert_B_B failed");
+
+ err = mm_image_get_image(convert_img, &width, &height, &format, &buf, &size);
+ thumb_info->data = buf;
+ thumb_info->size = size;
+ thumb_info->width = width;
+ thumb_info->height = height;
+
+ mm_image_destroy_image(convert_img);
} else {
thumb_err("Invalid parameter");
err = MS_MEDIA_ERR_INVALID_PARAMETER;
}
- SAFE_FREE(frame);
-
return err;
}