int image_util_decode_create(image_util_decode_h * handle)
{
- image_util_fenter();
-
image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
- decode_s *_handle = (decode_s *) calloc(1, sizeof(decode_s));
- image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ image_util_fenter();
+
+ decode_s *_handle = g_new0(decode_s, 1);
_handle->src_buffer = NULL;
_handle->dst_buffer = NULL;
g_free(image_header);
image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "Fail to __image_util_decode_check_image_type");
- IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->src_buffer);
g_free(_handle->path);
_handle->path = g_strdup(path);
err = __image_util_decode_check_image_type(src_buffer, &_handle->image_type);
image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "__image_util_decode_check_image_type failed");
- IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
-
- _handle->src_buffer = calloc(1, src_size);
- image_util_retvm_if(!_handle->src_buffer, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ IMAGE_UTIL_SAFE_G_FREE(_handle->path);
- memcpy(_handle->src_buffer, src_buffer, src_size);
+ g_free(_handle->src_buffer);
+ _handle->src_buffer = g_memdup(src_buffer, src_size);
_handle->src_size = src_size;
- IMAGE_UTIL_SAFE_G_FREE(_handle->path);
-
return err;
}
image_util_retvm_if((ret != IMAGE_UTIL_ERROR_NONE), ret, "__image_util_decode_read_header failed");
ret = __image_util_decode_check_image_type(image_header, &image_type);
- IMAGE_UTIL_SAFE_FREE(image_header);
+ g_free(image_header);
image_util_retvm_if((ret != IMAGE_UTIL_ERROR_NONE), ret, "__image_util_decode_check_image_type failed");
switch (image_type) {
}
mm_image_destroy_image(image_info);
- IMAGE_UTIL_SAFE_FREE(_handle->decode2_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->decode2_cb);
IMAGE_UTIL_SAFE_G_FREE(_handle->path);
} else {
ret = __image_util_decode_internal(_handle, &image_info);
image_util_retvm_if(!completed_cb, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid callback");
image_util_retvm_if(_handle->thread, IMAGE_UTIL_ERROR_INVALID_OPERATION, "The thread is already running");
- if (_handle->_decode_cb != NULL) {
- IMAGE_UTIL_SAFE_FREE(_handle->_decode_cb);
- _handle->_decode_cb = NULL;
- }
+ g_free(_handle->_decode_cb);
- _handle->_decode_cb = (decode_cb_s *) calloc(1, sizeof(decode_cb_s));
- image_util_retvm_if((_handle->_decode_cb == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Out of memory");
+ _handle->_decode_cb = g_new0(decode_cb_s, 1);
_handle->_decode_cb->user_data = user_data;
_handle->_decode_cb->image_decode_completed_cb = completed_cb;
err = __image_util_decode_create_thread(_handle);
- if (err != IMAGE_UTIL_ERROR_NONE) {
- IMAGE_UTIL_SAFE_FREE(_handle->_decode_cb);
- _handle->_decode_cb = NULL;
- }
+ if (err != IMAGE_UTIL_ERROR_NONE)
+ IMAGE_UTIL_SAFE_G_FREE(_handle->_decode_cb);
image_util_fleave();
_handle->is_decode2 = TRUE;
- _handle->decode2_cb = (decode2_cb_s *) calloc(1, sizeof(decode2_cb_s));
- image_util_retvm_if((!_handle->decode2_cb), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Out of memory");
+ _handle->decode2_cb = g_new0(decode2_cb_s, 1);
_handle->decode2_cb->user_data = user_data;
_handle->decode2_cb->image_decode_completed_cb = callback;
ret = __image_util_decode_create_thread(_handle);
if (ret != IMAGE_UTIL_ERROR_NONE)
- IMAGE_UTIL_SAFE_FREE(_handle->decode2_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->decode2_cb);
image_util_fleave();
/* g_thread_exit(handle->thread); */
if (_handle->thread) {
g_thread_join(_handle->thread);
- IMAGE_UTIL_SAFE_FREE(_handle->_decode_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->_decode_cb);
}
- IMAGE_UTIL_SAFE_G_FREE(_handle->path);
- IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
- IMAGE_UTIL_SAFE_FREE(_handle);
+
+ g_free(_handle->path);
+ g_free(_handle->src_buffer);
+ g_free(_handle);
image_util_fleave();
image_util_fenter();
image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
- if (handle->gif_encode_info.sources == NULL) {
- handle->gif_encode_info.sources = calloc(1, sizeof(mm_image_info_s *));
- image_util_retvm_if((handle->gif_encode_info.sources == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- handle->gif_encode_info.sources[0] = calloc(1, sizeof(mm_image_info_s));
- image_util_retvm_if((handle->gif_encode_info.sources[0] == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- handle->gif_encode_info.sources = realloc(handle->gif_encode_info.sources, sizeof(mm_image_info_s *) * (handle->gif_encode_info.source_count + 1));
- image_util_retvm_if((handle->gif_encode_info.sources == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- handle->gif_encode_info.sources[handle->gif_encode_info.source_count] = calloc(1, sizeof(mm_image_info_s));
- image_util_retvm_if((handle->gif_encode_info.sources[handle->gif_encode_info.source_count] == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
+ handle->gif_encode_info.sources = g_realloc(handle->gif_encode_info.sources, sizeof(mm_image_info_s *) * (handle->gif_encode_info.source_count + 1));
+ handle->gif_encode_info.sources[handle->gif_encode_info.source_count] = g_new0(mm_image_info_s, 1);
handle->gif_encode_info.sources[handle->gif_encode_info.source_count]->color = IMAGE_UTIL_COLORSPACE_RGBA8888;
handle->gif_encode_info.source_count++;
image_util_fenter();
- for (i = 0; i < handle->gif_encode_info.source_count; i++) {
- IMAGE_UTIL_SAFE_FREE(handle->gif_encode_info.sources[i]);
- }
- IMAGE_UTIL_SAFE_FREE(handle->gif_encode_info.sources);
+ for (i = 0; i < handle->gif_encode_info.source_count; i++)
+ IMAGE_UTIL_SAFE_G_FREE(handle->gif_encode_info.sources[i]);
+
+ IMAGE_UTIL_SAFE_G_FREE(handle->gif_encode_info.sources);
image_util_fleave();
}
image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
IMAGE_UTIL_TYPE_CHECK(image_type);
- encode_s *_handle = (encode_s *) calloc(1, sizeof(encode_s));
- image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ encode_s *_handle = g_new0(encode_s, 1);
_handle->image_type = image_type;
_handle->dst_buffer = NULL;
_handle->quality = 75;
_handle->compression = IMAGE_UTIL_PNG_COMPRESSION_6;
- memset(&_handle->src, 0, sizeof(mm_image_info_s));
- memset(&_handle->gif_encode_info, 0, sizeof(gif_encode_s));
-
_handle->src.color = IMAGE_UTIL_COLORSPACE_RGBA8888;
_handle->thread = NULL;
image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
image_util_retvm_if(!dst_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid dst_buffer");
- IMAGE_UTIL_SAFE_FREE(_handle->path);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->path);
_handle->dst_buffer = (void **)dst_buffer;
}
mm_image_destroy_image(_handle->new_src);
- IMAGE_UTIL_SAFE_FREE(_handle->encode_to_file_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->encode_to_file_cb);
IMAGE_UTIL_SAFE_G_FREE(_handle->path);
} else {
}
mm_image_destroy_image(_handle->new_src);
- IMAGE_UTIL_SAFE_FREE(_handle->encode_to_buffer_cb);
- IMAGE_UTIL_SAFE_FREE(buffer);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->encode_to_buffer_cb);
+ IMAGE_UTIL_SAFE_G_FREE(buffer);
}
} else { //old encode
_handle->_encode_cb->image_encode_completed_cb(ret, _handle->_encode_cb->user_data, _handle->dst_size);
}
- IMAGE_UTIL_SAFE_FREE(_handle->_encode_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->_encode_cb);
}
_handle->thread = NULL;
image_util_retvm_if(!completed_cb, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid callback");
image_util_retvm_if(_handle->thread, IMAGE_UTIL_ERROR_INVALID_OPERATION, "The thread is already running");
- if (_handle->_encode_cb != NULL) {
- IMAGE_UTIL_SAFE_FREE(_handle->_encode_cb);
- _handle->_encode_cb = NULL;
- }
- _handle->_encode_cb = (encode_cb_s *) calloc(1, sizeof(encode_cb_s));
- image_util_retvm_if((_handle->_encode_cb == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Out of memory");
+ g_free(_handle->_encode_cb);
+ _handle->_encode_cb = g_new0(encode_cb_s, 1);
_handle->_encode_cb->user_data = user_data;
_handle->_encode_cb->image_encode_completed_cb = completed_cb;
err = __image_util_encode_create_thread(_handle);
- if (err != IMAGE_UTIL_ERROR_NONE) {
- IMAGE_UTIL_SAFE_FREE(_handle->_encode_cb);
- _handle->_encode_cb = NULL;
- }
+ if (err != IMAGE_UTIL_ERROR_NONE)
+ IMAGE_UTIL_SAFE_G_FREE(_handle->_encode_cb);
return err;
}
ret = mm_image_clone_image(image, &_handle->new_src);
image_util_retvm_if(ret != MM_UTIL_ERROR_NONE, IMAGE_UTIL_ERROR_INVALID_OPERATION, "Fail to mm_image_clone_image");
- _handle->encode_to_file_cb = (encode_to_file_cb_s *) calloc(1, sizeof(encode_to_file_cb_s));
- if (!_handle->encode_to_file_cb) {
- image_util_error("Out of memory");
- mm_image_destroy_image(_handle->new_src);
-
- return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
- }
+ _handle->encode_to_file_cb = g_new0(encode_to_file_cb_s, 1);
_handle->path = g_strdup(file_path);
ret = __image_util_encode_create_thread(_handle);
if (ret != IMAGE_UTIL_ERROR_NONE) {
mm_image_destroy_image(_handle->new_src);
- IMAGE_UTIL_SAFE_FREE(_handle->encode_to_file_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->encode_to_file_cb);
IMAGE_UTIL_SAFE_G_FREE(_handle->path);
}
ret = mm_image_clone_image(image, &_handle->new_src);
image_util_retvm_if(ret != MM_UTIL_ERROR_NONE, IMAGE_UTIL_ERROR_INVALID_OPERATION, "Fail to mm_image_clone_image");
- _handle->encode_to_buffer_cb = (encode_to_buffer_cb_s *) calloc(1, sizeof(encode_to_buffer_cb_s));
- if (!_handle->encode_to_buffer_cb) {
- image_util_error("Out of memory");
- mm_image_destroy_image(_handle->new_src);
-
- return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
- }
+ _handle->encode_to_buffer_cb = g_new0(encode_to_buffer_cb_s, 1);
_handle->encode_to_buffer_cb->user_data = user_data;
_handle->encode_to_buffer_cb->image_encode_to_buffer_cb = completed_cb;
ret = __image_util_encode_create_thread(_handle);
if (ret != IMAGE_UTIL_ERROR_NONE) {
mm_image_destroy_image(_handle->new_src);
- IMAGE_UTIL_SAFE_FREE(_handle->encode_to_buffer_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->encode_to_buffer_cb);
}
image_util_fleave();
/* g_thread_exit(handle->thread); */
if (_handle->thread) {
g_thread_join(_handle->thread);
- IMAGE_UTIL_SAFE_FREE(_handle->_encode_cb);
+ IMAGE_UTIL_SAFE_G_FREE(_handle->_encode_cb);
}
__free_source_buffer(_handle);
- IMAGE_UTIL_SAFE_G_FREE(_handle->path);
- IMAGE_UTIL_SAFE_FREE(_handle);
+ g_free(_handle->path);
+ g_free(_handle);
return err;
}
ret = mm_util_gif_encode_create(&_handle);
if (ret != MM_UTIL_ERROR_NONE) {
image_util_error("mm_util_gif_encode_create is failed (%d)", ret);
- IMAGE_UTIL_SAFE_FREE(_handle);
+ IMAGE_UTIL_SAFE_G_FREE(_handle);
return _image_error_capi(ret);
}
int ret = IMAGE_UTIL_ERROR_NONE;
mm_gif_file_h _handle = (mm_gif_file_h)handle;
- image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+ image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
ret = mm_image_set_delay_time((mm_util_image_h)image, time_delay);
if (ret != MM_UTIL_ERROR_NONE) {
int ret = IMAGE_UTIL_ERROR_NONE;
mm_gif_file_h _handle = (mm_gif_file_h)handle;
- image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+ image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
ret = mm_util_gif_encode_set_file(_handle, file_path);
image_util_retvm_if(ret != MM_UTIL_ERROR_NONE, _image_error_capi(ret), "mm_util_gif_encode_set_file is failed (%d)", ret);
int ret = IMAGE_UTIL_ERROR_NONE;
mm_gif_file_h _handle = (mm_gif_file_h)handle;
- image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+ image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
ret = mm_util_gif_encode_set_mem(_handle, (void **)buffer, buffer_size);
image_util_retvm_if(ret != MM_UTIL_ERROR_NONE, _image_error_capi(ret), "mm_util_gif_encode_set_mem is failed (%d)", ret);
image_util_fenter();
- image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+ image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
mm_util_gif_encode_destroy(_handle);
ret = __create_media_format(__image_format_to_mimetype(format), width, height, &fmt);
if (ret != IMAGE_UTIL_ERROR_NONE) {
image_util_error("__create_media_format failed (%d)", ret);
- IMAGE_UTIL_SAFE_FREE(buffer);
+ g_free(buffer);
return IMAGE_UTIL_ERROR_INVALID_OPERATION;
}
image_util_error("__create_media_packet failed (%d)", ret);
media_format_unref(fmt);
- IMAGE_UTIL_SAFE_FREE(buffer);
+ g_free(buffer);
image_util_fleave();
image_util_debug("stride_width: %d, stride_height: %d, plane_ptr: %p, plane_size: %zu",
stride_width, stride_height, plane_ptr,plane_size);
- ptr = realloc(ptr, size + plane_size);
- image_util_retvm_if(!ptr, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+ ptr = g_realloc(ptr, size + plane_size);
memcpy(ptr + size, plane_ptr, plane_size);
size += plane_size;
image_util_debug("[Fotmat: %u] W x H : %d x %d buffer(size) : %p(%zu)", mimetype, width, height, ptr, size);
ret = mm_image_create_image(width, height, __mimetype_to_image_format(mimetype), ptr, size, image);
- IMAGE_UTIL_SAFE_FREE(ptr);
+ g_free(ptr);
image_util_retvm_if((ret != IMAGE_UTIL_ERROR_NONE), ret, "mm_image_create_image failed (%d)", ret);
image_util_fleave();
return IMAGE_UTIL_ERROR_NONE;
ERROR:
- IMAGE_UTIL_SAFE_FREE(ptr);
+ g_free(ptr);
return IMAGE_UTIL_ERROR_INVALID_OPERATION;
}