--- /dev/null
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
--- /dev/null
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
--- /dev/null
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./ # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
--- /dev/null
+CAPI_PROJECT_ROOT=/home/abyss/capi
+TET_INSTALL_HOST_PATH=/home/abyss/TETware
+TET_INSTALL_TARGET_PATH=/mnt/nfs/TETware
--- /dev/null
+#!/bin/sh
+
+. ./_export_target_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+CC ?= gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = capi-media-image-util dlog glib-2.0
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+#TARGETS = $(C_FILES:%.c=tc-%)
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TCS)
--- /dev/null
+/testcase/utc_image_util_jpeg
+/testcase/utc_media_image_util_basic
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+#include <stdio.h>
+#include <tet_api.h>
+#include <image_util.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+#define SAMPLE_JPEG "sample.jpg"
+#define WRONG_PATH ""
+#define OUTPUT_JPEG "test_output.jpg"
+
+image_util_colorspace_e SUPPORTED_COLORSPACE;
+image_util_colorspace_e NOT_SUPPORTED_COLORSPACE;
+image_util_colorspace_e FIRST_COLORSPACE;
+image_util_colorspace_e LAST_COLORSPACE;
+
+/**
+ * @brief Global struct for raw image data
+ */
+struct{
+ unsigned char *buffer;
+ int size;
+ int w;
+ int h;
+}raw_image = {NULL, 0, 0, 0};
+
+
+/**
+ * @brief Global struct for jpeg image
+ */
+struct{
+ unsigned char *buffer;
+ int size;
+}jpeg_image = {NULL, 0};
+
+
+#define API_NAME_IMAGE_UTIL_DECODE_JPEG "image_util_decode_jpeg"
+#define API_NAME_IMAGE_UTIL_ENCODE_JPEG "image_util_encode_jpeg"
+#define API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY "image_util_decode_jpeg_from_memory"
+#define API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY "image_util_encode_jpeg_to_memory"
+
+static void utc_image_util_decode_jpeg_n_1(void);
+static void utc_image_util_decode_jpeg_n_2(void);
+static void utc_image_util_decode_jpeg_n_3(void);
+static void utc_image_util_decode_jpeg_n_4(void);
+static void utc_image_util_decode_jpeg_n_5(void);
+static void utc_image_util_decode_jpeg_p(void);
+static void utc_image_util_decode_jpeg_from_memory_n_1(void);
+static void utc_image_util_decode_jpeg_from_memory_n_2(void);
+static void utc_image_util_decode_jpeg_from_memory_n_3(void);
+static void utc_image_util_decode_jpeg_from_memory_n_4(void);
+static void utc_image_util_decode_jpeg_from_memory_p(void);
+static void utc_image_util_encode_jpeg_n_1(void);
+static void utc_image_util_encode_jpeg_n_2(void);
+static void utc_image_util_encode_jpeg_n_3(void);
+static void utc_image_util_encode_jpeg_n_4(void);
+static void utc_image_util_encode_jpeg_n_5(void);
+static void utc_image_util_encode_jpeg_p(void);
+static void utc_image_util_encode_jpeg_to_memory_n_1(void);
+static void utc_image_util_encode_jpeg_to_memory_n_2(void);
+static void utc_image_util_encode_jpeg_to_memory_n_3(void);
+static void utc_image_util_encode_jpeg_to_memory_n_4(void);
+static void utc_image_util_encode_jpeg_to_memory_p(void);
+
+enum
+{
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+/**
+ * image_util_decode_jpeg
+ */
+ { utc_image_util_decode_jpeg_n_1, 1 },
+ { utc_image_util_decode_jpeg_n_2, 2 },
+ { utc_image_util_decode_jpeg_n_3, 3 },
+ { utc_image_util_decode_jpeg_n_4, 4 },
+ { utc_image_util_decode_jpeg_n_5, 5 },
+ { utc_image_util_decode_jpeg_p, 6},
+
+/**
+ * image_util_encode_jpeg
+ */
+ { utc_image_util_encode_jpeg_n_1, 7 },
+ { utc_image_util_encode_jpeg_n_2, 8 },
+ { utc_image_util_encode_jpeg_n_3, 9 },
+ { utc_image_util_encode_jpeg_n_4, 10 },
+ { utc_image_util_encode_jpeg_n_5, 11 },
+ { utc_image_util_encode_jpeg_p, 12},
+
+/**
+ * image_util_encode_jpeg_to_memory
+ */
+ { utc_image_util_encode_jpeg_to_memory_n_1, 13 },
+ { utc_image_util_encode_jpeg_to_memory_n_2, 14 },
+ { utc_image_util_encode_jpeg_to_memory_n_3, 15 },
+ { utc_image_util_encode_jpeg_to_memory_n_4, 16 },
+ { utc_image_util_encode_jpeg_to_memory_p, 17 },
+
+/**
+ * image_util_decode_jpeg_from_memory
+ */
+ { utc_image_util_decode_jpeg_from_memory_n_1, 18 },
+ { utc_image_util_decode_jpeg_from_memory_n_2, 19 },
+ { utc_image_util_decode_jpeg_from_memory_n_3, 20 },// SIGSEGV from api
+ { utc_image_util_decode_jpeg_from_memory_n_4, 21 },
+ { utc_image_util_decode_jpeg_from_memory_p, 22 }, // SIGSEGV from api
+ { NULL, 0 },
+};
+
+/**
+ * @brief Callback to find first supported colorspace
+ */
+static bool find_first_supported_colorspace_cb( image_util_colorspace_e colorspace, void * user_data)
+{
+ *(int*)user_data = colorspace;
+ return false;
+}
+
+static void startup(void)
+{
+ /* start of TC */
+ tet_printf("\n TC start");
+ // set first not supportes colorspace
+ image_util_foreach_supported_jpeg_colorspace( find_first_supported_colorspace_cb , (void*)(&SUPPORTED_COLORSPACE) );
+
+ // set oher colorspaces
+ NOT_SUPPORTED_COLORSPACE = IMAGE_UTIL_COLORSPACE_YUV422; //TODO: FIND NOT SUPPORTED FORMAT
+ FIRST_COLORSPACE = IMAGE_UTIL_COLORSPACE_YV12;
+ LAST_COLORSPACE = IMAGE_UTIL_COLORSPACE_BGRX8888;
+
+ // prepare buffers for raw and jpeg images
+ if(image_util_decode_jpeg(SAMPLE_JPEG, SUPPORTED_COLORSPACE, &raw_image.buffer, &raw_image.w, &raw_image.h, &raw_image.size) == IMAGE_UTIL_ERROR_NONE){
+ tet_printf("\n raw_image initialization OK");
+ if(image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, &jpeg_image.buffer, &jpeg_image.size) == IMAGE_UTIL_ERROR_NONE)
+ tet_printf("\n jpeg_image initialization OK");
+ else
+ tet_printf("\n jpeg_image initialization FAILED");
+ }
+ else
+ tet_printf("\n raw_image initialization FAILED");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ free(raw_image.buffer);
+ free(jpeg_image.buffer);
+ tet_printf("\n TC end");
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg(). Invalid path or image_buffer parameters;
+ */
+static void utc_image_util_decode_jpeg_n_1(void)
+{
+ int r;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg(NULL, SUPPORTED_COLORSPACE, NULL, &w, &h, &size);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg(). Parameter colorspace over the range.
+ */
+static void utc_image_util_decode_jpeg_n_2(void)
+{
+ int r;
+ int w, h;
+ int size;
+ unsigned char *buffer = NULL;
+
+ r = image_util_decode_jpeg(SAMPLE_JPEG, LAST_COLORSPACE + 1, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg(). Parameter colorspace below the range.
+ */
+static void utc_image_util_decode_jpeg_n_3(void)
+{
+ int r;
+ int w, h;
+ int size;
+ unsigned char *buffer = NULL;
+
+ r = image_util_decode_jpeg(SAMPLE_JPEG, FIRST_COLORSPACE - 1, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg(). Not supported format.
+ */
+static void utc_image_util_decode_jpeg_n_4(void)
+{
+ int r;
+ int w, h;
+ int size;
+ unsigned char *buffer = NULL;
+
+ r = image_util_decode_jpeg(SAMPLE_JPEG, NOT_SUPPORTED_COLORSPACE, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg(). Wrong image file path. (Incomplete documentation!)
+ */
+static void utc_image_util_decode_jpeg_n_5(void)
+{
+ int r;
+ int w, h;
+ int size;
+ unsigned char *buffer = NULL;
+
+ r = image_util_decode_jpeg(WRONG_PATH, SUPPORTED_COLORSPACE, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_NO_SUCH_FILE);
+}
+
+
+/**
+ * @brief Positive test case of image_util_decode_jpeg(). Al parameters OK, Success expected.
+ */
+static void utc_image_util_decode_jpeg_p(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg(SAMPLE_JPEG, SUPPORTED_COLORSPACE, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG, r, IMAGE_UTIL_ERROR_NONE);
+}
+
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg_from_memory(). Invalid jpeg_buffer or image_buffer parameters;
+ */
+static void utc_image_util_decode_jpeg_from_memory_n_1(void)
+{
+ int r;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg_from_memory(NULL, jpeg_image.size, SUPPORTED_COLORSPACE, NULL, &w, &h, &size);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg_from_memory(). Parameter colorspace below the range.
+ */
+static void utc_image_util_decode_jpeg_from_memory_n_2(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, FIRST_COLORSPACE -1, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg_from_memory(). Parameter colorspace over the range.
+ */
+static void utc_image_util_decode_jpeg_from_memory_n_3(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, LAST_COLORSPACE + 1, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_decode_jpeg_from_memory(). Not supported format.
+ */
+static void utc_image_util_decode_jpeg_from_memory_n_4(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, NOT_SUPPORTED_COLORSPACE, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
+}
+
+
+/**
+ * @brief Positive test image_util_decode_jpeg_from_memory(). Al parameters OK, Success expected.
+ */
+static void utc_image_util_decode_jpeg_from_memory_p(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int w, h;
+ int size;
+
+ r = image_util_decode_jpeg_from_memory(jpeg_image.buffer, jpeg_image.size, SUPPORTED_COLORSPACE, &buffer, &w, &h, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_DECODE_JPEG_FROM_MEMORY, r, IMAGE_UTIL_ERROR_NONE);
+}
+/**
+ * @brief Negative test case of image_util_encode_jpeg(). Invalid path or buffer parameters;
+ */
+static void utc_image_util_encode_jpeg_n_1(void)
+{
+ int r;
+
+ r = image_util_encode_jpeg(NULL, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, NULL);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg(). Parameter colorspace over the range.
+ */
+static void utc_image_util_encode_jpeg_n_2(void)
+{
+ int r;
+
+ r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , LAST_COLORSPACE + 1, 100, OUTPUT_JPEG);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+/**
+ * @brief Negative test case of image_util_encode_jpeg(). Parameter colorspace below the range.
+ */
+static void utc_image_util_encode_jpeg_n_3(void)
+{
+ int r;
+
+ r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , FIRST_COLORSPACE -1, 100, OUTPUT_JPEG);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg(). Not supported format.
+ */
+static void utc_image_util_encode_jpeg_n_4(void)
+{
+ int r;
+
+ r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , NOT_SUPPORTED_COLORSPACE, 100, OUTPUT_JPEG);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
+}
+
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg(). Wrong image file path.
+ */
+static void utc_image_util_encode_jpeg_n_5(void)
+{
+ int r;
+
+ r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, WRONG_PATH);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_NO_SUCH_FILE);
+}
+
+
+/**
+ * @brief Positive test case of image_util_encode_jpeg(). Al parameters OK, Success expected.
+ */
+static void utc_image_util_encode_jpeg_p(void)
+{
+ int r;
+
+ r = image_util_encode_jpeg(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, OUTPUT_JPEG);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG, r, IMAGE_UTIL_ERROR_NONE);
+}
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg_to_memory(). Invalid path or image_buffer or jpeg_buffer parameters;
+ */
+static void utc_image_util_encode_jpeg_to_memory_n_1(void)
+{
+ int r;
+ int size;
+
+ r = image_util_encode_jpeg_to_memory(NULL, 5 , 5 , SUPPORTED_COLORSPACE, 100, NULL, &size);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg_to_memory(). Parameter colorspace over the range.
+ */
+static void utc_image_util_encode_jpeg_to_memory_n_2(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int size;
+
+ r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , FIRST_COLORSPACE - 1, 100, &buffer, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg_to_memory(). Parameter colorspace below the range.
+ */
+static void utc_image_util_encode_jpeg_to_memory_n_3(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int size;
+
+ r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , LAST_COLORSPACE + 1, 100, &buffer, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @brief Negative test case of image_util_encode_jpeg_to_memory(). Not supported format.
+ */
+static void utc_image_util_encode_jpeg_to_memory_n_4(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int size;
+
+ r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , NOT_SUPPORTED_COLORSPACE, 100, &buffer, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
+}
+
+/**
+ * @brief Positive test case of image_util_encode_jpeg_to_memory(). Al parameters OK, Success expected.
+ */
+static void utc_image_util_encode_jpeg_to_memory_p(void)
+{
+ int r;
+ unsigned char *buffer = NULL;
+ int size;
+
+ r = image_util_encode_jpeg_to_memory(raw_image.buffer, raw_image.w , raw_image.h , SUPPORTED_COLORSPACE, 100, &buffer, &size);
+ free(buffer);
+ dts_check_eq(API_NAME_IMAGE_UTIL_ENCODE_JPEG_TO_MEMORY, r, IMAGE_UTIL_ERROR_NONE);
+}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include <tet_api.h>
+#include <image_util.h>
+
+
+
+#define API_NAME_IMAGEUTIL_COLORSPACE "image_util_colorspace"
+#define API_NAME_IMAGEUTIL_COLOR_CONVERT "image_util_color_convert"
+#define API_NAME_IMAGEUTIL_BUFFER_SIZE "image_util_buffer_size"
+#define API_NAME_IMAGEUTIL_TRANSFORM "image_util_color_transform"
+
+#define SAMPLE_FILENAME "./sample.jpg"
+
+#define LAST_COLORSPACE IMAGE_UTIL_COLORSPACE_BGRX8888
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+//Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.
+static void utc_image_util_supported_jpeg_colorspace_p(void); // how many colorspaces are available
+static void utc_image_util_supported_jpeg_colorspace_2_p(void); // does ,,foreach'' return pass?
+static void utc_image_util_supported_jpeg_colorspace_3_p(void); // does ,,foreach'' return pass for all cases?
+
+//Convert the image's colorspace.
+static void utc_image_util_convert_colorspace_p(void);
+static void utc_image_util_convert_colorspace_1_n(void);
+static void utc_image_util_convert_colorspace_2_n(void);
+
+//Calculates the size of image buffer for the specified resolution and colorspace.
+static void utc_image_util_calculate_bufsize_result_p(void);
+static void utc_image_util_calculate_bufsize_result_1_n(void);
+static void utc_image_util_calculate_bufsize_result_2_n(void);
+static void utc_image_util_calculate_bufsize_result_3_n(void);
+static void utc_image_util_calculate_bufsize_result_4_p(void);
+static void utc_image_util_calculate_bufsize_result_5_p(void);
+
+
+//Transforms the image to with the specified destination width and height and angle in degrees.
+static void utc_image_util_file_rotate_p(void);
+static void utc_image_util_file_rotate_2_p(void);
+static void utc_image_util_file_rotate_3_p(void);
+
+
+
+
+static bool jpeg_colorspace_cb( image_util_colorspace_e colorspace, void * user_data);
+static bool jpeg_colorspace_quit_cb( image_util_colorspace_e colorspace, void * user_data);
+static bool jpeg_colorspace_size_cb( image_util_colorspace_e colorspace, void * user_data);
+
+
+//available transforms
+#define AT_COUTN 4
+const int avail_trans[AT_COUTN] =
+{
+ IMAGE_UTIL_COLORSPACE_YV12,
+ IMAGE_UTIL_COLORSPACE_I420,
+ IMAGE_UTIL_COLORSPACE_NV12,
+ IMAGE_UTIL_COLORSPACE_RGB888,
+};
+
+
+
+enum
+{
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+
+
+
+struct tet_testlist tet_testlist[] = {
+ { utc_image_util_supported_jpeg_colorspace_p, 1},
+ { utc_image_util_supported_jpeg_colorspace_2_p, 2},
+ { utc_image_util_supported_jpeg_colorspace_3_p, 3},
+ { utc_image_util_calculate_bufsize_result_p, 4},
+ { utc_image_util_calculate_bufsize_result_1_n, 5},
+ { utc_image_util_calculate_bufsize_result_2_n, 6},
+ { utc_image_util_calculate_bufsize_result_3_n, 7},
+ { utc_image_util_calculate_bufsize_result_4_p, 8},
+ { utc_image_util_calculate_bufsize_result_5_p, 9},
+ { utc_image_util_convert_colorspace_p, 10},
+ { utc_image_util_convert_colorspace_1_n, 11},
+ { utc_image_util_convert_colorspace_2_n, 12},
+ { utc_image_util_file_rotate_p, 13},
+ { utc_image_util_file_rotate_2_p, 14},
+ { utc_image_util_file_rotate_3_p, 15},
+ { NULL, 0},
+};
+
+
+static void startup(void)
+{
+ // TC start
+}
+
+static void cleanup(void)
+{
+ // TC end
+}
+
+
+
+static bool jpeg_colorspace_cb( image_util_colorspace_e colorspace, void * user_data)
+{
+ return true;
+}
+
+
+static bool jpeg_colorspace_quit_cb( image_util_colorspace_e colorspace, void * user_data)
+{
+ int last = *((int*)user_data);
+ return (int)colorspace == last ? false : true;
+}
+
+
+
+static bool jpeg_colorspace_size_cb( image_util_colorspace_e colorspace, void * user_data)
+{
+ int * result = (int*)user_data;
+
+ const int W = 480, H = 320; // these values are taken from test file - sample.jpg
+ int width = 0, height = 0;
+ int size_decode = 0;
+ unsigned int size_calc = 0;
+ unsigned char * img_buf = 0;
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_buf, &width, &height, &size_decode );
+
+ // prepare buffers
+ image_util_calculate_buffer_size( W, H, colorspace, &size_calc );
+
+ free( img_buf );
+
+ *result = (size_decode == size_calc);
+
+ // if false then callbacks stop
+ return *result;
+}
+
+
+
+
+
+/**
+ * @brief how many colorspaces are available
+ */
+static void utc_image_util_supported_jpeg_colorspace_p(void)
+{
+ int pointer = 0;
+ int ret = image_util_foreach_supported_jpeg_colorspace( NULL , (void*)(&pointer) );
+ dts_check_eq( API_NAME_IMAGEUTIL_COLORSPACE, ret, IMAGE_UTIL_ERROR_INVALID_PARAMETER );
+}
+
+
+
+
+
+
+
+/**
+ * @brief does ,,foreach'' return pass?
+ */
+static void utc_image_util_supported_jpeg_colorspace_2_p(void)
+{
+ int err = image_util_foreach_supported_jpeg_colorspace( jpeg_colorspace_cb , (void*)NULL );
+ dts_check_eq( API_NAME_IMAGEUTIL_COLORSPACE, err, IMAGE_UTIL_ERROR_NONE );
+}
+
+
+
+
+
+
+
+/**
+ * @brief does ,,foreach'' return pass for all cases?
+ */
+static void utc_image_util_supported_jpeg_colorspace_3_p(void)
+{
+ int err;
+ char buf[100] = { '\0' };
+ snprintf( buf, 100, "%s", API_NAME_IMAGEUTIL_COLORSPACE );
+
+ // parameter i decides when loop of callbacks should break
+ int i;
+ for( i = 0; i < LAST_COLORSPACE; ++i )
+ {
+ err = image_util_foreach_supported_jpeg_colorspace( jpeg_colorspace_quit_cb , (void*)(&i) );
+ if( err != 0 )
+ {
+ sprintf( buf, " [error: colorspace_2_p on position %d]", i );
+ break;
+ }
+ }
+
+ dts_check_eq( buf, err, 0 );
+}
+
+
+
+
+
+
+/**
+ * @brief check the buffer size calculation with correct parameters
+ */
+static void utc_image_util_calculate_bufsize_result_p(void)
+{
+ int width = 100, height = 20;
+ unsigned int size = 0;
+
+ int err = image_util_calculate_buffer_size( width, height, IMAGE_UTIL_COLORSPACE_RGB888, &size );
+ dts_check_eq( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 );
+}
+
+
+
+
+
+/**
+ * @brief check the buffer size calculation with uncorrect parameters
+ */
+static void utc_image_util_calculate_bufsize_result_1_n(void)
+{
+ int width = 100, height = 20;
+ unsigned int size = 0;
+ const int colorspace = IMAGE_UTIL_COLORSPACE_BGRX8888 + 1; // after last one
+
+ int err = image_util_calculate_buffer_size( width, height, colorspace, &size );
+ dts_check_ne( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 );
+}
+
+
+
+
+
+
+/**
+ * @brief check the buffer size calculation with uncorrect parameters
+ */
+static void utc_image_util_calculate_bufsize_result_2_n(void)
+{
+ int width = -100, height = 20; // wrong parameter
+ unsigned int size = 0;
+ const int colorspace = IMAGE_UTIL_COLORSPACE_BGRX8888;
+
+ int err = image_util_calculate_buffer_size( width, height, colorspace, &size );
+ dts_check_ne( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 );
+}
+
+
+
+
+
+
+/**
+ * @brief check the buffer size calculation with uncorrect parameters
+ */
+static void utc_image_util_calculate_bufsize_result_3_n(void)
+{
+ int width = 0, height = 0; // wrong parameter
+ unsigned int size = 0;
+ const int colorspace = IMAGE_UTIL_COLORSPACE_BGRX8888;
+
+ int err = image_util_calculate_buffer_size( width, height, colorspace, &size );
+ dts_check_ne( API_NAME_IMAGEUTIL_BUFFER_SIZE, err, 0 );
+}
+
+
+
+
+
+/**
+ * @brief do the buffer size calculation and check if
+ * this is the same like with decode_jpeg function
+ */
+static void utc_image_util_calculate_bufsize_result_4_p(void)
+{
+ const int W = 480, H = 320; // these values are taken from original file sample.jpg
+ int width = 0, height = 0;
+ int size_decode = 0;
+ unsigned int size_calc = 0;
+ unsigned char * img_buf = 0;
+ const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_buf, &width, &height, &size_decode );
+
+ // prepare buffers
+ image_util_calculate_buffer_size( W, H, colorspace, &size_calc );
+
+ free( img_buf );
+
+ dts_check_eq( API_NAME_IMAGEUTIL_BUFFER_SIZE, (int)size_calc, size_decode );
+}
+
+
+
+
+/**
+ * @brief do the buffer size calculation for all colorspaces
+ * this is similar like ..._calculate_bufsize_result_4_p
+ */
+static void utc_image_util_calculate_bufsize_result_5_p(void)
+{
+ int result = -1;
+
+ // do the loop for all colorspaces and check bufsize there inside
+ image_util_foreach_supported_jpeg_colorspace( jpeg_colorspace_size_cb, (void*)(&result) );
+
+ // result is taken from inside the colorspace callbacks loop,
+ // there is compared buffor size
+ // result takes true or false
+ dts_check_eq( API_NAME_IMAGEUTIL_BUFFER_SIZE, result, 1 );
+}
+
+
+/**
+ * @brief check if color conversion returns positive
+ */
+static void utc_image_util_convert_colorspace_p(void)
+{
+ int width = 0, height = 0;
+ unsigned int size_decode = 0;
+ unsigned char * img_target = 0;
+ unsigned char * img_source = 0;
+ const image_util_colorspace_e cs_target = IMAGE_UTIL_COLORSPACE_RGB888;
+ const image_util_colorspace_e cs_source = IMAGE_UTIL_COLORSPACE_YV12;
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, cs_source, &img_source, &width, &height, &size_decode );
+ image_util_calculate_buffer_size(width, height, cs_target , &size_decode);
+ img_target = malloc( size_decode );
+
+ // do conversion
+ int ret = image_util_convert_colorspace( img_target, cs_target,
+ img_source, width, height, cs_source );
+ free( img_target );
+ free( img_source );
+
+ dts_check_eq( API_NAME_IMAGEUTIL_COLOR_CONVERT, ret, IMAGE_UTIL_ERROR_NONE );
+}
+
+
+
+
+
+
+/**
+ * @brief check if color conversion function has the verification of input parameters
+ */
+static void utc_image_util_convert_colorspace_1_n(void)
+{
+ int width = 0, height = 0;
+ unsigned char * img_target = 0; // NULL pointer!
+ unsigned char * img_source = 0; // NULL pointer!
+ const image_util_colorspace_e cs_target = IMAGE_UTIL_COLORSPACE_RGB888;
+ const image_util_colorspace_e cs_source = IMAGE_UTIL_COLORSPACE_YV12;
+
+ // do conversion
+ int ret = image_util_convert_colorspace( img_target, cs_target,
+ img_source, width, height, cs_source );
+
+ dts_check_ne( API_NAME_IMAGEUTIL_COLOR_CONVERT, ret, IMAGE_UTIL_ERROR_NONE );
+}
+
+
+
+/**
+ * @brief check if color conversion has verification of input parameters
+ */
+static void utc_image_util_convert_colorspace_2_n(void)
+{
+ int width = 0, height = 0;
+ int size_decode = 0;
+ unsigned char * img_target = 0;
+ unsigned char * img_source = 0;
+ const image_util_colorspace_e cs_target = IMAGE_UTIL_COLORSPACE_BGRX8888 + 1; // out of the scope!
+ const image_util_colorspace_e cs_source = IMAGE_UTIL_COLORSPACE_YV12;
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, cs_source, &img_source, &width, &height, &size_decode );
+
+ // do conversion
+ int ret = image_util_convert_colorspace( img_target, cs_target,
+ img_source, width, height, cs_source );
+ free( img_target );
+ free( img_source );
+
+ dts_check_ne( API_NAME_IMAGEUTIL_COLOR_CONVERT, ret, IMAGE_UTIL_ERROR_NONE );
+}
+
+
+
+
+/**
+ * @brief Simple use of transformation
+ */
+static void utc_image_util_file_rotate_p(void)
+{
+ int width = 0, height = 0;
+ int size_decode = 0;
+ unsigned char * img_target = 0;
+ unsigned char * img_source = 0;
+
+ image_util_rotation_e dest_rotation = IMAGE_UTIL_ROTATION_90;
+
+ const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_source, &width, &height, &size_decode );
+
+ image_util_calculate_buffer_size(width, height, colorspace , &size_decode);
+
+ img_target = malloc( size_decode );
+
+ // do rotation
+ int ret = image_util_rotate( img_target, &width, &height, dest_rotation,
+ img_source, width, height, colorspace );
+
+ free( img_target );
+ free( img_source );
+
+ dts_check_eq( API_NAME_IMAGEUTIL_TRANSFORM, ret, IMAGE_UTIL_ERROR_NONE );
+}
+
+
+
+
+
+/**
+ * @brief Image transformation for all rotation types
+ */
+static void utc_image_util_file_rotate_2_p(void)
+{
+ int ret = -1;
+
+ int width = 0, height = 0;
+ int target_width , target_height = 0;
+ int size_decode = 0;
+ unsigned char * img_target = 0;
+ unsigned char * img_source = 0;
+
+ const image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, colorspace, &img_source, &width, &height, &size_decode );
+ image_util_calculate_buffer_size(width, height, colorspace , &size_decode);
+
+ img_target = malloc( size_decode );
+
+ image_util_rotation_e rot;
+ for( rot = IMAGE_UTIL_ROTATION_NONE;
+ rot <= IMAGE_UTIL_ROTATION_FLIP_VERT; ++rot )
+ {
+ // do rotation
+ ret = image_util_rotate( img_target, &target_width, &target_height, rot,
+ img_source, width, height, colorspace );
+
+ if( ret != 0 )
+ break;
+ }
+
+ free( img_target );
+ free( img_source );
+
+ dts_check_eq( API_NAME_IMAGEUTIL_TRANSFORM, ret, IMAGE_UTIL_ERROR_NONE );
+}
+
+
+
+
+
+/**
+ * @brief Image transformation for all available colorspaces
+ */
+static void utc_image_util_file_rotate_3_p(void)
+{
+ int ret = -1;
+
+ // loop uses all colorspaces for one transformation
+ int i;
+ for( i = 0; i < AT_COUTN; ++i )
+ {
+ int width = 0, height = 0;
+ int size_decode = 0;
+ unsigned char * img_target = 0;
+ unsigned char * img_source_converted = 0;
+ unsigned char * img_source = 0;
+
+
+ // load jpeg sample file
+ image_util_decode_jpeg( SAMPLE_FILENAME, IMAGE_UTIL_COLORSPACE_RGB888 , &img_source, &width, &height, &size_decode );
+ // convert target format
+ if( IMAGE_UTIL_COLORSPACE_RGB888 != avail_trans[i] ){
+ image_util_calculate_buffer_size(width, height, avail_trans[i], &size_decode);
+ img_source_converted = malloc(size_decode);
+ image_util_convert_colorspace(img_source_converted , avail_trans[i] , img_source , width, height, IMAGE_UTIL_COLORSPACE_RGB888);
+ free(img_source);
+ img_source = img_source_converted;
+ }
+
+
+
+ image_util_calculate_buffer_size(width, height, avail_trans[i] , &size_decode);
+ img_target = malloc( size_decode );
+
+ // do rotation
+ ret = image_util_rotate( img_target, &width, &height, IMAGE_UTIL_ROTATION_180,
+ img_source, width, height, avail_trans[i] );
+
+ free( img_target );
+ free( img_source );
+
+ if( ret != 0 )
+ break;
+ }
+
+
+
+ dts_check_eq( API_NAME_IMAGEUTIL_TRANSFORM, ret, IMAGE_UTIL_ERROR_NONE );
+}
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/testcase/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
--- /dev/null
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage
+TET_PASS_TC_NAME=True # showing name , passed TC
--- /dev/null
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE= # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
+capi-media-image-util (0.1.0-11) unstable; urgency=low
+
+ * Add const to the unmodifying input parameter
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-11
+
+ -- Seungkeun Lee <sngn.lee@samsung.com> Wed, 23 May 2012 09:13:34 +0900
+
+capi-media-image-util (0.1.0-10) unstable; urgency=low
+
+ * remove transform, add rotate/resize/crop , change name YUV420 -> YV12
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-10
+
+ -- Seungkeun Lee <sngn.lee@samsung.com> Wed, 16 May 2012 14:48:40 +0900
+
capi-media-image-util (0.1.0-9) unstable; urgency=low
* Fix dependency
* boundary check update
* Git: slp-source.sec.samsung.net:slp/api/image-util
- * Tag: capi-media-image-util_0.1.0-7
+ * Tag: capi-media-image-util_0.1.0-7
- -- Seungkeun Lee <sngn.lee@samsung.com> Tue, 31 Jan 2012 14:04:32 +0900
+ -- Seungkeun Lee <sngn.lee@samsung.com> Fri, 27 Jan 2012 14:18:01 +0900
capi-media-image-util (0.1.0-6) unstable; urgency=low
- * update image_util_decode_jpeg_from_memory impl.
- * Git: api/image-util
- * capi-media-image-util_0.1.0-6
+ * Update image_util_decode_jpeg_from_memory
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-6
- -- Seungkeun Lee <sngn.lee@samsung.com> Fri, 23 Dec 2011 17:41:46 +0900
+ -- Seungkeun Lee <sngn.lee@samsung.com> Fri, 06 Jan 2012 17:05:17 +0900
capi-media-image-util (0.1.0-5) unstable; urgency=low
- * update version
+ * Update size parameter types
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-5
+
+ -- Seungkeun Lee <sngn.lee@samsung.com> Tue, 06 Dec 2011 11:29:46 +0900
- -- Seungkeun Lee <sngn.lee@samsung.com> Thu, 15 Dec 2011 12:57:39 +0900
+capi-media-image-util (0.1.0-4) unstable; urgency=low
-capi-media-image-util (0.0.1-1) unstable; urgency=low
+ * update error none value
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-4
- * Initial release.
+ -- Seungkeun Lee <sngn.lee@samsung.com> Mon, 05 Dec 2011 11:02:41 +0900
+
+capi-media-image-util (0.1.0-3) unstable; urgency=low
+
+ * Update Log formatting
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-3
+
+ -- Seungkeun Lee <sngn.lee@samsung.com> Sun, 27 Nov 2011 14:14:10 +0900
+
+capi-media-image-util (0.1.0-2) unstable; urgency=low
+
+ * update namespace
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-2
+
+ -- Seungkeun Lee <sngn.lee@samsung.com> Wed, 23 Nov 2011 15:07:09 +0900
+
+capi-media-image-util (0.1.0-1) unstable; urgency=low
+
+ * SLP API Baseline
+ * Git: slp-source.sec.samsung.net:slp/api/image-util
+ * Tag: capi-media-image-util_0.1.0-1
- -- Seungkeun Lee <sngn.lee@samsung.com> Wed, 07 Dec 2011 12:45:39 +0900
+ -- Seungkeun Lee <sngn.lee@samsung.com> Tue, 27 Sep 2011 17:55:13 +0900
*/
typedef enum
{
- IMAGE_UTIL_COLORSPACE_YUV420, /**< YUV420 */
- IMAGE_UTIL_COLORSPACE_YUV422, /**< YUV422 */
- IMAGE_UTIL_COLORSPACE_I420, /**< I420 */
- IMAGE_UTIL_COLORSPACE_NV12, /**< NV12 */
+ IMAGE_UTIL_COLORSPACE_YV12, /**< YV12 - YCrCb planar format */
+ IMAGE_UTIL_COLORSPACE_YUV422, /**< YUV422 - planer */
+ IMAGE_UTIL_COLORSPACE_I420, /**< I420 - planer */
+ IMAGE_UTIL_COLORSPACE_NV12, /**< NV12- planer */
- IMAGE_UTIL_COLORSPACE_UYVY, /**< UYVY */
- IMAGE_UTIL_COLORSPACE_YUYV, /**< YUYV */
+ IMAGE_UTIL_COLORSPACE_UYVY, /**< UYVY - packed */
+ IMAGE_UTIL_COLORSPACE_YUYV, /**< YUYV - packed */
IMAGE_UTIL_COLORSPACE_RGB565, /**< RGB565, high-byte is Blue */
IMAGE_UTIL_COLORSPACE_RGB888, /**< RGB888, high-byte is Blue */
* @see image_util_encode_jpeg()
* @see image_util_encode_jpeg_to_memory()
* @see image_util_decode_jpeg()
- * @see image_util_decode_jpeg_to_memory()
+ * @see image_util_decode_jpeg_from_memory()
*/
int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_colorspace_cb callback, void * user_data);
*
* @remarks To get @a dest buffer size uses image_util_calculate_buffer_size()
*
- * @param[out] dest The image buffer for result. Must be allocated by you
+ * @param[in/out] dest The image buffer for result. Must be allocated by you
* @param[in] dest_colorspace The colorspace to be converted
* @param[in] src The source image buffer
* @param[in] width The width of source image
*
* @see image_util_calculate_buffer_size()
*/
-int image_util_convert_colorspace( unsigned char * dest , image_util_colorspace_e dest_colorspace , unsigned char * src , int width, int height, image_util_colorspace_e src_colorspace);
+int image_util_convert_colorspace( unsigned char * dest , image_util_colorspace_e dest_colorspace , const unsigned char * src , int width, int height, image_util_colorspace_e src_colorspace);
/**
* @brief Calculates the size of image buffer for the specified resolution and colorspace
int image_util_calculate_buffer_size(int width , int height, image_util_colorspace_e colorspace , unsigned int *size);
/**
- * @brief Transforms the image to with the specified destination width and height and angle in degrees.
+ * @brief Resize the image to with the specified destination width and height
*
- * @remarks Because image processing constraints, the destination image size can be adjusted.\n
+ * @remarks Because padding of YUV format, the destination image size can be adjusted.\n
+ *
+ * @param[in/out] dest The image buffer for result. Must be allocated by you
+ * @param[in/out] dest_width The image width to resize, and resized width
+ * @param[in/out] dest_height The image height to resize, and resized height
+ * @param[in] src The image buffer for origin image
+ * @param[in] src_width The origin image width
+ * @param[in] src_height The origin image height
+ * @param[in] colorspace The image colorspace
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IMAGE_UTIL_ERROR_NONE Successful
+ * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @see image_util_calculate_buffer_size()
+ */
+int image_util_resize(unsigned char * dest, int *dest_width , int *dest_height, const unsigned char * src, int src_width, int src_height , image_util_colorspace_e colorspace);
+
+/**
+ * @brief Rotate the image to with the specified angle in degrees.
+ *
+ * @remarks Because padding of YUV format, the destination image size can be adjusted.\n
* Rotations are supported only in these colorspaces\n
- * #IMAGE_UTIL_COLORSPACE_YUV420 \n
+ * #IMAGE_UTIL_COLORSPACE_YV12 \n
* #IMAGE_UTIL_COLORSPACE_I420 \n
* #IMAGE_UTIL_COLORSPACE_NV12 \n
* #IMAGE_UTIL_COLORSPACE_RGB888 \n
- * @param[out] dest The image buffer for result. Must be allocated by you
- * @param[in/out] dest_width The image width to resize, and changed width
- * @param[in/out] dest_height The image height to resize, and changed height
+ *
+ * @param[in/out] dest The image buffer for result. Must be allocated by you
+ * @param[out] dest_width The rotated image width
+ * @param[out] dest_height The rotated image height
* @param[in] dest_rotation The angle to rotate
* @param[in] src The image buffer for origin image
* @param[in] src_width The origin image width
+ * @param[in] src_height The origin image height
+ * @param[in] colorspace The image colorspace
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IMAGE_UTIL_ERROR_NONE Successful
+ * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @see image_util_calculate_buffer_size()
+ */
+int image_util_rotate(unsigned char * dest, int *dest_width, int *dest_height, image_util_rotation_e dest_rotation, const unsigned char * src, int src_width, int src_height, image_util_colorspace_e colorspace);
+
+/**
+ * @brief Crop the image to with the specified point and dimension
+ *
+ * @remarks Because padding of YUV format, the destination image size can be adjusted.\n
+ * Crop is supported only in these colorspaces\n
+ * #IMAGE_UTIL_COLORSPACE_YV12 \n
+ * #IMAGE_UTIL_COLORSPACE_I420 \n
+ * #IMAGE_UTIL_COLORSPACE_RGB888 \n
+ * #IMAGE_UTIL_COLORSPACE_RGB565 \n
+ * #IMAGE_UTIL_COLORSPACE_ARGB8888\n
+ * #IMAGE_UTIL_COLORSPACE_BGRA8888\n
+ * #IMAGE_UTIL_COLORSPACE_RGBA8888\n
+ * #IMAGE_UTIL_COLORSPACE_BGRX8888\n
+ *
+ * @param[in/out] dest The image buffer for result. Must be allocated by you
+ * @param[in] x The starting x-axis of crop
+ * @param[in] y The starting y-axis of crop
+ * @param[in/out] width The image width to crop, and cropped width
+ * @param[in/out] height The image height to crop, and cropped height
+ * @param[in] src The image buffer for origin image
+ * @param[in] src_width The origin image width
* @param[in] src_height The origin image height
* @param[in] colorspace The image colorspace
*
* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
*
- * @see image_util_calculated_buffer_size()
+ * @see image_util_calculate_buffer_size()
*/
-int image_util_transform( unsigned char * dest , int *dest_width , int *dest_height , image_util_rotation_e dest_rotation , unsigned char * src , int src_width, int src_height , image_util_colorspace_e colorspace);
+int image_util_crop(unsigned char * dest, int x , int y, int* width, int *height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace);
+
* @see image_util_decode_jpeg()
* @see image_util_foreach_supported_jpeg_colorspace()
*/
-int image_util_decode_jpeg_from_memory( unsigned char * jpeg_buffer , int jpeg_size , image_util_colorspace_e colorspace, unsigned char ** image_buffer , int *width , int *height , unsigned int *size);
+int image_util_decode_jpeg_from_memory( const unsigned char * jpeg_buffer , int jpeg_size , image_util_colorspace_e colorspace, unsigned char ** image_buffer , int *width , int *height , unsigned int *size);
/**
* @brief Encodes image to the jpeg image
* @see image_util_foreach_supported_jpeg_colorspace()
* @see image_util_encode_jpeg_to_memory()
*/
-int image_util_encode_jpeg( unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path);
+int image_util_encode_jpeg( const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path);
/**
* @brief Encodes image to the jpeg image
* @see image_util_foreach_supported_jpeg_colorspace()
* @see image_util_encode_jpeg()
*/
-int image_util_encode_jpeg_to_memory(unsigned char *image_buffer, int width, int height, image_util_colorspace_e colorspace, int quality, unsigned char** jpeg_buffer, unsigned int *jpeg_size);
+int image_util_encode_jpeg_to_memory(const unsigned char *image_buffer, int width, int height, image_util_colorspace_e colorspace, int quality, unsigned char** jpeg_buffer, unsigned int *jpeg_size);
Name: capi-media-image-util
Summary: A Image Utility library in Tizen Native API
Version: 0.1.0
-Release: 9
-Group: TO_BE/FILLED_IN
-License: Apache-2.0
+Release: 11
+Group: TO_BE_FILLED
+License: TO_BE_FILLED
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(mm-common)
return IMAGE_UTIL_ERROR_NONE;
}
-int image_util_convert_colorspace( unsigned char * dest , image_util_colorspace_e dest_colorspace , unsigned char * src , int width, int height, image_util_colorspace_e src_colorspace){
+int image_util_convert_colorspace( unsigned char * dest , image_util_colorspace_e dest_colorspace , const unsigned char * src , int width, int height, image_util_colorspace_e src_colorspace){
int ret;
if( dest == NULL || src == NULL )
return _convert_image_util_error_code(__func__, ret);
}
-int image_util_transform( unsigned char * dest , int *dest_width , int *dest_height , image_util_rotation_e dest_rotation , unsigned char * src , int src_width, int src_height , image_util_colorspace_e colorspace){
+int image_util_resize(unsigned char * dest, int *dest_width , int *dest_height, const unsigned char * src, int src_width, int src_height , image_util_colorspace_e colorspace){
int ret;
if( dest == NULL || src == NULL )
return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
if( colorspace < 0 || colorspace >= sizeof(_convert_colorspace_tbl)/sizeof(int))
return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
- if( dest_rotation < 0 || dest_rotation > IMAGE_UTIL_ROTATION_FLIP_VERT )
- return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
if( dest_width == NULL || dest_height == NULL)
return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
- if( *dest_width <= 0 || *dest_height <= 0 )
+ if( *dest_width <= 0 || dest_height <= 0 )
return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
unsigned int dest_w, dest_h;
dest_w = *dest_width;
dest_h = *dest_height;
+ ret = mm_util_resize_image(src, src_width, src_height, _convert_colorspace_tbl[colorspace], dest,&dest_w, &dest_h);
+ if( ret == 0){
+ *dest_width = dest_w;
+ *dest_height = dest_h;
+ }
+
+ return _convert_image_util_error_code(__func__, ret);
+}
+
+int image_util_rotate(unsigned char * dest, int *dest_width, int *dest_height, image_util_rotation_e dest_rotation, const unsigned char * src, int src_width, int src_height, image_util_colorspace_e colorspace){
+ int ret;
+ if( dest == NULL || src == NULL )
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ if( colorspace < 0 || colorspace >= sizeof(_convert_colorspace_tbl)/sizeof(int))
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ if( dest_rotation < 0 || dest_rotation > IMAGE_UTIL_ROTATION_FLIP_VERT )
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ if( dest_width == NULL || dest_height == NULL)
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+
+ unsigned int dest_w, dest_h;
ret = mm_util_rotate_image(src, src_width, src_height, _convert_colorspace_tbl[colorspace], dest,&dest_w, &dest_h, dest_rotation);
if( ret == 0){
*dest_width = dest_w;
- *dest_height = dest_h;
+ *dest_height = dest_h;
}
-
-
- return _convert_image_util_error_code(__func__, ret);
+ return _convert_image_util_error_code(__func__, ret);
+}
+
+int image_util_crop(unsigned char * dest, int x , int y, int* width, int* height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace){
+ int ret;
+ if( dest == NULL || src == NULL )
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ if( colorspace < 0 || colorspace >= sizeof(_convert_colorspace_tbl)/sizeof(int))
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ if( width == NULL )
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ if( src_width <= x || src_height <= y || src_width < x+*width || src_height< y+*height)
+ return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+
+ unsigned int dest_w, dest_h;
+ dest_w = *width;
+ dest_h = *height;
+ ret = mm_util_crop_image( src, src_width, src_height, _convert_colorspace_tbl[colorspace], x, y, &dest_w, &dest_h, dest);
+ if( ret == 0){
+ *width = dest_w;
+ *height = dest_h;
+ }
+
+ return _convert_image_util_error_code(__func__, ret);
}
int image_util_decode_jpeg( const char *path , image_util_colorspace_e colorspace, unsigned char ** image_buffer , int *width , int *height , unsigned int *size){
return _convert_image_util_error_code(__func__, ret);
}
-int image_util_decode_jpeg_from_memory( unsigned char * jpeg_buffer , int jpeg_size , image_util_colorspace_e colorspace, unsigned char ** image_buffer , int *width , int *height , unsigned int *size){
+int image_util_decode_jpeg_from_memory( const unsigned char * jpeg_buffer , int jpeg_size , image_util_colorspace_e colorspace, unsigned char ** image_buffer , int *width , int *height , unsigned int *size){
int ret;
if( jpeg_buffer == NULL || image_buffer == NULL || size == NULL)
return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
return _convert_image_util_error_code(__func__, ret);
}
-int image_util_encode_jpeg( unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path){
+int image_util_encode_jpeg( const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path){
int ret;
if( path == NULL || buffer == NULL )
return _convert_image_util_error_code(__func__, IMAGE_UTIL_ERROR_INVALID_PARAMETER);
if( _convert_encode_colorspace_tbl[colorspace] == -1 )
return _convert_image_util_error_code(__func__, MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT);
- ret = mm_util_jpeg_encode_to_file((char*)path, buffer, width, height, _convert_encode_colorspace_tbl[colorspace], quality);
+ ret = mm_util_jpeg_encode_to_file(path, buffer, width, height, _convert_encode_colorspace_tbl[colorspace], quality);
return _convert_image_util_error_code(__func__, ret);
}
-int image_util_encode_jpeg_to_memory(unsigned char *image_buffer, int width, int height, image_util_colorspace_e colorspace, int quality, unsigned char** jpeg_buffer, unsigned int *jpeg_size){
+int image_util_encode_jpeg_to_memory( const unsigned char *image_buffer, int width, int height, image_util_colorspace_e colorspace, int quality, unsigned char** jpeg_buffer, unsigned int *jpeg_size){
int ret;
int isize;
if( jpeg_buffer == NULL || image_buffer == NULL || jpeg_size == NULL )
#include <stdio.h>
#include <image_util.h>
+/*
+ * Function displaying image on canva
+ */
+static void _display_buffer_as_efl_image(Evas_Object *img, unsigned char *buf, int w, int h, image_util_colorspace_e colorspace)
+{
+ unsigned int sizeBGRA8888;
+ int err;
+
+ /*
+ * Calculates the size of image buffer for the specified resolution and colorspace
+ */
+ err = image_util_calculate_buffer_size(w, h, IMAGE_UTIL_COLORSPACE_BGRA8888, &sizeBGRA8888);
+ if ( IMAGE_UTIL_ERROR_NONE != err)
+ return;
+ static unsigned char *new_buff;
+ free(new_buff);
+ new_buff = malloc(sizeBGRA8888);
+
+ /*
+ * Convert the image's colorspace
+ */
+ err = image_util_convert_colorspace(new_buff, IMAGE_UTIL_COLORSPACE_BGRA8888, buf, w, h, colorspace);
+ if ( IMAGE_UTIL_ERROR_NONE != err) {
+ free(new_buff);
+ return;
+ }
+
+ evas_object_hide(img);
+ evas_object_image_size_set(img, w, h);
+ evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
+ evas_object_image_data_copy_set(img, (void*)new_buff);
+ evas_object_image_reload(img);
+
+ evas_object_image_data_update_add(img,0,0, w, h);
+ evas_object_show(img);
+}
+
struct raw_image{
unsigned char *buffer;
int size;
Evas_Object* img;
char *colorspace_str_tbl[] = {
- "IMAGE_UTIL_COLORSPACE_YUV420", /**< YUV420 */
+ "IMAGE_UTIL_COLORSPACE_YV12", /**< YV12 */
"IMAGE_UTIL_COLORSPACE_YUV422", /**< YUV422 */
"IMAGE_UTIL_COLORSPACE_I420", /**< I420 */
"IMAGE_UTIL_COLORSPACE_NV12", /**< NV12 */
printf("image (%dx%d) - %dbyte , ret = %d(%x)\n", w,h, size, ret, ret);
if( ret != 0 )
return true;
-
-
- evas_object_image_size_set(img, w, h);
- unsigned char *bgra8888_image = evas_object_image_data_get(img, true);
- ret = image_util_convert_colorspace(bgra8888_image , IMAGE_UTIL_COLORSPACE_BGRA8888, buffer , w, h, colorspace );
- printf("convert %d\n", ret);
- free(buffer);
-
- evas_object_image_data_set(img, bgra8888_image);
-
- evas_object_hide(img);
- evas_object_resize(img, w,h);
- evas_object_image_fill_set(img, 0, 0, w, h);
- evas_object_image_data_update_add(img,0,0, w, h);
- evas_object_show(img);
-
-
- sleep(1);
-
+ _display_buffer_as_efl_image( img, buffer, w, h, colorspace);
+ sleep(2);
return true;
}
char filename[255];
printf("jpeg encode from [%s]\n", colorspace_str_tbl[colorspace] );
-
image_util_calculate_buffer_size(img_data->w,img_data->h, colorspace, &size);
buffer = malloc(size);
int j;
int ret;
- for( i = IMAGE_UTIL_COLORSPACE_YUV420 ; i <= IMAGE_UTIL_COLORSPACE_BGRX8888 ; i++ ){
+ for( i = IMAGE_UTIL_COLORSPACE_YV12 ; i <= IMAGE_UTIL_COLORSPACE_BGRX8888 ; i++ ){
unsigned char *buffer;
unsigned int size;
ret = image_util_convert_colorspace(buffer, i , origin_buffer, w, h, IMAGE_UTIL_COLORSPACE_BGRA8888);
printf("[%d] convert %s -> %s\n", ret , colorspace_str_tbl[IMAGE_UTIL_COLORSPACE_BGRA8888], colorspace_str_tbl[i]);
- for( j = IMAGE_UTIL_COLORSPACE_YUV420 ; j <= IMAGE_UTIL_COLORSPACE_BGRX8888 ; j++){
+ for( j = IMAGE_UTIL_COLORSPACE_YV12 ; j <= IMAGE_UTIL_COLORSPACE_BGRX8888 ; j++){
if( i == j )
continue;
unsigned char *buffer2;
}
-
-void transform_test( const char *path ){
+void rotate_test( const char *path ){
printf("****************\n");
- printf("transform_test TEST - start\n");
+ printf("rotate_test TEST - start\n");
printf("****************\n");
-
-
- int w,h;
- evas_object_image_file_set(img, path, NULL);
- unsigned char* origin_buffer = evas_object_image_data_get(img, false);
- evas_object_image_size_get(img, &w, &h);
- evas_object_resize(img, w,h);
-
+ int w,h,dw,dh;
int ret;
-
-
- unsigned char *buffer;
+ unsigned char *origin_buffer;
unsigned int size;
- int dw, dh;
-
- dh = 800;
- dw = 200;
-
- image_util_calculate_buffer_size(dw, dh, IMAGE_UTIL_COLORSPACE_BGRA8888 , &size);
- buffer = malloc(size);
-
- printf("%d, %d\n", dw, dh);
- ret = image_util_transform(buffer , &dw, &dh , IMAGE_UTIL_ROTATION_NONE , origin_buffer, w, h, IMAGE_UTIL_COLORSPACE_BGRA8888);
- printf("[%d] image_util_transform\n", ret);
-
- printf("%d, %d\n", dw, dh);
-
- evas_object_hide(img);
- evas_object_resize(img, dw,dh);
- evas_object_image_size_set(img, dw, dh);
- evas_object_image_data_set(img, buffer);
+ int i;
- evas_object_image_fill_set(img, 0, 0, dw, dh);
- evas_object_image_data_update_add(img,0,0, dw, dh);
- evas_object_show(img);
+ w = h = 0;
+ ret = image_util_decode_jpeg( path ,IMAGE_UTIL_COLORSPACE_RGB888, &origin_buffer, &w, &h , &size );
+ printf("image (%dx%d) - %dbyte , ret = %d(%x)\n", w,h, size, ret, ret);
+
+ _display_buffer_as_efl_image(img, origin_buffer, w,h, IMAGE_UTIL_COLORSPACE_RGB888);
+ sleep(2);
+
+ unsigned char *dest_buffer = NULL;
+ unsigned int nsize;
+ dw = h;
+ dh = w;
+ image_util_calculate_buffer_size( dw,dh, IMAGE_UTIL_COLORSPACE_RGB888 , &nsize);
+ dest_buffer = malloc(nsize);
+
+ for( i = 0 ; i < 10 ; i ++ ){
+ ret = image_util_rotate(dest_buffer, &dw,&dh, IMAGE_UTIL_ROTATION_90, origin_buffer, w,h, IMAGE_UTIL_COLORSPACE_RGB888);
+ printf("image_util_rotate ret = %d\n", ret);
+ printf("%x%x%x\n", dest_buffer[0], dest_buffer[20], dest_buffer[44]);
+ _display_buffer_as_efl_image(img, dest_buffer, dw,dh, IMAGE_UTIL_COLORSPACE_RGB888);
+ sleep(2);
+ int tw, th;
+ unsigned char *tmp_buffer;
+ tmp_buffer = dest_buffer;
+ dest_buffer = origin_buffer;
+ origin_buffer = tmp_buffer;
+ tw = dw;
+ th = dh;
+ dw = w;
+ dh = h;
+ w = tw;
+ h = th;
+ }
printf("****************\n");
printf("transform_test TEST - end\n");
}
void* test_main(void *arg){
- //jpeg_decode_test("sample.jpg");
+ jpeg_decode_test("sample.jpg");
//jpeg_encode_test("sample.jpg");
//colorspace_convert_test("sample.jpg");
- transform_test("sample.jpg");
+ rotate_test("sample.jpg");
return NULL;