From: Jiyong Min Date: Tue, 6 Mar 2018 04:52:46 +0000 (+0900) Subject: Change the order of the parameters X-Git-Tag: submit/tizen/20180314.004633~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c3893a3b14d4a9466c10b81e70eda966932fe3f;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Change the order of the parameters - The order is input parameter before output parameter. - The decoded data is composed with width, height, format, data and size. - The source data of encoding is replaced to the decoded data. Change-Id: Idf1de7e1515d5e5bc25e375031f81faaacdc07ba Signed-off-by: Jiyong Min --- diff --git a/bmp/include/mm_util_bmp.h b/bmp/include/mm_util_bmp.h index 63bea80..65e4220 100755 --- a/bmp/include/mm_util_bmp.h +++ b/bmp/include/mm_util_bmp.h @@ -45,34 +45,34 @@ typedef struct { /** * This function extracts raw data from bmp file * + * @param filename [in] input file name, encoded stream file * @param decoded [out] pointer of mm_util_bmp_data. * After using it, please free the allocated memory. - * @param filename [in] input file name, encoded stream file * @return This function returns zero on success, or negative value with error code. * @remark * @see mm_util_bmp_data * @since R1, 1.0 */ -int mm_util_decode_from_bmp_file(mm_util_bmp_data * decoded, const char *filename); +int mm_util_decode_from_bmp_file(const char *filename, mm_util_bmp_data * decoded); /** * This function extracts raw data from bmp memory * + * @param memory [in] input memory, encoded stream file + * @param src_size [in] input src size, encoded stream file * @param decoded [out] pointer of mm_util_bmp_data. * After using it, please free the allocated memory. - * @param memory [in] input memory, encoded stream file - * @param src_size [in] input src size, encoded stream file * @return This function returns zero on success, or negative value with error code. * @remark * @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); +int mm_util_decode_from_bmp_memory(void *memory, unsigned long long src_size, mm_util_bmp_data * decoded); /** * This function encodes raw data to bmp file * - * @param encoded [in ] pointer of mm_util_bmp_data. + * @param decoded [in] pointer of mm_util_bmp_data. * After using it, please free the allocated memory. * @param filename [out] output file name on to which the encoded stream will be written. * @return This function returns zero on success, or negative value with error code. @@ -80,21 +80,21 @@ int mm_util_decode_from_bmp_memory(mm_util_bmp_data * decoded, void *memory, uns * @see mm_util_bmp_data * @since R1, 1.0 */ -int mm_util_encode_bmp_to_file(mm_util_bmp_data * encoded, const char *filename); +int mm_util_encode_bmp_to_file(mm_util_bmp_data * decoded, const char *filename); /** * This function encodes raw data to buffer * - * @param encoded [in ] pointer of mm_util_bmp_data. - * After using it, please free the allocated memory. - * @param buffer [out] output buffer on to which the encoded stream will be written. - * @param size [out] The size of output buffer on to which the encoded stream will be written. + * @param decoded [in] pointer of mm_util_bmp_data. + * After using it, please free the allocated memory. + * @param buffer [out] output buffer on to which the encoded stream will be written. + * @param size [out] The size of output buffer on to which the encoded stream will be written. * @return This function returns zero on success, or negative value with error code. * @remark * @see mm_util_bmp_data * @since R1, 1.0 */ -int mm_util_encode_bmp_to_memory(mm_util_bmp_data *encoded, void **buffer, size_t *size); +int mm_util_encode_bmp_to_memory(mm_util_bmp_data *decoded, void **buffer, size_t *size); #ifdef __cplusplus } diff --git a/bmp/mm_util_bmp.c b/bmp/mm_util_bmp.c index 2deb97d..9254813 100755 --- a/bmp/mm_util_bmp.c +++ b/bmp/mm_util_bmp.c @@ -178,7 +178,7 @@ static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *mem return res; } -int mm_util_decode_from_bmp_file(mm_util_bmp_data *decoded, const char *filename) +int mm_util_decode_from_bmp_file(const char *filename, mm_util_bmp_data *decoded) { int ret; @@ -189,7 +189,7 @@ 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(void *memory, unsigned long long src_size, mm_util_bmp_data *decoded) { int ret; @@ -200,22 +200,22 @@ int mm_util_decode_from_bmp_memory(mm_util_bmp_data *decoded, void *memory, unsi return ret; } -int mm_util_encode_bmp_to_file(mm_util_bmp_data *encoded, const char *filename) +int mm_util_encode_bmp_to_file(mm_util_bmp_data *decoded, const char *filename) { bmpfile_t *bmp; rgb_pixel_t pixel = { 0, 0, 0, 0 }; uint16_t row, col; uint8_t *image; - if ((bmp = bmp_create(encoded->width, encoded->height, BYTES_PER_PIXEL * 8)) == NULL) { + if ((bmp = bmp_create(decoded->width, decoded->height, BYTES_PER_PIXEL * 8)) == NULL) { mm_util_error("Invalid depth value."); return MM_UTIL_ERROR_INVALID_OPERATION; } - image = (uint8_t *) encoded->data; - for (row = 0; row != encoded->height; row++) { - for (col = 0; col != encoded->width; col++) { - size_t z = (row * encoded->width + col) * BYTES_PER_PIXEL; + image = (uint8_t *) decoded->data; + for (row = 0; row != decoded->height; row++) { + for (col = 0; col != decoded->width; col++) { + size_t z = (row * decoded->width + col) * BYTES_PER_PIXEL; pixel.red = image[z]; pixel.green = image[z + 1]; pixel.blue = image[z + 2]; @@ -232,22 +232,22 @@ int mm_util_encode_bmp_to_file(mm_util_bmp_data *encoded, const char *filename) return MM_UTIL_ERROR_NONE; } -int mm_util_encode_bmp_to_memory(mm_util_bmp_data *encoded, void **buffer, size_t *size) +int mm_util_encode_bmp_to_memory(mm_util_bmp_data *decoded, void **buffer, size_t *size) { bmpfile_t *bmp; rgb_pixel_t pixel = { 0, 0, 0, 0 }; uint16_t row, col; uint8_t *image; - if ((bmp = bmp_create(encoded->width, encoded->height, BYTES_PER_PIXEL * 8)) == NULL) { + if ((bmp = bmp_create(decoded->width, decoded->height, BYTES_PER_PIXEL * 8)) == NULL) { mm_util_error("Invalid depth value."); return MM_UTIL_ERROR_INVALID_OPERATION; } - image = (uint8_t *) encoded->data; - for (row = 0; row != encoded->height; row++) { - for (col = 0; col != encoded->width; col++) { - size_t z = (row * encoded->width + col) * BYTES_PER_PIXEL; + image = (uint8_t *) decoded->data; + for (row = 0; row != decoded->height; row++) { + for (col = 0; col != decoded->width; col++) { + size_t z = (row * decoded->width + col) * BYTES_PER_PIXEL; pixel.red = image[z]; pixel.green = image[z + 1]; pixel.blue = image[z + 2]; diff --git a/bmp/test/mm_util_bmp_testsuite.c b/bmp/test/mm_util_bmp_testsuite.c index 5a408b2..cc0356d 100755 --- a/bmp/test/mm_util_bmp_testsuite.c +++ b/bmp/test/mm_util_bmp_testsuite.c @@ -219,7 +219,7 @@ gboolean _test_decode(const bmp_test_mode_e mode) /* test decoding bmp */ if (mode == TEST_DECODE_FILE) { - ret = mm_util_decode_from_bmp_file(&g_decoded_data, g_path); + ret = mm_util_decode_from_bmp_file(g_path, &g_decoded_data); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[BMP_testsuite] mm_util_decode_from_bmp_file failed %d\n", ret); return FALSE; @@ -234,7 +234,7 @@ gboolean _test_decode(const bmp_test_mode_e mode) return FALSE; } - ret = mm_util_decode_from_bmp_memory(&g_decoded_data, g_readed_data, (unsigned int)g_readed_size); + ret = mm_util_decode_from_bmp_memory(g_readed_data, (unsigned int)g_readed_size, &g_decoded_data); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[BMP_testsuite] mm_util_decode_from_bmp_memory failed %d\n", ret); return FALSE; diff --git a/imgcv/test/mm_util_imgcv_testsuite.c b/imgcv/test/mm_util_imgcv_testsuite.c index 49e54f8..e8bba03 100755 --- a/imgcv/test/mm_util_imgcv_testsuite.c +++ b/imgcv/test/mm_util_imgcv_testsuite.c @@ -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_with_downscale(&decoded, filename, MM_UTIL_COLOR_RGB24, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1); + ret = mm_util_decode_from_jpeg_file_with_downscale(filename, MM_UTIL_COLOR_RGB24, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, &decoded); if (!ret) { img_buffer = decoded.data; diff --git a/jpeg/include/mm_util_jpeg.h b/jpeg/include/mm_util_jpeg.h index 12b5460..659d6ab 100755 --- a/jpeg/include/mm_util_jpeg.h +++ b/jpeg/include/mm_util_jpeg.h @@ -61,65 +61,59 @@ typedef struct { /** * This function encodes rawfile to jpeg file. * + * @param decoded [in] pointer of input stream pointer, that is, pointer of decoded data. + * @param quality [in] encoding quality, from 1 to 100 * @param filename [in] output file name - * @param src [in] pointer of input stream pointer (raw data) - * @param width [in] width of src data - * @param height [in] height of src data - * @param fmt [in] color format - * @param quality [in] encoding quality, from 1 to 100 * @return This function returns zero on success, or negative value with error code. * @remark * @see mm_util_color_format_e * @since R1, 1.0 */ -int mm_util_jpeg_encode_to_file(const char *filename, void *src, int width, int height, mm_util_color_format_e fmt, int quality); +int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, const char *filename); /** * This function encodes raw file to jpeg into memory. * - * @param mem [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory. - * @param size [in] output stream size, that is, encoded stream size - * @param src [in] pointer of input stream pointer (raw data) - * @param width [in] width of src data - * @param height [in] height of src data - * @param fmt [in] color format - * @param quality [in] encoding quality, from 1 to 100 + * @param decoded [in] pointer of input stream pointer, that is, pointer of decoded data. + * @param quality [in] encoding quality, from 1 to 100 + * @param mem [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory. + * @param size [out] output stream size, that is, encoded stream size * @return This function returns zero on success, or negative value with error code. * @remark * @see mm_util_color_format_e * @since R1, 1.0 */ -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); +int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, unsigned int *size); /** * This function extracts yuv data from jpeg file with downscale decode option * - * @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 - * @param downscale [in] downscale value + * @param fmt [in] color format + * @param downscale [in] downscale value + * @param decoded [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory. * @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_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale); +int mm_util_decode_from_jpeg_file_with_downscale(const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded); /** * This function extracts yuv data from jpeg buffer with downscale decode option * - * @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 - * @param downscale [in] downscale value + * @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 + * @param downscale [in] downscale value + * @param decoded [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory. * @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_with_downscale(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale); +int mm_util_decode_from_jpeg_memory_with_downscale(void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded); #ifdef __cplusplus diff --git a/jpeg/mm_util_jpeg.c b/jpeg/mm_util_jpeg.c index 3ce4ab0..df6f717 100755 --- a/jpeg/mm_util_jpeg.c +++ b/jpeg/mm_util_jpeg.c @@ -406,7 +406,7 @@ static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_for mm_util_retvm_if((control_format != MM_UTIL_JPEG_FILE) && (control_format != MM_UTIL_JPEG_MEM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid control_format [%u]", control_format); mm_util_retvm_if((control_format == MM_UTIL_JPEG_FILE) && (fp == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fp"); - mm_util_retvm_if((control_format == MM_UTIL_JPEG_MEM) && ((mem == NULL) || (csize == 0)), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src or csize"); + mm_util_retvm_if((control_format == MM_UTIL_JPEG_MEM) && ((mem == NULL) || (csize == NULL)), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src or csize"); mm_util_retvm_if(rawdata == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid rawdata"); JSAMPROW y[16], cb[16], cr[16]; /* y[2][5] = color sample of row 2 and pixel column 5; (one plane) */ @@ -778,21 +778,22 @@ static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_for #endif -int mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int height, mm_util_color_format_e fmt, int quality) +int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, const char *filename) { int ret = MM_UTIL_ERROR_NONE; mm_util_fenter(); mm_util_retvm_if(filename == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid filename"); - mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src"); - mm_util_retvm_if((width <= 0) || (height <= 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width[%d] height[%d]", width, height); - mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt); + mm_util_retvm_if(decoded == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src"); + mm_util_retvm_if(decoded->data == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src data"); + mm_util_retvm_if((decoded->width <= 0) || (decoded->height <= 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width[%d] height[%d]", decoded->width, decoded->height); + mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(decoded->format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", decoded->format); mm_util_retvm_if((quality < 1) || (quality > 100), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid quality [%d]", quality); #ifdef LIBJPEG_TURBO mm_util_debug("#START# LIBJPEG_TURBO"); - ret = __mm_image_encode_to_jpeg_file_with_libjpeg_turbo(filename, src, width, height, fmt, quality); + ret = __mm_image_encode_to_jpeg_file_with_libjpeg_turbo(filename, decoded->data, decoded->width, decoded->height, decoded->format, quality); #else mm_util_debug("#START# LIBJPEG"); FILE *fp = NULL; @@ -802,23 +803,23 @@ int mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int return ret; } - if (fmt == MM_UTIL_COLOR_NV12) { + if (decoded->format == MM_UTIL_COLOR_NV12) { 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(src, width, height, MM_UTIL_COLOR_NV12, MM_UTIL_COLOR_YUV420, &dst, &res_w, &res_h, &res_buffer_size); - ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, NULL, dst, width, height, MM_UTIL_COLOR_YUV420, quality); + ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_NV12, MM_UTIL_COLOR_YUV420, &dst, &res_w, &res_h, &res_buffer_size); + ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, NULL, dst, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, quality); MMUTIL_SAFE_FREE(dst); - } else if (fmt == MM_UTIL_COLOR_NV21) { + } else if (decoded->format == MM_UTIL_COLOR_NV21) { mm_util_error("Not supported format NV12"); ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT; } else { - ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, NULL, src, width, height, fmt, quality); + ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, NULL, decoded->data, decoded->width, decoded->height, decoded->format, quality); } fsync((int)(fp->_fileno)); @@ -827,10 +828,12 @@ int mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int mm_util_debug("#End# libjpeg, Success!! ret: %d", ret); + mm_util_fleave(); + return ret; } -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) +int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, unsigned int *size) { int ret = MM_UTIL_ERROR_NONE; @@ -838,39 +841,42 @@ int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void* src, int mm_util_retvm_if(mem == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid filename"); mm_util_retvm_if(size == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid size"); - mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src"); - mm_util_retvm_if((width <= 0) || (height <= 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width[%d] height[%d]", width, height); - mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt); + mm_util_retvm_if(decoded == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src"); + mm_util_retvm_if(decoded->data == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src data"); + mm_util_retvm_if((decoded->width <= 0) || (decoded->height <= 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width[%d] height[%d]", decoded->width, decoded->height); + mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(decoded->format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", decoded->format); mm_util_retvm_if((quality < 1) || (quality > 100), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid quality [%d]", quality); #ifdef LIBJPEG_TURBO mm_util_debug("#START# libjpeg-turbo"); - ret = __mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(mem, size, src, width, height, fmt, quality); + ret = __mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(mem, size, decoded->data, decoded->width, decoded->height, decoded->format, quality); #else /* LIBJPEG_TURBO */ mm_util_debug("#START# libjpeg"); - if (fmt == MM_UTIL_COLOR_NV12) { + if (decoded->format == MM_UTIL_COLOR_NV12) { 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(src, width, height, MM_UTIL_COLOR_NV12, MM_UTIL_COLOR_YUV420, &dst, &res_w, &res_h, &res_buffer_size); - ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, NULL, mem, size, dst, width, height, MM_UTIL_COLOR_YUV420, quality); + ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_NV12, MM_UTIL_COLOR_YUV420, &dst, &res_w, &res_h, &res_buffer_size); + ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, NULL, mem, size, dst, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, quality); MMUTIL_SAFE_FREE(dst); - } else if (fmt == MM_UTIL_COLOR_NV21) { + } else if (decoded->format == MM_UTIL_COLOR_NV21) { return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT; } else { - ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, NULL, mem, size, src, width, height, fmt, quality); + ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, NULL, mem, size, decoded->data, decoded->width, decoded->height, decoded->format, quality); } #endif /* LIBJPEG_TURBO */ mm_util_debug("#END# libjpeg, Success!! ret: %d", ret); + mm_util_fleave(); + 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 mm_util_decode_from_jpeg_file_with_downscale(const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded) { int ret = MM_UTIL_ERROR_NONE; @@ -957,7 +963,7 @@ int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, return ret; } -int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale) +int mm_util_decode_from_jpeg_memory_with_downscale(void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded) { int ret = MM_UTIL_ERROR_NONE; diff --git a/jpeg/test/mm_util_jpeg_testsuite.c b/jpeg/test/mm_util_jpeg_testsuite.c index b2897db..a1cc89e 100755 --- a/jpeg/test/mm_util_jpeg_testsuite.c +++ b/jpeg/test/mm_util_jpeg_testsuite.c @@ -238,7 +238,7 @@ gboolean _test_decode(const jpeg_test_mode_e mode) /* test decoding jpeg */ if (mode == TEST_DECODE_FILE) { - ret = mm_util_decode_from_jpeg_file_with_downscale(&g_decoded_data, g_path, g_color, g_downscale); + ret = mm_util_decode_from_jpeg_file_with_downscale(g_path, g_color, g_downscale, &g_decoded_data); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[JPEG_testsuite] mm_util_decode_from_jpeg_file_with_downscale failed %d\n", ret); return FALSE; @@ -253,7 +253,7 @@ gboolean _test_decode(const jpeg_test_mode_e mode) return FALSE; } - ret = mm_util_decode_from_jpeg_memory_with_downscale(&g_decoded_data, g_readed_data, (unsigned int)g_readed_size, g_color, g_downscale); + ret = mm_util_decode_from_jpeg_memory_with_downscale(g_readed_data, (unsigned int)g_readed_size, g_color, g_downscale, &g_decoded_data); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[JPEG_testsuite] mm_util_decode_from_jpeg_memory_with_downscale failed %d\n", ret); return FALSE; @@ -286,13 +286,13 @@ gboolean _test_encode(const jpeg_test_mode_e mode) /* test encoding jpeg */ if (mode == TEST_ENCODE_FILE) { - ret = mm_util_jpeg_encode_to_file(ENCODE_FILE_PATH, g_decoded_data.data, g_decoded_data.width, g_decoded_data.height, g_decoded_data.format, g_quality); + ret = mm_util_jpeg_encode_to_file(&g_decoded_data, g_quality, ENCODE_FILE_PATH); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[JPEG_testsuite] mm_util_jpeg_encode_to_file failed : %d\n", ret); return FALSE; } } else if (mode == TEST_ENCODE_MEMORY) { - ret = mm_util_jpeg_encode_to_memory(&encoded_data, &encoded_size, g_decoded_data.data, g_decoded_data.width, g_decoded_data.height, g_decoded_data.format, g_quality); + ret = mm_util_jpeg_encode_to_memory(&g_decoded_data, g_quality, &encoded_data, &encoded_size); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[JPEG_testsuite] mm_util_jpeg_encode_to_file failed : %d\n", ret); SAFE_FREE(encoded_data); diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 0cb4af1..422dcbc 100755 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -1,6 +1,6 @@ Name: libmm-utility Summary: Multimedia Framework Utility Library -Version: 0.1.17 +Version: 0.1.18 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/png/include/mm_util_png.h b/png/include/mm_util_png.h index a5d82e6..e405f07 100755 --- a/png/include/mm_util_png.h +++ b/png/include/mm_util_png.h @@ -60,29 +60,29 @@ typedef struct { /** * This function extracts raw data from png file * + * @param fpath [in] input file name, encoded stream file * @param decoded [out] pointer of mm_util_png_data. * After using it, please free the allocated memory. - * @param filename [in] input file name, encoded stream file * @return This function returns zero on success, or negative value with error code. * @remark * @see mm_util_png_data, mm_util_init_decode_png * @since R1, 1.0 */ -int mm_util_decode_from_png_file(mm_util_png_data * decoded, const char *fpath); +int mm_util_decode_from_png_file(const char *fpath, mm_util_png_data * decoded); /** * This function extracts raw data from png buffer * + * @param memory [in] input stream pointer(pointer of encoded png stream data) + * @param src_size [in] size of input stream(size of pointer of encoded png stream data) * @param decoded [out] pointer of mm_util_png_data. * After using it, please free the allocated memory. - * @param filename [in] input stream pointer(pointer of encoded png stream data) - * @param memory [in] size of input stream(size of pointer of encoded png stream data) * @return This function returns zero on success, or negative value with error code. * @remark * @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(void *memory, unsigned long long src_size, mm_util_png_data * decoded); /** * This function extracts raw data to png file diff --git a/png/mm_util_png.c b/png/mm_util_png.c index b66fb62..6cc7d3c 100755 --- a/png/mm_util_png.c +++ b/png/mm_util_png.c @@ -201,7 +201,7 @@ static int __read_png(mm_util_png_data *decoded, FILE * fp, void *memory) return MM_UTIL_ERROR_NONE; } -int mm_util_decode_from_png_file(mm_util_png_data *decoded, const char *fpath) +int mm_util_decode_from_png_file(const char *fpath, mm_util_png_data *decoded) { int ret = MM_UTIL_ERROR_NONE; FILE *fp; @@ -218,7 +218,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(void *memory, unsigned long long src_size, mm_util_png_data *decoded) { int ret = MM_UTIL_ERROR_NONE; diff --git a/png/test/mm_util_png_testsuite.c b/png/test/mm_util_png_testsuite.c index 0655ebb..eaafeb4 100755 --- a/png/test/mm_util_png_testsuite.c +++ b/png/test/mm_util_png_testsuite.c @@ -224,7 +224,7 @@ gboolean _test_decode(const png_test_mode_e mode) /* test decoding png */ if (mode == TEST_DECODE_FILE) { - ret = mm_util_decode_from_png_file(&g_decoded_data, g_path); + ret = mm_util_decode_from_png_file(g_path, &g_decoded_data); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[PNG_testsuite] mm_util_decode_from_png_file failed %d\n", ret); return FALSE; @@ -239,7 +239,7 @@ gboolean _test_decode(const png_test_mode_e mode) return FALSE; } - ret = mm_util_decode_from_png_memory(&g_decoded_data, g_readed_data, (unsigned long long)g_readed_size); + ret = mm_util_decode_from_png_memory(g_readed_data, (unsigned long long)g_readed_size, &g_decoded_data); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\t[PNG_testsuite] mm_util_decode_from_png_memory failed %d\n", ret); return FALSE;