Code Refactoring - remove unused PNG progressive decoding 28/171228/4
authorJiyong Min <jiyong.min@samsung.com>
Tue, 27 Feb 2018 23:24:37 +0000 (08:24 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 27 Feb 2018 23:28:00 +0000 (08:28 +0900)
Change-Id: I235a533f148b3dee407dd5a319c10be873e6d2e3
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
packaging/libmm-utility.spec
png/include/mm_util_png.h
png/mm_util_png.c

index 7570fd9..0cb4af1 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.1.16
+Version:    0.1.17
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index e00e0bf..b5a3417 100755 (executable)
@@ -57,8 +57,6 @@ typedef struct {
        int filter_type;                        /**< Filter type*/
        size_t rowbytes;                        /**< Number or bytes in each row*/
 
-       int progressive;                        /**< Is progressive decoding */
-       unsigned int progressive_bytes;         /**< Number of bytes to process at a time for progressive decoding*/
        int transform;                          /**< Transform masks for decoding */
        int compression_level;                  /**< Compression level of encoding */
        int filter;                             /**< Filter */
index 8d3d43a..c905ac8 100755 (executable)
 #include "mm_util_private.h"
 
 #define MM_UTIL_PNG_BYTES_TO_CHECK 4
-#define MM_UTIL_PROGRESSIVE_BYTES_DEFAULT 1024
 #define MM_UTIL_BIT_DEPTH_8 8
 
 #define png_infopp_NULL (png_infopp)NULL
-#define png_voidp_NULL (png_voidp)NULL
 
 typedef struct {
        void *mem;
@@ -186,103 +184,6 @@ static int __read_png(mm_util_png_data *decoded, FILE * fp, void *memory)
        return MM_UTIL_ERROR_NONE;
 }
 
-static void user_info_callback(png_structp png_ptr, png_infop info)
-{
-       mm_util_png_data *decoded = (mm_util_png_data *) png_get_io_ptr(png_ptr);
-
-       mm_util_debug("user_info_callback");
-       __dec_set_prop(decoded, png_ptr, info);
-
-       /* Allocate output buffer */
-       decoded->data = (void *)png_malloc(png_ptr, sizeof(png_bytep) * decoded->size);
-}
-
-static void user_endrow_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass)
-{
-       mm_util_png_data *decoded = (mm_util_png_data *) png_get_io_ptr(png_ptr);
-
-       if (new_row) {
-               png_uint_32 offset = row_num * decoded->png.rowbytes;
-
-               png_progressive_combine_row(png_ptr, decoded->data + offset, new_row);
-       }
-}
-
-static void user_end_callback(png_structp png_ptr, png_infop info)
-{
-       mm_util_debug("and we are done reading this image");
-}
-
-static int __read_png_progressive(mm_util_png_data *decoded, FILE * fp, void *memory, unsigned long long src_size)
-{
-       png_structp png_ptr;
-       png_infop info_ptr;
-       static unsigned long long old_length = 0;
-
-       mm_util_debug("__read_png_progressive");
-       decoded->data = NULL;
-
-       png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp) NULL, __user_error_fn, __user_warning_fn);
-
-       if (png_ptr == NULL) {
-               mm_util_error("could not create read struct");
-               mm_util_safe_fclose(fp);
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
-
-       info_ptr = png_create_info_struct(png_ptr);
-       if (info_ptr == NULL) {
-               mm_util_error("could not create info struct");
-               mm_util_safe_fclose(fp);
-               png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
-
-       if (setjmp(png_jmpbuf(png_ptr))) {
-               mm_util_error("setjmp called due to internal libpng error");
-               if (decoded->data) {
-                       png_free(png_ptr, decoded->data);
-                       decoded->data = NULL;
-                       mm_util_debug("free data");
-               }
-               png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
-               mm_util_safe_fclose(fp);
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
-
-       png_set_progressive_read_fn(png_ptr, decoded, user_info_callback, user_endrow_callback, user_end_callback);
-
-       while (1) {
-               char buf[decoded->png.progressive_bytes];
-               unsigned long long bytes_read = 0;
-
-               if (fp) {
-                       if (!(bytes_read = fread(buf, 1, decoded->png.progressive_bytes, fp)))
-                               break;
-               } else if (memory) {
-                       unsigned long long length = src_size - old_length;
-
-                       if (length == 0)
-                               break;
-                       else if (length >= decoded->png.progressive_bytes)
-                               bytes_read = decoded->png.progressive_bytes;
-                       else
-                               bytes_read = length;
-
-                       memcpy(buf, memory + old_length, bytes_read);
-
-                       old_length += bytes_read;
-               } else
-                       break;
-               png_process_data(png_ptr, info_ptr, (png_bytep) buf, bytes_read);
-       };
-
-       png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
-       mm_util_safe_fclose(fp);
-
-       return MM_UTIL_ERROR_NONE;
-}
-
 int mm_util_decode_from_png_file(mm_util_png_data *decoded, const char *fpath)
 {
        int ret = MM_UTIL_ERROR_NONE;
@@ -294,12 +195,8 @@ int mm_util_decode_from_png_file(mm_util_png_data *decoded, const char *fpath)
                return ret;
        }
 
-       if (fp) {
-               if (decoded->png.progressive)
-                       ret = __read_png_progressive(decoded, fp, NULL, 0);
-               else
-                       ret = __read_png(decoded, fp, NULL);
-       }
+       if (fp)
+               ret = __read_png(decoded, fp, NULL);
 
        return ret;
 }
@@ -309,10 +206,8 @@ int mm_util_decode_from_png_memory(mm_util_png_data *decoded, void *memory, unsi
        int ret = MM_UTIL_ERROR_NONE;
 
        mm_util_debug("mm_util_decode_from_memory");
-       if (decoded->png.progressive)
-               ret = __read_png_progressive(decoded, NULL, memory, src_size);
-       else
-               ret = __read_png(decoded, NULL, memory);
+
+       ret = __read_png(decoded, NULL, memory);
 
        return ret;
 }
@@ -320,8 +215,6 @@ int mm_util_decode_from_png_memory(mm_util_png_data *decoded, void *memory, unsi
 void mm_util_init_decode_png(mm_util_png_data *data)
 {
        mm_util_debug("mm_util_init_decode_png");
-       data->png.progressive = 0;
-       data->png.progressive_bytes = MM_UTIL_PROGRESSIVE_BYTES_DEFAULT;
        data->png.transform = PNG_TRANSFORM_IDENTITY;
 }