Fix UTC/ITC failed after gif encoding enhanced 86/145686/2
authorJiyong Min <jiyong.min@samsung.com>
Wed, 23 Aug 2017 06:50:11 +0000 (15:50 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 23 Aug 2017 09:17:04 +0000 (18:17 +0900)
Change-Id: I37af16fb5c23342e7aca8d14abeb6cf7d84dc296
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
include/image_util_internal.h
include/image_util_private.h
src/image_util_internal.c

index a92f2c52ab7334fa3d804b60ed45596aa4c77049..26a26aae464b2c5b36f59c00e86e1cc641c5cb5e 100755 (executable)
@@ -361,7 +361,7 @@ int image_util_encode_add_frame(image_util_encode_h encode_h, image_util_frame_h
 * @pre image_util_encode_add_frame()
 * @see image_util_encode_create()
 */
-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);
 
 #ifdef __cplusplus
 }
index 1ce5ac48e8cc30d8daf214b15c75ffaa5115bc77..fddf8a6dcf733ac6c83ab7c9de27554de04d8624 100755 (executable)
@@ -122,6 +122,7 @@ typedef struct {
        unsigned long long src_size;
        void **dst_buffer;
        unsigned long long dst_size;
+       unsigned long gif_encode_size;
        char *path;
        void *image_h;
        unsigned long width;
index 5c5163f67d7cf4924e39e5ff7f4de507ee5b1215..133b1ab98c82c5bfd2df80a34460a669ac92eff7 100755 (executable)
@@ -27,7 +27,6 @@ int image_util_frame_create(void *decode_encode_h, image_util_frame_h *frame_h)
 
        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) {
@@ -130,26 +129,33 @@ int image_util_encode_add_frame(image_util_encode_h encode_h, image_util_frame_h
        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;
 
@@ -157,20 +163,19 @@ int image_util_encode_save(image_util_encode_h encode_h)
 
        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;
 }