* @see mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, mm_util_color_format_e dst_format);
+int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_color_format_e dst_format, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
+
/**
* This function resizes the source image.
unsigned int res_w = 0;
unsigned int res_h = 0;
unsigned char *res_buffer = NULL;
+ unsigned char *res_buffer_conv = NULL;
+ unsigned char *res_buffer_rotate = NULL;
size_t res_buffer_size = 0;
mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
mm_util_error("mm_util_crop_image failed");
return ret;
}
- dst_buf[dst_index] = res_buffer;
+ dst_buf[dst_index] = res_buffer;
src_index = dst_index;
src_width = res_w;
src_height = res_h;
if (handle->set_convert) {
dst_index++;
- mm_util_get_image_size(handle->dst_format, src_width, src_height, &res_buffer_size);
- dst_buf[dst_index] = calloc(1, res_buffer_size);
- if (dst_buf[dst_index] == NULL) {
- mm_util_error("[multi func] memory allocation error");
- __mm_destroy_temp_buffer(dst_buf);
- return MM_UTIL_ERROR_INVALID_OPERATION;
- }
- ret = mm_util_convert_colorspace(dst_buf[src_index], src_width, src_height, src_format, dst_buf[dst_index], handle->dst_format);
+ ret = mm_util_convert_colorspace(dst_buf[src_index], src_width, src_height, src_format, handle->dst_format, &res_buffer_conv, &res_w, &res_h, &res_buffer_size);
if (ret != MM_UTIL_ERROR_NONE) {
__mm_destroy_temp_buffer(dst_buf);
mm_util_error("mm_util_convert_colorspace failed");
return ret;
}
+
+ dst_buf[dst_index] = res_buffer_conv;
src_index = dst_index;
src_format = handle->dst_format;
+ src_width = res_w;
+ src_height = res_h;
}
if (handle->set_rotate) {
dst_index++;
- ret = mm_util_rotate_image(dst_buf[src_index], src_width, src_height, src_format, handle->rotation, &res_buffer, &res_w, &res_h, &res_buffer_size);
+
+ ret = mm_util_rotate_image(dst_buf[src_index], src_width, src_height, src_format, handle->rotation, &res_buffer_rotate, &res_w, &res_h, &res_buffer_size);
if (ret != MM_UTIL_ERROR_NONE) {
__mm_destroy_temp_buffer(dst_buf);
mm_util_error("mm_util_rotate_image failed");
return ret;
}
- dst_buf[dst_index] = res_buffer;
+ dst_buf[dst_index] = res_buffer_rotate;
src_index = dst_index;
src_width = res_w;
src_height = res_h;
return FALSE;
}
-int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, mm_util_color_format_e dst_format)
+int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_color_format_e dst_format, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size)
{
int ret = MM_UTIL_ERROR_NONE;
IMGPInfoFunc _mm_util_imgp_func = NULL;
mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(dst_format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_format [%d]", dst_format);
mm_util_retvm_if((__mm_util_check_format(src_format) == FALSE), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported src_format [%d]", src_format);
mm_util_retvm_if((__mm_util_check_format(dst_format) == FALSE), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported dst_format [%d]", dst_format);
+ mm_util_retvm_if(dst == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst");
+ mm_util_retvm_if(result_buf_width == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid result_buf_width");
+ mm_util_retvm_if(result_buf_height == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid result_buf_height");
+ mm_util_retvm_if(result_buf_size == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid result_buf_size");
mm_util_debug("src_width [%d] src_height [%d] src_format[%d] dst_format[%d]", src_width, src_height, src_format, dst_format);
goto ERROR;
}
+ res_w = src_width;
+ res_h = src_height;
+
ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_set_imgp_info_s failed");
ret = mm_util_crop_image(output_buffer, _imgp_info_s->output_stride, _imgp_info_s->output_elevation, dst_format, 0, 0, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &res_buffer, &res_w, &res_h, &res_buffer_size);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("mm_util_crop_image failed");
+ MMUTIL_SAFE_FREE(output_buffer);
ret = MM_UTIL_ERROR_INVALID_OPERATION;
goto ERROR;
}
- memcpy(dst, res_buffer, res_buffer_size);
+
+ MMUTIL_SAFE_FREE(output_buffer);
+ *dst = res_buffer;
+ *result_buf_size = res_buffer_size;
} else {
- memcpy(dst, output_buffer, _imgp_info_s->buffer_size);
+ *dst = output_buffer;
+ *result_buf_size = _imgp_info_s->buffer_size;
}
- /* Output result*/
- mm_util_debug("dst[%p] dst_width[%u] dst_height[%u] output_stride[%u] output_elevation[%u]",
- dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
+ *result_buf_width = res_w;
+ *result_buf_height = res_h;
+
+ mm_util_debug("dst[%p] result_buf_w[%u] result_buf_h[%u] output_stride[%u] output_elevation[%u]", dst, *result_buf_width, *result_buf_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
ERROR:
/* Finalize */
__mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- MMUTIL_SAFE_FREE(res_buffer);
-
mm_util_fleave();
return ret;
mm_util_retvm_if(dst == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst");
mm_util_retvm_if(dst_width == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_width");
mm_util_retvm_if(dst_height == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_height");
+ mm_util_retvm_if(result_buf_size == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid result_buf_size");
mm_util_debug("src_width [%d] src_height [%d] src_format[%d]", src_width, src_height, src_format);
int main(int argc, char *argv[])
{
int ret = 0;
- void *src;
+ void *src = NULL;
unsigned char *dst = NULL;
if (argc < 12) {
}
size_t src_size = 0;
- size_t dst_size = 0;
bool sync_mode = (strcmp(argv[1], "sync") == 0) ? TRUE : FALSE;
char *filename = strdup(argv[2]);
char *command = strdup(argv[3]);
char output_file[40] = {};
unsigned int res_w = 0;
unsigned int res_h = 0;
- unsigned char *res_buffer = NULL;
size_t res_buffer_size = 0;
/* async mode */
fprintf(stderr, "command: %s src_width: %d, src_height: %d, src_format: %d, dst_width: %d, dst_height: %d, dst_format:%d, rotation:%d\n", command, src_width, src_height, src_format, dst_width, dst_height, dst_format, rotation);
- if (strcmp(command, "convert") == 0) {
- if ((src_width != dst_width) || (src_width != dst_width)) {
- fprintf(stderr, "Wrong input. dst w/h should be same as src w/h\n");
- return 0;
- }
- }
-
- /* mem allocation for src dst buffer */
- mm_util_get_image_size(src_format, src_width, src_height, &src_size);
- mm_util_get_image_size(dst_format, dst_width, dst_height, &dst_size);
- src = calloc(1, src_size);
- dst = calloc(1, dst_size);
-
{ /* read input file */
FILE *fp = fopen(filename, "r");
if (fp == NULL) {
goto TEST_FAIL;
}
+ fseek(fp, 0, SEEK_END);
+ src_size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ src = calloc(1, src_size);
if (src == NULL) {
fprintf(stderr, "\tmemory allocation failed\n");
goto TEST_FAIL;
if (sync_mode) {
fprintf(stderr, "SYNC\n");
- if (strcmp(command, "convert") == 0) {
- ret = mm_util_convert_colorspace(src, src_width, src_height, src_format, dst, dst_format);
- } else if (strcmp(command, "resize") == 0) {
- ret = mm_util_resize_image(src, src_width, src_height, src_format, dst_width, dst_height, &res_buffer, &res_w, &res_h, &res_buffer_size);
- IMGP_FREE(dst);
- dst = res_buffer;
- } else if (strcmp(command, "rotate") == 0) {
- ret = mm_util_rotate_image(src, src_width, src_height, src_format, rotation, &res_buffer, &res_w, &res_h, &res_buffer_size);
- IMGP_FREE(dst);
- dst = res_buffer;
- } else if (strcmp(command, "crop") == 0) {
- ret = mm_util_crop_image(src, src_width, src_height, src_format, start_x, start_y, dst_width, dst_height, &res_buffer, &res_w, &res_h, &res_buffer_size);
- IMGP_FREE(dst);
- dst = res_buffer;
- }
+ if (strcmp(command, "convert") == 0)
+ ret = mm_util_convert_colorspace(src, src_width, src_height, src_format, dst_format, &dst, &res_w, &res_h, &res_buffer_size);
+ else if (strcmp(command, "resize") == 0)
+ ret = mm_util_resize_image(src, src_width, src_height, src_format, dst_width, dst_height, &dst, &res_w, &res_h, &res_buffer_size);
+ else if (strcmp(command, "rotate") == 0)
+ ret = mm_util_rotate_image(src, src_width, src_height, src_format, rotation, &dst, &res_w, &res_h, &res_buffer_size);
+ else if (strcmp(command, "crop") == 0)
+ ret = mm_util_crop_image(src, src_width, src_height, src_format, start_x, start_y, dst_width, dst_height, &dst, &res_w, &res_h, &res_buffer_size);
if (ret == MM_UTIL_ERROR_NONE) {
fprintf(stderr, "Success - %s\n", command);
{ /* write output file */
FILE *fpout = fopen(output_file, "w");
if (fpout) {
- fprintf(stderr, "dst: %p [%zu]\n", dst, dst_size);
- fwrite(dst, 1, dst_size, fpout);
+ fprintf(stderr, "dst: %p [%zu]\n", dst, res_buffer_size);
+ fwrite(dst, 1, res_buffer_size, fpout);
fprintf(stderr, "FREE\n");
fclose(fpout);
}
#else
mm_util_debug("#START# LIBJPEG");
if (fmt == MM_UTIL_COLOR_NV12) {
- size_t dst_size = 0;
- ret = mm_util_get_image_size(MM_UTIL_COLOR_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
+ unsigned int res_w = 0;
+ unsigned int res_h = 0;
+ size_t res_buffer_size = 0;
unsigned char *dst = NULL;
- dst = calloc(1, dst_size);
- if (dst) {
- ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_COLOR_NV12, dst, MM_UTIL_COLOR_YUV420);
- ret = __mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_COLOR_YUV420, quality);
- MMUTIL_SAFE_FREE(dst);
- } else {
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
+
+ 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_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_COLOR_YUV420, quality);
+
+ MMUTIL_SAFE_FREE(dst);
+
} else if (fmt == MM_UTIL_COLOR_NV21) {
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
} else {
#else /* LIBJPEG_TURBO */
mm_util_debug("#START# libjpeg");
if (fmt == MM_UTIL_COLOR_NV12) {
- size_t dst_size = 0;
- ret = mm_util_get_image_size(MM_UTIL_COLOR_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
+ unsigned int res_w = 0;
+ unsigned int res_h = 0;
+ size_t res_buffer_size = 0;
unsigned char *dst = NULL;
- dst = calloc(1, dst_size);
- if (dst) {
- ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_COLOR_NV12, dst, MM_UTIL_COLOR_YUV420);
- ret = __mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_COLOR_YUV420, quality);
- MMUTIL_SAFE_FREE(dst);
- } else {
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
+
+ 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_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_COLOR_YUV420, quality);
+
+ MMUTIL_SAFE_FREE(dst);
+
} else if (fmt == MM_UTIL_COLOR_NV21) {
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
} else {
#else
mm_util_debug("#START# libjpeg(fmt:%d)", fmt);
if (fmt == MM_UTIL_COLOR_NV12) {
- size_t dst_size = 0;
ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_COLOR_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
if (ret == MM_UTIL_ERROR_NONE) {
- int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
- if (err != MM_UTIL_ERROR_NONE)
- mm_util_error("fail mm_util_get_image_size");
-
+ unsigned int res_w = 0;
+ unsigned int res_h = 0;
+ size_t res_buffer_size = 0;
unsigned char *dst = NULL;
- dst = calloc(1, dst_size);
- if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
- MMUTIL_SAFE_FREE(decoded->data);
- decoded->data = calloc(1, dst_size);
- if (decoded->data == NULL) {
- mm_util_debug("memory allocation failed");
- MMUTIL_SAFE_FREE(dst);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memcpy(decoded->data, dst, dst_size);
- decoded->size = (unsigned int)dst_size;
- MMUTIL_SAFE_FREE(dst);
- } else {
+
+ ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
+
+ MMUTIL_SAFE_FREE(decoded->data);
+
+ decoded->data = calloc(1, res_buffer_size);
+ if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
+ MMUTIL_SAFE_FREE(dst);
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
+
+ memcpy(decoded->data, dst, res_buffer_size);
+ decoded->size = (unsigned int)res_buffer_size;
+
+ MMUTIL_SAFE_FREE(dst);
}
} else {
ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, fmt, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
#else
mm_util_debug("#START# libjpeg");
if (fmt == MM_UTIL_COLOR_NV12) {
- size_t dst_size = 0;
- unsigned char *dst = NULL;
-
ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_COLOR_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
if (ret == MM_UTIL_ERROR_NONE) {
- int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
- if (err != MM_UTIL_ERROR_NONE)
- mm_util_error("fail mm_util_get_image_size");
-
- dst = calloc(1, dst_size);
- if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
- MMUTIL_SAFE_FREE(decoded->data);
- decoded->data = calloc(1, dst_size);
- if (decoded->data == NULL) {
- mm_util_debug("memory allocation failed");
- MMUTIL_SAFE_FREE(dst);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memcpy(decoded->data, dst, dst_size);
- decoded->size = (unsigned int)dst_size;
- MMUTIL_SAFE_FREE(dst);
- } else {
+ 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(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
+
+ MMUTIL_SAFE_FREE(decoded->data);
+
+ decoded->data = calloc(1, res_buffer_size);
+ if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
+ MMUTIL_SAFE_FREE(dst);
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
+
+ memcpy(decoded->data, dst, res_buffer_size);
+ decoded->size = (unsigned int)res_buffer_size;
+
+ MMUTIL_SAFE_FREE(dst);
}
} else {
ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, fmt, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
#else
mm_util_debug("#START# libjpeg");
if (fmt == MM_UTIL_COLOR_NV12) {
- size_t dst_size = 0;
ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_COLOR_YUV420, downscale);
if (ret == MM_UTIL_ERROR_NONE) {
- int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
- if (err != MM_UTIL_ERROR_NONE)
- mm_util_error("fail mm_util_get_image_size");
-
+ unsigned int res_w = 0;
+ unsigned int res_h = 0;
+ size_t res_buffer_size = 0;
unsigned char *dst = NULL;
- dst = calloc(1, dst_size);
- if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
- MMUTIL_SAFE_FREE(decoded->data);
- decoded->data = calloc(1, dst_size);
- if (decoded->data == NULL) {
- mm_util_debug("memory allocation failed");
- MMUTIL_SAFE_FREE(dst);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memcpy(decoded->data, dst, dst_size);
- decoded->size = (unsigned int)dst_size;
- MMUTIL_SAFE_FREE(dst);
- } else {
+
+ ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
+
+ MMUTIL_SAFE_FREE(decoded->data);
+
+ decoded->data = calloc(1, res_buffer_size);
+ if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
+ MMUTIL_SAFE_FREE(dst);
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
+
+ memcpy(decoded->data, dst, res_buffer_size);
+ decoded->size = (unsigned int)res_buffer_size;
+
+ MMUTIL_SAFE_FREE(dst);
}
} else {
ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, fmt, downscale);
#else
mm_util_debug("#START# libjpeg");
if (fmt == MM_UTIL_COLOR_NV12) {
- size_t dst_size = 0;
- unsigned char *dst = NULL;
-
ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_COLOR_YUV420, downscale);
if (ret == MM_UTIL_ERROR_NONE) {
- int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
- if (err != MM_UTIL_ERROR_NONE)
- mm_util_error("fail mm_util_get_image_size");
-
- dst = calloc(1, dst_size);
- if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
- MMUTIL_SAFE_FREE(decoded->data);
- decoded->data = calloc(1, dst_size);
- if (decoded->data == NULL) {
- mm_util_debug("memory allocation failed");
- MMUTIL_SAFE_FREE(dst);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memcpy(decoded->data, dst, dst_size);
- decoded->size = (unsigned int)dst_size;
- MMUTIL_SAFE_FREE(dst);
- } else {
+ 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(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
+
+ MMUTIL_SAFE_FREE(decoded->data);
+
+ decoded->data = calloc(1, res_buffer_size);
+ if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
+ MMUTIL_SAFE_FREE(dst);
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
+ memcpy(decoded->data, dst, res_buffer_size);
+ decoded->size = (unsigned int)res_buffer_size;
+
+ MMUTIL_SAFE_FREE(dst);
}
} else {
ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, fmt, downscale);