#include <limits.h>
#include <tzplatform_config.h>
-#define TRANSFORM_TEST_PATH tzplatform_mkpath(TZ_USER_CONTENT, "imgp_result")
-
#define IMGP_FREE(src) { if (src != NULL) {g_free(src); src = NULL; } }
static gboolean _read_file(char *path, void **data, size_t *length)
unsigned char *dst = NULL;
if (argc < 12) {
- fprintf(stderr, "Usage: %s sync {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format roation crop_start_x crop_start_y \n", argv[0]);
- fprintf(stderr, "Usage: %s async {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format roation crop_start_x crop_start_y \n", argv[0]);
- fprintf(stderr, "ex: %s sync test.rgb resize 1920 1080 7 1280 720 7 0 0 0 \n", argv[0]);
+ fprintf(stderr, "Usage: %s {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format roation crop_start_x crop_start_y \n", argv[0]);
+ fprintf(stderr, "ex: %s test.rgb resize 1920 1080 7 1280 720 7 0 0 0 \n", argv[0]);
return ret;
}
size_t src_size = 0;
- bool sync_mode = (strcmp(argv[1], "sync") == 0) ? TRUE : FALSE;
- char *filename = strdup(argv[2]);
- char *command = strdup(argv[3]);
+ char *filename = strdup(argv[1]);
+ char *command = strdup(argv[2]);
unsigned int src_width = 0;
unsigned int src_height = 0;
mm_util_color_format_e src_format = 0;
size_t res_buffer_size = 0;
/* get arguments */
- if (FALSE == _get_input_data(argv[4], 0, UINT_MAX, &src_width)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong src_width %s\n", argv[4]);
+ if (FALSE == _get_input_data(argv[3], 0, UINT_MAX, &src_width)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong src_width %s\n", argv[3]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[5], 0, UINT_MAX, &src_height)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong src_height %s\n", argv[5]);
+ if (FALSE == _get_input_data(argv[4], 0, UINT_MAX, &src_height)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong src_height %s\n", argv[4]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[6], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &src_format)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong src_format %s\n", argv[6]);
+ if (FALSE == _get_input_data(argv[5], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &src_format)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong src_format %s\n", argv[5]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[7], 0, UINT_MAX, &dst_width)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong dst_width %s\n", argv[7]);
+ if (FALSE == _get_input_data(argv[6], 0, UINT_MAX, &dst_width)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong dst_width %s\n", argv[6]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[8], 0, UINT_MAX, &dst_height)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong dst_height %s\n", argv[8]);
+ if (FALSE == _get_input_data(argv[7], 0, UINT_MAX, &dst_height)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong dst_height %s\n", argv[7]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[9], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &dst_format)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong dst_format %s\n", argv[9]);
+ if (FALSE == _get_input_data(argv[8], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &dst_format)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong dst_format %s\n", argv[8]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[10], MM_UTIL_ROTATE_0, MM_UTIL_ROTATE_NUM - 1, &rotation)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong rotation %s\n", argv[10]);
+ if (FALSE == _get_input_data(argv[9], MM_UTIL_ROTATE_0, MM_UTIL_ROTATE_NUM - 1, &rotation)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong rotation %s\n", argv[9]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[11], 0, UINT_MAX, &start_x)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong start_x %s\n", argv[11]);
+ if (FALSE == _get_input_data(argv[10], 0, UINT_MAX, &start_x)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong start_x %s\n", argv[10]);
goto TEST_FAIL;
}
- if (FALSE == _get_input_data(argv[12], 0, UINT_MAX, &start_y)) {
- fprintf(stderr, "\t[IMGP_testsuite] wrong start_y %s\n", argv[12]);
+ if (FALSE == _get_input_data(argv[11], 0, UINT_MAX, &start_y)) {
+ fprintf(stderr, "\t[IMGP_testsuite] wrong start_y %s\n", argv[11]);
goto TEST_FAIL;
}
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);
/* ready output file */
- snprintf(output_file, 40, "%s_%s_%dx%d.raw", TRANSFORM_TEST_PATH, command, dst_width, dst_height);
-
- 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_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);
- } else {
- fprintf(stderr, "ERROR - %s\n", command);
- goto TEST_FAIL;
- }
-
- /* write output file */
- if (FALSE == _write_file(output_file, dst, res_buffer_size)) {
- fprintf(stderr, "\t[IMGP_testsuite] writing file(%s) error\n", output_file);
- goto TEST_FAIL;
- }
- } else { /* Async mode */
- fprintf(stderr, "ASYNC\n");
+ snprintf(output_file, 40, "result_%s_%d_%d.raw", command, dst_width, dst_height);
+
+ 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);
+ } else {
+ fprintf(stderr, "ERROR - %s\n", command);
+ goto TEST_FAIL;
+ }
+
+ /* write output file */
+ if (FALSE == _write_file(output_file, dst, res_buffer_size)) {
+ fprintf(stderr, "\t[IMGP_testsuite] writing file(%s) error\n", output_file);
+ goto TEST_FAIL;
}
+
TEST_FAIL:
IMGP_FREE(src);