#include <stdbool.h>
#include <stdlib.h>
+#include <glib.h>
+
#include "mm_util_type.h"
typedef void *mm_util_imgp_h;
typedef bool (*mm_util_completed_callback)(mm_util_color_image_h image, int error, void *user_param);
-/**
- @addtogroup UTILITY
- @{
-
- @par
- This part describes the APIs with repect to image converting library.
- */
-/**
- * Image rotation types
- */
typedef enum {
MM_UTIL_ROTATE_0, /**< Rotation 0 degree - no effect */
MM_UTIL_ROTATE_90, /**< Rotation 90 degree */
MM_UTIL_ROTATE_NUM /**< Number of rotation types */
} mm_util_img_rotate_type;
-/**
- * This function calculates the size of the image data in bytes.
- *
- * @param format [in] image format information
- * @param width [in] pixel size of width
- * @param height [in] pixel size of height
- * @param size [out] data size of image in bytes
- *
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e
- * @since R1, 1.0
- */
-int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize);
-
-/**
- *
- * @remark Transform Handle Creation
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @return This function returns transform processor result value
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_create(mm_util_imgp_h *imgp_handle);
-
-/**
- *
- * @remark Transform Handle Creation
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @param colorspace [in] colorspace The colorspace of the destination image buffer
-
- * @return This function returns transform processor result value
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_format_e colorspace);
-
-/**
- *
- * @remark Transform Handle Creation
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @param width [in] width The width of destination image buffer
- * @param height [in] height The height of destination image buffer
-
- * @return This function returns transform processor result value
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_set_resolution(mm_util_imgp_h imgp_handle, unsigned int width, unsigned int height);
-
-/**
- *
- * @remark Transform Handle Creation
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @param rotation [in] dest_rotation The rotation value of destination image buffer
-
- * @return This function returns transform processor result value
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_set_rotation(mm_util_imgp_h imgp_handle, mm_util_img_rotate_type rotation);
-
-/**
- *
- * @remark Transform Handle Creation
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @param start_x [in] The start x position of cropped image buffer
- * @param start_y [in] The start y position of cropped image buffer
- * @param end_x [in] The start x position of cropped image buffer
- * @param end_y [in] The start y position of cropped image buffer
-
- * @return This function returns transform processor result value
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_set_crop_area(mm_util_imgp_h imgp_handle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y);
-
-/**
- *
- * @remark Transform Handle Creation
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @param is_completed [in/out] Users can obtain the value of the conversion about whether to complete
+typedef struct {
+ void *user_data;
+ mm_util_completed_callback completed_cb;
+} mm_util_cb_s;
+
+typedef struct {
+ mm_image_info_s *src;
+ mm_image_info_s *dst;
+
+ /* for converting colorspace */
+ mm_util_color_format_e dst_format;
+ /* for image crop */
+ /* for resize */
+ unsigned int start_x;
+ unsigned int start_y;
+ unsigned int dst_width;
+ unsigned int dst_height;
+
+ /* for rotation */
+ mm_util_img_rotate_type rotation;
+
+ bool set_convert;
+ bool set_crop;
+ bool set_resize;
+ bool set_rotate;
+
+ /* for multi instance */
+ mm_util_cb_s *_util_cb;
+ bool is_completed;
+ bool is_finish;
+ GThread* thread;
+ GAsyncQueue *queue;
+} mm_util_s;
- * @return This function returns transform processor result value
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_transform_is_completed(mm_util_imgp_h imgp_handle, bool *is_completed);
-
-/**
- *
- * @remark Image Transform Pipeline
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @param completed_callback [in] Completed_callback
- * @param user_param [in] User parameter which is received from user when callback function was set
-
- * @return This function returns transform processor result value
- * if the result is 0, then you can use output_Filename pointer(char** value)
- * else if the result is -1, then do not execute when the colopsapce converter is not supported
- */
+int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize);
+//int mm_util_create(mm_util_imgp_h *imgp_handle);
+//int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_format_e colorspace);
+//int mm_util_set_resolution(mm_util_imgp_h imgp_handle, unsigned int width, unsigned int height);
+//int mm_util_set_rotation(mm_util_imgp_h imgp_handle, mm_util_img_rotate_type rotation);
+//int mm_util_set_crop_area(mm_util_imgp_h imgp_handle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y);
int mm_util_transform(mm_util_imgp_h imgp_handle, mm_util_color_image_h image, mm_util_completed_callback completed_callback, void * user_data);
-
-/**
- *
- * @remark Transform Handle Destory
- *
- * @param imgp_handle [in] image_util_imgp_h
- * @return This function returns transform processor result value
- * if the result is 0, then handle destory succeed
- * else if the result is -1, then handle destory failed
- */
-int mm_util_destroy(mm_util_imgp_h imgp_handle);
-
-/**
- * This function convert the pixel format from source format to destination format.
- *
- * @param src [in] pointer of source image data
- * @param src_width [in] pixel size of source image width
- * @param src_height [in] pixel size of source image height
- * @param src_format [in] pixel format of source image
- * @param dst [in/out] pointer of destination image data
- * @param dst_format [in] pixel format of destination image
- *
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e
- * @since R1, 1.0
- */
+//int mm_util_destroy(mm_util_imgp_h imgp_handle);
int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_color_format_e dst_format, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
-
-
-/**
- * This function resizes the source image.
- *
- * @param src [in] pointer of source image data
- * @param src_width [in] pixel size of source image width
- * @param src_height [in] pixel size of source image height
- * @param src_format [in] pixel format of source image
- * @param dst [in/out] pointer of destination image data
- * @param dst_width [in/out] pixel size of destination image width
- * @param dst_height [in/out] pixel size of destination image height
- *
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e
- * @since R1, 1.0
- */
int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned int dst_width, unsigned int dst_height, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
-
-
-/**
- * This function rotates the source image.
- *
- * @param src [in] pointer of source image data
- * @param src_width [in] pixel size of source image width
- * @param src_height [in] pixel size of source image height
- * @param src_format [in] pixel format of source image
- * @param dst [in/out] pointer of destination image data
- * @param dst_width [in/out] pixel size of destination image width
- * @param dst_height [in/out] pixel size of destination image height
- * @param angle [in] rotation enum value
- *
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e, mm_util_img_rotate_type
- * @since R1, 1.0
- */
int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_img_rotate_type angle, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
-
-
-/**
- * This function crop the source image.
- *
- * @param src [in] pointer of source image data
- * @param src_width [in] pixel size of source image width
- * @param src_height [in] pixel size of source image height
- * @param src_format [in] pixel format of source image
- * @param crop_start_x [in] pixel point of cropped image
- * @param crop_start_y [in] pixel point of cropped image
- * @param crop_dest_width [in/out] cropped image width (value is changed when yuv image width is odd)
- * @param crop_dest_height [in/out] cropped image height
-
- * @param dst [in/out] pointer of destination image data
- *
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e, mm_util_img_rotate_type
- * @since R1, 1.0
- */
int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height,
unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);