if (g_test_decode[i].decode_result == FALSE)
continue;
- ret = image_util_encode_set_input_buffer(encoded, g_test_decode[i].decoded);
+ ret = image_util_encode_set_resolution(encoded, g_test_decode[i].width, g_test_decode[i].height);
if (ret != IMAGE_UTIL_ERROR_NONE)
continue;
- ret = image_util_encode_set_resolution(encoded, g_test_decode[i].width, g_test_decode[i].height);
+ ret = image_util_encode_set_input_buffer(encoded, g_test_decode[i].decoded);
if (ret != IMAGE_UTIL_ERROR_NONE)
continue;
continue;
image_util_frame_h frame = NULL;
- ret = image_util_frame_create(encoded, &frame);
+ ret = image_util_frame_create(&frame);
if (ret != IMAGE_UTIL_ERROR_NONE)
continue;
- ret = image_util_frame_set_frame(frame, g_test_decode[i].decoded);
+ ret = image_util_frame_set_resolution(frame, g_test_decode[i].width, g_test_decode[i].height);
+ if (ret != IMAGE_UTIL_ERROR_NONE) {
+ image_util_frame_destroy(frame);
+ continue;
+ }
+
+ ret = image_util_frame_set_frame(frame, g_test_decode[i].decoded, g_test_decode[i].decode_size);
if (ret != IMAGE_UTIL_ERROR_NONE) {
image_util_frame_destroy(frame);
continue;
#ifndef __TIZEN_MULTIMEDIA_IMAGE_UTIL_INTERNAL_H__
#define __TIZEN_MULTIMEDIA_IMAGE_UTIL_INTERNAL_H__
+#include <stddef.h>
#include <image_util_type.h>
#ifdef __cplusplus
/**
* @internal
* @brief Creates the handle of the frame to encode.
-* @since_tizen 4.0
+* @since_tizen 5.5
*
-* @param[in] encode_h The encode handle
+* @param[in] width The width of input image
+* @param[in] height The height of input image
+* @param[in] color The colorspace of input image
+* @param[in] data The data of input image
+* @param[in] size The size of the data
* @param[in, out] frame_h The frame handle created by encode handle
*
* @return @c 0 on success,
*
* @retval #IMAGE_UTIL_ERROR_NONE Successful
* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY Out of memory
+*
+* @post image_util_encode_frame_destroy()
+* @see image_util_encode_frame_destroy()
+*/
+int image_util_frame_create(image_util_frame_h *frame_h);
+
+/**
+* @internal
+* @brief Creates the handle of the frame to encode.
+* @since_tizen 5.5
+*
+* @param[in] frame_h The frame handle to encode
+* @param[in] width The width of input image
+* @param[in] height The height of input image
+*
+* @return @c 0 on success,
+* otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
*
* @post image_util_encode_frame_destroy()
* @see image_util_encode_frame_destroy()
*/
-int image_util_frame_create(image_util_encode_h handle, image_util_frame_h *frame_h);
+int image_util_frame_set_resolution(image_util_frame_h frame_h, unsigned long width, unsigned long height);
/**
* @internal
-* @brief Sets the delay of the gif.
+* @brief Sets the frame buffer and size.
* @since_tizen 4.0
*
-* @remarks The unit of the delay time is 10ms. If the delay time set to 50ms, the value of @delay_time should be 5.
-* If the delay time set to 1 sec, the value of @delay_time should be 100.
+* @remarks The @a buffer should be released using free().
*
* @param[in] frame_h The frame handle to encode
-* @param[in] delay_time The delay time of the frame of the gif
+* @param[in] buffer The frame buffer to encode
+* @param[in] size The buffer size to encode
*
* @return @c 0 on success,
* otherwise a negative error value
* @pre image_util_encode_frame_create()
* @see image_util_encode_frame_create()
*/
-int image_util_frame_set_gif_delay(image_util_frame_h frame_h, const int delay_time);
+int image_util_frame_set_frame(image_util_frame_h frame_h, unsigned char *buffer, size_t size);
/**
* @internal
-* @brief Sets the frame buffer.
+* @brief Sets the delay of the gif.
* @since_tizen 4.0
*
-* @remarks The @a buffer should be released using free().
+* @remarks The unit of the delay time is 10ms. If the delay time set to 50ms, the value of @delay_time should be 5.
+* If the delay time set to 1 sec, the value of @delay_time should be 100.
*
* @param[in] frame_h The frame handle to encode
-* @param[in] buffer The frame buffer to encode
+* @param[in] delay_time The delay time of the frame of the gif
*
* @return @c 0 on success,
* otherwise a negative error value
* @pre image_util_encode_frame_create()
* @see image_util_encode_frame_create()
*/
-int image_util_frame_set_frame(image_util_frame_h frame_h, unsigned char *buffer);
+int image_util_frame_set_gif_delay(image_util_frame_h frame_h, const int delay_time);
/**
* @internal
GThread *thread;
} decode_s;
-typedef struct {
- void *frame_h;
-} frame_s;
-
typedef enum {
ERR_TYPE_COMMON,
ERR_TYPE_TRANSFORM,
#include <image_util.h>
#include <image_util_private.h>
-static int _image_util_encode_get_gif_frame(mm_gif_file_h gif_data, unsigned int index, mm_gif_image_h *frame)
+static int _image_util_encode_get_gif_frame(mm_gif_file_h gif_data, unsigned int index, mm_image_info_s **frame)
{
int err = MM_UTIL_ERROR_NONE;
image_util_retvm_if((gif_data == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
_handle->height = height;
mm_util_gif_encode_set_resolution(gif_data, width, height);
}
- mm_gif_image_h frame = NULL;
+ mm_image_info_s * frame = NULL;
err = _image_util_encode_get_gif_frame(gif_data, _handle->current_resolution_count, &frame);
image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_get_gif_frame failed %d", err);
image_util_retvm_if((delay_time > INT_MAX), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid delay time");
- mm_gif_image_h frame = NULL;
+ mm_image_info_s * frame = NULL;
err = _image_util_encode_get_gif_frame(gif_data, _handle->current_delay_count, &frame);
image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_get_gif_frame failed %d", err);
/* initialize buffer and value for source buffer */
if (_handle->image_type == IMAGE_UTIL_GIF) {
mm_gif_file_h gif_data = (mm_gif_file_h) _handle->image_h;
- mm_gif_image_h frame = NULL;
+ mm_image_info_s * frame = NULL;
image_util_retvm_if(gif_data == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid gif data");
err = _image_util_encode_get_gif_frame(gif_data, _handle->current_buffer_count, &frame);
return _image_error_capi(ERR_TYPE_TRANSFORM, err);
}
-int image_util_frame_create(image_util_encode_h handle, image_util_frame_h *frame_h)
+int image_util_frame_create(image_util_frame_h *frame_h)
{
- int ret = MM_UTIL_ERROR_NONE;
-
- image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
- encode_s *image = (encode_s *)handle;
- image_util_retvm_if((image->image_h == NULL), IMAGE_UTIL_ERROR_INVALID_OPERATION, "The image handle is wrong");
+ mm_image_info_s *_image_info = calloc(1, sizeof(mm_image_info_s));
+ image_util_retvm_if(_image_info == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
- frame_s *frame = calloc(1, sizeof(frame_s));
- if (frame == NULL) {
- image_util_error("Memory allocation is failed.");
- return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
- }
+ _image_info->color = IMAGE_UTIL_COLORSPACE_ARGB8888;
- if (image->image_type == IMAGE_UTIL_GIF) {
- mm_gif_file_h gif_data = (mm_gif_file_h)image->image_h;
- mm_gif_image_h gif_frame = NULL;
-
- ret = mm_util_gif_image_create(gif_data, &gif_frame);
- if (ret != MM_UTIL_ERROR_NONE) {
- image_util_error("mm_util_gif_image_create is failed(%d).", ret);
- IMAGE_UTIL_SAFE_FREE(frame);
- return _image_error_capi(ERR_TYPE_ENCODE, ret);
- }
- frame->frame_h = gif_frame;
- } else {
- image_util_error("The image type(%d) is not supported.", image->image_type);
- IMAGE_UTIL_SAFE_FREE(frame);
- return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- }
+ *frame_h = (mm_image_info_s *)_image_info;
+
+ return IMAGE_UTIL_ERROR_NONE;
+}
+
+int image_util_frame_set_resolution(image_util_frame_h frame_h, const unsigned long width, const unsigned long height)
+{
+ image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+ image_util_retvm_if((width == 0 || height == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ mm_image_info_s *frame = (mm_image_info_s *)frame_h;
- *frame_h = frame;
+ frame->width = width;
+ frame->height = height;
return IMAGE_UTIL_ERROR_NONE;
}
int image_util_frame_set_gif_delay(image_util_frame_h frame_h, const int delay_time)
{
- int ret = MM_UTIL_ERROR_NONE;
-
image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
image_util_retvm_if((delay_time <= 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Delay Time");
- frame_s *frame = (frame_s *)frame_h;
+ mm_image_info_s *frame = (mm_image_info_s *)frame_h;
- ret = mm_util_gif_image_set_delay_time(frame->frame_h, delay_time);
- if (ret != MM_UTIL_ERROR_NONE) {
- image_util_error("mm_util_gif_image_set_delay_time is failed(%d).", ret);
- return _image_error_capi(ERR_TYPE_ENCODE, ret);
- }
+ frame->delay_time = delay_time;
return IMAGE_UTIL_ERROR_NONE;
}
-int image_util_frame_set_frame(image_util_frame_h frame_h, unsigned char *buffer)
+int image_util_frame_set_frame(image_util_frame_h frame_h, unsigned char *buffer, size_t size)
{
- int ret = MM_UTIL_ERROR_NONE;
-
image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
- image_util_retvm_if((buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Buffer");
+ image_util_retvm_if((buffer == NULL || size == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Buffer");
- frame_s *frame = (frame_s *)frame_h;
+ mm_image_info_s *frame = (mm_image_info_s *)frame_h;
- ret = mm_util_gif_image_set_image(frame->frame_h, buffer);
- if (ret != MM_UTIL_ERROR_NONE) {
- image_util_error("mm_util_gif_image_set_image is failed(%d).", ret);
- return _image_error_capi(ERR_TYPE_ENCODE, ret);
+ frame->data = calloc(1, size);
+ if (frame->data == NULL) {
+ image_util_error("Memory allocation failed");
+ mm_util_gif_image_destory(frame);
+ return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
}
+ memcpy(frame->data, buffer, size);
+
+ frame->size = size;
+
return IMAGE_UTIL_ERROR_NONE;
}
{
image_util_retm_if((frame_h == NULL), "Invalid Handle");
- frame_s *frame = (frame_s *)frame_h;
- mm_util_gif_image_destory(frame->frame_h);
+ mm_image_info_s *frame = (mm_image_info_s *)frame_h;
+ IMAGE_UTIL_SAFE_FREE(frame->data);
IMAGE_UTIL_SAFE_FREE(frame);
}
image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
encode_s *encode = (encode_s *)encode_h;
- frame_s *frame = (frame_s *)frame_h;
+ mm_image_info_s *frame = (mm_image_info_s *)frame_h;
image_util_retvm_if((encode->image_h == NULL), IMAGE_UTIL_ERROR_INVALID_OPERATION, "The image handle is wrong");
image_util_retvm_if((encode->image_type != IMAGE_UTIL_GIF), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "The image type(%d) is not supported.", encode->image_type);
- image_util_retvm_if((frame->frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_OPERATION, "The frame handle is wrong");
+ image_util_retvm_if((frame->width == 0) || (frame->height == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ image_util_retvm_if(frame->data == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
mm_gif_file_h gif_data = (mm_gif_file_h)encode->image_h;
return _image_error_capi(ERR_TYPE_ENCODE, ret);
}
- ret = mm_util_gif_encode_add_image(gif_data, (mm_gif_image_h)frame->frame_h);
+ ret = mm_util_gif_encode_add_image(gif_data, (mm_image_info_s *)frame);
if (ret != MM_UTIL_ERROR_NONE) {
image_util_error("mm_util_gif_encode_add_image is failed(%d).", ret);
return _image_error_capi(ERR_TYPE_ENCODE, ret);