return result_passwd;
}
+static int __media_svc_encode_jpeg(unsigned char *src, unsigned long width, unsigned long height, image_util_colorspace_e colorspace, int quality, unsigned char **dst, unsigned long long *dst_size) {
+ int res = IMAGE_UTIL_ERROR_NONE;
+ image_util_encode_h encoder = NULL;
+ res = image_util_encode_create(IMAGE_UTIL_JPEG , &encoder);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_create failed! (%d)", res);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_set_input_buffer(encoder, src);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_set_input_buffer failed! (%d)", res);
+ image_util_encode_destroy(encoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_set_colorspace(encoder, colorspace);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_set_colorspace failed! (%d)", res);
+ image_util_encode_destroy(encoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_set_resolution(encoder, width, height);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_set_resolution failed! (%d)", res);
+ image_util_encode_destroy(encoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_set_quality(encoder, quality);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_set_quality failed! (%d)", res);
+ image_util_encode_destroy(encoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_set_output_buffer(encoder, dst);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_set_output_buffer failed! (%d)", res);
+ image_util_encode_destroy(encoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_run(encoder, dst_size);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_run failed! (%d)", res);
+ image_util_encode_destroy(encoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_encode_destroy(encoder);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_encode_destroy failed! (%d)", res);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+static int __media_svc_decode_jpeg(unsigned char *src, unsigned long long size, image_util_colorspace_e colorspace, unsigned char **dst, unsigned long *width, unsigned long *height, unsigned long long *dst_size) {
+ int res = IMAGE_UTIL_ERROR_NONE;
+ image_util_decode_h decoder = NULL;
+ res = image_util_decode_create(&decoder);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_create failed! (%d)", res);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_decode_set_input_buffer(decoder, src, size);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_set_input_buffer failed! (%d)", res);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_decode_set_colorspace(decoder, colorspace);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_set_colorspace failed! (%d)", res);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_decode_set_output_buffer(decoder, dst);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_set_output_buffer failed! (%d)", res);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_decode_run(decoder, width, height, dst_size);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_run failed! (%d)", res);
+ image_util_decode_destroy(decoder);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ res = image_util_decode_destroy(decoder);
+ if (res != IMAGE_UTIL_ERROR_NONE) {
+ media_svc_error("image_util_decode_destroy failed! (%d)", res);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, const char *img_format, unsigned char **resize_image, unsigned int *resize_size)
{
int ret = MS_MEDIA_ERR_NONE;
int resized_width = 0;
int resized_height = 0;
unsigned int buf_size = 0;
+ image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
media_svc_debug("type [jpeg] size [%d]", size);
/* decoding */
- ret = image_util_decode_jpeg_from_memory(image, size, IMAGE_UTIL_COLORSPACE_RGB888, &raw_image, &width, &height, &raw_size);
+ ret = __media_svc_decode_jpeg(image, (unsigned long long)size, colorspace, &raw_image, (unsigned long *)&width, (unsigned long *)&height, (unsigned long long *)&raw_size);
if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("image_util_decode_jpeg_from_memory failed");
+ media_svc_error("__media_svc_decode_jpeg failed");
+ *resize_image = image;
+ *resize_size = size;
+ return MS_MEDIA_ERR_NONE;
+ }
+
+ if (raw_image == NULL) {
+ media_svc_error("raw_image is null");
*resize_image = image;
*resize_size = size;
return MS_MEDIA_ERR_NONE;
resized_height = height * MEDIA_SVC_ARTWORK_SIZE / width;
}
- image_util_calculate_buffer_size(resized_width, resized_height, IMAGE_UTIL_COLORSPACE_RGB888 , &buf_size);
+ image_util_calculate_buffer_size(resized_width, resized_height, colorspace, &buf_size);
resized_raw_image = malloc(buf_size);
memset(resized_raw_image, 0, buf_size);
- ret = image_util_resize(resized_raw_image, &resized_width, &resized_height, raw_image, width, height, IMAGE_UTIL_COLORSPACE_RGB888);
+ ret = image_util_resize(resized_raw_image, &resized_width, &resized_height, raw_image, width, height, colorspace);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("image_util_resize failed");
*resize_image = image;
SAFE_FREE(raw_image);
/* encoding */
- ret = image_util_encode_jpeg_to_memory(resized_raw_image, resized_width, resized_height, IMAGE_UTIL_COLORSPACE_RGB888, 90, resize_image, resize_size);
+ ret = __media_svc_encode_jpeg(resized_raw_image, (unsigned long)resized_width, (unsigned long)resized_height, colorspace, 90, resize_image, (unsigned long long *)resize_size);
if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("image_util_encode_jpeg_to_memory failed");
+ media_svc_error("__media_svc_encode_jpeg failed");
*resize_image = image;
*resize_size = size;
SAFE_FREE(resized_raw_image);
}
SAFE_FREE(resized_raw_image);
+ if (*resize_image == NULL) {
+ media_svc_error("*resize_image is null");
+ *resize_image = image;
+ *resize_size = size;
+ return MS_MEDIA_ERR_NONE;
+ }
} else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
media_svc_debug("type [png] size [%d]", size);
*resize_image = image;
if (mmf_error != FILEINFO_ERROR_NONE) {
media_svc_error("fail to free tag attr - err(%x)", mmf_error);
}
- } else {
+ } else {
/* in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */
char *no_tag_title = NULL;
media_svc_error("no tag information");