)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(dependents "dlog glib-2.0")
+SET(dependents "dlog glib-2.0 iniparser")
INCLUDE(FindPkgConfig)
pkg_check_modules(${fw_name} REQUIRED ${dependents})
int mm_util_file_read(const char *path, void **data, size_t *size);
int mm_util_file_write(const char *path, void *data, size_t size);
+// for reading ini
+int mm_util_ini_get_int(const char *category, const char *item, int default_value);
+
#ifdef __cplusplus
}
#endif
*/
#include <stdio.h>
+#include <iniparser.h>
#include "mm_util_private.h"
+#define IMAGE_UTIL_INI_PATH SYSCONFDIR"/multimedia/mmfw_image_util.ini"
+
gboolean mm_util_is_valid_color_format(mm_util_color_format_e color)
{
if ((color < MM_UTIL_COLOR_YUV420) || (color >= MM_UTIL_COLOR_NUM)) {
return MM_UTIL_ERROR_NONE;
}
+int mm_util_ini_get_int(const char *category, const char *item, int default_value)
+{
+ gchar *path = NULL;
+ int val;
+ dictionary *dict = NULL;
+
+ mm_util_retvm_if(!category, default_value, "category is NULL");
+ mm_util_retvm_if(!item, default_value, "item is NULL");
+
+ dict = iniparser_load(IMAGE_UTIL_INI_PATH);
+ mm_util_retvm_if(!dict, default_value, "could not open ini[%s], use default values[%d]", IMAGE_UTIL_INI_PATH, default_value);
+
+ path = g_strconcat(category, ":", item, NULL);
+
+ val = iniparser_getint(dict, path, default_value);
+ mm_util_info("[INI] %s = %d", path, val);
+
+ g_free(path);
+ iniparser_freedict(dict);
+
+ return val;
+}
#include "mm_util_jxl.h"
#include "mm_util_private.h"
-// TODO: it will be moved into .ini of mmfw_config
-#define NUM_OF_THREADS 4
-
+#define DEFAULT_THREAD 1
+#define INI_CATEGORY_JPEG_XL "jpeg-xl"
+#define INI_ITEM_NUM_OF_DECODING_TRHEADS "decoding_threads"
+#define INI_ITEM_NUM_OF_ENCODING_TRHEADS "encoding_threads"
static JxlPixelFormat jxl_formats[] = {
[MM_UTIL_COLOR_RGB24] = {3, JXL_TYPE_UINT8, JXL_BIG_ENDIAN, 0}, // RGB -> RGB
return err;
}
+static size_t __get_decoding_threads_configuration(void)
+{
+ static int num_of_decoding_threads = -1;
+
+ if (num_of_decoding_threads != -1)
+ return num_of_decoding_threads;
+
+ return (size_t)(num_of_decoding_threads = mm_util_ini_get_int(INI_CATEGORY_JPEG_XL, INI_ITEM_NUM_OF_DECODING_TRHEADS, DEFAULT_THREAD));
+}
+
+static size_t __get_encoding_threads_configuration(void)
+{
+ static int num_of_encoding_threads = -1;
+
+ if (num_of_encoding_threads != -1)
+ return num_of_encoding_threads;
+
+ return (size_t)(num_of_encoding_threads = mm_util_ini_get_int(INI_CATEGORY_JPEG_XL, INI_ITEM_NUM_OF_ENCODING_TRHEADS, DEFAULT_THREAD));
+}
+
static int __get_decoded_data(mm_util_image_h decoded, uint32_t *width, uint32_t *height, JxlPixelFormat *format, uint8_t **pixels, size_t *pixels_size)
{
mm_image_info_s *_image = (mm_image_info_s *)decoded;
goto Exit;
}
- jxl_thread = JxlThreadParallelRunnerCreate(NULL, NUM_OF_THREADS);
+ jxl_thread = JxlThreadParallelRunnerCreate(NULL, __get_decoding_threads_configuration());
if (!jxl_thread) {
mm_util_error("failed to JxlThreadParallelRunnerCreate");
goto Exit;
goto Exit;
}
- jxl_thread = JxlThreadParallelRunnerCreate(NULL, NUM_OF_THREADS);
+ jxl_thread = JxlThreadParallelRunnerCreate(NULL, __get_encoding_threads_configuration());
if (!jxl_thread) {
mm_util_error("failed to JxlThreadParallelRunnerCreate");
goto Exit;
Name: libmm-utility
Summary: Multimedia Framework Utility Library
-Version: 0.4.3
+Version: 0.4.4
Release: 0
Group: System/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(gmodule-2.0)
+BuildRequires: pkgconfig(iniparser)
BuildRequires: libjpeg-turbo-devel
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(opencv) >= 3.4.1
cp %{SOURCE1001} .
%build
-export CFLAGS="$CFLAGS -DGMAGICK_DEBUG=0 -D_FORTIFY_SOURCE=2"
+export CFLAGS="$CFLAGS -DGMAGICK_DEBUG=0 -D_FORTIFY_SOURCE=2 -DSYSCONFDIR=\\\"%{_hal_sysconfdir}\\\""
%cmake . -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0}
make %{?jobs:-j%jobs}