1. [imgcv] Removed mmlog 44/51744/3
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 13 Nov 2015 10:59:53 +0000 (19:59 +0900)
committerhj kim <backto.kim@samsung.com>
Wed, 2 Dec 2015 05:17:22 +0000 (21:17 -0800)
2. [imgcv] Relplaced MM_ERR_XX to MM_UTIL_ERROR_XXX
3. [imgcv] Fixed mm_util_imgcv_testsuite

Change-Id: Id7adb7999184ec67821389682008a380c881eb35
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
imgcv/Makefile.am
imgcv/include/mm_util_imgcv.h
imgcv/include/mm_util_imgcv_internal.h
imgcv/mm_util_imgcv.c
imgcv/test/Makefile.am
imgcv/test/mm_util_imgcv_testsuite.c
packaging/libmm-utility.spec

index 51f0f21..4853a9e 100755 (executable)
@@ -9,23 +9,24 @@ noinst_HEADERS = include/mm_util_imgcv_internal.h
 libmmutil_imgcv_la_SOURCES = mm_util_imgcv.c
 
 libmmutil_imgcv_la_CFLAGS = -I$(srcdir)/include \
-                          -I$(includedir)/drm \
-                          $(MMCOMMON_CFLAGS) \
-                           $(GLIB_CFLAGS) \
-                           $(GMODULE_CFLAGS) \
-                                                  $(OPENCV_CFLAGS) \
-                           $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\"
+                               -I$(srcdir)/../imgp/include \
+                               $(MMCOMMON_CFLAGS) \
+                               $(GLIB_CFLAGS) \
+                               $(GMODULE_CFLAGS) \
+                               $(MEDIA_CFLAGS) \
+                               $(OPENCV_CFLAGS) \
+                               $(srcdir)/../imgp/libmmutil_imgp.la
 
 libmmutil_imgcv_la_LIBADD = $(MMCOMMON_LIBS) \
-                           $(GLIB_LIBS) \
-                           $(GMODULE_LIBS) \
-                                                  $(OPENCV_LIBS) \
-                           $(MMLOG_LIBS)
+                               $(GLIB_LIBS) \
+                               $(GMODULE_LIBS) \
+                               $(MEDIA_LIBS) \
+                               $(OPENCV_LIBS)
 
-libmmutil_imgcv_la_CFLAGS += -lttrace $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -DLIBPREFIX=\"$(libdir)\"
+libmmutil_imgcv_la_CFLAGS += -lttrace -DLIBPREFIX=\"$(libdir)\"
 
 pcfiles = mmutil-imgcv.pc
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = $(pcfiles)
 EXTRA_DIST = $(pcfiles)
-#SUBDIRS = . test
+SUBDIRS = . test
index 911ade1..22058ab 100755 (executable)
@@ -25,8 +25,6 @@
 extern "C" {
 #endif
 
-#include <mm_types.h>
-
 /**
     @addtogroup UTILITY
     @{
index 5dfa43d..b3e2cbb 100755 (executable)
 #include <stdlib.h>
 #include <string.h>
 
-#include <glib.h>
-#include "mm_util_imgcv.h"
-
 #ifdef __cplusplus
        extern "C" {
 #endif
 
-#include <gmodule.h>
-#include <mm_debug.h>
-#include <mm_types.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>
-
 #include <opencv/cv.h>
 #include <opencv2/imgproc/imgproc_c.h>
 
index e0d1257..587846b 100755 (executable)
  */
 #include <limits.h>
 #include <math.h>
-#include <mm_debug.h>
+#include "mm_util_debug.h"
+#include "mm_util_imgp.h"
 #include "mm_util_imgcv.h"
 #include "mm_util_imgcv_internal.h"
 #include <gmodule.h>
-#include <mm_error.h>
 #ifdef ENABLE_TTRACE
 #include <ttrace.h>
 #define TTRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_IMAGE, NAME)
 
 static int _mm_util_imgcv_init(mm_util_imgcv_s *handle, int width, int height)
 {
-       debug_log("Enter _mm_util_imgcv_init");
+       mm_util_debug("Enter _mm_util_imgcv_init");
 
        handle->width = width;
        handle->height = height;
 
        handle->inImg = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, RGB_COLOR_CHANNELS);
        if (handle->inImg == NULL) {
-               return MM_ERROR_IMAGE_INTERNAL;
+               return MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
        handle->hBins = DEFAULT_NUM_HBINS;
@@ -73,44 +73,44 @@ static int _mm_util_imgcv_init(mm_util_imgcv_s *handle, int width, int height)
        handle->vRanges[0] = 0;
        handle->vRanges[1] = DEFAULT_RANGE_VALUE;
 
-       debug_log("Leave _mm_util_imgcv_uninit");
+       mm_util_debug("Leave _mm_util_imgcv_uninit");
 
-       return MM_ERROR_NONE;
+       return MM_UTIL_ERROR_NONE;
 }
 
 static void _mm_util_imgcv_uninit(mm_util_imgcv_s *handle)
 {
-       debug_log("Enter _mm_util_imgcv_uninit");
+       mm_util_debug("Enter _mm_util_imgcv_uninit");
 
        if (handle->inImg != NULL) {
                cvReleaseImageHeader(&handle->inImg);
                handle->inImg = NULL;
        }
 
-       debug_log("Leave _mm_util_imgcv_uninit");
+       mm_util_debug("Leave _mm_util_imgcv_uninit");
 }
 
 static int _mm_util_imgcv_set_buffer(mm_util_imgcv_s *handle, void *image_buffer)
 {
-       debug_log("Enter _mm_util_imgcv_set_buffer");
+       mm_util_debug("Enter _mm_util_imgcv_set_buffer");
 
        unsigned char *buffer = (unsigned char *)image_buffer;
 
-       debug_log("image_buffer [%p], width [%d]", buffer, handle->width);
+       mm_util_debug("image_buffer [%p], width [%d]", buffer, handle->width);
 
        cvSetData(handle->inImg, buffer, RGB_COLOR_CHANNELS*(handle->width));
        if (handle->inImg == NULL) {
-               return  MM_ERROR_IMAGE_INTERNAL;
+               return  MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       debug_log("Leave _mm_util_imgcv_set_buffer");
+       mm_util_debug("Leave _mm_util_imgcv_set_buffer");
 
-       return MM_ERROR_NONE;
+       return MM_UTIL_ERROR_NONE;
 }
 
 static void _convert_hsv_to_rgb(int hVal, int sVal, int vVal, float *rVal, float *gVal, float *bVal)
 {
-       debug_log("Enter _convert_hsv_to_rgb");
+       mm_util_debug("Enter _convert_hsv_to_rgb");
 
        CvMat *mat1 = cvCreateMat(1,1,CV_8UC3);
        cvSet2D(mat1, 0, 0, cvScalar((double)hVal, (double)sVal, (double)vVal, 0.0));
@@ -124,15 +124,15 @@ static void _convert_hsv_to_rgb(int hVal, int sVal, int vVal, float *rVal, float
        *gVal = (float)bgr.val[1];
        *rVal = (float)bgr.val[2];
 
-       debug_log("from HSV[%f, %f, %f]", (float)hVal, (float)sVal, (float)vVal);
-       debug_log("to BGR[%f, %f, %f]", *bVal, *gVal, *rVal);
+       mm_util_debug("from HSV[%f, %f, %f]", (float)hVal, (float)sVal, (float)vVal);
+       mm_util_debug("to BGR[%f, %f, %f]", *bVal, *gVal, *rVal);
 
-       debug_log("Leave _convert_hsv_to_rgb");
+       mm_util_debug("Leave _convert_hsv_to_rgb");
 }
 
 static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b)
 {
-       debug_log("Enter _mm_util_imgcv_calculate_hist");
+       mm_util_debug("Enter _mm_util_imgcv_calculate_hist");
 
        int nh = 0;
        int ns = 0;
@@ -155,8 +155,8 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
        IplImage *vImg = cvCreateImage(cvSize(handle->width, handle->height), IPL_DEPTH_8U, 1);
 
        if (!hsvImg || !hImg || !sImg || !vImg) {
-               debug_error("fail to cvCreateImage()\n");
-               return MM_ERROR_IMAGE_INTERNAL;
+               mm_util_error("fail to cvCreateImage()\n");
+               return MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
        IplImage *planes [] = {hImg, sImg, vImg};
@@ -170,7 +170,7 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
        /* create histogram*/
        CvHistogram *hist = cvCreateHist(HISTOGRAM_CHANNELS, histsize, CV_HIST_ARRAY, ranges, 1);
        if (hist == NULL) {
-               return MM_ERROR_IMAGE_INTERNAL;
+               return MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
        cvCalcHist(planes, hist, 0, NULL);
@@ -196,8 +196,8 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
 
        _convert_hsv_to_rgb(hVal, sVal, vVal, &rVal, &gVal, &bVal);
 
-       debug_log("nh[%d], ns[%d], nv[%d]\n", max_bin_idx[0], max_bin_idx[1], max_bin_idx[2]);
-       debug_log("h[%d], s[%d], v[%d]\n", hVal, sVal, vVal);
+       mm_util_debug("nh[%d], ns[%d], nv[%d]\n", max_bin_idx[0], max_bin_idx[1], max_bin_idx[2]);
+       mm_util_debug("h[%d], s[%d], v[%d]\n", hVal, sVal, vVal);
        *rgb_r = rVal;
        *rgb_g = gVal;
        *rgb_b = bVal;
@@ -209,56 +209,56 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
 
        cvReleaseHist(&hist);
 
-       debug_log("Leave _mm_util_imgcv_calculate_hist");
+       mm_util_debug("Leave _mm_util_imgcv_calculate_hist");
 
-       return MM_ERROR_NONE;
+       return MM_UTIL_ERROR_NONE;
 }
 
 int mm_util_cv_extract_representative_color(void *image_buffer, int width, int height, unsigned char *r_color, unsigned char *g_color, unsigned char *b_color)
 {
-       debug_log("Enter mm_util_cv_extract_representative_color");
+       mm_util_debug("Enter mm_util_cv_extract_representative_color");
        if (image_buffer == NULL) {
-               debug_error("#ERROR#: image buffer is NULL");
+               mm_util_error("#ERROR#: image buffer is NULL");
 
-               return MM_ERROR_IMAGE_INVALID_VALUE;
+               return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
        mm_util_imgcv_s *handle = (mm_util_imgcv_s *)malloc(sizeof(mm_util_imgcv_s));
        if (handle == NULL) {
-               debug_error("#ERROR#: fail to create handle");
+               mm_util_error("#ERROR#: fail to create handle");
 
-               return MM_ERROR_IMAGE_NO_FREE_SPACE;
+               return MM_UTIL_ERROR_OUT_OF_MEMORY;
        }
 
        int ret = _mm_util_imgcv_init(handle, width, height);
-       if (ret != MM_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                _mm_util_imgcv_uninit(handle);
                free(handle);
                handle = NULL;
 
-               debug_error("#ERROR#: Fail to mm_util_imgcv_init: ret=%d", ret);
+               mm_util_error("#ERROR#: Fail to mm_util_imgcv_init: ret=%d", ret);
 
                return ret;
        }
 
        ret = _mm_util_imgcv_set_buffer(handle, image_buffer);
-       if (ret != MM_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                _mm_util_imgcv_uninit(handle);
                free(handle);
                handle = NULL;
 
-               debug_error("#ERROR#: Fail to mm_util_imgcv_set_buffer: ret=%d", ret);
+               mm_util_error("#ERROR#: Fail to mm_util_imgcv_set_buffer: ret=%d", ret);
 
                return ret;
        }
 
        ret = _mm_util_imgcv_calculate_hist(handle, r_color, g_color, b_color);
-       if (ret != MM_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                _mm_util_imgcv_uninit(handle);
                free(handle);
                handle = NULL;
 
-               debug_error("#ERROR#: Fail to mm_util_imgcv_calculate_hist: ret=%d", ret);
+               mm_util_error("#ERROR#: Fail to mm_util_imgcv_calculate_hist: ret=%d", ret);
 
                return ret;
        }
@@ -268,7 +268,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h
        free(handle);
        handle = NULL;
 
-       debug_log("Leave mm_util_cv_extract_representative_color");
+       mm_util_debug("Leave mm_util_cv_extract_representative_color");
 
-       return MM_ERROR_NONE;
+       return MM_UTIL_ERROR_NONE;
 }
index 2b65344..1b5733c 100755 (executable)
@@ -3,10 +3,11 @@ bin_PROGRAMS = mm_util_imgcv_testsuite
 mm_util_imgcv_testsuite_SOURCES = mm_util_imgcv_testsuite.c
 
 mm_util_imgcv_testsuite_CFLAGS = -I$(srcdir)/../include \
-                                                                -I$(srcdir)/../../jpeg/include \
-                                 $(MMCOMMON_CFLAGS) \
-                                 $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -fPIE -pie
+                                                               -I$(srcdir)/../../jpeg/include \
+                                                               -I$(srcdir)/../../imgp/include
 
+mm_util_imgcv_testsuite_CFLAGS += $(MMCOMON_CFLAGS) \
+                                                               -fPIE -pie
 ############################################
 
 mm_util_imgcv_testsuite_DEPENDENCIES = $(srcdir)/../libmmutil_imgcv.la
index b1e9a18..5494de3 100755 (executable)
 #include <stdlib.h>
 #include <string.h>
 
-#include "mm_util_jpeg.h"
+#include <mm_util_jpeg.h>
 #include <mm_util_imgcv.h>
 #include <mm_util_imgcv_internal.h>
-#include <mm_error.h>
 
 #define MAX_FILENAME_LEN 1024
 
@@ -42,18 +41,17 @@ int main(int argc, char *argv[])
        char filename [MAX_FILENAME_LEN];
 
        if (argc < 1) {
-               debug_error("[%s][%05d] Usage: ./mm_imgcv_testsuite filename(jpg format only)\n");
+               fprintf(stderr, "Usage: ./mm_imgcv_testsuite filename(jpg format only)\n");
                return ret;
        }
 
        len = strlen(argv[1]);
        if (len > MAX_FILENAME_LEN) {
-               debug_error("[%s] filename is too long\n");
+               fprintf(stderr, "filename is too long\n");
                return -1;
        }
 
        strncpy(filename, argv[1], len);
-       debug_log("Filename is %s\n", filename);
 
        /* decode jpg image */
        mm_util_jpeg_yuv_data decoded;
@@ -61,26 +59,26 @@ int main(int argc, char *argv[])
 
        ret = mm_util_decode_from_jpeg_file(&decoded, filename, MM_UTIL_JPEG_FMT_RGB888);
 
-       if (ret == MM_ERROR_NONE) {
+       if (!ret) {
                img_buffer = decoded.data;
                width = decoded.width;
                height = decoded.height;
                img_buffer_size = decoded.size;
-               debug_log("Success - buffer[%p], width[%d], height[%d], size[%d]",
+               fprintf(stderr, "Success - buffer[%p], width[%d], height[%d], size[%d]",
                                                                img_buffer, width, height, img_buffer_size);
        } else {
-               debug_log("ERROR - Fail to decode jpeg image file");
+               fprintf(stderr, "ERROR - Fail to decode jpeg image file");
                return ret;
        }
 
        /* extract color */
        unsigned char rgb_r, rgb_g, rgb_b;
-       ret = image_util_color_extract_from_buffer(img_buffer, width, height, MM_UTIL_IMGCV_FMT_RGB888, &rgb_r, &rgb_g, &rgb_b);
+       ret = mm_util_cv_extract_representative_color(img_buffer, width, height, &rgb_r, &rgb_g, &rgb_b);
 
-       if (ret == MM_ERROR_NONE) {
-               debug_log("Success - R[%d], G[%d], B[%d]", rgb_r, rgb_g, rgb_b);
+       if (!ret) {
+               fprintf(stderr, "Success - R[%d], G[%d], B[%d]", rgb_r, rgb_g, rgb_b);
        } else {
-               debug_log("Error - fail to extract color");
+               fprintf(stderr, "Error - fail to extract color");
        }
 
        free(img_buffer);
index 4a5c07d..715043a 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.17
+Version:    0.18
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0