Remove mm_util_decode_from_jpeg_memory() and mm_util_decode_from_jpeg_file() API... 27/170727/2
authorhj kim <backto.kim@samsung.com>
Thu, 22 Feb 2018 01:08:22 +0000 (10:08 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 22 Feb 2018 01:58:15 +0000 (10:58 +0900)
Change-Id: I113bb58a73153d91c0d08c602e4c5283dbc996a4

imgcv/test/mm_util_imgcv_testsuite.c
jpeg/include/mm_util_jpeg.h
jpeg/mm_util_jpeg.c
jpeg/test/mm_util_jpeg_testsuite.c
packaging/libmm-utility.spec

index c9298df..49e54f8 100755 (executable)
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
        mm_util_jpeg_yuv_data decoded;
        memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
 
-       ret = mm_util_decode_from_jpeg_file(&decoded, filename, MM_UTIL_COLOR_RGB24);
+       ret = mm_util_decode_from_jpeg_file_with_downscale(&decoded, filename, MM_UTIL_COLOR_RGB24, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
 
        if (!ret) {
                img_buffer = decoded.data;
index 51af0a9..12b5460 100755 (executable)
@@ -92,35 +92,6 @@ int mm_util_jpeg_encode_to_file(const char *filename, void *src, int width, int
  */
 int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void *src, int width, int height, mm_util_color_format_e fmt, int quality);
 
-
-/**
- * This function extracts yuv data from jpeg file
- *
- * @param decoded [out]     pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory.
- * @param filename [in]     input file name, encoded stream file
- * @param fmt [in]          color format
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see         mm_util_jpeg_yuv_data, mm_util_color_format_e
- * @since       R1, 1.0
- */
-int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt);
-
-
-/**
- * This function extracts yuv data from jpeg buffer
- *
- * @param decoded [out]     pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory.
- * @param src [in]          input stream pointer(pointer of encoded jpeg stream data)
- * @param size [in]         size of input stream(size of pointer of encoded jpeg stream data)
- * @param fmt [in]          color format
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see         mm_util_jpeg_yuv_data, mm_util_color_format_e
- * @since       R1, 1.0
- */
-int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt);
-
 /**
  * This function extracts yuv data from jpeg file with downscale decode option
  *
index a6530f2..9b74b24 100755 (executable)
@@ -1231,142 +1231,6 @@ int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void* src, int
        return ret;
 }
 
-int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt)
-{
-       int ret = MM_UTIL_ERROR_NONE;
-
-       mm_util_fenter();
-
-       mm_util_retvm_if(decoded == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid decoded");
-       mm_util_retvm_if(filename == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid filename");
-       mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
-
-       FILE *fp = NULL;
-       ret = mm_util_safe_fopen(filename, "rb", &fp);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               mm_util_error("mm_util_safe_fopen failed (%d)", ret);
-               return ret;
-       }
-
-       unsigned char magic[2] = {0};
-       size_t read_size = 0;
-       if (fp) {
-               read_size = fread((void *)magic, 1, 2, fp);
-               if (read_size > 0)
-                       mm_util_debug("Success fread");
-
-               mm_util_debug("%x %x", magic[0], magic[1]);
-               mm_util_safe_fclose(fp);
-       } else {
-               mm_util_error("[infile] file open [%s]", filename);
-               mm_util_stderror("file open failed");
-               return MM_UTIL_ERROR_NO_SUCH_FILE;
-       }
-
-       if (magic[0] == 0xff && magic[1] == 0xd8) {
-#ifdef LIBJPEG_TURBO
-               mm_util_debug("#START# LIBJPEG_TURBO");
-               ret = __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
-#else
-               mm_util_debug("#START# libjpeg(fmt:%d)", fmt);
-               if (fmt == MM_UTIL_COLOR_NV12) {
-                       ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_COLOR_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
-                       if (ret == MM_UTIL_ERROR_NONE) {
-                               unsigned int res_w = 0;
-                               unsigned int res_h = 0;
-                               size_t res_buffer_size = 0;
-                               unsigned char *dst = NULL;
-
-                               ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
-
-                               MMUTIL_SAFE_FREE(decoded->data);
-
-                               decoded->data = calloc(1, res_buffer_size);
-                               if (decoded->data == NULL) {
-                                       mm_util_debug("memory allocation failed");
-                                       MMUTIL_SAFE_FREE(dst);
-                                       return MM_UTIL_ERROR_OUT_OF_MEMORY;
-                               }
-
-                               memcpy(decoded->data, dst, res_buffer_size);
-                               decoded->size = (unsigned int)res_buffer_size;
-
-                               MMUTIL_SAFE_FREE(dst);
-                       }
-               } else {
-                       ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, fmt, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
-               }
-#endif
-               mm_util_debug("decoded->data: %p\t width: %d\t height: %d\t size: %u", decoded->data, decoded->width, decoded->height, decoded->size);
-               mm_util_debug("#End# libjpeg, Success!! ret: %d", ret);
-       } else if (magic[0] == 0x47 && magic[1] == 0x49) {
-               mm_util_error("Not JPEG IMAGE - GIF");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if (magic[0] == 0x89 && magic[1] == 0x50) {
-               mm_util_error("Not JPEG IMAGE - PNG");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if (magic[0] == 0x49 && magic[1] == 0x49) {
-               mm_util_error("Not JPEG IMAGE - TIFF");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else {
-               mm_util_error("Not JPEG IMAGE");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       }
-
-       mm_util_fleave();
-
-       return ret;
-}
-
-int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt)
-{
-       int ret = MM_UTIL_ERROR_NONE;
-
-       mm_util_fenter();
-
-       mm_util_retvm_if(decoded == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid decoded");
-       mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
-       mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
-
-#ifdef LIBJPEG_TURBO
-       mm_util_debug("#START# libjpeg");
-       ret = __mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(decoded, src, size, fmt);
-#else
-       mm_util_debug("#START# libjpeg");
-       if (fmt == MM_UTIL_COLOR_NV12) {
-               ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_COLOR_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
-               if (ret == MM_UTIL_ERROR_NONE) {
-                       unsigned int res_w = 0;
-                       unsigned int res_h = 0;
-                       size_t res_buffer_size = 0;
-                       unsigned char *dst = NULL;
-
-                       ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
-
-                       MMUTIL_SAFE_FREE(decoded->data);
-
-                       decoded->data = calloc(1, res_buffer_size);
-                       if (decoded->data == NULL) {
-                               mm_util_debug("memory allocation failed");
-                               MMUTIL_SAFE_FREE(dst);
-                               return MM_UTIL_ERROR_OUT_OF_MEMORY;
-                       }
-
-                       memcpy(decoded->data, dst, res_buffer_size);
-                       decoded->size = (unsigned int)res_buffer_size;
-
-                       MMUTIL_SAFE_FREE(dst);
-               }
-       } else {
-               ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, fmt, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
-       }
-#endif
-       mm_util_debug("decoded->data: %p\t width: %d\t height: %d\t size: %u", decoded->data, decoded->width, decoded->height, decoded->size);
-       mm_util_debug("#END# libjpeg, Success!! ret: %d", ret);
-
-       return ret;
-}
-
 int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale)
 {
        int ret = MM_UTIL_ERROR_NONE;
@@ -1409,7 +1273,7 @@ int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded,
                mm_util_debug("#START# LIBJPEG_TURBO");
                ret = __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
 #else
-               mm_util_debug("#START# libjpeg");
+               mm_util_debug("#START# libjpeg fmt [%d]", fmt);
                if (fmt == MM_UTIL_COLOR_NV12) {
                        ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_COLOR_YUV420, downscale);
                        if (ret == MM_UTIL_ERROR_NONE) {
@@ -1498,6 +1362,7 @@ int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data *decode
                                MMUTIL_SAFE_FREE(dst);
                                return MM_UTIL_ERROR_OUT_OF_MEMORY;
                        }
+
                        memcpy(decoded->data, dst, res_buffer_size);
                        decoded->size = (unsigned int)res_buffer_size;
 
index 7a39197..092bdbf 100755 (executable)
@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
        } else if (!strcmp("decode", argv[1])) {
                if (_read_file(argv[2], &src, &src_size)) {
                        fmt = atoi(argv[3]);
-                       ret = mm_util_decode_from_jpeg_memory(&decoded_data, src, src_size, fmt);
+                       ret = mm_util_decode_from_jpeg_memory_with_downscale(&decoded_data, src, src_size, fmt, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
 
                        free(src);
                        src = NULL;
index 78c0461..70db861 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.1.14
+Version:    0.1.15
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0