MM_UTIL_JPEG_MEM,
} mm_util_jpeg_cont_format_e;
-static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, FILE *fp, void **mem, size_t *csize, void *rawdata, int width, int height, mm_util_color_format_e color_format, int quality)
+static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, void *rawdata, int width, int height, mm_util_color_format_e color_format, int quality, FILE *fp, void **mem, size_t *csize)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
return iErrorCode;
}
-static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, mm_util_jpeg_yuv_data *decoded_data, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale)
+static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded_data)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
struct jpeg_decompress_struct dinfo;
}
decoded_data->format = color_format;
- /* Start decompressor*/
+ /* Start decompressor */
jpeg_start_decompress(&dinfo);
mm_util_debug("jpeg_start_decompress");
unsigned char *dst = NULL;
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);
+ ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, dst, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, quality, fp, NULL, NULL);
MMUTIL_SAFE_FREE(dst);
ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
} else {
- ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, NULL, decoded->data, decoded->width, decoded->height, decoded->format, quality);
+ ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, decoded->data, decoded->width, decoded->height, decoded->format, quality, fp, NULL, NULL);
}
fsync((int)(fp->_fileno));
unsigned char *dst = NULL;
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);
+ ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, dst, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, quality, NULL, mem, size);
MMUTIL_SAFE_FREE(dst);
} 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, decoded->data, decoded->width, decoded->height, decoded->format, quality);
+ ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, decoded->data, decoded->width, decoded->height, decoded->format, quality, NULL, mem, size);
}
mm_util_debug("#END# libjpeg, Success!! ret: %d", ret);
#else
mm_util_debug("#START# libjpeg fmt [%d]", fmt);
if (fmt == MM_UTIL_COLOR_NV12) {
- ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, decoded, fp, NULL, 0, MM_UTIL_COLOR_YUV420, downscale);
+ ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, 0, MM_UTIL_COLOR_YUV420, downscale, decoded);
if (ret == MM_UTIL_ERROR_NONE) {
unsigned int res_w = 0;
unsigned int res_h = 0;
decoded->size = res_buffer_size;
}
} else {
- ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, decoded, fp, NULL, 0, fmt, downscale);
+ ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, 0, fmt, downscale, decoded);
}
#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("#START# libjpeg");
if (fmt == MM_UTIL_COLOR_NV12) {
- ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_MEM, decoded, NULL, src, size, MM_UTIL_COLOR_YUV420, downscale);
+ ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_MEM, NULL, src, size, MM_UTIL_COLOR_YUV420, downscale, decoded);
if (ret == MM_UTIL_ERROR_NONE) {
unsigned int res_w = 0;
unsigned int res_h = 0;
decoded->size = res_buffer_size;
}
} else {
- ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_MEM, decoded, NULL, src, size, fmt, downscale);
+ ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_MEM, NULL, src, size, fmt, downscale, decoded);
}
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);