Change the buffer(memory) parameter of the image for decoding and remove unused code 63/165763/6 accepted/tizen/unified/20180109.172741 submit/tizen/20180108.064644
authorJiyong Min <jiyong.min@samsung.com>
Wed, 3 Jan 2018 23:14:20 +0000 (08:14 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Thu, 4 Jan 2018 09:28:50 +0000 (18:28 +0900)
(The buffer is used as 'void *', so 'void **' is changed to 'void *'.)

Change-Id: Id1636f5e5550983efd7742205dcce462dc7b5385

bmp/include/mm_util_bmp.h
bmp/mm_util_bmp.c
gif/include/mm_util_gif.h
gif/mm_util_gif.c
png/include/mm_util_png.h
png/mm_util_png.c

index 16eb713b37307346729c40748336f0c9cf4efd37..648528fb227bf651d17d88129ce51c8b716d05a9 100755 (executable)
@@ -76,45 +76,7 @@ int mm_util_decode_from_bmp_file(mm_util_bmp_data * decoded, const char *filenam
  * @see                     mm_util_bmp_data
  * @since                   R1, 1.0
  */
-int mm_util_decode_from_bmp_memory(mm_util_bmp_data * decoded, void **memory, unsigned long long src_size);
-
-#if 0
-/**
- * This function gets the width of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_bmp_data.
- * @return                    Width of the decoded image.
- * @remark
- * @see                       mm_util_bmp_data
- * @since                     R1, 1.0
- */
-unsigned long mm_util_bmp_decode_get_width(mm_util_bmp_data * data);
-
-/**
- * This function gets the height of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_bmp_data.
- * @return                    Height of the decoded image.
- * @remark
- * @see                       mm_util_bmp_data
- * @since                     R1, 1.0
- */
-unsigned long mm_util_bmp_decode_get_height(mm_util_bmp_data * data);
-
-/**
- * This function gets the size of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_bmp_data.
- * @return                    Size of the decoded image.
- * @remark
- * @see                       mm_util_bmp_data
- * @since                     R1, 1.0
- */
-unsigned long long mm_util_bmp_decode_get_size(mm_util_bmp_data * data);
-#endif
+int mm_util_decode_from_bmp_memory(mm_util_bmp_data * decoded, void *memory, unsigned long long src_size);
 
 /**
  * This function encodes raw data to bmp file
index 8749a408fe0214d21e7976e134c3cb17130994e6..2c51412de4e640e44c1b4997e572e4ca2c03a381 100755 (executable)
@@ -187,34 +187,17 @@ int mm_util_decode_from_bmp_file(mm_util_bmp_data *decoded, const char *filename
        return ret;
 }
 
-int mm_util_decode_from_bmp_memory(mm_util_bmp_data *decoded, void **memory, unsigned long long src_size)
+int mm_util_decode_from_bmp_memory(mm_util_bmp_data *decoded, void *memory, unsigned long long src_size)
 {
        int ret;
 
        mm_util_debug("mm_util_decode_from_gif_file");
 
-       ret = __read_bmp(decoded, NULL, *memory, src_size);
+       ret = __read_bmp(decoded, NULL, memory, src_size);
 
        return ret;
 }
 
-#if 0
-unsigned long mm_util_decode_get_width(mm_util_bmp_data *data)
-{
-       return data->width;
-}
-
-unsigned long mm_util_decode_get_height(mm_util_bmp_data *data)
-{
-       return data->height;
-}
-
-unsigned long long mm_util_decode_get_size(mm_util_bmp_data *data)
-{
-       return data->size;
-}
-#endif
-
 int mm_util_encode_bmp_to_file(mm_util_bmp_data *encoded, const char *filename)
 {
        bmpfile_t *bmp;
index 39889e15737bf4e306dc84f1d2919ee3c977b59a..3f33f0096dace284574cc5f9625b0099df2ca13b 100755 (executable)
@@ -129,13 +129,13 @@ int mm_util_decode_from_gif_file(mm_util_gif_data * decoded, const char *filenam
  *
  * @param decoded  [out]    pointer of mm_util_gif_data.
  *                          After using it, please free the allocated memory.
- * @param filename [in]     input file memory, encoded stream file
+ * @param memory [in]     input file memory, encoded stream file
  * @return                  This function returns zero on success, or negative value with error code.
  * @remark
  * @see                     mm_util_gif_data
  * @since                   R1, 1.0
  */
-int mm_util_decode_from_gif_memory(mm_util_gif_data * decoded, void **memory);
+int mm_util_decode_from_gif_memory(mm_util_gif_data * decoded, void *memory);
 
 /**
  * This function creates gif file for output file
index 2ac934c8fc8bcebd311b0ddc42995373d64e91c7..1ba245588e84c95e29138423aef365e99d67128b 100755 (executable)
@@ -257,13 +257,13 @@ int mm_util_decode_from_gif_file(mm_util_gif_data *decoded, const char *fpath)
        return ret;
 }
 
-int mm_util_decode_from_gif_memory(mm_util_gif_data *decoded, void **memory)
+int mm_util_decode_from_gif_memory(mm_util_gif_data *decoded, void *memory)
 {
        int ret;
 
        mm_util_debug("mm_util_decode_from_gif_memory");
 
-       ret = __read_gif(decoded, NULL, *memory);
+       ret = __read_gif(decoded, NULL, memory);
 
        return ret;
 }
index a678774dffcec3809c2278e545c1166682f2390a..6e5b641830c7667518ce1b27462ae2deb19d9a72 100755 (executable)
@@ -146,18 +146,6 @@ typedef struct {
        void *data;                             /**< data */
 } mm_util_png_data;
 
-#if 0
-/**
- * This function checks if the given file is a png file.
- *
- * @param filename [in]     file name
- * @return                  This function returns 1 if file is png, or 0 if not a png.
- * @remark
- * @see
- * @since                   R1, 1.0
- */
-bool mm_util_check_if_png(const char *fpath);
-#endif
 /**
  * This function extracts raw data from png file
  *
@@ -183,7 +171,7 @@ int mm_util_decode_from_png_file(mm_util_png_data * decoded, const char *fpath);
  * @see                     mm_util_png_data, mm_util_init_decode_png
  * @since                   R1, 1.0
  */
-int mm_util_decode_from_png_memory(mm_util_png_data * decoded, void **memory, unsigned long long src_size);
+int mm_util_decode_from_png_memory(mm_util_png_data * decoded, void *memory, unsigned long long src_size);
 
 /**
  * This function initializes the values of mm_util_png.
@@ -197,95 +185,6 @@ int mm_util_decode_from_png_memory(mm_util_png_data * decoded, void **memory, un
  */
 void mm_util_init_decode_png(mm_util_png_data * data);
 
-#if 0
-/**
- * This function sets if the decoding should be done progressively.
- * This function should be called after mm_util_init_decode_png.
- *
- * @param data         [in]     pointer of mm_util_png_data.
- * @param progressive  [in]     If decoding should be done progressively.
- * @return                      None.
- * @remark
- * @see                         mm_util_png, mm_util_png_data, mm_util_init_decode_png
- * @since                       R1, 1.0
- */
-void mm_util_png_decode_set_progressive(mm_util_png_data * data, int progressive);
-
-/**
- * This function sets the amount of bytes to process at a time for progressive decoding.
- * This function should be called only if mm_util_decode_set_progressive is set.
- *
- * @param data               [in]     pointer of mm_util_png_data.
- * @param progressive_bytes  [in]     Number of bytes to process at a time.
- * @return                            None.
- * @remark
- * @see                               mm_util_png, mm_util_png_data, mm_util_decode_set_progressive
- * @since                             R1, 1.0
- */
-void mm_util_png_decode_set_progressive_bytes(mm_util_png_data * data, int progressive_bytes);
-
-/**
- * This function sets the transform mask for decoding using high level interface.
- * This should be set for non progressive decoding.
- *
- * @param data       [in]     pointer of mm_util_png_data.
- * @param transform  [in]     Transform mask for decoding.
- * @return                    None.
- * @remark
- * @see                       mm_util_png, mm_util_png_data, mm_util_png_transform_type
- * @since                     R1, 1.0
- */
-void mm_util_png_decode_set_transform(mm_util_png_data * data, int transform);
-
-/**
- * This function gets the width of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_png_data.
- * @return                    Width of the decoded image.
- * @remark
- * @see                       mm_util_png_data
- * @since                     R1, 1.0
- */
-png_uint_32 mm_util_png_decode_get_width(mm_util_png_data * data);
-
-/**
- * This function gets the height of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_png_data.
- * @return                    Height of the decoded image.
- * @remark
- * @see                       mm_util_png_data
- * @since                     R1, 1.0
- */
-png_uint_32 mm_util_png_decode_get_height(mm_util_png_data * data);
-
-/**
- * This function gets the bit depth of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_png_data.
- * @return                    Bit depth of the decoded image.
- * @remark
- * @see                       mm_util_png, mm_util_png_data
- * @since                     R1, 1.0
- */
-int mm_util_png_decode_get_bit_depth(mm_util_png_data * data);
-
-/**
- * This function gets the size of the decoded image.
- * This should be called after the actual decoding.
- *
- * @param data       [in]     pointer of mm_util_png_data.
- * @return                    Size of the decoded image.
- * @remark
- * @see                       mm_util_png, mm_util_png_data
- * @since                     R1, 1.0
- */
-png_uint_32 mm_util_png_decode_get_size(mm_util_png_data * data);
-#endif
-
 /**
  * This function extracts raw data to png file
  *
index 518df5b987abf65f65889ef39a78a1a870d821dd..b4c10a17846f3801e6c3cae817c554e1966ec48e 100755 (executable)
@@ -37,27 +37,6 @@ typedef struct {
        png_size_t size;
 } read_data;
 
-#if 0
-bool mm_util_check_if_png(const char *fpath)
-{
-       char buf[MM_UTIL_PNG_BYTES_TO_CHECK];
-       FILE *fp;
-
-       mm_util_debug("mm_util_check_if_png");
-       if ((fp = fopen(fpath, "rb")) == NULL)
-               return MM_UTIL_ERROR_NO_SUCH_FILE;
-
-       if (fread(buf, 1, MM_UTIL_PNG_BYTES_TO_CHECK, fp) != MM_UTIL_PNG_BYTES_TO_CHECK) {
-               fclose(fp);
-               return 0;
-       }
-
-       fclose(fp);
-       fp = NULL;
-       return png_check_sig((void *)buf, MM_UTIL_PNG_BYTES_TO_CHECK);
-}
-#endif
-
 static void __user_error_fn(png_structp png_ptr, png_const_charp error_msg)
 {
        mm_util_error("%s", error_msg);
@@ -232,7 +211,7 @@ 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)
+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;
@@ -281,7 +260,7 @@ static int __read_png_progressive(mm_util_png_data *decoded, FILE * fp, void **m
                if (fp) {
                        if (!(bytes_read = fread(buf, 1, decoded->png.progressive_bytes, fp)))
                                break;
-               } else if (*memory) {
+               } else if (memory) {
                        unsigned long long length = src_size - old_length;
 
                        if (length == 0)
@@ -291,7 +270,7 @@ static int __read_png_progressive(mm_util_png_data *decoded, FILE * fp, void **m
                        else
                                bytes_read = length;
 
-                       memcpy(buf, *memory + old_length, bytes_read);
+                       memcpy(buf, memory + old_length, bytes_read);
 
                        old_length += bytes_read;
                } else
@@ -325,7 +304,7 @@ int mm_util_decode_from_png_file(mm_util_png_data *decoded, const char *fpath)
        return ret;
 }
 
-int mm_util_decode_from_png_memory(mm_util_png_data *decoded, void **memory, unsigned long long src_size)
+int mm_util_decode_from_png_memory(mm_util_png_data *decoded, void *memory, unsigned long long src_size)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
@@ -333,7 +312,7 @@ int mm_util_decode_from_png_memory(mm_util_png_data *decoded, void **memory, uns
        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;
 }
@@ -346,44 +325,9 @@ void mm_util_init_decode_png(mm_util_png_data *data)
        data->png.transform = MM_UTIL_PNG_TRANSFORM_IDENTITY;
 }
 
-#if 0
-void mm_util_png_decode_set_progressive(mm_util_png_data *data, int progressive)
-{
-       data->png.progressive = progressive;
-}
-
-void mm_util_png_decode_set_progressive_bytes(mm_util_png_data *data, int progressive_bytes)
-{
-       data->png.progressive_bytes = progressive_bytes;
-}
-
-void mm_util_png_decode_set_transform(mm_util_png_data *data, int transform)
-{
-       data->png.transform = transform;
-}
-
-png_uint_32 mm_util_png_decode_get_width(mm_util_png_data *data)
-{
-       return data->width;
-}
-
-png_uint_32 mm_util_png_decode_get_height(mm_util_png_data *data)
-{
-       return data->height;
-}
-
-int mm_util_png_decode_get_bit_depth(mm_util_png_data *data)
-{
-       return data->png.bit_depth;
-}
-
-png_uint_32 mm_util_png_decode_get_size(mm_util_png_data *data)
-{
-       return data->size;
-}
-#endif
 static void user_flush_data(png_structp png_ptr G_GNUC_UNUSED)
 {
+       /* do nothing */
 }
 
 static void user_write_data(png_structp png_ptr, png_bytep data, png_uint_32 length)