decode_encode_s *image = (decode_encode_s *)decode_encode_h;
image_util_retvm_if((image->image_h == NULL), MM_UTIL_ERROR_INVALID_OPERATION, "The image handle is wrong");
- image_util_retvm_if((image->width == 0) || (image->height == 0), MM_UTIL_ERROR_INVALID_OPERATION, "The resolution is wrong");
frame_s *frame = calloc(1, sizeof(frame_s));
if (frame == NULL) {
decode_encode_s *encode = (decode_encode_s *)encode_h;
frame_s *frame = (frame_s *)frame_h;
image_util_retvm_if((encode->image_h == NULL), MM_UTIL_ERROR_INVALID_OPERATION, "The image handle is wrong");
+ image_util_retvm_if((encode->image_type != IMAGE_UTIL_GIF), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "The image type(%d) is not supported.", encode->image_type);
image_util_retvm_if((frame->frame_h == NULL), MM_UTIL_ERROR_INVALID_OPERATION, "The frame handle is wrong");
- if (encode->image_type == IMAGE_UTIL_GIF) {
- mm_gif_file_h gif_data = (mm_gif_file_h)encode->image_h;
+ mm_gif_file_h gif_data = (mm_gif_file_h)encode->image_h;
- ret = mm_util_gif_encode_add_image(gif_data, (mm_gif_image_h)frame->frame_h);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
- image_util_error("mm_util_gif_encode_add_image is failed(%d).", ret);
- mm_util_gif_encode_destroy(gif_data);
- return MM_UTIL_ERROR_INVALID_OPERATION;
- }
- } else {
- image_util_error("The image type(%d) is not supported.", encode->image_type);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ if (encode->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);
+ }
+ if (ret != IMAGE_UTIL_ERROR_NONE) {
+ image_util_error("mm_util_gif_encode_add_image is failed(%d).", ret);
+ return MM_UTIL_ERROR_INVALID_OPERATION;
+ }
+
+ ret = mm_util_gif_encode_add_image(gif_data, (mm_gif_image_h)frame->frame_h);
+ if (ret != IMAGE_UTIL_ERROR_NONE) {
+ image_util_error("mm_util_gif_encode_add_image is failed(%d).", ret);
+ return MM_UTIL_ERROR_INVALID_OPERATION;
}
+ encode->current_buffer_count++;
return IMAGE_UTIL_ERROR_NONE;
}
-int image_util_encode_save(image_util_encode_h encode_h)
+int image_util_encode_save(image_util_encode_h encode_h, unsigned long long *size)
{
int ret = IMAGE_UTIL_ERROR_NONE;
decode_encode_s *encode = (decode_encode_s *)encode_h;
image_util_retvm_if((encode->image_h == NULL), MM_UTIL_ERROR_INVALID_OPERATION, "The image handle is wrong");
+ image_util_retvm_if((encode->image_type != IMAGE_UTIL_GIF), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "The image type(%d) is not supported.", encode->image_type);
- if (encode->image_type == IMAGE_UTIL_GIF) {
- mm_gif_file_h gif_data = (mm_gif_file_h)encode->image_h;
+ mm_gif_file_h gif_data = (mm_gif_file_h)encode->image_h;
- ret = mm_util_gif_encode_save(gif_data);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
- image_util_error("mm_util_gif_encode_save is failed(%d).", ret);
- mm_util_gif_encode_destroy(gif_data);
- return MM_UTIL_ERROR_INVALID_OPERATION;
- }
- } else {
- image_util_error("The image type(%d) is not supported.", encode->image_type);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ ret = mm_util_gif_encode_save(gif_data);
+ if (ret != IMAGE_UTIL_ERROR_NONE) {
+ image_util_error("mm_util_gif_encode_save is failed(%d).", ret);
+ mm_util_gif_encode_destroy(gif_data);
+ return MM_UTIL_ERROR_INVALID_OPERATION;
}
+ *size = (unsigned long long)encode->gif_encode_size;
+ encode->current_buffer_count = 0;
+
return IMAGE_UTIL_ERROR_NONE;
}