char *szErrorVal = NULL;
switch ( nRet )
{
- case IMAGE_UTIL_ERROR_INVALID_PARAMETER: szErrorVal = "IMAGE_UTIL_ERROR_INVALID_PARAMETER"; break;
- case IMAGE_UTIL_ERROR_OUT_OF_MEMORY: szErrorVal = "IMAGE_UTIL_ERROR_OUT_OF_MEMORY"; break;
- case IMAGE_UTIL_ERROR_NO_SUCH_FILE: szErrorVal = "IMAGE_UTIL_ERROR_NO_SUCH_FILE"; break;
- case IMAGE_UTIL_ERROR_INVALID_OPERATION: szErrorVal = "IMAGE_UTIL_ERROR_INVALID_OPERATION"; break;
- case IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT: szErrorVal = "IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT"; break;
- case IMAGE_UTIL_ERROR_NONE: szErrorVal = "IMAGE_UTIL_ERROR_NONE"; break;
- default: szErrorVal = "Unknown Error"; break;
+ case IMAGE_UTIL_ERROR_INVALID_PARAMETER: szErrorVal = "IMAGE_UTIL_ERROR_INVALID_PARAMETER"; break;
+ case IMAGE_UTIL_ERROR_OUT_OF_MEMORY: szErrorVal = "IMAGE_UTIL_ERROR_OUT_OF_MEMORY"; break;
+ case IMAGE_UTIL_ERROR_NO_SUCH_FILE: szErrorVal = "IMAGE_UTIL_ERROR_NO_SUCH_FILE"; break;
+ case IMAGE_UTIL_ERROR_INVALID_OPERATION: szErrorVal = "IMAGE_UTIL_ERROR_INVALID_OPERATION"; break;
+ case IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT: szErrorVal = "IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT"; break;
+ case IMAGE_UTIL_ERROR_NONE: szErrorVal = "IMAGE_UTIL_ERROR_NONE"; break;
+ default: szErrorVal = "Unknown Error"; break;
}
return szErrorVal;
}
int image_load(const char *file_path, mv_source_h source)
{
- if (NULL == file_path || NULL == source)
- {
- FPRINTF("[Line : %d][%s] File path or source is NULL\\n", __LINE__, API_NAMESPACE);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
+ if (NULL == file_path || NULL == source)
+ {
+ FPRINTF("[Line : %d][%s] File path or source is NULL\\n", __LINE__, API_NAMESPACE);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
- unsigned long width = 0;
- unsigned long height = 0;
- unsigned long long buffer_size = 0;
- unsigned char *data_buffer = NULL;
- image_util_decode_h hDecoder = NULL;
+ unsigned long width = 0;
+ unsigned long height = 0;
+ unsigned long long buffer_size = 0;
+ unsigned char *data_buffer = NULL;
+ image_util_decode_h hDecoder = NULL;
- int ret = image_util_decode_create(&hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_create Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- ret = image_util_decode_set_input_path(hDecoder, file_path);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- FPRINTF("[Line : %d][%s] image_util_decode_set_input_path Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- ret = image_util_decode_set_colorspace(hDecoder, IMAGE_UTIL_COLORSPACE_RGB888);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- FPRINTF("[Line : %d][%s] image_util_decode_set_colorspace Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- ret = image_util_decode_set_output_buffer(hDecoder, &data_buffer);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- FPRINTF("[Line : %d][%s] image_util_decode_set_output_buffer Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
+ int ret = image_util_decode_create(&hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_create Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ ret = image_util_decode_set_input_path(hDecoder, file_path);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ FPRINTF("[Line : %d][%s] image_util_decode_set_input_path Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ ret = image_util_decode_set_colorspace(hDecoder, IMAGE_UTIL_COLORSPACE_RGB888);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ FPRINTF("[Line : %d][%s] image_util_decode_set_colorspace Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ ret = image_util_decode_set_output_buffer(hDecoder, &data_buffer);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ FPRINTF("[Line : %d][%s] image_util_decode_set_output_buffer Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
- ret = image_util_decode_run(hDecoder, &width, &height, &buffer_size);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- if (data_buffer)
- {
- free(data_buffer);
- data_buffer = NULL;
- }
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- FPRINTF("[Line : %d][%s] image_util_decode_run Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
+ ret = image_util_decode_run(hDecoder, &width, &height, &buffer_size);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ if (data_buffer)
+ {
+ free(data_buffer);
+ data_buffer = NULL;
+ }
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ FPRINTF("[Line : %d][%s] image_util_decode_run Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
- mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
+ mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
- ret = mv_source_clear(source);
- if (MEDIA_VISION_ERROR_NONE != ret)
- {
- if (data_buffer)
- {
- free(data_buffer);
- data_buffer = NULL;
- }
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- FPRINTF("[Line : %d][%s] Error occured when clearing the source\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
+ ret = mv_source_clear(source);
+ if (MEDIA_VISION_ERROR_NONE != ret)
+ {
+ if (data_buffer)
+ {
+ free(data_buffer);
+ data_buffer = NULL;
+ }
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ FPRINTF("[Line : %d][%s] Error occured when clearing the source\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
- ret = mv_source_fill_by_buffer(source, data_buffer, buffer_size, width, height, source_colorspace);
- if (MEDIA_VISION_ERROR_NONE != ret)
- {
- if (data_buffer)
- {
- free(data_buffer);
- data_buffer = NULL;
- }
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
- FPRINTF("[Line : %d][%s] Error occured when filling the source by buffer\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
+ ret = mv_source_fill_by_buffer(source, data_buffer, buffer_size, width, height, source_colorspace);
+ if (MEDIA_VISION_ERROR_NONE != ret)
+ {
+ if (data_buffer)
+ {
+ free(data_buffer);
+ data_buffer = NULL;
+ }
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
+ FPRINTF("[Line : %d][%s] Error occured when filling the source by buffer\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
- if (data_buffer)
- {
- free(data_buffer);
- data_buffer = NULL;
- }
- ret = image_util_decode_destroy(hDecoder);
- if (IMAGE_UTIL_ERROR_NONE != ret)
- {
- FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
- return ret;
- }
+ if (data_buffer)
+ {
+ free(data_buffer);
+ data_buffer = NULL;
+ }
+ ret = image_util_decode_destroy(hDecoder);
+ if (IMAGE_UTIL_ERROR_NONE != ret)
+ {
+ FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\\n", __LINE__, API_NAMESPACE);
+ return ret;
+ }
- return MEDIA_VISION_ERROR_NONE;
+ return MEDIA_VISION_ERROR_NONE;
}
/** @} */