image_util_fenter();
image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
- if (handle->sources == NULL) {
- handle->sources = calloc(1, sizeof(mm_image_info_s *));
- image_util_retvm_if((handle->sources == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- handle->sources[0] = calloc(1, sizeof(mm_image_info_s));
- image_util_retvm_if((handle->sources[0] == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ 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->sources = realloc(handle->sources, sizeof(mm_image_info_s *) * (handle->source_count + 1));
- image_util_retvm_if((handle->sources == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- handle->sources[handle->source_count] = calloc(1, sizeof(mm_image_info_s));
- image_util_retvm_if((handle->sources[handle->source_count] == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ 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->sources[handle->source_count]->color = IMAGE_UTIL_COLORSPACE_RGBA8888;
- handle->source_count++;
+ handle->gif_encode_info.sources[handle->gif_encode_info.source_count]->color = IMAGE_UTIL_COLORSPACE_RGBA8888;
+ handle->gif_encode_info.source_count++;
image_util_fleave();
return IMAGE_UTIL_ERROR_NONE;
unsigned int i = 0;
image_util_fenter();
- image_util_retm_if(handle == NULL || handle->sources == NULL, "Invalid handle");
+ image_util_retm_if(handle == NULL || handle->gif_encode_info.sources == NULL, "Invalid handle");
- for(i = 0; i < handle->source_count; i++) {
- IMAGE_UTIL_SAFE_FREE(handle->sources[i]);
+ 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->sources);
+ IMAGE_UTIL_SAFE_FREE(handle->gif_encode_info.sources);
image_util_fleave();
}
_handle->image_type = image_type;
_handle->dst_buffer = NULL;
_handle->path = NULL;
- _handle->current_buffer_count = 0;
- _handle->current_resolution_count = 0;
- _handle->current_delay_count = 0;
_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->source_count = 0;
if (_handle->image_type == IMAGE_UTIL_GIF) {
+ _handle->gif_encode_info.source_count = 0;
+ _handle->gif_encode_info.current_buffer_count = 0;
+ _handle->gif_encode_info.current_resolution_count = 0;
+ _handle->gif_encode_info.current_delay_count = 0;
+
__allocate_source_buffer(_handle);
- err = mm_util_gif_encode_create(&_handle->image_h);
+ err = mm_util_gif_encode_create(&_handle->gif_encode_info.image_h);
image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(err), "Error - mm_util_gif_encode_create is failed (%d)", err);
}
/* multi-src for a-gif */
if (_handle->image_type == IMAGE_UTIL_GIF) {
- if (_handle->source_count <= _handle->current_resolution_count) {
+ if (_handle->gif_encode_info.source_count <= _handle->gif_encode_info.current_resolution_count) {
err = __allocate_source_buffer(_handle);
image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "__allocate_source_buffer is failed");
}
- _handle->sources[_handle->current_resolution_count]->width = width;
- _handle->sources[_handle->current_resolution_count]->height = height;
- _handle->current_resolution_count++;
+ _handle->gif_encode_info.sources[_handle->gif_encode_info.current_resolution_count]->width = width;
+ _handle->gif_encode_info.sources[_handle->gif_encode_info.current_resolution_count]->height = height;
+ _handle->gif_encode_info.current_resolution_count++;
} else {
_handle->src.width = width;
_handle->src.height = height;
image_util_retvm_if((delay_time > INT_MAX), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid delay time");
/* multi-src for a-gif */
- if (_handle->source_count <= _handle->current_delay_count) {
+ if (_handle->gif_encode_info.source_count <= _handle->gif_encode_info.current_delay_count) {
err = __allocate_source_buffer(_handle);
image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "__allocate_source_buffer is failed");
}
- _handle->sources[_handle->current_delay_count]->delay_time = (int)delay_time;
- _handle->current_delay_count++;
+ _handle->gif_encode_info.sources[_handle->gif_encode_info.current_delay_count]->delay_time = (int)delay_time;
+ _handle->gif_encode_info.current_delay_count++;
return err;
}
/* multi-src for a-gif */
if (_handle->image_type == IMAGE_UTIL_GIF) {
- if (_handle->source_count <= _handle->current_buffer_count) {
+ if (_handle->gif_encode_info.source_count <= _handle->gif_encode_info.current_buffer_count) {
err = __allocate_source_buffer(_handle);
image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "__allocate_source_buffer is failed");
}
- _handle->sources[_handle->current_buffer_count]->data = (void *)src_buffer;
- _handle->current_buffer_count++;
+ _handle->gif_encode_info.sources[_handle->gif_encode_info.current_buffer_count]->data = (void *)src_buffer;
+ _handle->gif_encode_info.current_buffer_count++;
} else {
_handle->src.data = (void *)src_buffer;
}
image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
image_util_retvm_if((_handle->image_type != IMAGE_UTIL_GIF && __is_invalid_image_info(_handle->src)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
- image_util_retvm_if((_handle->image_type == IMAGE_UTIL_GIF && (_handle->sources == NULL || __is_invalid_image_info(*_handle->sources[0]))), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
+ image_util_retvm_if((_handle->image_type == IMAGE_UTIL_GIF && (_handle->gif_encode_info.sources == NULL || __is_invalid_image_info(*_handle->gif_encode_info.sources[0]))), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
switch (_handle->image_type) {
case IMAGE_UTIL_JPEG:
break;
case IMAGE_UTIL_GIF:
{
- image_util_debug("[Count] source_count:%u, buffer:%u, resolution:%u, delay:%u", _handle->source_count, _handle->current_buffer_count, _handle->current_resolution_count, _handle->current_delay_count);
- if ((_handle->source_count > 1) && ((_handle->source_count != _handle->current_buffer_count) || (_handle->source_count != _handle->current_resolution_count) || (_handle->source_count != _handle->current_delay_count))) {
+ image_util_debug("[Count] source_count:%u, buffer:%u, resolution:%u, delay:%u", _handle->gif_encode_info.source_count, _handle->gif_encode_info.current_buffer_count, _handle->gif_encode_info.current_resolution_count, _handle->gif_encode_info.current_delay_count);
+ if ((_handle->gif_encode_info.source_count > 1) && ((_handle->gif_encode_info.source_count != _handle->gif_encode_info.current_buffer_count) || (_handle->gif_encode_info.source_count != _handle->gif_encode_info.current_resolution_count) || (_handle->gif_encode_info.source_count != _handle->gif_encode_info.current_delay_count))) {
image_util_error("Total frame count does not match with the data set, for animated gif encoding");
return IMAGE_UTIL_ERROR_INVALID_OPERATION;
}
if (_handle->path)
- err = mm_util_encode_to_gif_file(_handle->sources, _handle->source_count, _handle->path);
+ err = mm_util_encode_to_gif_file(_handle->gif_encode_info.sources, _handle->gif_encode_info.source_count, _handle->path);
else
- err = mm_util_encode_to_gif_memory(_handle->sources, _handle->source_count, _handle->dst_buffer, &_handle->dst_size);
+ err = mm_util_encode_to_gif_memory(_handle->gif_encode_info.sources, _handle->gif_encode_info.source_count, _handle->dst_buffer, &_handle->dst_size);
}
break;
case IMAGE_UTIL_BMP:
encode_s *encode = (encode_s *)encode_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->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->image_h;
+ mm_gif_file_h gif_data = (mm_gif_file_h)encode->gif_encode_info.image_h;
- if (encode->current_buffer_count == 0) {
+ 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_size);
+ 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);
image_util_error("mm_util_gif_encode_add_image is failed(%d).", ret);
return _image_error_capi(ret);
}
- encode->current_buffer_count++;
+ encode->gif_encode_info.current_buffer_count++;
return IMAGE_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->image_h == NULL), IMAGE_UTIL_ERROR_INVALID_OPERATION, "The image handle is wrong");
+ 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->image_h;
+ 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) {
return _image_error_capi(ret);
}
- *size = (unsigned long long)encode->gif_encode_size;
- encode->current_buffer_count = 0;
+ *size = (unsigned long long)encode->gif_encode_info.gif_encode_size;
+ encode->gif_encode_info.current_buffer_count = 0;
return IMAGE_UTIL_ERROR_NONE;
}