Change to resize image with mm_util_image_h
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_util.c
index 49c6ebf..5fb7c21 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <inttypes.h>
 #include <sys/vfs.h> /* struct statfs */
 #include <sys/time.h> /* gettimeofday */
 #include <sys/stat.h>
@@ -34,6 +35,7 @@
 #include "mm_camcorder_internal.h"
 #include "mm_camcorder_util.h"
 #include "mm_camcorder_sound.h"
+#include <mm_util_image.h>
 #include <mm_util_imgp.h>
 #include <mm_util_jpeg.h>
 
@@ -255,7 +257,7 @@ gint _mmcamcorder_find_tag(FILE *f, guint32 tag_fourcc, gboolean do_rewind)
                uint32_t buf_fourcc = 0;
 
                if (read_item < 8) {
-                       _mmcam_dbg_err("fread failed : %d", read_item);
+                       _mmcam_dbg_err("fread failed : %zu", read_item);
                        break;
                }
 
@@ -284,7 +286,7 @@ gint _mmcamcorder_find_tag(FILE *f, guint32 tag_fourcc, gboolean do_rewind)
                                buf_size = buf_size - 8; /* include tag */
                        }
 
-                       _mmcam_dbg_log("seek %llu", buf_size);
+                       _mmcam_dbg_log("seek %"PRIu64, buf_size);
                        if (fseeko(f, (off_t)buf_size, SEEK_CUR) != 0) {
                                _mmcam_dbg_err("fseeko() fail");
                                return FALSE;
@@ -310,7 +312,7 @@ gboolean _mmcamcorder_find_fourcc(FILE *f, guint32 tag_fourcc, gboolean do_rewin
                uint32_t buf_fourcc = 0;
 
                if (read_item < 8) {
-                       _mmcam_dbg_err("fread failed : %d", read_item);
+                       _mmcam_dbg_err("fread failed : %zu", read_item);
                        break;
                }
 
@@ -345,7 +347,7 @@ gboolean _mmcamcorder_find_fourcc(FILE *f, guint32 tag_fourcc, gboolean do_rewin
                                buf_size = buf_size - 8; /* include tag */
                        }
 
-                       _mmcam_dbg_log("seek %llu", buf_size);
+                       _mmcam_dbg_log("seek %"PRIu64, buf_size);
                        if (fseeko(f, (off_t)buf_size, SEEK_CUR) != 0) {
                                _mmcam_dbg_err("fseeko() fail");
                                return FALSE;
@@ -603,7 +605,7 @@ guint64 _mmcamcorder_get_container_size(const guchar *size)
        result = result | (temp << 8);
        result = result | size[3];
 
-       _mmcam_dbg_log("result : %llu", result);
+       _mmcam_dbg_log("result : %"G_GUINT64_FORMAT, result);
 
        return result;
 }
@@ -630,7 +632,7 @@ guint64 _mmcamcorder_get_container_size64(const guchar *size)
        result = result | (temp << 8);
        result = result | size[7];
 
-       _mmcam_dbg_log("result : %llu", result);
+       _mmcam_dbg_log("result : %"G_GUINT64_FORMAT, result);
 
        return result;
 }
@@ -764,7 +766,7 @@ int _mmcamcorder_get_freespace(storage_type_e type, guint64 *free_space)
        *free_space = vfs.f_bsize * vfs.f_bavail;
        /*
        _mmcam_dbg_log("vfs.f_bsize [%lu], vfs.f_bavail [%lu]", vfs.f_bsize, vfs.f_bavail);
-       _mmcam_dbg_log("memory size %llu [%s]", *free_space, path);
+       _mmcam_dbg_log("memory size %"G_GUINT64_FORMAT" [%s]", *free_space, path);
        */
        return 0;
 }
@@ -1546,6 +1548,12 @@ unsigned int _mmcamcorder_get_fourcc(int pixtype, int codectype, int use_zero_co
        case MM_PIXEL_FORMAT_RGB888:
                fourcc = GST_MAKE_FOURCC('R', 'G', 'B', ' ');
                break;
+       case MM_PIXEL_FORMAT_RGBA:
+               fourcc = GST_MAKE_FOURCC('B', 'G', 'R', 'x');
+               break;
+       case MM_PIXEL_FORMAT_ARGB:
+               fourcc = GST_MAKE_FOURCC('x', 'R', 'G', 'B');
+               break;
        case MM_PIXEL_FORMAT_ENCODED:
                if (codectype == MM_IMAGE_CODEC_JPEG) {
                        fourcc = GST_MAKE_FOURCC('J', 'P', 'E', 'G');
@@ -1726,6 +1734,8 @@ gboolean _mmcamcorder_resize_frame(unsigned char *src_data, unsigned int src_wid
        int ret = TRUE;
        int mm_ret = MM_ERROR_NONE;
        int input_format = MM_UTIL_COLOR_YUV420;
+       mm_util_image_h src_image = NULL;
+       mm_util_image_h dst_image = NULL;
 
        if (!src_data || !dst_data || !dst_width || !dst_height || !dst_length) {
                _mmcam_dbg_err("something is NULL %p,%p,%p,%p,%p",
@@ -1760,14 +1770,26 @@ gboolean _mmcamcorder_resize_frame(unsigned char *src_data, unsigned int src_wid
 
        _mmcam_dbg_log("src size %dx%d -> dst size %dx%d", src_width, src_height, *dst_width, *dst_height);
 
-       mm_ret = mm_util_resize_image(src_data, src_width, src_height, input_format,
-               *dst_width, *dst_height, dst_data, dst_width, dst_height, dst_length);
+       mm_ret = mm_image_create_image(src_width, src_height, input_format, src_data, (size_t)src_length, &src_image);
+       if (mm_ret != MM_ERROR_NONE) {
+               GST_ERROR("mm_image_create_image failed 0x%x", ret);
+               return FALSE;
+       }
 
+       mm_ret = mm_util_resize_image(src_image, *dst_width, *dst_height, &dst_image);
+       mm_image_destroy_image(src_image);
        if (mm_ret != MM_ERROR_NONE) {
                GST_ERROR("mm_util_resize_image failed 0x%x", ret);
                return FALSE;
        }
 
+       mm_ret = mm_image_get_image(dst_image, dst_width, dst_height, NULL, dst_data, dst_length);
+       mm_image_destroy_image(dst_image);
+       if (mm_ret != MM_ERROR_NONE) {
+               GST_ERROR("mm_image_get_image failed 0x%x", ret);
+               return FALSE;
+       }
+
        _mmcam_dbg_log("resize done %dx%d -> %dx%d, %p, length %zu",
                src_width, src_height, *dst_width, *dst_height, *dst_data, *dst_length);