lib_LTLIBRARIES = libmmutil_bmp.la
installmmutil_bmpdir = $(includedir)/mmf
-installmmutil_bmp_HEADERS = include/mm_util_bmp.h
+installmmutil_bmp_HEADERS = include/mm_util_bmp.h \
+ ../common/include/mm_util_type.h
libmmutil_bmp_la_SOURCES = mm_util_bmp.c
libmmutil_bmp_la_CFLAGS = -I$(srcdir)/include \
- -I$(srcdir)/../imgp/include \
+ -I$(srcdir)/../common/include \
$(GLIB_CFLAGS) \
$(MEDIA_CFLAGS) \
-I/usr/include \
- $(SYSTEMINFO_CFLAGS) \
$(srcdir)/../imgp/libmmutil_imgp.la
libmmutil_bmp_la_LIBADD = $(GLIB_LIBS) -lnsbmp -lbmp -ldl -lttrace\
$(GMODULE_LIBS) \
- $(SYSTEMINFO_LIBS)\
$(MEDIA_LIBS)
libmmutil_bmp_la_CFLAGS += -DLIBPREFIX=\"$(libdir)\"
#ifdef __cplusplus
extern "C" {
#endif
-#include "mm_util_imgp.h"
+#include "mm_util_type.h"
#include "libnsbmp.h"
#include "bmpfile.h"
*
*/
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+#include <stdio.h>
#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <fcntl.h>
#include <unistd.h>
-#include <errno.h>
-#include <stdio.h> /* fopen() */
-#include <system_info.h>
#include "mm_util_bmp.h"
-#include "mm_util_debug.h"
+#include "mm_util_private.h"
#define BYTES_PER_PIXEL 4
-#define BMP_SAFE_FREE(src) { if (src != NULL) {free(src); src = NULL; } }
-
void *__bitmap_create(int width, int height, unsigned int state);
unsigned char *__bitmap_get_buffer(void *bitmap);
size_t __bitmap_get_bpp(void *bitmap);
}
size = sb.st_size;
- buffer = malloc(size);
+ buffer = calloc(1, size);
if (!buffer) {
mm_util_error("Unable to allocate %lld bytes", (long long)size);
fclose(fd);
n = fread(buffer, 1, size, fd);
if (n != size) {
mm_util_error("file read failed");
- BMP_SAFE_FREE(buffer);
+ MMUTIL_SAFE_FREE(buffer);
fclose(fd);
return NULL;
}
void __bitmap_destroy(void *bitmap)
{
- BMP_SAFE_FREE(bitmap);
+ MMUTIL_SAFE_FREE(bitmap);
}
static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *memory, unsigned long long src_size)
decoded->width = bmp.width;
decoded->height = bmp.height;
decoded->size = bmp.width * bmp.height * BYTES_PER_PIXEL;
- decoded->data = malloc(decoded->size);
+ decoded->data = calloc(1, decoded->size);
if (decoded->data == NULL) {
mm_util_error("Failed to saved memory allocation");
res = MM_UTIL_ERROR_OUT_OF_MEMORY;
cleanup:
bmp_finalise(&bmp);
if (filename)
- BMP_SAFE_FREE(data);
+ MMUTIL_SAFE_FREE(data);
return res;
}
if (bmp_save2(bmp, buffer, size) == false) {
mm_util_error("Saving bmp was failed.");
bmp_destroy(bmp);
- BMP_SAFE_FREE(*buffer);
+ MMUTIL_SAFE_FREE(*buffer);
*size = 0;
return MM_UTIL_ERROR_INVALID_OPERATION;
}
mm_util_bmp_testsuite_SOURCES = mm_util_bmp_testsuite.c
mm_util_bmp_testsuite_CFLAGS = -I$(srcdir)/../include \
- -I$(srcdir)/../../imgp/include
+ -I$(srcdir)/../../common/include
mm_util_bmp_testsuite_CFLAGS += $(MEDIA_CFLAGS) \
-fPIE -pie \
$(TZ_PLATFORM_CONFIG_FLAGS)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <mm_util_bmp.h>
--- /dev/null
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * 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.
+ *
+ */
+#ifndef __MM_UTILITY_DEBUG_H__
+#define __MM_UTILITY_DEBUG_H__
+
+#include <dlog.h>
+#include <errno.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "MM_UTIL"
+
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_RED "\033[31m"
+
+#define mm_util_debug(fmt, arg...) do { \
+ LOGD(FONT_COLOR_RESET""fmt"", ##arg); \
+ } while (0)
+
+#define mm_util_info(fmt, arg...) do { \
+ LOGI(FONT_COLOR_RESET""fmt"", ##arg); \
+ } while (0)
+
+#define mm_util_warn(fmt, arg...) do { \
+ LOGW(FONT_COLOR_RESET""fmt"", ##arg); \
+ } while (0)
+
+#define mm_util_error(fmt, arg...) do { \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+ } while (0)
+
+#define mm_util_fenter() do { \
+ LOGD(FONT_COLOR_RESET"<Enter>"); \
+ } while (0)
+
+#define mm_util_fleave() do { \
+ LOGD(FONT_COLOR_RESET"<Leave>"); \
+ } while (0)
+
+#define mm_util_retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+ return; \
+ } \
+ } while (0)
+
+#define mm_util_retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+ return (val); \
+ } \
+ } while (0)
+
+#define ERR_BUF_LENGHT 256
+#define mm_util_stderror(fmt) do { \
+ char buf[ERR_BUF_LENGHT] = {0,}; \
+ strerror_r(errno, buf, ERR_BUF_LENGHT); \
+ mm_util_error(fmt" : standard error= [%s]", buf); \
+ } while (0)
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTILITY_DEBUG_H__*/
--- /dev/null
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MM_UTIL_PRIVATE_H__
+#define __MM_UTIL_PRIVATE_H__
+
+#include <glib.h>
+#include <stdlib.h>
+#include "mm_util_debug.h"
+#include "mm_util_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MMUTIL_SAFE_FREE(x) { if (x) { free(x); x = NULL; } }
+#define MMUTIL_SAFE_G_FREE(x) { if (x) { g_free(x); x = NULL; } }
+#define MMUTIL_SAFE_STRCPY(dst, src, n) g_strlcpy(dst, src, n)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTIL_PRIVATE_H__*/
--- /dev/null
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MM_UTIL_TYPE_H__
+#define __MM_UTIL_TYPE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * error type
+ */
+typedef enum {
+ MM_UTIL_ERROR_NONE = 0, /**< Successful */
+ MM_UTIL_ERROR_INVALID_PARAMETER = -1, /**< Invalid parameter */
+ MM_UTIL_ERROR_OUT_OF_MEMORY = -2, /**< Out of memory */
+ MM_UTIL_ERROR_NO_SUCH_FILE = -3, /**< No such file */
+ MM_UTIL_ERROR_INVALID_OPERATION = -4, /**< Internal error */
+ MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT = -5, /**< Not supported format */
+} mm_util_error_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTIL_TYPE_H__*/
AC_SUBST(MEDIA_CFLAGS)
AC_SUBST(MEDIA_LIBS)
-PKG_CHECK_MODULES(TBM, libtbm)
-AC_SUBST(TBM_CFLAGS)
-AC_SUBST(TBM_LIBS)
-
PKG_CHECK_MODULES(OPENCV, opencv)
AC_SUBST(OPENCV_CFLAGS)
AC_SUBST(OPENCV_LIBS)
-PKG_CHECK_MODULES(SYSTEMINFO, capi-system-info)
-AC_SUBST(SYSTEMINFO_CFLAGS)
-AC_SUBST(SYSTEMINFO_LIBS)
-
PKG_CHECK_MODULES(TTRACE, [ttrace], AC_DEFINE(ENABLE_TTRACE, 1, [ttrace available]))
AC_SUBST(TTRACE)
lib_LTLIBRARIES = libmmutil_gif.la
installmmutil_gifdir = $(includedir)/mmf
-installmmutil_gif_HEADERS = include/mm_util_gif.h
+installmmutil_gif_HEADERS = include/mm_util_gif.h \
+ ../common/include/mm_util_type.h
libmmutil_gif_la_SOURCES = mm_util_gif.c
libmmutil_gif_la_CFLAGS = -I$(srcdir)/include \
- -I$(srcdir)/../imgp/include \
+ -I$(srcdir)/../common/include \
$(GLIB_CFLAGS) \
$(GIO_CFLAGS) \
$(MEDIA_CFLAGS) \
-I/usr/include \
- $(SYSTEMINFO_CFLAGS) \
$(srcdir)/../imgp/libmmutil_imgp.la
libmmutil_gif_la_LIBADD = $(GLIB_LIBS) -lgif -ldl -lttrace\
$(GIO_LIBS) \
$(GMODULE_LIBS) \
- $(SYSTEMINFO_LIBS)\
$(MEDIA_LIBS)
libmmutil_gif_la_CFLAGS += -DLIBPREFIX=\"$(libdir)\"
#include <glib.h>
#include "gif_lib.h"
-#include "mm_util_imgp.h"
+#include "mm_util_type.h"
/**
@addtogroup UTILITY
*
*/
-#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
#include <gio/gio.h>
#include "mm_util_gif.h"
#include "mm_util_gif_private.h"
-#include "mm_util_debug.h"
+#include "mm_util_private.h"
#include <limits.h>
#define GIF_TMP_FILE "/tmp/.libmm_gif.gif"
GifByteType *buffer;
mm_util_debug("__convert_gif_to_rgba");
- if ((decoded->data = (void *)malloc(width * height * 4)) == NULL) {
+ if ((decoded->data = (void *)calloc(1, width * height * 4)) == NULL) {
mm_util_error("Failed to allocate memory required, aborted.");
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
decoded->size = (unsigned long long)GifFile->SWidth * (unsigned long long)GifFile->SHeight * 4;
if ((screen_buffer = (GifRowType *)
- malloc(GifFile->SHeight * sizeof(GifRowType))) == NULL) {
+ calloc(1, GifFile->SHeight * sizeof(GifRowType))) == NULL) {
mm_util_error("Failed to allocate memory required, aborted.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
goto error;
COLORMAP_FREE(gif_file->color_map);
- MMUTIL_SAFE_FREE(gif_file->filename);
+ MMUTIL_SAFE_G_FREE(gif_file->filename);
MMUTIL_SAFE_FREE(gif_file->buffer);
}
mm_util_gif_testsuite_SOURCES = mm_util_gif_testsuite.c
mm_util_gif_testsuite_CFLAGS = -I$(srcdir)/../include \
- -I$(srcdir)/../../imgp/include
+ -I$(srcdir)/../../common/include
mm_util_gif_testsuite_CFLAGS += $(GLIB_CFLAGS) \
$(MEDIA_CFLAGS) \
-fPIE -pie \
#include <string.h>
#include <errno.h>
#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <mm_util_gif.h>
#define ENCODED_FILEPATH "/opt/usr/home/owner/media/mm_util_test.gif"
lib_LTLIBRARIES = libmmutil_imgcv.la
installmmutil_imgcvdir = $(includedir)/mmf
-installmmutil_imgcv_HEADERS = include/mm_util_imgcv.h
+installmmutil_imgcv_HEADERS = include/mm_util_imgcv.h \
+ ../common/include/mm_util_type.h
noinst_HEADERS = include/mm_util_imgcv_internal.h
libmmutil_imgcv_la_SOURCES = mm_util_imgcv.c
libmmutil_imgcv_la_CFLAGS = -I$(srcdir)/include \
- -I$(srcdir)/../imgp/include \
+ -I$(srcdir)/../common/include \
$(GLIB_CFLAGS) \
$(GMODULE_CFLAGS) \
$(MEDIA_CFLAGS) \
#ifndef __MM_UTILITY_IMGCV_H__
#define __MM_UTILITY_IMGCV_H__
+#include "mm_util_type.h"
+
#ifdef __cplusplus
extern "C" {
#endif
*/
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
*/
#include <limits.h>
#include <math.h>
-#include "mm_util_debug.h"
-#include "mm_util_imgp.h"
+#include "mm_util_private.h"
#include "mm_util_imgcv.h"
#include "mm_util_imgcv_internal.h"
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- mm_util_imgcv_s *handle = (mm_util_imgcv_s *)malloc(sizeof(mm_util_imgcv_s));
+ mm_util_imgcv_s *handle = (mm_util_imgcv_s *)calloc(1, sizeof(mm_util_imgcv_s));
if (handle == NULL) {
mm_util_error("#ERROR#: fail to create handle");
mm_util_imgcv_testsuite_CFLAGS = -I$(srcdir)/../include \
-I$(srcdir)/../../jpeg/include \
- -I$(srcdir)/../../imgp/include
+ -I$(srcdir)/../../common/include
mm_util_imgcv_testsuite_CFLAGS += $(MMCOMON_CFLAGS) \
-fPIE -pie
*
*/
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <mm_util_jpeg.h>
lib_LTLIBRARIES = libmmutil_imgp.la
installmmutil_imgpdir = $(includedir)/mmf
-installmmutil_imgp_HEADERS = include/mm_util_imgp.h
-noinst_HEADERS = include/mm_util_imgp_internal.h \
- include/mm_util_debug.h
+installmmutil_imgp_HEADERS = include/mm_util_imgp.h \
+ ../common/include/mm_util_type.h
+noinst_HEADERS = include/mm_util_imgp_internal.h
libmmutil_imgp_la_SOURCES = mm_util_imgp.c
-libmmutil_imgp_la_CFLAGS = -I$(srcdir)/include \
+libmmutil_imgp_la_CFLAGS = -I$(srcdir)/../common/include \
+ -I$(srcdir)/include \
-I$(includedir)/drm \
$(GLIB_CFLAGS) \
$(GMODULE_CFLAGS) \
$(XFIXES_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(DRI2_CFLAGS) \
- $(TBM_CFLAGS) \
$(DLOG_CFLAGS)
libmmutil_imgp_la_LIBADD = $(GLIB_LIBS) \
$(XFIXES_LIBS) \
$(DRI2PROTO_LIBS) \
$(DRI2_LIBS) \
- $(TBM_LIBS) \
$(DLOG_LIBS)
libmmutil_imgp_la_CFLAGS += -lcapi-media-tool -lttrace -DLIBPREFIX=\"$(libdir)\"
+++ /dev/null
-/*
- * libmm-utility
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: YoungHun Kim <yh8004.kim@samsung.com>
- *
- * 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.
- *
- */
-#ifndef __MM_UTILITY_DEBUG_H__
-#define __MM_UTILITY_DEBUG_H__
-
-#include <dlog.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "MM_UTIL"
-
-#define FONT_COLOR_RESET "\033[0m"
-#define FONT_COLOR_RED "\033[31m"
-
-#define mm_util_debug(fmt, arg...) do { \
- LOGD(FONT_COLOR_RESET""fmt"", ##arg); \
- } while (0)
-
-#define mm_util_info(fmt, arg...) do { \
- LOGI(FONT_COLOR_RESET""fmt"", ##arg); \
- } while (0)
-
-#define mm_util_warn(fmt, arg...) do { \
- LOGW(FONT_COLOR_RESET""fmt"", ##arg); \
- } while (0)
-
-#define mm_util_error(fmt, arg...) do { \
- LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
- } while (0)
-
-#define mm_util_fenter() do { \
- LOGD(FONT_COLOR_RESET"<Enter>"); \
- } while (0)
-
-#define mm_util_fleave() do { \
- LOGD(FONT_COLOR_RESET"<Leave>"); \
- } while (0)
-
-#define mm_util_retm_if(expr, fmt, arg...) do { \
- if (expr) { \
- LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
- return; \
- } \
- } while (0)
-
-#define mm_util_retvm_if(expr, val, fmt, arg...) do { \
- if (expr) { \
- LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
- return (val); \
- } \
- } while (0)
-
-#define MMUTIL_SAFE_FREE(x) { if (x) { free(x); x = NULL; } }
-/**
-* @}
-*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*__MM_UTILITY_DEBUG_H__*/
#endif
#include <media_packet.h>
+#include "mm_util_type.h"
typedef void *mm_util_imgp_h;
This part describes the APIs with repect to image converting library.
*/
-/**
- * error type
- */
-typedef enum {
- MM_UTIL_ERROR_NONE = 0, /**< Successful */
- MM_UTIL_ERROR_INVALID_PARAMETER = -1, /**< Invalid parameter */
- MM_UTIL_ERROR_OUT_OF_MEMORY = -2, /**< Out of memory */
- MM_UTIL_ERROR_NO_SUCH_FILE = -3, /**< No such file */
- MM_UTIL_ERROR_INVALID_OPERATION = -4, /**< Internal error */
- MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT = -5, /**< Not supported format */
-} mm_util_error_e;
-
/**
* Image formats
*/
#endif
#include <gmodule.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <time.h>
#include <unistd.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-/* tbm */
-#include <tbm_surface_internal.h>
#define PATH_NEON_LIB LIBPREFIX "/libmmutil_imgp_neon.so"
#define PATH_GSTCS_LIB LIBPREFIX "/libmmutil_imgp_gstcs.so"
#define IMGP_FUNC_NAME "mm_imgp"
-#define IMGP_FREE(src) { if (src != NULL) {g_free(src); src = NULL; } }
-#define SAFE_STRCPY(dst, src, n) g_strlcpy(dst, src, n)
/**
* Image Process Info for dlopen
* limitations under the License.
*
*/
+
+#include <gmodule.h>
#include <limits.h>
-#include "mm_util_debug.h"
+#include "mm_util_private.h"
#include "mm_util_imgp.h"
#include "mm_util_imgp_internal.h"
int i = 0;
for (i = 0; i < 4; i++)
- IMGP_FREE(buffer[i]);
+ MMUTIL_SAFE_FREE(buffer[i]);
}
static gboolean __mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format)
unsigned int src_fmt_len = strlen(src_fmt_lable) + 1;
unsigned int dst_fmt_len = strlen(dst_fmt_lable) + 1;
mm_util_debug("src_fmt_lable: %s dst_fmt_lable: %s", src_fmt_lable, dst_fmt_lable);
- _imgp_info_s->input_format_label = (char *)malloc(src_fmt_len);
+ _imgp_info_s->input_format_label = (char *)calloc(1, src_fmt_len);
if (_imgp_info_s->input_format_label == NULL) {
mm_util_error("[input] input_format_label is null");
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
memset(_imgp_info_s->input_format_label, 0, src_fmt_len);
- SAFE_STRCPY(_imgp_info_s->input_format_label, src_fmt_lable, src_fmt_len);
+ MMUTIL_SAFE_STRCPY(_imgp_info_s->input_format_label, src_fmt_lable, src_fmt_len);
- _imgp_info_s->output_format_label = (char *)malloc(dst_fmt_len);
+ _imgp_info_s->output_format_label = (char *)calloc(1, dst_fmt_len);
if (_imgp_info_s->output_format_label == NULL) {
mm_util_error("[input] input_format_label is null");
- IMGP_FREE(_imgp_info_s->input_format_label);
+ MMUTIL_SAFE_G_FREE(_imgp_info_s->input_format_label);
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
memset(_imgp_info_s->output_format_label, 0, dst_fmt_len);
- SAFE_STRCPY(_imgp_info_s->output_format_label, dst_fmt_lable, dst_fmt_len);
+ MMUTIL_SAFE_STRCPY(_imgp_info_s->output_format_label, dst_fmt_lable, dst_fmt_len);
mm_util_debug("input_format_label: %s output_format_label: %s", _imgp_info_s->input_format_label, _imgp_info_s->output_format_label);
} else {
ret = MM_UTIL_ERROR_INVALID_PARAMETER;
}
- IMGP_FREE(_imgp_info_s->input_format_label);
- IMGP_FREE(_imgp_info_s->output_format_label);
- IMGP_FREE(_imgp_info_s);
+ MMUTIL_SAFE_G_FREE(_imgp_info_s->input_format_label);
+ MMUTIL_SAFE_G_FREE(_imgp_info_s->output_format_label);
+ MMUTIL_SAFE_FREE(_imgp_info_s);
return ret;
}
mm_util_debug("src: %p, dst: %p", handle->src, handle->dst);
- dst_buf[src_index] = g_malloc(handle->src_buf_size);
+ dst_buf[src_index] = calloc(1, handle->src_buf_size);
src_width = handle->src_width;
src_height = handle->src_height;
src_format = handle->src_format;
if (handle->set_crop) {
dst_index++;
__mm_util_get_crop_image_size(src_format, handle->dst_width, handle->dst_height, &dst_buf_size);
- dst_buf[dst_index] = g_malloc(dst_buf_size);
+ dst_buf[dst_index] = calloc(1, dst_buf_size);
if (dst_buf[dst_index] == NULL) {
mm_util_error("[multi func] memory allocation error");
__mm_destroy_temp_buffer(dst_buf);
} else if (handle->set_resize) {
dst_index++;
mm_util_get_image_size(src_format, handle->dst_width, handle->dst_height, &dst_buf_size);
- dst_buf[dst_index] = g_malloc(dst_buf_size);
+ dst_buf[dst_index] = calloc(1, dst_buf_size);
if (dst_buf[dst_index] == NULL) {
mm_util_error("[multi func] memory allocation error");
__mm_destroy_temp_buffer(dst_buf);
if (handle->set_convert) {
dst_index++;
mm_util_get_image_size(handle->dst_format, src_width, src_height, &dst_buf_size);
- dst_buf[dst_index] = g_malloc(dst_buf_size);
+ dst_buf[dst_index] = calloc(1, dst_buf_size);
if (dst_buf[dst_index] == NULL) {
mm_util_error("[multi func] memory allocation error");
__mm_destroy_temp_buffer(dst_buf);
}
}
mm_util_get_image_size(src_format, src_width, src_height, &dst_buf_size);
- dst_buf[dst_index] = g_malloc(dst_buf_size);
+ dst_buf[dst_index] = calloc(1, dst_buf_size);
if (dst_buf[dst_index] == NULL) {
mm_util_error("[multi func] memory allocation error");
__mm_destroy_temp_buffer(dst_buf);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_create_media_format failed");
media_format_unref(src_fmt);
- IMGP_FREE(handle->dst);
+ MMUTIL_SAFE_FREE(handle->dst);
return ret;
}
media_format_unref(src_fmt);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_create_media_packet failed");
media_format_unref(dst_fmt);
- IMGP_FREE(handle->dst);
+ MMUTIL_SAFE_FREE(handle->dst);
return ret;
}
media_format_unref(dst_fmt);
- IMGP_FREE(handle->dst);
+ MMUTIL_SAFE_FREE(handle->dst);
return ret;
}
ret = __mm_util_handle_init(handle);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("_mm_util_handle_init failed");
- IMGP_FREE(handle);
+ MMUTIL_SAFE_FREE(handle);
TTRACE_END();
return ret;
}
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- IMGP_FREE(handle->_util_cb);
- handle->_util_cb = (mm_util_cb_s *)malloc(sizeof(mm_util_cb_s));
+ MMUTIL_SAFE_FREE(handle->_util_cb);
+ handle->_util_cb = (mm_util_cb_s *)calloc(1, sizeof(mm_util_cb_s));
if (handle->_util_cb) {
handle->_util_cb->completed_cb = completed_callback;
handle->_util_cb->user_data = user_data;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- IMGP_FREE(handle->_util_cb);
- IMGP_FREE(handle);
+ MMUTIL_SAFE_FREE(handle->_util_cb);
+ MMUTIL_SAFE_FREE(handle);
mm_util_debug("Success - Destroy Handle");
TTRACE_END();
mm_util_debug("(%d x %d)", src_width, src_height);
- imgp_info_s *_imgp_info_s = (imgp_info_s *) g_malloc0(sizeof(imgp_info_s));
+ imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
if (_imgp_info_s == NULL) {
mm_util_error("ERROR - alloc handle");
TTRACE_END();
return ret;
}
- output_buffer = (unsigned char *) malloc(output_buffer_size);
+ output_buffer = (unsigned char *) calloc(1, output_buffer_size);
if (output_buffer == NULL) {
- mm_util_error("malloc failed");
+ mm_util_error("memory allocation failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- mm_util_debug("malloc outputbuffer: %p (%d)", output_buffer, output_buffer_size);
+ mm_util_debug("memory allocation outputbuffer: %p (%d)", output_buffer, output_buffer_size);
/* image processing */
_mm_util_imgp_func = __mm_util_imgp_process(_module);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("image processing failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return ret;
}
} else {
mm_util_error("g_module_symbol failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = mm_util_crop_image(output_buffer, _imgp_info_s->output_stride, _imgp_info_s->output_elevation, dst_format, 0, 0, &_imgp_info_s->dst_width, &_imgp_info_s->dst_height, dst);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_util_imgp_finalize failed");
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_util_imgp_finalize failed");
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
mm_util_fleave();
mm_util_debug("(%d x %d)", src_width, src_height);
- imgp_info_s *_imgp_info_s = (imgp_info_s *) g_malloc0(sizeof(imgp_info_s));
+ imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
if (_imgp_info_s == NULL) {
mm_util_error("ERROR - alloc handle");
TTRACE_END();
return ret;
}
- output_buffer = (unsigned char *) malloc(output_buffer_size);
+ output_buffer = (unsigned char *) calloc(1, output_buffer_size);
if (output_buffer == NULL) {
- mm_util_error("malloc failed");
+ mm_util_error("memory allocation failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- mm_util_debug("malloc outputbuffer: %p (%d)", output_buffer, output_buffer_size);
+ mm_util_debug("memory allocation outputbuffer: %p (%d)", output_buffer, output_buffer_size);
/* image processing */
_mm_util_imgp_func = __mm_util_imgp_process(_module);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("image processing failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return ret;
}
} else {
mm_util_error("g_module_symbol failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_util_imgp_finalize failed");
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
mm_util_fenter();
mm_util_debug("(%d x %d)", src_width, src_height);
- imgp_info_s *_imgp_info_s = (imgp_info_s *) g_malloc0(sizeof(imgp_info_s));
+ imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
if (_imgp_info_s == NULL) {
mm_util_error("ERROR - alloc handle");
TTRACE_END();
return ret;
}
- output_buffer = (unsigned char *) malloc(output_buffer_size);
+ output_buffer = (unsigned char *) calloc(1, output_buffer_size);
if (output_buffer == NULL) {
- mm_util_error("malloc failed");
+ mm_util_error("memory allocation failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- mm_util_debug("malloc outputbuffer: %p (%d)", output_buffer, output_buffer_size);
+ mm_util_debug("memory allocation outputbuffer: %p (%d)", output_buffer, output_buffer_size);
/* image processing */
_mm_util_imgp_func = __mm_util_imgp_process(_module);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("image processing failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return ret;
}
} else {
mm_util_error("g_module_symbol failed");
__mm_util_imgp_finalize(_module, _imgp_info_s);
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_util_imgp_finalize failed");
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
TTRACE_END();
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
- IMGP_FREE(output_buffer);
+ MMUTIL_SAFE_FREE(output_buffer);
mm_util_fleave();
mm_util_imgp_testsuite_SOURCES = mm_util_imgp_testsuite.c
mm_util_imgp_testsuite_CFLAGS = -I$(srcdir)/../include \
+ -I$(srcdir)/../../common/include \
-I$(includedir)/drm \
$(GMODULE_CFLAGS) \
$(MMCAMCORDER_CFLAGS) \
$(XFIXES_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(DRI2_CFLAGS) \
- $(TBM_CFLAGS) \
-fPIE -pie
############################################
$(XFIXES_LIBS) \
$(DRI2PROTO_LIBS) \
$(DRI2_LIBS) \
- $(TBM_LIBS) \
$(MMLOG_LIBS)
* limitations under the License.
*
*/
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <media_packet.h>
#include "mm_util_imgp.h"
-#include "mm_util_imgp_internal.h"
-#include "mm_util_debug.h"
#define MAX_STRING_LEN 128
#define IMAGE_FORMAT_LABEL_BUFFER_SIZE 4
+#define IMGP_FREE(src) { if (src != NULL) {g_free(src); src = NULL; } }
+
mm_util_imgp_h imgp_handle = 0;
bool completed = false;
case MM_UTIL_IMG_FMT_NV61:
default:
mimetype = -1;
- mm_util_debug("Not Supported Format");
+ fprintf(stderr, "Not Supported Format\n");
break;
}
- mm_util_debug("imgp fmt: %d mimetype fmt: %d", colorspace, mimetype);
+ fprintf(stderr, "imgp fmt: %d mimetype fmt: %d\n", colorspace, mimetype);
return mimetype;
}
int _packet_finalize_callback(media_packet_h packet, int err, void *user_data)
{
- mm_util_debug("==> finalize callback func is called [%d] \n", err);
+ fprintf(stderr, "==> finalize callback func is called [%d] \n", err);
return MEDIA_PACKET_FINALIZE;
}
{
uint64_t size = 0;
char* output_file = (char *)user_data;
- mm_util_debug("imgp_handle: %p", imgp_handle);
+ fprintf(stderr, "imgp_handle: %p\n", imgp_handle);
- mm_util_debug("output_file: %s", output_file);
+ fprintf(stderr, "output_file: %s\n", output_file);
if (error == MM_UTIL_ERROR_NONE) {
- mm_util_debug("completed");
+ fprintf(stderr, "completed\n");
FILE *fp = fopen(output_file, "w");
if (fp) {
media_packet_get_buffer_size(*packet, &size);
if (err != MEDIA_PACKET_ERROR_NONE) {
IMGP_FREE(dst);
fclose(fp);
- mm_util_error("Error media_packet_get_buffer_data_ptr (%d)", err);
+ fprintf(stderr, "Error media_packet_get_buffer_data_ptr (%d)\n", err);
_signal();
return FALSE;
}
- mm_util_debug("dst: %p [%llu]", dst, size);
+ fprintf(stderr, "dst: %p [%llu]\n", dst, size);
fwrite(dst, 1, size, fp);
- mm_util_debug("FREE");
+ fprintf(stderr, "FREE\n");
fclose(fp);
}
- mm_util_debug("write result");
+ fprintf(stderr, "write result\n");
} else {
- mm_util_error("[Error] complete cb (%d)", error);
+ fprintf(stderr, "[Error] complete cb (%d)\n", error);
}
completed = true;
- mm_util_debug("Destory - dst packet");
+ fprintf(stderr, "Destory - dst packet\n");
media_packet_destroy(*packet);
_signal();
unsigned int size = 0;
- mm_util_debug("command: %s src_width: %d, src_height: %d, src_format: %d, dst_width: %d, dst_height: %d, dst_format:%d, rotation:%d", command, src_width, src_height, src_format, dst_width, dst_height, dst_format, rotation);
+ fprintf(stderr, "command: %s src_width: %d, src_height: %d, src_format: %d, dst_width: %d, dst_height: %d, dst_format:%d, rotation:%d\n", command, src_width, src_height, src_format, dst_width, dst_height, dst_format, rotation);
/* mem allocation for src dst buffer */
mm_util_get_image_size(src_format, src_width, src_height, &size);
src_size = (uint64_t)size;
mm_util_get_image_size(dst_format, dst_width, dst_height, &size);
dst_size = (uint64_t)size;
- src = malloc(src_size);
- dst = malloc(dst_size);
+ src = calloc(1, src_size);
+ dst = calloc(1, dst_size);
{ /* read input file */
FILE *fp = fopen(filename, "r");
if (fp == NULL) {
- mm_util_debug("\tfile open failed %d\n", errno);
+ fprintf(stderr, "\tfile open failed %d\n", errno);
goto TEST_FAIL;
}
if (src == NULL) {
- mm_util_debug("\tmemory allocation failed\n");
+ fprintf(stderr, "\tmemory allocation failed\n");
goto TEST_FAIL;
}
if (fread(src, 1, (int)src_size, fp) == src_size)
- mm_util_debug("#Success# fread");
+ fprintf(stderr, "#Success# fread\n");
else
- mm_util_error("#Error# fread");
+ fprintf(stderr, "#Error# fread\n");
if (src == NULL || src_size <= 0) {
- mm_util_error("#Error# fread");
+ fprintf(stderr, "#Error# fread\n");
goto TEST_FAIL;
}
}
{ /* ready output file */
- char *output_fmt = (char *) g_malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ char *output_fmt = (char *) calloc(1, sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
memset(output_fmt, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
if (dst_format == MM_UTIL_IMG_FMT_YUV420 ||
dst_format == MM_UTIL_IMG_FMT_YUV422 ||
}
if (sync_mode) {
- mm_util_debug("SYNC");
+ fprintf(stderr, "SYNC\n");
if (strcmp(command, "convert") == 0)
ret = mm_util_convert_colorspace(src, src_width, src_height, src_format, dst, dst_format);
else if (strcmp(command, "resize") == 0)
ret = mm_util_crop_image(src, src_width, src_height, src_format, start_x, start_y, &dst_width, &dst_height, dst);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - %s", command);
+ fprintf(stderr, "Success - %s\n", command);
} else {
- mm_util_debug("ERROR - %s", command);
+ fprintf(stderr, "ERROR - %s\n", command);
goto TEST_FAIL;
}
{ /* write output file */
FILE *fpout = fopen(output_file, "w");
if (fpout) {
- mm_util_debug("dst: %p [%llu]", dst, dst_size);
+ fprintf(stderr, "dst: %p [%llu]\n", dst, dst_size);
fwrite(dst, 1, dst_size, fpout);
- mm_util_debug("FREE");
+ fprintf(stderr, "FREE\n");
fclose(fpout);
}
}
} else { /* Async mode */
- mm_util_debug("ASYNC");
+ fprintf(stderr, "ASYNC\n");
/* Create Transform */
ret = mm_util_create(&imgp_handle);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Create Transcode Handle [imgp_handle: %p]", imgp_handle);
+ fprintf(stderr, "Success - Create Transcode Handle [imgp_handle: %p]\n", imgp_handle);
} else {
- mm_util_debug("ERROR - Create Transcode Handle");
+ fprintf(stderr, "ERROR - Create Transcode Handle\n");
goto TEST_FAIL;
}
if (media_format_create(&fmt) == MEDIA_FORMAT_ERROR_NONE) {
if (media_format_set_video_mime(fmt, _format_to_mime(src_format)) != MEDIA_FORMAT_ERROR_NONE) {
media_format_unref(fmt);
- mm_util_error("[Error] Set - video mime");
+ fprintf(stderr, "[Error] Set - video mime\n");
goto TEST_FAIL;
}
if (media_format_set_video_width(fmt, src_width) != MEDIA_FORMAT_ERROR_NONE) {
media_format_unref(fmt);
- mm_util_error("[Error] Set - video width");
+ fprintf(stderr, "[Error] Set - video width\n");
goto TEST_FAIL;
}
if (media_format_set_video_height(fmt, src_height) != MEDIA_FORMAT_ERROR_NONE) {
media_format_unref(fmt);
- mm_util_error("[Error] Set - video height");
+ fprintf(stderr, "[Error] Set - video height\n");
goto TEST_FAIL;
}
if (media_format_set_video_avg_bps(fmt, 15000000) != MEDIA_FORMAT_ERROR_NONE) {
media_format_unref(fmt);
- mm_util_error("[Error] Set - video avg bps");
+ fprintf(stderr, "[Error] Set - video avg bps\n");
goto TEST_FAIL;
}
if (media_format_set_video_max_bps(fmt, 20000000) != MEDIA_FORMAT_ERROR_NONE) {
media_format_unref(fmt);
- mm_util_error("[Error] Set - video max bps");
+ fprintf(stderr, "[Error] Set - video max bps\n");
goto TEST_FAIL;
}
- mm_util_debug("media_format_set_video_info success! w:%d, h:%d, format:%d\n", src_width, src_height, src_format);
+ fprintf(stderr, "media_format_set_video_info success! w:%d, h:%d, format:%d\n", src_width, src_height, src_format);
} else {
- mm_util_error("media_format_create failed...");
+ fprintf(stderr, "media_format_create failed...\n");
}
/* Set Source */
ret = media_packet_create_alloc(fmt, (media_packet_finalize_cb)_packet_finalize_callback, NULL, &src_packet);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Create Media Packet(%p)", src_packet);
+ fprintf(stderr, "Success - Create Media Packet(%p)\n", src_packet);
uint64_t buffer_size = (uint64_t)size;
if (media_packet_get_buffer_size(src_packet, &buffer_size) == MEDIA_PACKET_ERROR_NONE) {
- ptr = malloc(buffer_size);
+ ptr = calloc(1, buffer_size);
if (ptr == NULL) {
- mm_util_debug("\tmemory allocation failed\n");
+ fprintf(stderr, "\tmemory allocation failed\n");
goto TEST_FAIL;
}
if (media_packet_get_buffer_data_ptr(src_packet, &ptr) == MEDIA_PACKET_ERROR_NONE) {
if (src != NULL && src_size > 0) {
memcpy(ptr, src, buffer_size);
- mm_util_debug("memcpy");
+ fprintf(stderr, "memcpy\n");
}
}
}
} else {
- mm_util_debug("ERROR - Create Media Packet");
+ fprintf(stderr, "ERROR - Create Media Packet\n");
return ret;
}
ret = mm_util_set_hardware_acceleration(imgp_handle, FALSE);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Set hardware_acceleration");
+ fprintf(stderr, "Success - Set hardware_acceleration\n");
} else {
- mm_util_debug("ERROR - Set hardware_acceleration");
+ fprintf(stderr, "ERROR - Set hardware_acceleration\n");
goto TEST_FAIL;
}
if (strcmp(command, "convert") == 0) {
ret = mm_util_set_colorspace_convert(imgp_handle, dst_format);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Set colorspace Info");
+ fprintf(stderr, "Success - Set colorspace Info\n");
} else {
- mm_util_debug("ERROR - Set colorspace Info");
+ fprintf(stderr, "ERROR - Set colorspace Info\n");
goto TEST_FAIL;
}
}
if (strcmp(command, "crop") == 0) {
ret = mm_util_set_crop_area(imgp_handle, start_x, start_y, (start_x + dst_width), (start_y + dst_height));
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Set crop Info");
+ fprintf(stderr, "Success - Set crop Info\n");
} else {
- mm_util_debug("ERROR - Set crop Info");
+ fprintf(stderr, "ERROR - Set crop Info\n");
goto TEST_FAIL;
}
}
if (strcmp(command, "resize") == 0) {
ret = mm_util_set_resolution(imgp_handle, dst_width, dst_height);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Set resolution Info");
+ fprintf(stderr, "Success - Set resolution Info\n");
} else {
- mm_util_debug("ERROR - Set resolution Info");
+ fprintf(stderr, "ERROR - Set resolution Info\n");
goto TEST_FAIL;
}
}
if (strcmp(command, "rotate") == 0) {
ret = mm_util_set_rotation(imgp_handle, rotation);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Set rotation Info");
+ fprintf(stderr, "Success - Set rotation Info\n");
} else {
- mm_util_debug("ERROR - Set rotation Info");
+ fprintf(stderr, "ERROR - Set rotation Info\n");
goto TEST_FAIL;
}
}
/* Transform */
ret = mm_util_transform(imgp_handle, src_packet, (mm_util_completed_callback) _transform_completed_cb, output_file);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Transform");
+ fprintf(stderr, "Success - Transform\n");
} else {
- mm_util_error("ERROR - Transform");
+ fprintf(stderr, "ERROR - Transform\n");
goto TEST_FAIL;
}
- mm_util_debug("Wait...");
+ fprintf(stderr, "Wait...\n");
g_mutex_init(&g_thread_mutex);
g_cond_init(&g_thread_cond);
_wait();
ret = mm_util_destroy(imgp_handle);
if (ret == MM_UTIL_ERROR_NONE) {
- mm_util_debug("Success - Destroy");
+ fprintf(stderr, "Success - Destroy\n");
} else {
- mm_util_error("ERROR - Destroy");
+ fprintf(stderr, "ERROR - Destroy\n");
goto TEST_FAIL;
}
IMGP_FREE(filename);
if (!sync_mode) {
media_format_unref(fmt);
- mm_util_debug("Destory - src packet");
+ fprintf(stderr, "Destory - src packet\n");
media_packet_destroy(src_packet);
- mm_util_debug("destroy");
+ fprintf(stderr, "destroy\n");
}
return 0;
libmmutil_jpeg_la_SOURCES = mm_util_jpeg.c
libmmutil_jpeg_la_CFLAGS = -I$(srcdir)/include \
+ -I$(srcdir)/../common/include \
-I$(srcdir)/../imgp/include \
$(GLIB_CFLAGS) \
$(MEDIA_CFLAGS) \
-I/usr/include \
- $(SYSTEMINFO_CFLAGS) \
$(srcdir)/../imgp/libmmutil_imgp.la
libmmutil_jpeg_la_LIBADD = $(GLIB_LIBS) -ljpeg -ldl -lttrace -lturbojpeg\
$(GMODULE_LIBS) \
- $(SYSTEMINFO_LIBS)\
$(MEDIA_LIBS)
libmmutil_jpeg_la_CFLAGS += -DLIBPREFIX=\"$(libdir)\"
#ifndef __MM_UTIL_JPEG_H__
#define __MM_UTIL_JPEG_H__
+#include "mm_util_type.h"
+
#ifdef __cplusplus
extern "C" {
#endif
*
*/
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h> /* fopen() */
+#include <stdio.h>
+#include <unistd.h> /* fsync() */
#include <jpeglib.h>
#define LIBJPEG_TURBO 0
#define ENC_MAX_LEN 8192
#include <glib.h>
#include "mm_util_jpeg.h"
#include "mm_util_imgp.h"
-#include "mm_util_debug.h"
+#include "mm_util_private.h"
#ifdef ENABLE_TTRACE
#include <ttrace.h>
#define TTRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_IMAGE, NAME)
#define MM_JPEG_ROUND_DOWN_4(num) ((num)&(~3))
#define MM_JPEG_ROUND_DOWN_16(num) ((num)&(~15))
-#define ERR_BUF_LENGHT 256
-#define mm_util_stderror(fmt) do { \
- char buf[ERR_BUF_LENGHT] = {0,}; \
- strerror_r(errno, buf, ERR_BUF_LENGHT); \
- mm_util_error(fmt" : standard error= [%s]", buf); \
- } while (0)
-
-#define IMG_JPEG_FREE(src) { if (src != NULL) {free(src); src = NULL; } }
-
#if LIBJPEG_TURBO
#define PAD(v, p) ((v+(p)-1)&(~((p)-1)))
#define _throwtj() {printf("TurboJPEG ERROR:\n%s\n", tjGetErrorStr()); }
mm_util_debug("MM_UTIL_JPEG_FMT_RGB888 dstSize: %d _hdrsubsamp:%d", dstSize, _hdrsubsamp);
}
- if ((decoded_data->data = (void *)malloc(dstSize)) == NULL) {
+ if ((decoded_data->data = (void *)calloc(1, dstSize)) == NULL) {
mm_util_error("dstBuf is NULL");
return;
}
mm_util_error("dhandle=tjInitDecompress()) is NULL");
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- srcBuf = (unsigned char *) malloc(sizeof(char) * jpegSize);
+ srcBuf = (unsigned char *) calloc(1, sizeof(char) * jpegSize);
if (srcBuf == NULL) {
fclose(src);
tjDestroy(dhandle);
mm_util_error("dhandle=tjInitDecompress()) is NULL");
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- srcBuf = (unsigned char *) malloc(sizeof(char) * size);
+ srcBuf = (unsigned char *) calloc(1, sizeof(char) * size);
if (srcBuf == NULL) {
fclose(src);
tjDestroy(dhandle);
unsigned long jpegSize = 0;
jpegSize = w*h*tjPixelSize[TJPF_RGB];
- srcBuf = (unsigned char *)malloc(jpegSize);
+ srcBuf = (unsigned char *)calloc(1, jpegSize);
if (srcBuf == NULL) {
mm_util_error("srcBuf is NULL");
} else if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422) {
__initBuf(srcBuf, w, h, TJPF_GRAY, flags);
} else {
- IMG_JPEG_FREE(srcBuf);
+ MMUTIL_SAFE_FREE(srcBuf);
mm_util_error("[%s][%05d] We can't support the IMAGE format");
return;
}
mm_util_error("fmt:%d is wrong", fmt);
}
- IMG_JPEG_FREE(srcBuf);
+ MMUTIL_SAFE_FREE(srcBuf);
}
static int __mm_image_encode_to_jpeg_file_with_libjpeg_turbo(const char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
mm_util_debug("jpeg_start_compress");
if (flag) {
- void *large_rect = malloc(width);
- void *small_rect = malloc(width);
+ void *large_rect = calloc(1, width);
+ void *small_rect = calloc(1, width);
if (large_rect) {
memset(large_rect, 0x10, width);
} else {
- IMG_JPEG_FREE(small_rect);
+ MMUTIL_SAFE_FREE(small_rect);
fclose(fpWriter);
mm_util_error("large rectangle memory");
return MM_UTIL_ERROR_INVALID_PARAMETER;
if (small_rect) {
memset(small_rect, 0x80, width);
} else {
- IMG_JPEG_FREE(large_rect);
+ MMUTIL_SAFE_FREE(large_rect);
fclose(fpWriter);
mm_util_error("small rectangle memory");
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
}
jpeg_write_raw_data(&cinfo, data, 16);
- IMG_JPEG_FREE(large_rect);
- IMG_JPEG_FREE(small_rect);
+ MMUTIL_SAFE_FREE(large_rect);
+ MMUTIL_SAFE_FREE(small_rect);
} else {
for (j = 0; j < height; j += 16) {
for (i = 0; i < 16; i++) {
mm_util_debug("jpeg_start_compress");
if (flag) {
- void *large_rect = malloc(width);
- void *small_rect = malloc(width);
+ void *large_rect = calloc(1, width);
+ void *small_rect = calloc(1, width);
if (large_rect) {
memset(large_rect, 0x10, width);
} else {
- IMG_JPEG_FREE(small_rect);
+ MMUTIL_SAFE_FREE(small_rect);
mm_util_error("large rectangle memory");
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
if (small_rect) {
memset(small_rect, 0x80, width);
} else {
- IMG_JPEG_FREE(large_rect);
+ MMUTIL_SAFE_FREE(large_rect);
mm_util_error("small rectangle memory");
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
}
}
jpeg_write_raw_data(&cinfo, data, 16);
- IMG_JPEG_FREE(large_rect);
- IMG_JPEG_FREE(small_rect);
+ MMUTIL_SAFE_FREE(large_rect);
+ MMUTIL_SAFE_FREE(small_rect);
} else {
for (j = 0; j < height; j += 16) {
for (i = 0; i < 16; i++) {
/* If we get here, the JPEG code has signaled an error. We need to clean up the JPEG object, close the input file, and return.*/
mm_util_debug("setjmp");
jpeg_destroy_decompress(&dinfo);
- IMG_JPEG_FREE(decoded_data->data);
+ MMUTIL_SAFE_FREE(decoded_data->data);
fclose(infile);
mm_util_debug("fclose");
return MM_UTIL_ERROR_INVALID_PARAMETER;
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
- decoded_data->data = (void *) g_malloc0(decoded_data->size);
+ decoded_data->data = (void *) calloc(1, decoded_data->size);
decoded_data->format = input_fmt;
if (decoded_data->data == NULL) {
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. We need to clean up the JPEG object, close the input file, and return.*/
mm_util_debug("setjmp");
- IMG_JPEG_FREE(decoded_data->data);
+ MMUTIL_SAFE_FREE(decoded_data->data);
jpeg_destroy_decompress(&dinfo);
return MM_UTIL_ERROR_NO_SUCH_FILE;
}
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
- decoded_data->data = (void *) g_malloc0(decoded_data->size);
+ decoded_data->data = (void *) calloc(1, decoded_data->size);
decoded_data->format = input_fmt;
if (decoded_data->data == NULL) {
unsigned int dst_size = 0;
ret = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
unsigned char *dst = NULL;
- dst = malloc(dst_size);
+ dst = calloc(1, dst_size);
if (dst) {
ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
ret = __mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
} else {
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
unsigned int dst_size = 0;
ret = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
unsigned char *dst = NULL;
- dst = malloc(dst_size);
+ dst = calloc(1, dst_size);
if (dst) {
ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
ret = __mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
} else {
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
mm_util_error("fail mm_util_get_image_size");
unsigned char *dst = NULL;
- dst = malloc(dst_size);
+ dst = calloc(1, dst_size);
if (dst) {
ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
- IMG_JPEG_FREE(decoded->data);
- decoded->data = malloc(dst_size);
+ MMUTIL_SAFE_FREE(decoded->data);
+ decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
memcpy(decoded->data, dst, dst_size);
decoded->size = dst_size;
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
} else {
mm_util_debug("memory allocation failed");
TTRACE_END();
if (err != MM_UTIL_ERROR_NONE)
mm_util_error("fail mm_util_get_image_size");
- dst = malloc(dst_size);
+ dst = calloc(1, dst_size);
if (dst) {
ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
- IMG_JPEG_FREE(decoded->data);
- decoded->data = malloc(dst_size);
+ MMUTIL_SAFE_FREE(decoded->data);
+ decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
memcpy(decoded->data, dst, dst_size);
decoded->size = dst_size;
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
} else {
mm_util_debug("memory allocation failed");
TTRACE_END();
mm_util_error("fail mm_util_get_image_size");
unsigned char *dst = NULL;
- dst = malloc(dst_size);
+ dst = calloc(1, dst_size);
if (dst) {
ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
- IMG_JPEG_FREE(decoded->data);
- decoded->data = malloc(dst_size);
+ MMUTIL_SAFE_FREE(decoded->data);
+ decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
memcpy(decoded->data, dst, dst_size);
decoded->size = dst_size;
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
} else {
mm_util_debug("memory allocation failed");
TTRACE_END();
if (err != MM_UTIL_ERROR_NONE)
mm_util_error("fail mm_util_get_image_size");
- dst = malloc(dst_size);
+ dst = calloc(1, dst_size);
if (dst) {
ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
- IMG_JPEG_FREE(decoded->data);
- decoded->data = malloc(dst_size);
+ MMUTIL_SAFE_FREE(decoded->data);
+ decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
mm_util_debug("memory allocation failed");
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
TTRACE_END();
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
memcpy(decoded->data, dst, dst_size);
decoded->size = dst_size;
- IMG_JPEG_FREE(dst);
+ MMUTIL_SAFE_FREE(dst);
} else {
mm_util_debug("memory allocation failed");
TTRACE_END();
mm_util_jpeg_testsuite_SOURCES = mm_util_jpeg_testsuite.c
mm_util_jpeg_testsuite_CFLAGS = -I$(srcdir)/../include \
- -I$(srcdir)/../../imgp/include
+ -I$(srcdir)/../../common/include
mm_util_jpeg_testsuite_CFLAGS += $(MEDIA_CFLAGS) \
-fPIE -pie \
$(TZ_PLATFORM_CONFIG_FLAGS)
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <mm_util_jpeg.h>
-#include <mm_util_imgp.h>
#include <tzplatform_config.h>
#define ENCODE_RESULT_PATH tzplatform_mkpath(TZ_USER_CONTENT, "encode_test.jpg")
file_size = ftell(fp);
if (file_size > -1L) {
rewind(fp);
- *data = (void *)malloc(file_size);
+ *data = (void *)calloc(1, file_size);
if (*data == NULL) {
- fprintf(stderr, "\tmalloc failed %d\n", errno);
+ fprintf(stderr, "\tmemory allocation failed %d\n", errno);
fclose(fp);
fp = NULL;
return FALSE;
BuildRequires: libjpeg-turbo-devel
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-media-tool)
-BuildRequires: pkgconfig(libtbm)
BuildRequires: pkgconfig(opencv)
-BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(ttrace)
BuildRequires: libpng-devel
BuildRequires: giflib-devel
lib_LTLIBRARIES = libmmutil_png.la
installmmutil_pngdir = $(includedir)/mmf
-installmmutil_png_HEADERS = include/mm_util_png.h
+installmmutil_png_HEADERS = include/mm_util_png.h \
+ ../common/include/mm_util_type.h
libmmutil_png_la_SOURCES = mm_util_png.c
libmmutil_png_la_CFLAGS = -I$(srcdir)/include \
- -I$(srcdir)/../imgp/include \
+ -I$(srcdir)/../common/include \
$(GLIB_CFLAGS) \
$(MEDIA_CFLAGS) \
-I/usr/include \
- $(SYSTEMINFO_CFLAGS) \
$(srcdir)/../imgp/libmmutil_imgp.la
libmmutil_png_la_LIBADD = $(GLIB_LIBS) -lpng -ldl -lttrace\
$(GMODULE_LIBS) \
- $(SYSTEMINFO_LIBS)\
$(MEDIA_LIBS)
libmmutil_png_la_CFLAGS += -DLIBPREFIX=\"$(libdir)\"
#ifdef __cplusplus
extern "C" {
#endif
-#include "mm_util_imgp.h"
#include "png.h"
+#include "mm_util_type.h"
/**
@addtogroup UTILITY
*
*/
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
#include <stdio.h> /* fopen() */
-#include <system_info.h>
#include <glib.h>
#include "mm_util_png.h"
-#include "mm_util_debug.h"
+#include "mm_util_private.h"
#define MM_UTIL_PNG_BYTES_TO_CHECK 4
#define MM_UTIL_PROGRESSIVE_BYTES_DEFAULT 1024
mm_util_png_testsuite_SOURCES = mm_util_png_testsuite.c
mm_util_png_testsuite_CFLAGS = -I$(srcdir)/../include \
- -I$(srcdir)/../../imgp/include
+ -I$(srcdir)/../../common/include
mm_util_png_testsuite_CFLAGS += $(MEDIA_CFLAGS) \
-fPIE -pie \
$(TZ_PLATFORM_CONFIG_FLAGS)
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <mm_util_png.h>
#define DECODE_RESULT_PATH "/media/decode_test."
file_size = ftell(fp);
if (file_size > -1L) {
rewind(fp);
- *data = (void *)malloc(file_size);
+ *data = (void *)calloc(1, file_size);
if (*data == NULL) {
- fprintf(stderr, "\tmalloc failed %d\n", errno);
+ fprintf(stderr, "\tmemory allocation failed %d\n", errno);
fclose(fp);
fp = NULL;
return FALSE;
snprintf(filename, BUFFER_SIZE, "%s%s", DECODE_RESULT_PATH, "png");
}
- data = malloc(decoded_data.size);
+ data = calloc(1, decoded_data.size);
memcpy(data, decoded_data.data, decoded_data.size);
mm_util_init_encode_png(&encoded_data);