Fix video thumbnail format issue 37/231637/1 accepted/tizen/5.5/unified/20200423.232618 submit/tizen_5.5/20200423.075012
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 23 Apr 2020 06:58:47 +0000 (15:58 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 23 Apr 2020 06:58:47 +0000 (15:58 +0900)
Change-Id: I3aca617be6e44e56078d7460eb925db6429e2596
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/media-thumb-internal.c

index ddba747..bed7cd6 100755 (executable)
@@ -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;
 }