From: Kim Kibum Date: Sun, 29 Apr 2012 08:01:22 +0000 (+0900) Subject: upload tizen1.0 source X-Git-Tag: 2.0_alpha~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a2aab80077345c78eaa492dd20f4fd95598d74f;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git upload tizen1.0 source --- diff --git a/debian/changelog b/debian/changelog index 2e3d901..91a19d6 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libmm-utility (0.1-56) unstable; urgency=low + + * Update the exceptional image rotate + * Git: pkgs/l/libmm-utility + * Tag: libmm-utility_0.1-56 + + -- YoungHun Kim Fri, 02 Mar 2012 11:46:50 +0900 + libmm-utility (0.1-55) unstable; urgency=low * Update rotate image format diff --git a/imgp/mm_util_imgp.c b/imgp/mm_util_imgp.c index 19cfdb2..d281235 100755 --- a/imgp/mm_util_imgp.c +++ b/imgp/mm_util_imgp.c @@ -204,7 +204,7 @@ _mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_ } static gboolean -_mm_check_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format ) +_mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format ) { gboolean _bool=FALSE; mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] src_format: %d, dst_format:%d", __func__, __LINE__, src_format, dst_format); @@ -243,7 +243,7 @@ _mm_check_convert_format(mm_util_img_format src_format, mm_util_img_format dst_f } static gboolean -_mm_check_resize_format(mm_util_img_format _format) +_mm_select_resize_plugin(mm_util_img_format _format) { gboolean _bool = FALSE; mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] _format: %d", __func__, __LINE__, _format); @@ -256,18 +256,77 @@ _mm_check_resize_format(mm_util_img_format _format) } static gboolean -_mm_check_rotate_format(mm_util_img_format _format) +_mm_select_rotate_plugin(mm_util_img_format _format, unsigned int width, unsigned int height, mm_util_img_rotate_type angle) { gboolean _bool = FALSE; - mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] _format: %d", __func__, __LINE__, _format); - if( (_format == MM_UTIL_IMG_FMT_YUV420) || (_format == MM_UTIL_IMG_FMT_I420) - || (_format == MM_UTIL_IMG_FMT_NV12) || (_format == MM_UTIL_IMG_FMT_RGB565) || (_format == MM_UTIL_IMG_FMT_RGB888)) { + gboolean _rgb_Flag = FALSE; + mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] _format: %d", __func__, __LINE__, _format); + + if( _format == MM_UTIL_IMG_FMT_RGB888 ||_format == MM_UTIL_IMG_FMT_RGB565) { + unsigned int imgsize = 0; + unsigned int rotate_imgsize = 0; + mm_util_get_image_size(_format, width, height, &imgsize); + mm_util_get_image_size(_format, height, width, &rotate_imgsize); + + if( (imgsize == rotate_imgsize) ||((imgsize != rotate_imgsize) && angle == MM_UTIL_ROTATE_90) ) { //constraint of image processing because MM_UTIL_ROTATE_180 may be twice MM_UTIL_ROTATE_90 + _rgb_Flag = TRUE; + } + } + + if( (_format == MM_UTIL_IMG_FMT_YUV420) || (_format == MM_UTIL_IMG_FMT_I420) || (_format == MM_UTIL_IMG_FMT_NV12) ||(_rgb_Flag) ) { _bool = TRUE; } return _bool; } +static int +_mm_confirm_dst_width_height(unsigned int src_width, unsigned int src_height, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle) +{ + int ret = MM_ERROR_NONE; + + if(!dst_width || !dst_height) { + mmf_debug (MMF_DEBUG_ERROR, "[%s][%05d] dst_width || dst_height Buffer is NULL", __func__, __LINE__); + return MM_ERROR_IMAGE_INVALID_VALUE; + } + + switch(angle) { + case MM_UTIL_ROTATE_0: + case MM_UTIL_ROTATE_180: + case MM_UTIL_ROTATE_FLIP_HORZ: + case MM_UTIL_ROTATE_FLIP_VERT: + if(*dst_width != src_width) { + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] *dst_width: %d", __func__, __LINE__, *dst_width); + *dst_width = src_width; + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] #Confirmed# *dst_width: %d", __func__, __LINE__, *dst_width); + } + if(*dst_height != src_height) { + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] *dst_height: %d", __func__, __LINE__, *dst_height); + *dst_height = src_height; + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] #Confirmed# *dst_height: %d", __func__, __LINE__, *dst_height); + } + break; + case MM_UTIL_ROTATE_90: + case MM_UTIL_ROTATE_270: + if(*dst_width != src_height) { + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] *dst_width: %d", __func__, __LINE__, *dst_width); + *dst_width = src_height; + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] #Confirmed# *dst_width: %d", __func__, __LINE__, *dst_width); + } + if(*dst_height != src_width) { + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] *dst_height: %d", __func__, __LINE__, *dst_height); + *dst_height = src_width; + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] #Confirmed# *dst_height: %d", __func__, __LINE__, *dst_height); + } + break; + + default: + mmf_debug (MMF_DEBUG_ERROR, "[%s][%05d] Not supported rotate value\n", __func__, __LINE__); + return MM_ERROR_IMAGE_INVALID_VALUE; + } + return ret; +} + static int _mm_set_format_label(char* format_label, mm_util_img_format _format) { @@ -338,7 +397,7 @@ _mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, unsigned char *src, mm_util_img mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] src image size error", __func__, __LINE__); } mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] src_size: %d\n", __func__, __LINE__, src_size); - _imgp_info_s->src=(char*)malloc(sizeof(char*) * src_size); + _imgp_info_s->src=(unsigned char*)malloc(sizeof(char*) * src_size); if(_imgp_info_s->src == NULL) { mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] _imgp_info_s->src is NULL", __func__, __LINE__); free(_imgp_info_s->src); @@ -357,7 +416,7 @@ _mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, unsigned char *src, mm_util_img mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] dst image size error", __func__, __LINE__); } mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] dst_size: %d\n", __func__, __LINE__, dst_size); - _imgp_info_s->dst=(char*)malloc(sizeof(char*) * dst_size); + _imgp_info_s->dst=(unsigned char*)malloc(sizeof(char*) * dst_size); if(_imgp_info_s->dst == NULL) { mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] _imgp_info_s->src is NULL", __func__, __LINE__); free(_imgp_info_s->dst); @@ -365,8 +424,8 @@ _mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, unsigned char *src, mm_util_img return MM_ERROR_IMAGE_FILEOPEN; } _imgp_info_s->dst_format=dst_format; - _imgp_info_s->dst_width = dst_width; - _imgp_info_s->dst_height = dst_height; + _imgp_info_s->dst_width = dst_width; + _imgp_info_s->dst_height = dst_height; _imgp_info_s->angle= angle; mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] [input] format label : %s src: %p width: %d height: %d [output] format label: %s width: %d height: %d rotation_value: %d", @@ -426,7 +485,7 @@ _mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s) module = NULL; }else { mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] #module is NULL#", __func__, __LINE__ ); - return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT; + return MM_ERROR_IMAGE_INVALID_VALUE; } if(_imgp_info_s) { @@ -438,13 +497,11 @@ _mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s) free(_imgp_info_s->dst);_imgp_info_s->dst=NULL; } mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] #Success _imgp_info_s->dst#", __func__, __LINE__ ); - if(_imgp_info_s) { - free(_imgp_info_s); _imgp_info_s=NULL; - } + free(_imgp_info_s); _imgp_info_s=NULL; mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] #Success _imgp_info_s#", __func__, __LINE__ ); }else { mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] #_imgp_info_s is NULL#", __func__, __LINE__ ); - return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT; + return MM_ERROR_IMAGE_INVALID_VALUE; } return ret; } @@ -483,7 +540,7 @@ mm_util_convert_colorspace(unsigned char *src, unsigned int src_width, unsigned imgp_plugin_type_e _imgp_plugin_type_e=-1; /* Initialize */ - if( _mm_check_convert_format(src_format, dst_format)) { + if( _mm_select_convert_plugin(src_format, dst_format)) { _imgp_plugin_type_e = IMGP_NEON; }else { _imgp_plugin_type_e = IMGP_GSTCS; @@ -521,6 +578,9 @@ mm_util_convert_colorspace(unsigned char *src, unsigned int src_width, unsigned /* Output result*/ mm_util_get_image_size(_imgp_info_s->dst_format, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &dst_size); + mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d", + __func__, __LINE__, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation); + memcpy(dst, _imgp_info_s->dst, dst_size); /* Finalize */ @@ -563,7 +623,7 @@ mm_util_resize_image(unsigned char *src, unsigned int src_width, unsigned int sr imgp_plugin_type_e _imgp_plugin_type_e=-1; /* Initialize */ - if( _mm_check_resize_format(src_format)) { + if( _mm_select_resize_plugin(src_format)) { _imgp_plugin_type_e = IMGP_NEON; }else { _imgp_plugin_type_e = IMGP_GSTCS; @@ -603,7 +663,14 @@ mm_util_resize_image(unsigned char *src, unsigned int src_width, unsigned int sr /* Output result*/ mm_util_get_image_size(_imgp_info_s->dst_format, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &dst_size); + mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d", + __func__, __LINE__, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation); + memcpy(dst, _imgp_info_s->dst, dst_size); + mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] #Success# memcpy"); + + *dst_width = _imgp_info_s->dst_width; + *dst_height = _imgp_info_s->dst_height; /* Finalize */ ret = _mm_util_imgp_finalize(_module, _imgp_info_s); @@ -652,7 +719,7 @@ mm_util_rotate_image(unsigned char *src, unsigned int src_width, unsigned int sr imgp_plugin_type_e _imgp_plugin_type_e=-1; /* Initialize */ - if( _mm_check_rotate_format(src_format)) { + if( _mm_select_rotate_plugin(src_format, src_width, src_height, angle)) { _imgp_plugin_type_e = IMGP_NEON; }else { _imgp_plugin_type_e = IMGP_GSTCS; @@ -665,6 +732,12 @@ mm_util_rotate_image(unsigned char *src, unsigned int src_width, unsigned int sr _module = _mm_util_imgp_initialize(_imgp_plugin_type_e); } mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] _mm_set_imgp_info_s", __func__, __LINE__); + ret=_mm_confirm_dst_width_height(src_width, src_height, dst_width, dst_height, angle); + if(ret != MM_ERROR_NONE) { + mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] dst_width || dest_height size Error", __func__, __LINE__); + return MM_ERROR_IMAGE_INVALID_VALUE; + } + ret=_mm_set_imgp_info_s(_imgp_info_s, src, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle); mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] _mm_set_imgp_info_s", __func__, __LINE__); if(ret != MM_ERROR_NONE) { @@ -683,13 +756,19 @@ mm_util_rotate_image(unsigned char *src, unsigned int src_width, unsigned int sr return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT; } }else { - mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] g_module_symbol failed", __func__, __LINE__); + mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] g_module_symbol failed", __func__, __LINE__); return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT; } /* Output result*/ mm_util_get_image_size(_imgp_info_s->dst_format, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &dst_size); + mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d, dst_size: %d", + __func__, __LINE__, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation,dst_size); + memcpy(dst, _imgp_info_s->dst, dst_size); + mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] #Success# memcpy"); + *dst_width = _imgp_info_s->dst_width; + *dst_height = _imgp_info_s->dst_height; /* Finalize */ ret = _mm_util_imgp_finalize(_module, _imgp_info_s); @@ -753,7 +832,7 @@ mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned i break; case MM_UTIL_IMG_FMT_RGB888: - stride = width * 3; + stride = MM_UTIL_ROUND_UP_4 (width * 3); size = stride * height; *imgsize = size; break; @@ -786,6 +865,7 @@ mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned i mmf_debug (MMF_DEBUG_ERROR, "[%s][%05d] Not supported format\n", __func__, __LINE__); return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT; } + mmf_debug (MMF_DEBUG_LOG, "[%s][%05d] format: %d, *imgsize: %d\n", __func__, __LINE__, format, *imgsize); return ret; } diff --git a/imgp/test/mm_util_imgp_testsuite.c b/imgp/test/mm_util_imgp_testsuite.c index 467a61a..1a62b3b 100755 --- a/imgp/test/mm_util_imgp_testsuite.c +++ b/imgp/test/mm_util_imgp_testsuite.c @@ -42,17 +42,17 @@ int main(int argc, char *argv[]) char output_file[25]; unsigned int src_size = 0; unsigned int dst_size = 0; - if (argc < 5) { + if (argc < 6) { mmf_debug(MMF_DEBUG_ERROR, "[%s][%05d] Usage: ./mm_image_testsuite filename [yuv420 | yuv420p | yuv422 | uyvy | vyuy | nv12 | nv12t | rgb565 | rgb888 | argb | jpeg] width height\n", __func__, __LINE__); exit (0); } - int src_cs =atoi(argv[4]); + int src_cs =atoi(argv[6]); #if _CONVERT_ - int dst_cs = atoi(argv[5]); + int dst_cs = atoi(argv[7]); #endif #if _ROTATE_ - mm_util_img_rotate_type angle = MM_UTIL_ROTATE_FLIP_HORZ; + mm_util_img_rotate_type angle = atoi(argv[8]); #endif int ret = 0; int cnt = 0; @@ -65,6 +65,9 @@ int main(int argc, char *argv[]) src_width = atoi(argv[2]); src_height = atoi(argv[3]); + + dst_width = atoi(argv[4]); + dst_height = atoi(argv[5]); mm_util_get_image_size(src_cs, src_width, src_height, &src_size); mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] convert src buffer size=%d\n", __func__, __LINE__, src_size); @@ -72,8 +75,6 @@ int main(int argc, char *argv[]) fread(src, 1, src_size, fp); #if _ROTATE_ - dst_width = src_width ; - dst_height = src_height; mm_util_get_image_size(src_cs, dst_width, dst_height, &dst_size); dst = malloc(dst_size); mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] dst: %p", __func__, __LINE__, dst); @@ -127,10 +128,10 @@ int main(int argc, char *argv[]) MMTA_ACUM_ITEM_END("colorspace", 0); MMTA_ACUM_ITEM_SHOW_RESULT(); MMTA_RELEASE (); -#endif +#endif if(ret==0) { if(cnt == 0) { - sprintf(output_file, "result%d.rgb", cnt); + sprintf(output_file, "result%d_%dx%d.rgb", cnt, dst_width, dst_height); FILE *fpout = fopen(output_file, "w"); mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] %s = %dx%d dst_size: %d", __func__, __LINE__, output_file, src_width, src_height, dst_size); mmf_debug(MMF_DEBUG_LOG, "[%s][%05d] mm_util_convert_colorspace dst:%p ret = %d",__func__, __LINE__, dst, ret); diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 161d5ab..feb7f5a 100644 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -7,7 +7,7 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig -BuildRequires: pkgconfig(mm-common), libmm-common-internal-devel +BuildRequires: pkgconfig(mm-common) BuildRequires: pkgconfig(mm-log) BuildRequires: pkgconfig(mm-ta) BuildRequires: pkgconfig(glib-2.0) @@ -44,6 +44,7 @@ sed -i -e "s#@IMGP_REQPKG@#$IMGP_REQPKG#g" imgp/mmutil-imgp.pc sed -i -e "s#@JPEG_REQPKG@#$JPEG_REQPKG#g" jpeg/mmutil-jpeg.pc %install +rm -rf %{buildroot} %make_install %clean