IMAGE_UTIL_SAFE_FREE(buffer[i]);
}
-static int __mm_util_processing(transformation_s *handle)
+static int __mm_util_transform(transformation_s *handle)
{
int ret = IMAGE_UTIL_ERROR_NONE;
unsigned char *dst_buf[4] = {NULL,};
image_util_debug("orig_image: %p [%zu] %lu X %lu (%u)", pop_data->data, pop_data->size, pop_data->width, pop_data->height, pop_data->color);
- ret = __mm_util_processing(handle);
+ ret = __mm_util_transform(handle);
image_util_debug("result_image: %p [%zu] %lu X %lu (%u)", handle->dst->data, handle->dst->size, handle->dst->width, handle->dst->height, handle->dst->color);
return NULL;
}
-static int __mm_util_create_thread(transformation_s *handle)
-{
- int ret = IMAGE_UTIL_ERROR_NONE;
-
- image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- image_util_retvm_if(handle->thread != NULL, IMAGE_UTIL_ERROR_NONE, "[NO-ERROR] Thread is already created");
-
- /*create threads*/
- handle->thread = g_thread_new("transform_thread", (GThreadFunc)__mm_util_thread_repeate, (gpointer)handle);
- image_util_retvm_if(handle->thread == NULL, IMAGE_UTIL_ERROR_INVALID_OPERATION, "ERROR - create thread");
-
- image_util_debug("New thread is created");
-
- return ret;
-}
-
-static int __mm_util_transform(transformation_s *handle, mm_image_info_s *image)
-{
- int ret = IMAGE_UTIL_ERROR_NONE;
-
- image_util_fenter();
-
- image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- image_util_retvm_if(image == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid image");
-
- image_util_debug("image: %p", image);
-
- if (handle->queue) {
- image_util_debug("g_async_queue_push");
- g_async_queue_push(handle->queue, GINT_TO_POINTER(image));
- ret = __mm_util_create_thread(handle);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
- image_util_error("ERROR - Create thread");
- return ret;
- } else {
- image_util_debug("Success -__mm_util_create_thread");
- }
- }
-
- image_util_fleave();
-
- return ret;
-}
-
static int _image_util_packet_to_image(media_packet_h packet, mm_image_info_s **color_image)
{
int err = IMAGE_UTIL_ERROR_NONE;
image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
image_util_retvm_if((completed_cb == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid callback");
image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid source");
+ image_util_retvm_if((_handle->queue == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid queue");
image_util_retvm_if((!_handle->set_convert && !_handle->set_resize && !_handle->set_rotate && !_handle->set_crop), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid transform");
err = _image_util_packet_to_image(src, &color_image);
_handle->_util_cb->user_data = user_data;
_handle->_util_cb->completed_cb = completed_cb;
- err = __mm_util_transform(_handle, color_image);
- if (err != IMAGE_UTIL_ERROR_NONE) {
- image_util_error("Error - Run transform (%d)", err);
- __mm_util_destroy_color_image(color_image);
- return err;
+ image_util_debug("g_async_queue_push");
+ g_async_queue_push(_handle->queue, GINT_TO_POINTER(color_image));
+
+ if (!_handle->thread) {
+ /*create threads*/
+ _handle->thread = g_thread_new("transform_thread", (GThreadFunc)__mm_util_thread_repeate, (gpointer)_handle);
+ if (_handle->thread == NULL) {
+ image_util_error("Fail - Create thread");
+ __mm_util_destroy_color_image(color_image);
+ return IMAGE_UTIL_ERROR_INVALID_OPERATION;
+ } else {
+ image_util_debug("Success - Create thread");
+ }
+ } else {
+ image_util_debug("Thread alreay exist");
}
return IMAGE_UTIL_ERROR_NONE;