From 18bd01c065b66fc882c7e8aa9a9a1ba3e7353b6e Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Wed, 14 Mar 2018 12:10:11 +0900 Subject: [PATCH] Remain old function and rename jpeg refactoring Change-Id: I172fffbed1e3dbab5be8b100b8a4c6b9c4faa2d8 --- jpeg/include/mm_util_jpeg.h | 16 +++++++++++++++- jpeg/mm_util_jpeg.c | 22 +++++++++++++++++++++- jpeg/test/mm_util_jpeg_testsuite.c | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/jpeg/include/mm_util_jpeg.h b/jpeg/include/mm_util_jpeg.h index 168fe49..c6d8f01 100755 --- a/jpeg/include/mm_util_jpeg.h +++ b/jpeg/include/mm_util_jpeg.h @@ -84,7 +84,21 @@ int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, con * @see mm_util_color_format_e * @since R1, 1.0 */ -int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size); +int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, unsigned char *src, unsigned int width, unsigned int height, mm_util_color_format_e color, int quality); + +/** + * This function encodes raw file to jpeg into memory. + * + * @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_encode_to_jpeg_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size); /** * This function extracts yuv data from jpeg file with downscale decode option diff --git a/jpeg/mm_util_jpeg.c b/jpeg/mm_util_jpeg.c index 7dd7656..c75b0d7 100755 --- a/jpeg/mm_util_jpeg.c +++ b/jpeg/mm_util_jpeg.c @@ -483,7 +483,27 @@ int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, con return ret; } -int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size) +int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, unsigned char *src, unsigned int width, unsigned int height, mm_util_color_format_e color, int quality) +{ + int ret = MM_UTIL_ERROR_NONE; + size_t encoded_size = 0; + + mm_util_jpeg_yuv_data decoded; + memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data)); + + decoded.width = (int)width; + decoded.height = (int)height; + decoded.format = color; + decoded.data = src; + + ret = mm_util_encode_to_jpeg_memory(&decoded, quality, mem, &encoded_size); + *size = (unsigned int)encoded_size; + mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "mm_util_encode_to_jpeg_memory fail (%d)", ret); + + return ret; +} + +int mm_util_encode_to_jpeg_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size) { 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 f8ffded..892a6a7 100755 --- a/jpeg/test/mm_util_jpeg_testsuite.c +++ b/jpeg/test/mm_util_jpeg_testsuite.c @@ -291,7 +291,7 @@ gboolean _test_encode(const jpeg_test_mode_e mode) return FALSE; } } else if (mode == TEST_ENCODE_MEMORY) { - ret = mm_util_jpeg_encode_to_memory(&g_decoded_data, g_quality, &encoded_data, &encoded_size); + ret = mm_util_encode_to_jpeg_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); -- 2.7.4