extern "C" {
#endif
-#include <stdbool.h>
#include "mm_util_type.h"
typedef void *mm_util_anim_enc_h;
g_queue_push_tail(g_queue_images, image);
}
-static gboolean __decode_files_in_queue()
+static bool __decode_files_in_queue()
{
if (g_queue_images)
g_queue_free_full(g_queue_images, mm_image_destroy_image);
if (g_queue_images->length == 0) {
g_print("\t[ANIM_testsuite] no test image\n");
- return FALSE;
+ return false;
}
g_print("[ANIM_testsuite] %u images have been decoded.\n", g_queue_images->length);
- return TRUE;
+ return true;
}
static int __sort_compare(gconstpointer a, gconstpointer b, gpointer user_data)
return g_ascii_strcasecmp(_a, _b);
}
-static gboolean __set_input_dir(const char *path)
+static bool __set_input_dir(const char *path)
{
GDir *dir = NULL;
const gchar *filename = NULL;
if (!dir) {
g_print("\t[ANIM_testsuite] invalid directory: %s (%s)\n", path, g_error ? g_error->message : "none");
g_error_free(g_error);
- return FALSE;
+ return false;
}
if (g_queue_files)
if (g_queue_files->length == 0) {
g_print("\t[ANIM_testsuite] no test file in directory!\n");
- return FALSE;
+ return false;
}
/* decode files of dir */
if (!__decode_files_in_queue()) {
g_print("\t[ANIM_testsuite] fail to decode images!\n");
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void __print_help(const char *argv0)
fprintf(stderr, "\t\t2. support jpeg/png/gif/bmp/webp files to animation webp\n");
}
-static gboolean __get_arguments(int argc, char *argv[])
+static bool __get_arguments(int argc, char *argv[])
{
g_path = g_strdup(argv[1]);
if (!MMUTIL_STRING_VALID(g_path)) {
fprintf(stderr, "\t[ANIM_testsuite] invalid path %s\n", argv[1]);
- return FALSE;
+ return false;
}
if (!__set_input_dir(g_path)) {
fprintf(stderr, "\t[ANIM_testsuite] __set_input_dir failed\n");
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void __add_image(gpointer data, gpointer user_data)
goto ERROR;
}
- ret = mm_util_anim_enc_set_lossless(anim_enc, TRUE);
+ ret = mm_util_anim_enc_set_lossless(anim_enc, true);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[ANIM_testsuite] mm_util_anim_enc_set_lossless failed : %d\n", ret);
if (ret != MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT)
return ret;
}
-static gboolean __test_encode_to_file(mm_util_img_codec_type type, const char *path)
+static bool __test_encode_to_file(mm_util_img_codec_type type, const char *path)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_anim_enc_h anim_enc = NULL;
ret = __anim_encode_setup(type, &anim_enc);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[ANIM_testsuite] __anim_enc_setup failed : %d\n", ret);
- return FALSE;
+ return false;
}
g_queue_foreach(g_queue_images, __add_image, anim_enc);
return (ret == MM_UTIL_ERROR_NONE);
}
-static gboolean __test_encode_to_buffer(mm_util_img_codec_type type, const char *path)
+static bool __test_encode_to_buffer(mm_util_img_codec_type type, const char *path)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_anim_enc_h anim_enc = NULL;
ret = __anim_encode_setup(type, &anim_enc);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[ANIM_testsuite] __anim_enc_setup failed : %d\n", ret);
- return FALSE;
+ return false;
}
g_queue_foreach(g_queue_images, __add_image, anim_enc);
return 0;
}
-
#ifndef __MM_UTIL_IMAGE_H__
#define __MM_UTIL_IMAGE_H__
-#include <glib.h>
#include <stdint.h>
#include "mm_util_type.h"
#define TEMP_DATA_SIZE SIZE_MAX //To be removed
-gboolean mm_image_is_valid_image(mm_util_image_h image);
+bool mm_image_is_valid_image(mm_util_image_h image);
void mm_image_debug_image(mm_util_image_h image, const char *message);
int mm_image_create_image(unsigned int width, unsigned int height,
#ifndef __MM_UTIL_PRIVATE_H__
#define __MM_UTIL_PRIVATE_H__
-#include <glib.h>
-#include <stdbool.h>
#include <stdio.h>
-#include <stdlib.h>
+#include <glib.h>
#include "mm_util_type.h"
#include "mm_util_debug.h"
#include "mm_util_image.h"
#define MMUTIL_SAFE_STRCPY(dst, src, n) g_strlcpy(dst, src, n)
#define MMUTIL_STRING_VALID(str) (str != NULL && strlen(str) > 0)
-#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
-
/* for alignment */
#define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1)
#define MM_UTIL_ROUND_UP_4(num) (((num)+3)&~3)
bool lossless;
} mm_util_enc_opt_t;
-gboolean mm_util_is_valid_color_format(mm_util_color_format_e color);
+bool mm_util_is_valid_color_format(mm_util_color_format_e color);
// for using fp like jpeg
int mm_util_safe_fopen(const char *path, const char *mode, FILE **fp);
int mm_util_ini_get_int(const char *category, const char *item, int default_value);
// for testsuites
-gboolean mm_util_safe_str_to_uint(const char *str, unsigned int *number);
-gboolean mm_util_safe_str_to_valid_uint(const char *str, unsigned int min, unsigned int max, unsigned int *value);
+bool mm_util_safe_str_to_uint(const char *str, unsigned int *number);
+bool mm_util_safe_str_to_valid_uint(const char *str, unsigned int min, unsigned int max, unsigned int *value);
#ifdef __cplusplus
}
#include "mm_util_private.h"
-gboolean mm_image_is_valid_image(mm_util_image_h image)
+bool mm_image_is_valid_image(mm_util_image_h image)
{
mm_image_info_s *_image = (mm_image_info_s *)image;
- mm_util_retvm_if(image == NULL, FALSE, "Invalid image");
- mm_util_retvm_if(_image->width == 0, FALSE, "Invalid width");
- mm_util_retvm_if(_image->height == 0, FALSE, "Invalid height");
- mm_util_retvm_if(!IS_VALID_COLOR(_image->color), FALSE, "Invalid color [%d]", _image->color);
- mm_util_retvm_if((_image->data == NULL) || (_image->size == 0), FALSE, "Invalid data [%zu, %p]", _image->size, _image->data);
+ mm_util_retvm_if(image == NULL, false, "Invalid image");
+ mm_util_retvm_if(_image->width == 0, false, "Invalid width");
+ mm_util_retvm_if(_image->height == 0, false, "Invalid height");
+ mm_util_retvm_if(!IS_VALID_COLOR(_image->color), false, "Invalid color [%d]", _image->color);
+ mm_util_retvm_if((_image->data == NULL) || (_image->size == 0), false, "Invalid data [%zu, %p]", _image->size, _image->data);
- return TRUE;
+ return true;
}
void mm_image_debug_image(mm_util_image_h image, const char *message)
#define IMAGE_UTIL_INI_PATH SYSCONFDIR"/multimedia/mmfw_image_util.ini"
-gboolean mm_util_is_valid_color_format(mm_util_color_format_e color)
+bool mm_util_is_valid_color_format(mm_util_color_format_e color)
{
if ((color < MM_UTIL_COLOR_YUV420) || (color >= MM_UTIL_COLOR_NUM)) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
int mm_util_safe_fopen(const char *path, const char *mode, FILE **fp)
return val;
}
-gboolean mm_util_safe_str_to_uint(const char *str, unsigned int *number)
+bool mm_util_safe_str_to_uint(const char *str, unsigned int *number)
{
gint64 temp = 0;
if (!str || strlen(str) == 0)
- return FALSE;
+ return false;
temp = g_ascii_strtoll(str, NULL, 10);
if (errno != 0) {
mm_util_stderror("g_ascii_strtoll");
- return FALSE;
+ return false;
}
if (temp < 0 || temp > UINT_MAX)
- return FALSE;
+ return false;
*number = (unsigned int)temp;
- return TRUE;
+ return true;
}
-gboolean mm_util_safe_str_to_valid_uint(const char *str, unsigned int min, unsigned int max, unsigned int *value)
+bool mm_util_safe_str_to_valid_uint(const char *str, unsigned int min, unsigned int max, unsigned int *value)
{
unsigned int converted = 0;
- gboolean is_num = mm_util_safe_str_to_uint(str, &converted);
+ bool is_num = mm_util_safe_str_to_uint(str, &converted);
if (!is_num || converted < min || converted > max)
- return FALSE;
+ return false;
*value = converted;
- return TRUE;
+ return true;
}
return MM_UTIL_ERROR_NONE;
}
-static gboolean __gif_is_good_frame(GifFileType *gif_image)
+static bool __gif_is_good_frame(GifFileType *gif_image)
{
mm_util_debug("Frame pos: %d, %d size: %dx%d", gif_image->Image.Left, gif_image->Image.Top, gif_image->Image.Width, gif_image->Image.Height);
if (gif_image->Image.Top < 0 || gif_image->Image.Left < 0 || gif_image->Image.Width <= 0 || gif_image->Image.Height <= 0) {
mm_util_error("Frame has wrong dimensions");
- return FALSE;
+ return false;
}
if (gif_image->Image.Left + gif_image->Image.Width > gif_image->SWidth || gif_image->Image.Top + gif_image->Image.Height > gif_image->SHeight) {
mm_util_debug("Frame is not full screen frame");
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static int __gif_fill_frame_buffer(GifFileType *gif_image, GifRowType *frame_buffer)
GifRecordType record_type = UNDEFINED_RECORD_TYPE;
GifRowType *frame_buffer = NULL;
GifFileType *GifFile;
- gboolean is_found = FALSE;
+ bool is_found = false;
ColorMapObject *ColorMap = NULL;
gif_io_buf_s io_buf = { memory, src_size, 0 };
void *image_buffer = NULL;
goto error;
}
- is_found = TRUE;
+ is_found = true;
ret = __gif_fill_frame_buffer(GifFile, frame_buffer);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_make_color_map failed");
if (EGifPutImageDesc(gif_file->GifFile, 0, 0, gif_image->width, gif_image->height,
- FALSE, color_map) == GIF_ERROR) {
+ false, color_map) == GIF_ERROR) {
mm_util_error("EGifPutImageDesc failed due to %s", GifErrorString(gif_file->GifFile->Error));
COLORMAP_FREE(color_map);
g_free(intermediate_image);
/* use fixed graphics control */
graphic_control_block.DisposalMode = DISPOSAL_UNSPECIFIED;
- graphic_control_block.UserInputFlag = FALSE;
+ graphic_control_block.UserInputFlag = false;
graphic_control_block.TransparentColor = NO_TRANSPARENT_COLOR;
graphic_control_block.DelayTime = delay_time;
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_encode_open_mem failed");
/* To initialize data after GifFile opened */
- EGifSetGifVersion(gif_file->GifFile, TRUE);
+ EGifSetGifVersion(gif_file->GifFile, true);
/* Write screen description */
if (EGifPutScreenDesc(gif_file->GifFile, width, height, 8 /* color_res */, 0 /* background_color */, NULL) == GIF_ERROR) {
fprintf(stderr, "\t\t4. mode : 0 - auto, 1 - decode from file, 2 - decode from memory, 3 - encode to file, 4 - encode to memory\n");
}
-gboolean _get_arguments(int argc, char *argv[])
+bool _get_arguments(int argc, char *argv[])
{
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[1], TEST_AUTO, TEST_NUM - 1, &g_test_mode)) {
+ if (!mm_util_safe_str_to_valid_uint(argv[1], TEST_AUTO, TEST_NUM - 1, &g_test_mode)) {
fprintf(stderr, "\t[GIF_testsuite] wrong mode(%s) for test\n", argv[1]);
_print_help(argv[0]);
- return FALSE;
+ return false;
}
g_path = g_strdup(argv[2]);
if (argc < 4) {
fprintf(stderr, "\t[GIF_testsuite] not enough args\n");
_print_help(argv[0]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[3], &g_width)) {
+ if (!mm_util_safe_str_to_uint(argv[3], &g_width)) {
fprintf(stderr, "\t[GIF_testsuite] wrong width %s\n", argv[3]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[4], &g_height)) {
+ if (!mm_util_safe_str_to_uint(argv[4], &g_height)) {
fprintf(stderr, "\t[GIF_testsuite] wrong height %s\n", argv[4]);
- return FALSE;
+ return false;
}
} else {
fprintf(stderr, "\t[GIF_testsuite] wrong mode for test %s\n", argv[1]);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-gboolean _test_decode(const mm_util_test_mode_e mode)
+bool _test_decode(const mm_util_test_mode_e mode)
{
int ret = 0;
unsigned char *data = NULL;
ret = mm_util_decode_from_gif_file(g_path, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_decode_from_gif_file failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_get_image(g_decoded_data, &g_width, &g_height, NULL, &data, &size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_image_get_image failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(DECODE_FILE_PATH, data, size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_file_write failed %d\n", ret);
MMUTIL_SAFE_FREE(data);
- return FALSE;
+ return false;
}
MMUTIL_SAFE_FREE(data);
} else if (mode == TEST_DECODE_BUFFER) {
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_file_read failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_decode_from_gif_memory(g_read_data, g_read_size, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_decode_from_gif_memory failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_get_image(g_decoded_data, &g_width, &g_height, NULL, &data, &size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_image_get_image failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(DECODE_MEM_PATH, data, size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_file_write failed %d\n", ret);
MMUTIL_SAFE_FREE(data);
- return FALSE;
+ return false;
}
MMUTIL_SAFE_FREE(data);
}
- return TRUE;
+ return true;
}
-gboolean _test_encode(const mm_util_test_mode_e mode)
+bool _test_encode(const mm_util_test_mode_e mode)
{
int ret = 0;
/* for encoding gif to memory */
size_t encoded_size = 0;
if ((mode != TEST_ENCODE_FILE) && (mode != TEST_ENCODE_BUFFER))
- return TRUE;
+ return true;
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_file_read failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_create_image(g_width, g_height, MM_UTIL_COLOR_RGBA, (unsigned char *)g_read_data, g_read_size, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_image_create_image failed : %d\n", ret);
- return FALSE;
+ return false;
}
/* test encoding gif */
ret = mm_util_encode_to_gif_file(&g_decoded_data, 1, ENCODE_FILE_PATH);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_encode_gif_to_file failed : %d\n", ret);
- return FALSE;
+ return false;
}
} else if (mode == TEST_ENCODE_BUFFER) {
ret = mm_util_encode_to_gif_memory(&g_decoded_data, 1, &encoded_data, &encoded_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_encode_gif_to_memory failed : %d\n", ret);
MMUTIL_SAFE_FREE(encoded_data);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(ENCODE_MEM_PATH, encoded_data, encoded_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[GIF_testsuite] mm_util_file_write failed %d\n", ret);
MMUTIL_SAFE_FREE(encoded_data);
- return FALSE;
+ return false;
}
}
MMUTIL_SAFE_FREE(encoded_data);
- return TRUE;
+ return true;
}
-gboolean _test_auto()
+bool _test_auto()
{
mm_util_test_mode_e test_mode = TEST_DECODE_FILE;
}
/* test decoding gif */
if ((test_mode == TEST_DECODE_FILE) || (test_mode == TEST_DECODE_BUFFER)) {
- if (FALSE == _test_decode(test_mode)) {
+ if (!_test_decode(test_mode)) {
fprintf(stderr, "\t[GIF_testsuite] >>>>>>>>>>>>>>>>>>>>>> \'%s\' TEST FAIL\n", MODE_TO_STR[test_mode]);
- return FALSE;
+ return false;
}
}
/* test encoding gif */
if ((test_mode == TEST_ENCODE_FILE) || (test_mode == TEST_ENCODE_BUFFER)) {
- if (FALSE == _test_encode(test_mode)) {
+ if (!_test_encode(test_mode)) {
fprintf(stderr, "\t[GIF_testsuite] >>>>>>>>>>>>>>>>>>>>>> \'%s\' TEST FAIL\n", MODE_TO_STR[test_mode]);
- return FALSE;
+ return false;
}
}
test_mode++;
}
- return TRUE;
+ return true;
}
int main(int argc, char *argv[])
return 0;
}
- if (FALSE == _get_arguments(argc, argv)) {
+ if (!_get_arguments(argc, argv)) {
fprintf(stderr, "\t[GIF_testsuite] _get_arguments failed\n");
goto out;
}
/* test all functions automatically */
if (g_test_mode == TEST_AUTO) {
- if (FALSE == _test_auto())
+ if (!_test_auto())
fprintf(stderr, "\t[GIF_testsuite] _test_auto failed\n");
goto out;
}
/* test decoding gif */
if ((g_test_mode == TEST_DECODE_FILE) || (g_test_mode == TEST_DECODE_BUFFER)) {
- if (FALSE == _test_decode(g_test_mode)) {
+ if (!_test_decode(g_test_mode)) {
fprintf(stderr, "\t[GIF_testsuite] _test_decode(%s) failed\n", MODE_TO_STR[g_test_mode]);
goto out;
}
/* test encoding gif */
if ((g_test_mode == TEST_ENCODE_FILE) || (g_test_mode == TEST_ENCODE_BUFFER)) {
- if (FALSE == _test_encode(g_test_mode)) {
+ if (!_test_encode(g_test_mode)) {
fprintf(stderr, "\t[GIF_testsuite] _test_encode(%s) failed\n", MODE_TO_STR[g_test_mode]);
goto out;
}
fileSize = (size_t)size;
}
-gboolean FileInterface::ReadData()
+bool FileInterface::ReadData()
{
if (!fp || fileSize == 0)
- return FALSE;
+ return false;
readData = (unsigned char *)calloc(1, fileSize);
if (fread(readData, 1, fileSize, fp) != fileSize) {
- return FALSE;
+ return false;
}
readDataSize = fileSize;
- return TRUE;
+ return true;
}
#include <stdio.h>
#include <stdlib.h>
-#include <glib.h>
class FileInterface {
private:
FileInterface(const char *path);
~FileInterface(void);
- gboolean ReadData();
+ bool ReadData();
};
#endif /*__FILE_INTERFACE_H__*/
TEST(libmm_gif_Test, mm_util_decode_from_gif_memory_p)
{
int ret = MM_UTIL_ERROR_NONE;
- gboolean err = TRUE;
+ bool err = true;
mm_util_image_h decode_image = NULL;
FileInterface IFile = FileInterface(DECODE_FILE_PATH);
TEST(libmm_gif_Test, mm_util_decode_from_gif_memory_n)
{
int ret = MM_UTIL_ERROR_NONE;
- gboolean err = TRUE;
+ bool err = true;
mm_util_image_h decode_image = NULL;
FileInterface IFile = FileInterface(DECODE_FILE_PATH);
return RUN_ALL_TESTS();
}
-
g_print("\t\t\t e.g. %s 1 test.heif 7\n", argv0);
}
-static gboolean __get_arguments(int argc, char *argv[])
+static bool __get_arguments(int argc, char *argv[])
{
if (!mm_util_safe_str_to_valid_uint(argv[1], TEST_AUTO, TEST_NUM - 1, &g_test_mode)) {
g_print("\t[HEIF_testsuite] wrong mode(%s) for test\n", argv[1]);
__print_help(argv[0]);
- return FALSE;
+ return false;
}
g_path = g_strdup(argv[2]);
g_print("\t[HEIF_testsuite] color is default(%d)\n", g_color);
} else {
g_print("\t[HEIF_testsuite] wrong mode for test %s\n", argv[1]);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-static gboolean __test_decode(const mm_util_test_mode_e mode, mm_util_color_format_e color, const char *path)
+static bool __test_decode(const mm_util_test_mode_e mode, mm_util_color_format_e color, const char *path)
{
int ret = 0;
if (!path) {
g_print("\t[HEIF_testsuite] No-Error\n");
- return TRUE;
+ return true;
}
/* test decoding heif */
ret = mm_util_decode_heif_from_file(g_path, color, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[HEIF_testsuite] mm_util_decode_heif_from_file failed %d\n", ret);
- return FALSE;
+ return false;
}
} else if (mode == TEST_DECODE_BUFFER) {
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[HEIF_testsuite] mm_util_file_read failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_decode_heif_from_buffer(g_read_data, g_read_size, color, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[HEIF_testsuite] mm_util_decode_heif_from_buffer failed %d\n", ret);
- return FALSE;
+ return false;
}
}
ret = mm_util_jpeg_encode_to_file(g_decoded_data, 100, path);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[HEIF_testsuite] mm_util_jpeg_encode_to_file failed %d : %s\n", ret, path);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-static gboolean __test_auto()
+static bool __test_auto()
{
mm_util_test_mode_e test_mode = TEST_DECODE_FILE;
mm_util_color_format_e color = MM_UTIL_COLOR_YUV420;
- gboolean result = FALSE;
+ bool result = false;
while (test_mode <= TEST_DECODE_BUFFER) {
g_print("\t[HEIF_testsuite] >>>>>>>>>>>>>>>>>>>>>> \'%s\' TEST START\n", MODE_TO_STR[test_mode]);
test_mode++;
}
- return TRUE;
+ return true;
}
int main(int argc, char *argv[])
return RUN_ALL_TESTS();
}
-
#define ROUND_UP_X(v, x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
#define DIV_ROUND_UP_X(v, x) (((v) + GEN_MASK(x)) >> (x))
-typedef gboolean(*IMGPInfoFunc) (imgp_info_s *, const unsigned char *, unsigned char **, imgp_type_e);
+typedef bool(*IMGPInfoFunc) (imgp_info_s *, const unsigned char *, unsigned char **, imgp_type_e);
static int __check_valid_picture_size(unsigned int width, unsigned int height)
{
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
-static gboolean __mm_gst_can_resize_format(mm_util_color_format_e color_format)
+static bool __mm_gst_can_resize_format(mm_util_color_format_e color_format)
{
- gboolean _bool = FALSE;
+ bool _bool = false;
mm_util_debug("color_format [%d]", color_format);
case MM_UTIL_COLOR_BGRA:
case MM_UTIL_COLOR_RGBA:
case MM_UTIL_COLOR_BGRX:
- _bool = TRUE;
+ _bool = true;
break;
default:
mm_util_error("Not supported format"); //only not support NV12
return _bool;
}
-static gboolean __mm_gst_can_rotate_format(mm_util_color_format_e color_format)
+static bool __mm_gst_can_rotate_format(mm_util_color_format_e color_format)
{
- gboolean _bool = FALSE;
+ bool _bool = false;
mm_util_debug("color_format [%d]", color_format);
case MM_UTIL_COLOR_ARGB:
case MM_UTIL_COLOR_BGRA:
case MM_UTIL_COLOR_RGBA:
- _bool = TRUE;
+ _bool = true;
break;
default:
mm_util_error("Not supported format");
mm_util_fenter();
mm_util_retvm_if(imgsize == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid imgsize");
- mm_util_retvm_if(IS_VALID_COLOR(format) == FALSE, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid format(%u)", format);
+ mm_util_retvm_if(IS_VALID_COLOR(format) == false, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid format(%u)", format);
mm_util_retvm_if(__check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width(%u) or height(%u)", width, height);
switch (format) {
static bool __mm_util_check_format(mm_util_color_format_e color_format)
{
if ((color_format >= MM_UTIL_COLOR_YUV420) && (color_format <= MM_UTIL_COLOR_BGRX))
- return TRUE;
+ return true;
- return FALSE;
+ return false;
}
int mm_util_convert_colorspace(mm_util_image_h src, mm_util_color_format_e color, mm_util_image_h *dst)
goto ERROR;
}
- if (__mm_gst_can_resize_format(_imgp_info_s->src_format) == FALSE) {
+ if (__mm_gst_can_resize_format(_imgp_info_s->src_format) == false) {
mm_util_error("Not supported format");
ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
goto ERROR;
goto ERROR;
}
- if (__mm_gst_can_rotate_format(_imgp_info_s->src_format) == FALSE) {
+ if (__mm_gst_can_rotate_format(_imgp_info_s->src_format) == false) {
mm_util_error("Not supported format");
ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
goto ERROR;
fprintf(stderr, "\t\t9. ex: %s test.rgb crop 1920 1080 7 100 100 640 480 \n", argv0);
}
-gboolean _get_arguments(int argc, char *argv[])
+bool _get_arguments(int argc, char *argv[])
{
unsigned int index = 1;
g_args.path = g_strdup(argv[index++]);
g_args.cmd = g_strdup(argv[index++]);
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.width)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.width)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong src_width %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.height)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.height)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong src_height %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[index++], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_args.colorspace)) {
+ if (!mm_util_safe_str_to_valid_uint(argv[index++], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_args.colorspace)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong src_format %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
if (strcmp(g_args.cmd, "convert") == 0) {
if (argc < 7) {
_print_help(argv[0]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[index++], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_args.cs)) {
+ if (!mm_util_safe_str_to_valid_uint(argv[index++], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_args.cs)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong dst_format %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
} else if (strcmp(g_args.cmd, "resize") == 0) {
if (argc < 8) {
_print_help(argv[0]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.w)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.w)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong dst_width %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.h)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.h)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong dst_height %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
} else if (strcmp(g_args.cmd, "rotate") == 0) {
if (argc < 7) {
_print_help(argv[0]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[index++], MM_UTIL_ROTATE_0, MM_UTIL_ROTATE_NUM - 1, &g_args.rot)) {
+ if (!mm_util_safe_str_to_valid_uint(argv[index++], MM_UTIL_ROTATE_0, MM_UTIL_ROTATE_NUM - 1, &g_args.rot)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong rotation %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
} else if (strcmp(g_args.cmd, "crop") == 0) {
if (argc < 10) {
_print_help(argv[0]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.x)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.x)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong start_x %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.y)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.y)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong start_y %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.w)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.w)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong dst_width %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[index++], &g_args.h)) {
+ if (!mm_util_safe_str_to_uint(argv[index++], &g_args.h)) {
fprintf(stderr, "\t[IMGP_testsuite] wrong dst_height %s\n", argv[index-1]);
- return FALSE;
+ return false;
}
}
fprintf(stderr, "\t[IMGP_testsuite] cmd: %s, w: %u, h: %u, cs:%u, rot:%u, x: %u, y: %u\n",
g_args.cmd, g_args.w, g_args.h, g_args.cs, g_args.rot, g_args.x, g_args.y);
- return TRUE;
+ return true;
}
int main(int argc, char *argv[])
memset(&g_transformed, 0, sizeof(g_transformed));
/* get arguments */
- if (FALSE == _get_arguments(argc, argv)) {
+ if (!_get_arguments(argc, argv)) {
fprintf(stderr, "\t[IMGP_testsuite] _get_arguments failed\n");
goto TEST_FAIL;
}
return 0;
}
-
return RUN_ALL_TESTS();
}
-
longjmp(myerr->setjmp_buffer, 1); /* Return control to the setjmp point */
}
-static gboolean __is_supported_color_format_with_libjpeg(mm_util_color_format_e color_format)
+static bool __is_supported_color_format_with_libjpeg(mm_util_color_format_e color_format)
{
- gboolean _bool = FALSE;
+ bool _bool = false;
if (color_format == MM_UTIL_COLOR_RGB24 ||
color_format == MM_UTIL_COLOR_RGBA ||
color_format == MM_UTIL_COLOR_YUV422 ||
color_format == MM_UTIL_COLOR_UYVY ||
color_format == MM_UTIL_COLOR_GRAYSCALE) {
- _bool = TRUE;
+ _bool = true;
}
if (!_bool)
return _bool;
}
-static gboolean __mm_util_is_supported_color_format(mm_util_color_format_e color_format)
+static bool __mm_util_is_supported_color_format(mm_util_color_format_e color_format)
{
- gboolean _bool = FALSE;
+ bool _bool = false;
if (__is_supported_color_format_with_libjpeg(color_format) ||
color_format == MM_UTIL_COLOR_NV12) {
- _bool = TRUE;
+ _bool = true;
}
if (!_bool)
if (dinfo->image_width > ENC_MAX_LEN || dinfo->image_height > ENC_MAX_LEN) {
dinfo->scale_num = 1;
dinfo->scale_denom = 8;
- dinfo->do_fancy_upsampling = FALSE;
- dinfo->do_block_smoothing = FALSE;
+ dinfo->do_fancy_upsampling = false;
+ dinfo->do_block_smoothing = false;
dinfo->dither_mode = JDITHER_ORDERED;
} else if (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) {
dinfo->scale_num = 1;
dinfo->scale_denom = (unsigned int)downscale;
- dinfo->do_fancy_upsampling = FALSE;
- dinfo->do_block_smoothing = FALSE;
+ dinfo->do_fancy_upsampling = false;
+ dinfo->do_block_smoothing = false;
dinfo->dither_mode = JDITHER_ORDERED;
}
jpeg_set_defaults(&cinfo);
mm_util_debug("jpeg_set_defaults");
- cinfo.raw_data_in = TRUE; /* Supply downsampled data */
- cinfo.do_fancy_downsampling = FALSE;
+ cinfo.raw_data_in = true; /* Supply downsampled data */
+ cinfo.do_fancy_downsampling = false;
cinfo.comp_info[0].h_samp_factor = 2;
if (_decoded->color == MM_UTIL_COLOR_YUV420)
cinfo.comp_info[2].h_samp_factor = 1;
cinfo.comp_info[2].v_samp_factor = 1;
- jpeg_set_quality(&cinfo, quality, TRUE);
+ jpeg_set_quality(&cinfo, quality, true);
mm_util_debug("jpeg_set_quality");
cinfo.dct_method = JDCT_FASTEST;
- jpeg_start_compress(&cinfo, TRUE);
+ jpeg_start_compress(&cinfo, true);
mm_util_debug("jpeg_start_compress");
ret = __jpeg_encode_yuv(&cinfo, _width, _height, decoded);
jpeg_set_defaults(&cinfo);
mm_util_debug("jpeg_set_defaults");
- jpeg_set_quality(&cinfo, quality, TRUE);
+ jpeg_set_quality(&cinfo, quality, true);
mm_util_debug("jpeg_set_quality");
- jpeg_start_compress(&cinfo, TRUE);
+ jpeg_start_compress(&cinfo, true);
mm_util_debug("jpeg_start_compress");
while (cinfo.next_scanline < cinfo.image_height) {
__jpeg_decode_open(&dinfo, control_format, fp, src, (unsigned long)size);
/*read file parameters with jpeg_read_header() */
- jpeg_read_header(&dinfo, TRUE);
+ jpeg_read_header(&dinfo, true);
mm_util_debug("jpeg_read_header");
/* set parameters for decompression */
mm_util_fenter();
mm_util_retvm_if(!MMUTIL_STRING_VALID(file_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid file_path");
- mm_util_retvm_if((IS_VALID_COLOR(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
+ mm_util_retvm_if((IS_VALID_COLOR(fmt) == false), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
mm_util_retvm_if((!__mm_util_is_supported_color_format(fmt)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", fmt);
mm_util_retvm_if(!decoded, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image handle");
mm_util_retvm_if(!memory, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid jpeg image");
mm_util_retvm_if(!src_size, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_size");
- mm_util_retvm_if((IS_VALID_COLOR(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
+ mm_util_retvm_if((IS_VALID_COLOR(fmt) == false), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
mm_util_retvm_if((!__mm_util_is_supported_color_format(fmt)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", fmt);
mm_util_retvm_if(!decoded, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image handle");
fprintf(stderr, "\t\t4. mode : 0 - auto, 1 - decode from file, 2 - decode from memory, 3 - encode to file, 4 - encode to memory\n");
}
-gboolean _get_arguments(int argc, char *argv[])
+bool _get_arguments(int argc, char *argv[])
{
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[1], TEST_AUTO, TEST_NUM - 1, &g_test_mode)) {
+ if (!mm_util_safe_str_to_valid_uint(argv[1], TEST_AUTO, TEST_NUM - 1, &g_test_mode)) {
fprintf(stderr, "\t[JPEG_testsuite] wrong mode(%s) for test\n", argv[1]);
_print_help(argv[0]);
- return FALSE;
+ return false;
}
g_path = g_strdup(argv[2]);
if (g_test_mode == TEST_AUTO) {
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[3], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color))
+ if (!mm_util_safe_str_to_valid_uint(argv[3], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color))
fprintf(stderr, "\t[JPEG_testsuite] color is default(%d)\n", g_color);
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[4], 1, 100, &g_quality))
+ if (!mm_util_safe_str_to_valid_uint(argv[4], 1, 100, &g_quality))
fprintf(stderr, "\t[JPEG_testsuite] quality is default(%d)\n", g_quality);
/* min: MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, max: MM_UTIL_JPEG_DECODE_DOWNSCALE_1_8 */
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[5], 1, 8, &g_downscale))
+ if (!mm_util_safe_str_to_valid_uint(argv[5], 1, 8, &g_downscale))
fprintf(stderr, "\t[JPEG_testsuite] downscale is default(%d)\n", g_downscale);
} else if (g_test_mode == TEST_DECODE_FILE) {
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[3], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color))
+ if (!mm_util_safe_str_to_valid_uint(argv[3], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color))
fprintf(stderr, "\t[JPEG_testsuite] color is default(%d)\n", g_color);
} else if (g_test_mode == TEST_DECODE_BUFFER) {
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[3], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color))
+ if (!mm_util_safe_str_to_valid_uint(argv[3], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color))
fprintf(stderr, "\t[JPEG_testsuite] color is default(%d)\n", g_color);
} else if (g_test_mode == TEST_ENCODE_FILE || g_test_mode == TEST_ENCODE_BUFFER) {
if (argc < 5) {
fprintf(stderr, "\t[JPEG_testsuite] not enough args\n");
_print_help(argv[0]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[3], &g_width)) {
+ if (!mm_util_safe_str_to_uint(argv[3], &g_width)) {
fprintf(stderr, "\t[JPEG_testsuite] wrong width %s\n", argv[3]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_uint(argv[4], &g_height)) {
+ if (!mm_util_safe_str_to_uint(argv[4], &g_height)) {
fprintf(stderr, "\t[JPEG_testsuite] wrong height %s\n", argv[4]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[5], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color)) {
+ if (!mm_util_safe_str_to_valid_uint(argv[5], MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NUM - 1, &g_color)) {
fprintf(stderr, "\t[JPEG_testsuite] wrong color %s\n", argv[5]);
- return FALSE;
+ return false;
}
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[6], 1, 100, &g_quality))
+ if (!mm_util_safe_str_to_valid_uint(argv[6], 1, 100, &g_quality))
fprintf(stderr, "\t[JPEG_testsuite] quality is default(%d)\n", g_quality);
/* min: MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, max: MM_UTIL_JPEG_DECODE_DOWNSCALE_1_8 */
- if (FALSE == mm_util_safe_str_to_valid_uint(argv[7], 1, 8, &g_downscale))
+ if (!mm_util_safe_str_to_valid_uint(argv[7], 1, 8, &g_downscale))
fprintf(stderr, "\t[JPEG_testsuite] downscale is default(%d)\n", g_downscale);
} else {
fprintf(stderr, "\t[JPEG_testsuite] wrong mode for test %s\n", argv[1]);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-gboolean _test_decode(const mm_util_test_mode_e mode)
+bool _test_decode(const mm_util_test_mode_e mode)
{
int ret = 0;
unsigned char *data = NULL;
ret = mm_util_decode_from_jpeg_file(g_path, g_color, g_downscale, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_decode_from_jpeg_file failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_get_image(g_decoded_data, &g_width, &g_height, NULL, &data, &size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_image_get_image failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(DECODE_FILE_PATH, data, size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_file_write failed %d\n", ret);
MMUTIL_SAFE_FREE(data);
- return FALSE;
+ return false;
}
MMUTIL_SAFE_FREE(data);
} else if (mode == TEST_DECODE_BUFFER) {
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_file_read failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_decode_from_jpeg_memory(g_read_data, g_read_size, g_color, g_downscale, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_decode_from_jpeg_memory failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_get_image(g_decoded_data, &g_width, &g_height, NULL, &data, &size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_image_get_image failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(DECODE_MEM_PATH, data, size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_file_write failed %d\n", ret);
MMUTIL_SAFE_FREE(data);
- return FALSE;
+ return false;
}
MMUTIL_SAFE_FREE(data);
}
- return TRUE;
+ return true;
}
-gboolean _test_encode(const mm_util_test_mode_e mode)
+bool _test_encode(const mm_util_test_mode_e mode)
{
int ret = 0;
/* for encoding jpeg to memory */
size_t encoded_size = 0;
if ((mode != TEST_ENCODE_FILE) && (mode != TEST_ENCODE_BUFFER))
- return TRUE;
+ return true;
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_file_read failed %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_create_image(g_width, g_height, g_color, (unsigned char *)g_read_data,
g_read_size, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_image_create_image failed : %d\n", ret);
- return FALSE;
+ return false;
}
/* test encoding jpeg */
ret = mm_util_jpeg_encode_to_file(g_decoded_data, (int)g_quality, ENCODE_FILE_PATH);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_jpeg_encode_to_file failed : %d\n", ret);
- return FALSE;
+ return false;
}
} else if (mode == TEST_ENCODE_BUFFER) {
ret = mm_util_encode_to_jpeg_memory(g_decoded_data, (int)g_quality, &encoded_data, &encoded_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_jpeg_encode_to_file failed : %d\n", ret);
MMUTIL_SAFE_FREE(encoded_data);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(ENCODE_MEM_PATH, encoded_data, encoded_size);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[JPEG_testsuite] mm_util_file_write failed %d\n", ret);
MMUTIL_SAFE_FREE(encoded_data);
- return FALSE;
+ return false;
}
}
MMUTIL_SAFE_FREE(encoded_data);
- return TRUE;
+ return true;
}
-gboolean _test_auto()
+bool _test_auto()
{
mm_util_test_mode_e test_mode = TEST_DECODE_FILE;
}
/* test decoding jpeg */
if ((test_mode == TEST_DECODE_FILE) || (test_mode == TEST_DECODE_BUFFER)) {
- if (FALSE == _test_decode(test_mode)) {
+ if (!_test_decode(test_mode)) {
fprintf(stderr, "\t[JPEG_testsuite] >>>>>>>>>>>>>>>>>>>>>> \'%s\' TEST FAIL\n", MODE_TO_STR[test_mode]);
- return FALSE;
+ return false;
}
}
/* test encoding jpeg */
if ((test_mode == TEST_ENCODE_FILE) || (test_mode == TEST_ENCODE_BUFFER)) {
- if (FALSE == _test_encode(test_mode)) {
+ if (!_test_encode(test_mode)) {
fprintf(stderr, "\t[JPEG_testsuite] >>>>>>>>>>>>>>>>>>>>>> \'%s\' TEST FAIL\n", MODE_TO_STR[test_mode]);
- return FALSE;
+ return false;
}
}
test_mode++;
}
- return TRUE;
+ return true;
}
int main(int argc, char *argv[])
return 0;
}
- if (FALSE == _get_arguments(argc, argv)) {
+ if (!_get_arguments(argc, argv)) {
fprintf(stderr, "\t[JPEG_testsuite] _get_arguments failed\n");
goto out;
}
/* test all functions automatically */
if (g_test_mode == TEST_AUTO) {
- if (FALSE == _test_auto())
+ if (!_test_auto())
fprintf(stderr, "\t[JPEG_testsuite] _test_auto failed\n");
goto out;
}
/* test decoding jpeg */
if ((g_test_mode == TEST_DECODE_FILE) || (g_test_mode == TEST_DECODE_BUFFER)) {
- if (FALSE == _test_decode(g_test_mode)) {
+ if (!_test_decode(g_test_mode)) {
fprintf(stderr, "\t[JPEG_testsuite] _test_decode(%s) failed\n", MODE_TO_STR[g_test_mode]);
goto out;
}
/* test encoding jpeg */
if ((g_test_mode == TEST_ENCODE_FILE) || (g_test_mode == TEST_ENCODE_BUFFER)) {
- if (FALSE == _test_encode(g_test_mode)) {
+ if (!_test_encode(g_test_mode)) {
fprintf(stderr, "\t[JPEG_testsuite] _test_encode(%s) failed\n", MODE_TO_STR[g_test_mode]);
goto out;
}
fileSize = (size_t)size;
}
-gboolean FileInterface::ReadData()
+bool FileInterface::ReadData()
{
if (!fp || fileSize == 0)
- return FALSE;
+ return false;
readData = (unsigned char *)calloc(1, fileSize);
if (fread(readData, 1, fileSize, fp) != fileSize) {
- return FALSE;
+ return false;
}
readDataSize = fileSize;
- return TRUE;
+ return true;
}
#include <stdio.h>
#include <stdlib.h>
-#include <glib.h>
class FileInterface {
private:
FileInterface(const char *path);
~FileInterface(void);
- gboolean ReadData();
+ bool ReadData();
};
#endif /*__FILE_INTERFACE_H__*/
TEST(libmm_jpeg_Test, mm_util_decode_from_jpeg_memory_p)
{
int ret = MM_UTIL_ERROR_NONE;
- gboolean err = TRUE;
+ bool err = true;
mm_util_image_h decode_image = NULL;
FileInterface IFile = FileInterface(DECODE_FILE_PATH);
TEST(libmm_jpeg_Test, mm_util_decode_from_jpeg_memory_n)
{
int ret = MM_UTIL_ERROR_NONE;
- gboolean err = TRUE;
+ bool err = true;
mm_util_image_h decode_image = NULL;
FileInterface IFile = FileInterface(DECODE_FILE_PATH);
return RUN_ALL_TESTS();
}
-
g_print("\t\t\t e.g. %s %d test.jxl 1920 1280 7\n", argv0, TEST_ENCODE_FILE);
}
-static gboolean __get_arguments(int argc, char *argv[])
+static bool __get_arguments(int argc, char *argv[])
{
unsigned int lossless = 0;
if (!mm_util_safe_str_to_valid_uint(argv[1], TEST_AUTO, TEST_NUM - 1, &g_test_mode)) {
g_print("\t[JXL_testsuite] wrong mode(%s) for test\n", argv[1]);
__print_help(argv[0]);
- return FALSE;
+ return false;
}
g_path = g_strdup(argv[2]);
if (argc < 5) {
g_print("\t[JPEG_testsuite] not enough args\n");
__print_help(argv[0]);
- return FALSE;
+ return false;
}
if (!mm_util_safe_str_to_uint(argv[3], &g_width)) {
g_print("\t[JXL_testsuite] wrong width %s\n", argv[3]);
- return FALSE;
+ return false;
}
if (!mm_util_safe_str_to_uint(argv[4], &g_height)) {
g_print("\t[JXL_testsuite] wrong height %s\n", argv[4]);
- return FALSE;
+ return false;
}
if (!mm_util_safe_str_to_valid_uint(argv[5], 0, MM_UTIL_COLOR_NUM - 1, &g_color)) {
g_print("\t[JXL_testsuite] wrong color %s\n", argv[5]);
- return FALSE;
+ return false;
}
// optional : lossless
g_lossless = (lossless == 1) ? true : false;
} else {
g_print("\t[JXL_testsuite] wrong mode for test %s\n", argv[1]);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-static gboolean __get_decoded_data(void)
+static bool __get_decoded_data(void)
{
int ret = 0;
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_file_read failed : %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_image_create_image(g_width, g_height, g_color,
(const unsigned char*)g_read_data, g_read_size, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_image_create_image failed : %d\n", ret);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void __set_enc_opt(bool lossless)
g_print("\t[JXL_testsuite] __set_enc_opt lossless: %s\n", (lossless) ? "lossless" : "lossy");
}
-static gboolean __test_decode(const mm_util_test_mode_e mode, mm_util_color_format_e color)
+static bool __test_decode(const mm_util_test_mode_e mode, mm_util_color_format_e color)
{
int ret = 0;
MMUTIL_SAFE_IMAGE_FREE(g_decoded_data);
if ((mode != TEST_DECODE_FILE) && (mode != TEST_DECODE_BUFFER))
- return TRUE;
+ return true;
/* test decoding jxl */
if (mode == TEST_DECODE_FILE) {
ret = mm_util_decode_jxl_from_file(g_path, color, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_decode_jxl_from_file failed %d\n", ret);
- return FALSE;
+ return false;
}
} else if (mode == TEST_DECODE_BUFFER) {
ret = mm_util_file_read(g_path, &g_read_data, &g_read_size);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_file_read failed : %d\n", ret);
- return FALSE;
+ return false;
}
ret = mm_util_decode_jxl_from_buffer(g_read_data, g_read_size, color, &g_decoded_data);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_decode_jxl_from_buffer failed %d\n", ret);
- return FALSE;
+ return false;
}
}
ret = mm_util_jpeg_encode_to_file(g_decoded_data, 100, g_test_filename[mode][color]);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_jpeg_encode_to_file failed %d : %s\n", ret, g_test_filename[mode][color]);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-static gboolean __test_encode(const mm_util_test_mode_e mode, mm_util_color_format_e color)
+static bool __test_encode(const mm_util_test_mode_e mode, mm_util_color_format_e color)
{
int ret = 0;
void *encoded_data = NULL;
size_t encoded_size = 0;
if ((mode != TEST_ENCODE_FILE) && (mode != TEST_ENCODE_BUFFER))
- return TRUE;
+ return true;
/* test encoding jxl */
if (mode == TEST_ENCODE_FILE) {
ret = mm_util_encode_jxl_to_file(g_decoded_data, g_enc_opt, g_test_filename[mode][color]);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_encode_jxl_to_file failed : %d\n", ret);
- return FALSE;
+ return false;
}
} else if (mode == TEST_ENCODE_BUFFER) {
ret = mm_util_encode_jxl_to_buffer(g_decoded_data, g_enc_opt, &encoded_data, &encoded_size);
if (ret != MM_UTIL_ERROR_NONE) {
g_print("\t[JXL_testsuite] mm_util_encode_jxl_to_buffer failed : %d\n", ret);
MMUTIL_SAFE_FREE(encoded_data);
- return FALSE;
+ return false;
}
ret = mm_util_file_write(g_test_filename[mode][color], encoded_data, encoded_size);
if (ret != MM_UTIL_ERROR_NONE)
MMUTIL_SAFE_FREE(encoded_data);
}
- return TRUE;
+ return true;
}
static void __test_auto(void)
{
mm_util_color_format_e color = 0;
- gboolean result = FALSE;
+ bool result = false;
/* test for both decoding & encoding */
for (color = 0; color < MM_UTIL_COLOR_NUM; color++) {
_image_info = CloneImageInfo(0);
mm_util_retvm_if(!_image_info, MM_UTIL_ERROR_INVALID_OPERATION, "Error: CloneImageInfo failed.");
- SAFE_STRLCPY(image->filename, out_path, sizeof(image->filename));
+ MMUTIL_SAFE_STRCPY(image->filename, out_path, sizeof(image->filename));
DeleteImageProfile(image, "EXIF");
DeleteImageProfile(image, "8BIM");
g_queue_push_tail(g_queue_images, image);
}
-static gboolean __decode_files_in_queue()
+static bool __decode_files_in_queue()
{
if (g_queue_images)
g_queue_free_full(g_queue_images, mm_image_destroy_image);
if (g_queue_images->length == 0) {
g_print("No valid image\n");
- return FALSE;
+ return false;
}
g_print("%u valid image have been decoded.\n", g_queue_images->length);
- return TRUE;
+ return true;
}
static int __sort_compare(gconstpointer a, gconstpointer b, gpointer user_data)
return g_ascii_strcasecmp(_a, _b);
}
-static gboolean __set_input_dir(const char *path)
+static bool __set_input_dir(const char *path)
{
GDir *dir = NULL;
const gchar *filename = NULL;
if (!dir) {
g_print("invalid dir %s (%s)\n", path, g_error ? g_error->message : "none");
g_error_free(g_error);
- return FALSE;
+ return false;
}
if (g_queue_files)
if (g_queue_files->length == 0) {
g_print("\tNo test file in directory(%s)!\n", path);
- return FALSE;
+ return false;
}
/* decode files of dir */
if (!__decode_files_in_queue()) {
g_print("Fail to decode files from dir! %s\n", path);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void __print_help(const char *argv0)
fprintf(stderr, "\t\t2. support jpeg/png/gif/bmp/webp files to animation webp\n");
}
-static gboolean __get_arguments(int argc, char *argv[])
+static bool __get_arguments(int argc, char *argv[])
{
g_path = g_strdup(argv[1]);
if (!MMUTIL_STRING_VALID(g_path)) {
fprintf(stderr, "\t[WEBP_testsuite] invalid path %s\n", argv[1]);
- return FALSE;
+ return false;
}
if (!__set_input_dir(g_path)) {
fprintf(stderr, "\t[WEBP_testsuite] __set_input_dir failed\n");
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void __add_image(gpointer data, gpointer user_data)
return ret;
}
-static gboolean __test_encode_to_file()
+static bool __test_encode_to_file()
{
int ret = 0;
mm_util_webp_anim_enc_h anim_enc = NULL;
ret = __webp_encode_setup(&anim_enc);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[WEBP_testsuite] __webp_encode_setup failed : %d\n", ret);
- return FALSE;
+ return false;
}
g_queue_foreach(g_queue_images, __add_image, anim_enc);
return (ret == MM_UTIL_ERROR_NONE);
}
-static gboolean __test_encode_to_buffer()
+static bool __test_encode_to_buffer()
{
int ret = 0;
mm_util_webp_anim_enc_h anim_enc = NULL;
ret = __webp_encode_setup(&anim_enc);
if (ret != MM_UTIL_ERROR_NONE) {
fprintf(stderr, "\t[WEBP_testsuite] __webp_encode_setup failed : %d\n", ret);
- return FALSE;
+ return false;
}
g_queue_foreach(g_queue_images, __add_image, anim_enc);
return 0;
}
-