INCLUDE_DIRECTORIES(${INC_DIR})
# for package file
-SET(dependents "dlog mmutil-magick mmutil-common mmutil-gif mmutil-jpeg mmutil-imgp mmutil-anim capi-base-common capi-media-tool glib-2.0")
+SET(dependents "dlog mmutil-magick mmutil-common mmutil-gif mmutil-jpeg mmutil-imgp mmutil-anim mmutil-heif capi-base-common capi-media-tool glib-2.0")
SET(pc_dependents "capi-base-common capi-media-tool")
INCLUDE(FindPkgConfig)
pkg_check_modules(${fw_name} REQUIRED ${dependents})
*
* Image Util API provides support for encoding and decoding of images. The API allows :
*- Encoding of a JPEG/PNG/GIF/BMP and WEBP(Since 6.0) image.
- *- Decoding of a JPEG/PNG/GIF/BMP and WEBP(Since 6.0) image.
+ *- Decoding of a JPEG/PNG/GIF/BMP/WEBP(Since 6.0) and HEIF(Since 6.5) image.
* Encoding supports gif images including the animated, but decoding gif does not support the animated.
*
- * The decoding of a jpeg/png/gif/bmp image located at a given path, to a buffer can be done by calling #image_util_decode_run() function and decoding of a jpeg image on memory
+ * The decoding of a jpeg/png/gif/bmp/webp/heif image located at a given path, to a buffer can be done by calling #image_util_decode_run() function and decoding of a jpeg/png/gif/bmp/webp/heif image on memory
* can be done by calling #image_util_decode_set_output_buffer(). Similarly, for encoding #image_util_encode_run() and #image_util_encode_set_output_buffer() functions can be called
* to encode an image buffer to a jpeg/png/gif/bmp/webp image and a buffer respectively.
*
* %http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
* %http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
* Finds out image type by reading the header of the image provided in input path.\n
-* Since 6.0, this module supports WEBP image format.
+* Since 6.0, this module supports WEBP image format.\n
+* Since 6.5, this module supports HEIF image format.
*
* @param[in] handle The handle of image util decoding
* @param[in] path The path to input image
* @remarks One of image_util_decode_set_input_path() or image_util_decode_set_input_buffer() should be set.\n
* If both are set then the latest input set, is considered.\n
* Finds out image type by reading the header of the image provided in input buffer.\n
-* Since 6.0, this module supports WEBP image format.
+* Since 6.0, this module supports WEBP image format.\n
+* Since 6.5, this module supports HEIF image format.
*
* @param[in] handle The handle of image util decoding
* @param[in] src_buffer The input image buffer
} transformation_s;
#define IMAGE_UTIL_TYPE_CHECK(type) \
- image_util_retvm_if((type < IMAGE_UTIL_JPEG || type > IMAGE_UTIL_WEBP), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image type [%d]", type)
+ image_util_retvm_if((type < IMAGE_UTIL_JPEG || type > IMAGE_UTIL_HEIF), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image type [%d]", type)
#define IMAGE_UTIL_SUPPORT_TYPE_CHECK(value, support) \
image_util_retvm_if((value != support), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format")
IMAGE_UTIL_GIF, /**< Image format GIF */
IMAGE_UTIL_BMP, /**< Image format BMP */
IMAGE_UTIL_WEBP, /**< Image format WEBP (Since 6.0) */
+ IMAGE_UTIL_HEIF, /**< Image format HEIF (Since 6.5) */
} image_util_type_e;
/**
Name: capi-media-image-util
Summary: A Image Utility library in Tizen Native API
-Version: 0.2.12
+Version: 0.3.0
Release: 0
Group: Multimedia/API
License: Apache-2.0
BuildRequires: pkgconfig(mmutil-gif)
BuildRequires: pkgconfig(mmutil-magick)
BuildRequires: pkgconfig(mmutil-anim)
+BuildRequires: pkgconfig(mmutil-heif)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-media-tool)
BuildRequires: pkgconfig(glib-2.0)
#include <mm_util_gif.h>
#include <mm_util_magick.h>
#include <mm_util_image.h>
+#include <mm_util_heif.h>
#include <image_util.h>
#include <image_util_private.h>
static unsigned char _GIF_HEADER[] = { 'G', 'I', 'F' };
static unsigned char _BMP_HEADER[] = { 'B', 'M' };
static unsigned char _WEBP_HEADER[] = { 0x57, 0x45, 0x42, 0x50 };
+ static unsigned char _HEIF_HEADER[] = { 'f', 't', 'y', 'p' };
static struct {
image_util_type_e image_type;
{ IMAGE_UTIL_PNG, _PNG_HEADER, sizeof(_PNG_HEADER), 0 },
{ IMAGE_UTIL_GIF, _GIF_HEADER, sizeof(_GIF_HEADER), 0 },
{ IMAGE_UTIL_BMP, _BMP_HEADER, sizeof(_BMP_HEADER), 0 },
- { IMAGE_UTIL_WEBP, _WEBP_HEADER, sizeof(_WEBP_HEADER), 8 }
- ,};
+ { IMAGE_UTIL_WEBP, _WEBP_HEADER, sizeof(_WEBP_HEADER), 8 },
+ { IMAGE_UTIL_HEIF, _HEIF_HEADER, sizeof(_HEIF_HEADER), 4 },
+ };
unsigned int i = 0;
image_util_retvm_if(!image_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_buffer");
err = mm_util_decode_from_jpeg_memory(_handle->src_buffer, _handle->src_size, colorspace, downscale, image_info);
}
break;
+
case IMAGE_UTIL_GIF:
{
if (_handle->path)
err = mm_util_decode_from_gif_memory(_handle->src_buffer, _handle->src_size, image_info);
}
break;
+
case IMAGE_UTIL_PNG:
/* fall through */
case IMAGE_UTIL_BMP:
err = mm_util_decode_image_from_buffer(_handle->src_buffer, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_WEBP), _handle->colorspace, image_info);
}
break;
+
+ case IMAGE_UTIL_HEIF:
+ {
+ if (_handle->path)
+ err = mm_util_decode_heif_from_file(_handle->path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_HEIF), image_info);
+ else
+ err = mm_util_decode_heif_from_buffer(_handle->src_buffer, _handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_HEIF), image_info);
+ }
+ break;
+
default:
image_util_error("Not supported format [%d]", _handle->image_type);
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
ret = mm_util_decode_image_from_file(file_path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_WEBP), image);
break;
+ case IMAGE_UTIL_HEIF:
+ ret = mm_util_decode_heif_from_file(file_path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_HEIF), image);
+ break;
+
default:
image_util_error("Not supported format [%d]", image_type);
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
ret = mm_util_decode_image_from_buffer((void *)buffer, buffer_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_WEBP), image);
break;
+ case IMAGE_UTIL_HEIF:
+ ret = mm_util_decode_heif_from_buffer((void *)buffer, buffer_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_HEIF), image);
+ break;
+
default:
image_util_error("Not supported format [%d]", image_type);
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
image_util_fenter();
image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
IMAGE_UTIL_TYPE_CHECK(image_type);
+ image_util_retvm_if(image_type == IMAGE_UTIL_HEIF, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image type [%d]", image_type);
encode_s *_handle = g_new0(encode_s, 1);
[IMAGE_UTIL_COLORSPACE_NV61] = _NOT_SUPPORTED_COLORSPACE,
};
+static int _convert_heif_colorspace_tbl[] = {
+ [IMAGE_UTIL_COLORSPACE_YV12] = MM_UTIL_COLOR_YUV420,
+ [IMAGE_UTIL_COLORSPACE_YUV422] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_I420] = MM_UTIL_COLOR_YUV420,
+ [IMAGE_UTIL_COLORSPACE_NV12] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_UYVY] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_YUYV] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_RGB565] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_RGB888] = MM_UTIL_COLOR_RGB24,
+ [IMAGE_UTIL_COLORSPACE_ARGB8888] = MM_UTIL_COLOR_ARGB,
+ [IMAGE_UTIL_COLORSPACE_BGRA8888] = MM_UTIL_COLOR_BGRA,
+ [IMAGE_UTIL_COLORSPACE_RGBA8888] = MM_UTIL_COLOR_RGBA,
+ [IMAGE_UTIL_COLORSPACE_BGRX8888] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV21] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV16] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV61] = _NOT_SUPPORTED_COLORSPACE,
+};
+
unsigned int _get_number_of_colorspace(void)
{
return G_N_ELEMENTS(_convert_colorspace_tbl);
case IMAGE_UTIL_WEBP:
image_util_retvm_if((_convert_webp_colorspace_tbl[colorspace] == _NOT_SUPPORTED_COLORSPACE), FALSE, "[webp] %d not supported format", colorspace);
break;
+ case IMAGE_UTIL_HEIF:
+ image_util_retvm_if((_convert_heif_colorspace_tbl[colorspace] == _NOT_SUPPORTED_COLORSPACE), FALSE, "[heif] %d not supported format", colorspace);
+ break;
default:
image_util_retvm_if(TRUE, FALSE, "Invalid image type");
}
case IMAGE_UTIL_WEBP:
new_colorspace = _convert_webp_colorspace_tbl[colorspace];
break;
+ case IMAGE_UTIL_HEIF:
+ new_colorspace = _convert_heif_colorspace_tbl[colorspace];
+ break;
default:
image_util_error("Invalid image type");
}
#define FILE_FOR_ENCODE_AGIF tzplatform_mkpath(TZ_USER_CONTENT, "imgutil_test_encode_agif")
#define FILE_FOR_ENCODE_ANIM tzplatform_mkpath(TZ_USER_CONTENT, "imgutil_test_encode_anim")
-#define IMAGE_UTIL_TYPE_MAX IMAGE_UTIL_WEBP
+#define IMAGE_UTIL_TYPE_MAX IMAGE_UTIL_HEIF
/* parameters for testsuite */
typedef enum {