From b0cf69aa0fd6980478fba9131c6ee800ebd25d69 Mon Sep 17 00:00:00 2001 From: hj kim Date: Mon, 12 Nov 2018 17:26:00 +0900 Subject: [PATCH] Remove unused internal APIs. 1.Sync APIs for transform 2. APIs to support AGIF Change-Id: Id7e4bd4280c138e3fbfe4995f939d12d21b1a387 --- decode-test/image_util_decode_encode_testsuite.c | 87 ------ include/image_util_internal.h | 333 ----------------------- src/image_util_internal.c | 249 ----------------- 3 files changed, 669 deletions(-) mode change 100644 => 100755 decode-test/image_util_decode_encode_testsuite.c delete mode 100644 include/image_util_internal.h delete mode 100755 src/image_util_internal.c diff --git a/decode-test/image_util_decode_encode_testsuite.c b/decode-test/image_util_decode_encode_testsuite.c old mode 100644 new mode 100755 index e0cc4ae..5a7ae55 --- a/decode-test/image_util_decode_encode_testsuite.c +++ b/decode-test/image_util_decode_encode_testsuite.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -46,8 +45,6 @@ typedef enum { FIRST_GIF_TEST, GIFTEST_ENCODE_FILE = FIRST_GIF_TEST, GIFTEST_ENCODE_MEM, - GIFTEST_ENCODE_FRAME_FILE, /* interanl */ - GIFTEST_ENCODE_FRAME_MEM, /* interanl */ TEST_COMMAND_NUM, } test_command_e; @@ -606,84 +603,6 @@ gboolean test_encode_gif() return TRUE; } -gboolean test_encode_gif_frame_by_frame() -{ - int ret = 0; - unsigned int i = 0; - image_util_encode_h encoded = NULL; - - ret = image_util_encode_create(g_test_input.image_type, &encoded); - if (ret != IMAGE_UTIL_ERROR_NONE) - return FALSE; - - if (g_test_input.cmd == GIFTEST_ENCODE_FRAME_MEM) - ret = image_util_encode_set_output_buffer(encoded, &g_test_encode.encoded); - else - ret = image_util_encode_set_output_path(encoded, g_test_encode.out_path); - if (ret != IMAGE_UTIL_ERROR_NONE) { - image_util_encode_destroy(encoded); - return FALSE; - } - - ret = image_util_encode_set_resolution(encoded, g_test_decode[0].width, g_test_decode[0].height); - if (ret != IMAGE_UTIL_ERROR_NONE) { - image_util_encode_destroy(encoded); - return FALSE; - } - - for (i = 0; i < g_num_of_files; i++) { - if (g_test_decode[i].decode_result == FALSE) - continue; - - image_util_frame_h frame = NULL; - ret = image_util_frame_create(&frame); - if (ret != IMAGE_UTIL_ERROR_NONE) - continue; - - 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; - } - - ret = image_util_frame_set_gif_delay(frame, 50); - if (ret != IMAGE_UTIL_ERROR_NONE) { - image_util_frame_destroy(frame); - continue; - } - - ret = image_util_encode_add_frame(encoded, frame); - if (ret != IMAGE_UTIL_ERROR_NONE) { - image_util_frame_destroy(frame); - continue; - } - image_util_frame_destroy(frame); - } - - ret = image_util_encode_save(encoded, &g_test_encode.encode_size); - if (ret != IMAGE_UTIL_ERROR_NONE) { - image_util_encode_destroy(encoded); - return FALSE; - } - - image_util_encode_destroy(encoded); - - if (g_test_input.cmd == GIFTEST_ENCODE_FRAME_MEM) { - if (_write_file(g_test_encode.out_path, g_test_encode.encoded, (size_t)g_test_encode.encode_size) == FALSE) { - fprintf(stderr, "\tWrite the encoded result failed!\n"); - return FALSE; - } - } - - return TRUE; -} - int main(int argc, char *argv[]) { if (argc < ARGC_MIN) { @@ -725,12 +644,6 @@ int main(int argc, char *argv[]) _free_datas(); return 0; } - } else if ((g_test_input.cmd == GIFTEST_ENCODE_FRAME_FILE) || (g_test_input.cmd == GIFTEST_ENCODE_FRAME_MEM)) { - if (test_encode_gif_frame_by_frame() == FALSE) { - fprintf(stderr, "\tEncode(gif frame by frame) Tests failed!\n"); - _free_datas(); - return 0; - } } else { if (test_encode() == FALSE) { fprintf(stderr, "\tEncode(default) Tests failed!\n"); diff --git a/include/image_util_internal.h b/include/image_util_internal.h deleted file mode 100644 index f2b583d..0000000 --- a/include/image_util_internal.h +++ /dev/null @@ -1,333 +0,0 @@ -/* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef __TIZEN_MULTIMEDIA_IMAGE_UTIL_INTERNAL_H__ -#define __TIZEN_MULTIMEDIA_IMAGE_UTIL_INTERNAL_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @file image_util_internal.h - * @brief This file contains the image util internal API. - */ - -/** -* @internal -* @brief Converts the image's colorspace. -* @since_tizen 2.3 -* -* @remarks You must get the @a dest buffer size using image_util_transform_calculate_buffer_size(). -* -* @param[in, out] dest The image buffer for result \n -* Must be allocated by the user -* @param[in] dest_colorspace The colorspace to be converted -* @param[in] src The source image buffer -* @param[in] width The width of the source image -* @param[in] height The height of the source image -* @param[in] src_colorspace The colorspace of the source image buffer -* -* @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 -* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion -* -* @see image_util_transform_calculate_buffer_size() -* @see image_util_transform_create() -* @see image_util_transform_destroy() -*/ -int image_util_convert_colorspace(unsigned char *dest, image_util_colorspace_e dest_colorspace, const unsigned char *src, int width, int height, image_util_colorspace_e src_colorspace); - -/** -* @internal -* @brief Resizes the image to the specified destination width and height. -* @since_tizen 2.3 -* -* @remarks Because of YUV format padding, the destination image size can be adjusted. -* -* @param[in, out] dest The image buffer for result \n -* Must be allocated by the user. -* @param[in, out] dest_width The image width to resize, and resized width -* @param[in, out] dest_height The image height to resize, and resized height -* @param[in] src The image buffer for the original image -* @param[in] src_width The original image width -* @param[in] src_height The original image height -* @param[in] colorspace The image colorspace -* -* -* @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 -* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion -* -* @see image_util_transform_calculate_buffer_size() -*/ -int image_util_resize(unsigned char *dest, int *dest_width, int *dest_height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace); - -/** -* @internal -* @brief Rotates the image to the specified angle given in degrees. -* @since_tizen 2.3 -* -* @remarks Because of YUV format padding, the destination image size can be adjusted. -* Rotations are supported only in these color spaces\n -* #IMAGE_UTIL_COLORSPACE_YV12\n -* #IMAGE_UTIL_COLORSPACE_I420\n -* #IMAGE_UTIL_COLORSPACE_NV12\n -* #IMAGE_UTIL_COLORSPACE_RGB888\n -* #IMAGE_UTIL_COLORSPACE_RGB565\n -* #IMAGE_UTIL_COLORSPACE_ARGB8888\n -* #IMAGE_UTIL_COLORSPACE_BGRA8888\n -* #IMAGE_UTIL_COLORSPACE_RGBA8888\n -* #IMAGE_UTIL_COLORSPACE_BGRX8888\n. -* -* @param[in, out] dest The image buffer for result \n -* Must be allocated by the user. -* @param[out] dest_width The rotated image width -* @param[out] dest_height The rotated image height -* @param[in] dest_rotation The angle to rotate -* @param[in] src The image buffer for the original image -* @param[in] src_width The original image width -* @param[in] src_height The original image height -* @param[in] colorspace The image colorspace -* -* @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 -* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion -* -* @see image_util_transform_calculate_buffer_size() -*/ -int image_util_rotate(unsigned char *dest, int *dest_width, int *dest_height, image_util_rotation_e dest_rotation, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace); - -/** -* @internal -* @brief Crops the image to the specified point and dimension. -* @since_tizen 2.3 -* -* @remarks Because of YUV format padding, the destination image size can be adjusted. -* Crop is supported only in these colorspaces\n -* #IMAGE_UTIL_COLORSPACE_YV12 \n -* #IMAGE_UTIL_COLORSPACE_I420 \n -* #IMAGE_UTIL_COLORSPACE_RGB888 \n -* #IMAGE_UTIL_COLORSPACE_RGB565 \n -* #IMAGE_UTIL_COLORSPACE_ARGB8888\n -* #IMAGE_UTIL_COLORSPACE_BGRA8888\n -* #IMAGE_UTIL_COLORSPACE_RGBA8888\n -* #IMAGE_UTIL_COLORSPACE_BGRX8888\n. -* -* @param[in, out] dest The image buffer for result. Must be allocated by you -* @param[in] x The starting x-axis of crop -* @param[in] y The starting y-axis of crop -* @param[in/out] width The image width to crop, and cropped width -* @param[in/out] height The image height to crop, and cropped height -* @param[in] src The image buffer for original image -* @param[in] src_width The original image width -* @param[in] src_height The original image height -* @param[in] colorspace The image colorspace -* -* @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 -* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion -* -* @see image_util_transform_calculate_buffer_size() -*/ -int image_util_crop(unsigned char *dest, int x, int y, int *width, int *height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace); - -/** -* @internal -* @brief Image util frame handle. -* @since_tizen 4.0 -*/ -typedef void *image_util_frame_h; - -/** -* @internal -* @brief Creates the handle of the frame to encode. -* @since_tizen 5.5 -* -* @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, -* otherwise a negative error value -* -* @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_set_resolution(image_util_frame_h frame_h, unsigned long width, unsigned long height); - -/** -* @internal -* @brief Sets the frame buffer and size. -* @since_tizen 4.0 -* -* @remarks The @a buffer should be released using free(). -* -* @param[in] frame_h The frame handle to encode -* @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 -* -* @retval #IMAGE_UTIL_ERROR_NONE Successful -* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation -* -* @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, size_t size); - -/** -* @internal -* @brief Sets the delay of the gif. -* @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. -* -* @param[in] frame_h The frame handle 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 -* -* @retval #IMAGE_UTIL_ERROR_NONE Successful -* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation -* -* @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); - -/** -* @internal -* @brief Destroyes the handle of the frame to encode. -* @since_tizen 4.0 -* -* @param[in] frame_h The frame handle to destroy -* -* @retval #IMAGE_UTIL_ERROR_NONE Successful -* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation -* -* @pre image_util_encode_frame_create() -* @see image_util_encode_frame_create() -*/ -void image_util_frame_destroy(image_util_frame_h frame_h); - -/** -* @internal -* @brief Adds the handle of the frame to encode. -* @since_tizen 4.0 -* -* @remarks The added frame is encoded to internal space. After frames are added,\n -* the application should call @image_util_encode_save function to complete encoding. -* -* @param[in] encode_h The encode handle -* @param[in] frame_h The frame handle to encode -* -* @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 -* -* @pre image_util_encode_create() -* @post image_util_encode_save() -* @see image_util_encode_create() -*/ -int image_util_encode_add_frame(image_util_encode_h encode_h, image_util_frame_h frame_h); - -/** -* @internal -* @brief Saves the enocoded image to the file or the buffer. -* @since_tizen 4.0 -* -* @remarks The saved images are encoded with added frames. Before call this function,\n -* the application should call @image_util_encode_add_frame function once or more. -* @param[in] encode_h The encode handle to save -* -* @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 -* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion -* -* @pre image_util_encode_create() -* @pre image_util_encode_add_frame() -* @see image_util_encode_create() -*/ -int image_util_encode_save(image_util_encode_h encode_h, unsigned long long *size); - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_MULTIMEDIA_IMAGE_UTIL_INTERNAL_H__ */ diff --git a/src/image_util_internal.c b/src/image_util_internal.c deleted file mode 100755 index 77f7ed2..0000000 --- a/src/image_util_internal.c +++ /dev/null @@ -1,249 +0,0 @@ -/* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include -#include -#include - -#include -#include - -int image_util_convert_colorspace(unsigned char *dest, image_util_colorspace_e dest_colorspace, const unsigned char *src, int width, int height, image_util_colorspace_e src_colorspace) -{ - int err = MM_UTIL_ERROR_NONE; - unsigned int res_w = 0; - unsigned int res_h = 0; - unsigned char *res_buffer = NULL; - size_t res_buffer_size = 0; - - image_util_retvm_if((dest == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest is null"); - image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "src is null"); - image_util_retvm_if((is_valid_colorspace(dest_colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid dst_colorspace"); - image_util_retvm_if((is_valid_colorspace(src_colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid src_colorspace"); - - err = mm_util_convert_colorspace(src, width, height, TYPECAST_COLOR(src_colorspace), TYPECAST_COLOR(dest_colorspace), &res_buffer, &res_w, &res_h, &res_buffer_size); - if (err == MM_UTIL_ERROR_NONE) - memcpy(dest, res_buffer, res_buffer_size); - - IMAGE_UTIL_SAFE_FREE(res_buffer); - - return _image_error_capi(err); -} - -int image_util_resize(unsigned char *dest, int *dest_width, int *dest_height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace) -{ - int err = MM_UTIL_ERROR_NONE; - unsigned int res_w = 0; - unsigned int res_h = 0; - unsigned char *res_buffer = NULL; - size_t res_buffer_size = 0; - - image_util_retvm_if((dest == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest is null"); - image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "src is null"); - image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace"); - image_util_retvm_if((dest_width == NULL || dest_height == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest_width or dest_height is null"); - image_util_retvm_if((*dest_width <= 0 || *dest_height <= 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid dest_width or Invalid dest_height"); - - err = mm_util_resize_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), *dest_width, *dest_height, &res_buffer, &res_w, &res_h, &res_buffer_size); - if (err == MM_UTIL_ERROR_NONE) { - memcpy(dest, res_buffer, res_buffer_size); - *dest_width = (int)res_w; - *dest_height = (int)res_h; - } - - return _image_error_capi(err); -} - -int image_util_rotate(unsigned char *dest, int *dest_width, int *dest_height, image_util_rotation_e dest_rotation, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace) -{ - int err = MM_UTIL_ERROR_NONE; - unsigned int res_w = 0; - unsigned int res_h = 0; - unsigned char *res_buffer = NULL; - size_t res_buffer_size = 0; - - image_util_retvm_if((dest == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest is null"); - image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "src is null"); - image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace"); - image_util_retvm_if((dest_rotation < 0 || dest_rotation > IMAGE_UTIL_ROTATION_FLIP_VERT), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid rotation"); - image_util_retvm_if((dest_width == NULL || dest_height == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest_width or dest_height is null"); - - err = mm_util_rotate_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), dest_rotation, &res_buffer, &res_w, &res_h, &res_buffer_size); - if (err == MM_UTIL_ERROR_NONE) { - memcpy(dest, res_buffer, res_buffer_size); - *dest_width = (int)res_w; - *dest_height = (int)res_h; - } - return _image_error_capi(err); -} - -int image_util_crop(unsigned char *dest, int x, int y, int *width, int *height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace) -{ - int err = MM_UTIL_ERROR_NONE; - unsigned int res_w = 0; - unsigned int res_h = 0; - unsigned char *res_buffer = NULL; - size_t res_buffer_size = 0; - - image_util_retvm_if((dest == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest is null"); - image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "src is null"); - image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace"); - image_util_retvm_if((width == NULL || height == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "width or height is null"); - image_util_retvm_if((src_width <= x || src_height <= y || src_width < x + *width || src_height < y + *height), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid crop area"); - - err = mm_util_crop_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), x, y, *width, *height, &res_buffer, &res_w, &res_h, &res_buffer_size); - if (err == MM_UTIL_ERROR_NONE) { - memcpy(dest, res_buffer, res_buffer_size); - *width = (int)res_w; - *height = (int)res_h; - } - - IMAGE_UTIL_SAFE_FREE(res_buffer); - - return _image_error_capi(err); -} - -int image_util_frame_create(image_util_frame_h *frame_h) -{ - image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); - - 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"); - - _image_info->color = IMAGE_UTIL_COLORSPACE_ARGB8888; - - *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->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) -{ - 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"); - - mm_image_info_s *frame = (mm_image_info_s *)frame_h; - - 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, size_t size) -{ - image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); - image_util_retvm_if((buffer == NULL || size == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Buffer"); - - mm_image_info_s *frame = (mm_image_info_s *)frame_h; - - frame->data = calloc(1, size); - if (frame->data == NULL) { - image_util_error("Memory allocation failed"); - return IMAGE_UTIL_ERROR_OUT_OF_MEMORY; - } - - memcpy(frame->data, buffer, size); - - frame->size = size; - - return IMAGE_UTIL_ERROR_NONE; -} - -void image_util_frame_destroy(image_util_frame_h frame_h) -{ - image_util_retm_if((frame_h == NULL), "Invalid Handle"); - - mm_image_info_s *frame = (mm_image_info_s *)frame_h; - - IMAGE_UTIL_SAFE_FREE(frame->data); - IMAGE_UTIL_SAFE_FREE(frame); -} - -int image_util_encode_add_frame(image_util_encode_h encode_h, image_util_frame_h frame_h) -{ - int ret = MM_UTIL_ERROR_NONE; - - image_util_retvm_if((encode_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); - image_util_retvm_if((frame_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); - - encode_s *encode = (encode_s *)encode_h; - mm_image_info_s *frame = (mm_image_info_s *)frame_h; - image_util_retvm_if((encode->gif_encode_info.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->width == 0) || (frame->height == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid frame"); -// image_util_retvm_if((frame->width != encode->width) || (frame->height != encode->height), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid frame"); - image_util_retvm_if(frame->data == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid frame"); - - mm_gif_file_h gif_data = (mm_gif_file_h)encode->gif_encode_info.image_h; - - if (encode->gif_encode_info.current_buffer_count == 0) { - if (encode->path) - ret = mm_util_gif_encode_set_file(gif_data, encode->path); - else - ret = mm_util_gif_encode_set_mem(gif_data, encode->dst_buffer, &encode->gif_encode_info.gif_encode_size); - } - if (ret != MM_UTIL_ERROR_NONE) { - image_util_error("mm_util_gif_encode_add_image is failed(%d).", ret); - return _image_error_capi(ret); - } - - 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(ret); - } - encode->gif_encode_info.current_buffer_count++; - - return IMAGE_UTIL_ERROR_NONE; -} - -int image_util_encode_save(image_util_encode_h encode_h, unsigned long long *size) -{ - int ret = MM_UTIL_ERROR_NONE; - - image_util_retvm_if((encode_h == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); - - encode_s *encode = (encode_s *)encode_h; - image_util_retvm_if((encode->gif_encode_info.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); - - mm_gif_file_h gif_data = (mm_gif_file_h)encode->gif_encode_info.image_h; - - ret = mm_util_gif_encode_save(gif_data); - if (ret != MM_UTIL_ERROR_NONE) { - image_util_error("mm_util_gif_encode_save is failed(%d).", ret); - mm_util_gif_encode_destroy(gif_data); - return _image_error_capi(ret); - } - - *size = (unsigned long long)encode->gif_encode_info.gif_encode_size; - encode->gif_encode_info.current_buffer_count = 0; - - return IMAGE_UTIL_ERROR_NONE; -} -- 2.7.4