Apply tizen coding rule 87/53887/1 accepted/tizen/mobile/20151210.083532 accepted/tizen/tv/20151210.083559 accepted/tizen/wearable/20151210.083614 submit/tizen/20151210.060625
authorHaejeong Kim <backto.kim@samsung.com>
Thu, 10 Dec 2015 04:58:07 +0000 (13:58 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Thu, 10 Dec 2015 04:58:24 +0000 (13:58 +0900)
Change-Id: Idfe729c9f1f474237a31ae3c0d19d09ceca8a3dd

gif/mm_util_gif.c
imgcv/mm_util_imgcv.c
imgcv/test/mm_util_imgcv_testsuite.c
imgp/mm_util_imgp.c
imgp/test/mm_util_imgp_testsuite.c
jpeg/mm_util_jpeg.c
jpeg/test/mm_util_jpeg_testsuite.c
test/mm_utility_testsuite.c

index 921bdab835934b5be2012c05f590570cf49e0ba9..2e623ead3f812c63c25ef670e6c7ed588245f126 100755 (executable)
@@ -237,11 +237,11 @@ int read_gif(mm_util_gif_data * decoded, const char *filename, void *memory)
 
        ret = MM_UTIL_ERROR_NONE;
 error:
-       if(screen_buffer) {
-               if(screen_buffer[0])
+       if (screen_buffer) {
+               if (screen_buffer[0])
                        (void)free(screen_buffer[0]);
                for (i = 1; i < GifFile->SHeight; i++) {
-                       if(screen_buffer[i])
+                       if (screen_buffer[i])
                                (void)free(screen_buffer[i]);
                }
                (void)free(screen_buffer);
index 587846b112066b9efd73d1340313891181fcd55d..8a6a2f6818267b7eae46e3f5bb242063df835e1a 100755 (executable)
@@ -112,10 +112,10 @@ static void _convert_hsv_to_rgb(int hVal, int sVal, int vVal, float *rVal, float
 {
        mm_util_debug("Enter _convert_hsv_to_rgb");
 
-       CvMat *mat1 = cvCreateMat(1,1,CV_8UC3);
+       CvMat *mat1 = cvCreateMat(1, 1 , CV_8UC3);
        cvSet2D(mat1, 0, 0, cvScalar((double)hVal, (double)sVal, (double)vVal, 0.0));
 
-       CvMat *mat2 = cvCreateMat(1,1,CV_8UC3);
+       CvMat *mat2 = cvCreateMat(1, 1, CV_8UC3);
 
        cvCvtColor(mat1, mat2, CV_HSV2BGR);
 
@@ -143,8 +143,8 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
        int vVal = 0;
 
        float rVal = 0.f;
-    float gVal = 0.f;
-    float bVal = 0.f;
+       float gVal = 0.f;
+       float bVal = 0.f;
 
        unsigned int maxBinVal = 0;
        int max_bin_idx[3] = {-1, -1, -1};
@@ -159,7 +159,7 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
                return MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       IplImage *planes [] = {hImg, sImg, vImg};
+       IplImage *planes[] = {hImg, sImg, vImg};
 
        cvCvtColor(handle->inImg, hsvImg, CV_RGB2HSV);
        cvSplit(hsvImg, hImg, sImg, vImg, NULL);
@@ -175,10 +175,10 @@ static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char
 
        cvCalcHist(planes, hist, 0, NULL);
 
-       for (nh=0; nh<(handle->hBins); nh++) {
-               for (ns=0; ns<(handle->sBins); ns++) {
-                       for (nv=0; nv<(handle->vBins); nv++) {
-                               unsigned int binVal = (unsigned int)cvGetReal3D( (hist)->bins, nh, ns, nv);
+       for (nh = 0; nh < (handle->hBins); nh++) {
+               for (ns = 0; ns < (handle->sBins); ns++) {
+                       for (nv = 0; nv < (handle->vBins); nv++) {
+                               unsigned int binVal = (unsigned int)cvGetReal3D((hist)->bins, nh, ns, nv);
                                if (binVal > maxBinVal) {
                                        maxBinVal = binVal;
                                        max_bin_idx[0] = nh;
index 5494de360ff9a73fb4e77d044cb3ddc60f06df87..2b3e08dd546659700a87842c82103fbd871d32bd 100755 (executable)
@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
        unsigned char *img_buffer;
        unsigned int  img_buffer_size;
 
-       char filename [MAX_FILENAME_LEN];
+       char filename[MAX_FILENAME_LEN];
 
        if (argc < 1) {
                fprintf(stderr, "Usage: ./mm_imgcv_testsuite filename(jpg format only)\n");
index 5ce6d77beaa08e2fbe25f086cbf8790f0287203a..60fb22403cfe67b9fd9e5280e808447cc30850f6 100755 (executable)
@@ -37,8 +37,8 @@
 #define MM_UTIL_ROUND_UP_8(num) (((num)+7)&~7)
 #define MM_UTIL_ROUND_UP_16(num) (((num)+15)&~15)
 #define GEN_MASK(x) ((1<<(x))-1)
-#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
-#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
+#define ROUND_UP_X(v, x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
+#define DIV_ROUND_UP_X(v, x) (((v) + GEN_MASK(x)) >> (x))
 #define GST "gstcs"
 
 typedef gboolean(*IMGPInfoFunc) (imgp_info_s*, const unsigned char*, unsigned char*, imgp_plugin_type_e);
@@ -46,7 +46,7 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
 
 static int check_valid_picture_size(int width, int height)
 {
-       if((int)width>0 && (int)height>0 && (width+128)*(unsigned long long)(height+128) < INT_MAX/4) {
+       if ((int)width > 0 && (int)height > 0 && (width + 128)*(unsigned long long)(height + 128) < INT_MAX/4) {
                return MM_UTIL_ERROR_NONE;
        }
 
@@ -57,18 +57,18 @@ static void __mm_destroy_temp_buffer(unsigned char *buffer[])
 {
        int i = 0;
 
-       for(i = 0; i < 4; i++) {
+       for (i = 0; i < 4; i++) {
                IMGP_FREE(buffer[i]);
        }
 }
 
-static gboolean __mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format )
+static gboolean __mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format)
 {
-       gboolean _bool=FALSE;
+       gboolean _bool = FALSE;
 
        mm_util_debug("src_format: %d, dst_format:%d", src_format, dst_format);
 
-       if((dst_format == MM_UTIL_IMG_FMT_NV16) || (dst_format == MM_UTIL_IMG_FMT_NV61) ||
+       if ((dst_format == MM_UTIL_IMG_FMT_NV16) || (dst_format == MM_UTIL_IMG_FMT_NV61) ||
                ((src_format == MM_UTIL_IMG_FMT_YUV422) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
                ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
                ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
@@ -81,7 +81,7 @@ static gboolean __mm_cannot_convert_format(mm_util_img_format src_format, mm_uti
                ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUYV)) ||
                ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
                ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
-               ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRX8888)) ) {
+               ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRX8888))) {
 
                _bool = TRUE;
        }
@@ -93,18 +93,18 @@ static gboolean __mm_gst_can_resize_format(char* __format_label)
 {
        gboolean _bool = FALSE;
 
-       mm_util_debug("Format label: %s",__format_label);
+       mm_util_debug("Format label: %s", __format_label);
 
-       if(strcmp(__format_label, "AYUV") == 0
-               || strcmp(__format_label, "UYVY") == 0 ||strcmp(__format_label, "Y800") == 0 || strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0
+       if (strcmp(__format_label, "AYUV") == 0
+               || strcmp(__format_label, "UYVY") == 0 || strcmp(__format_label, "Y800") == 0 || strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0
                || strcmp(__format_label, "RGB888") == 0 || strcmp(__format_label, "RGB565") == 0 || strcmp(__format_label, "BGR888") == 0 || strcmp(__format_label, "RGBA8888") == 0
-               || strcmp(__format_label, "ARGB8888") == 0 ||strcmp(__format_label, "BGRA8888") == 0 || strcmp(__format_label, "ABGR8888") == 0 || strcmp(__format_label, "RGBX") == 0
+               || strcmp(__format_label, "ARGB8888") == 0 || strcmp(__format_label, "BGRA8888") == 0 || strcmp(__format_label, "ABGR8888") == 0 || strcmp(__format_label, "RGBX") == 0
                || strcmp(__format_label, "XRGB") == 0 || strcmp(__format_label, "BGRX") == 0 || strcmp(__format_label, "XBGR") == 0 || strcmp(__format_label, "Y444") == 0
                || strcmp(__format_label, "Y42B") == 0 || strcmp(__format_label, "YUY2") == 0 || strcmp(__format_label, "YUYV") == 0 || strcmp(__format_label, "UYVY") == 0
                || strcmp(__format_label, "Y41B") == 0 || strcmp(__format_label, "Y16") == 0 || strcmp(__format_label, "Y800") == 0 || strcmp(__format_label, "Y8") == 0
                || strcmp(__format_label, "GREY") == 0 || strcmp(__format_label, "AY64") == 0 || strcmp(__format_label, "YUV422") == 0) {
 
-               _bool=TRUE;
+               _bool = TRUE;
        }
 
        return _bool;
@@ -116,25 +116,25 @@ static gboolean __mm_gst_can_rotate_format(const char* __format_label)
 
        mm_util_debug("Format label: %s boolean: %d", __format_label, _bool);
 
-       if(strcmp(__format_label, "I420") == 0 ||strcmp(__format_label, "YV12") == 0 || strcmp(__format_label, "IYUV") == 0
-               || strcmp(__format_label, "RGB888") == 0||strcmp(__format_label, "BGR888") == 0 ||strcmp(__format_label, "RGBA8888") == 0
-               || strcmp(__format_label, "ARGB8888") == 0 ||strcmp(__format_label, "BGRA8888") == 0 ||strcmp(__format_label, "ABGR8888") == 0 ) {
+       if (strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0 || strcmp(__format_label, "IYUV") == 0
+               || strcmp(__format_label, "RGB888") == 0 || strcmp(__format_label, "BGR888") == 0 || strcmp(__format_label, "RGBA8888") == 0
+               || strcmp(__format_label, "ARGB8888") == 0 || strcmp(__format_label, "BGRA8888") == 0 || strcmp(__format_label, "ABGR8888") == 0) {
 
-               _bool=TRUE;
+               _bool = TRUE;
        }
 
-       mm_util_debug("boolean: %d",_bool);
+       mm_util_debug("boolean: %d", _bool);
 
        return _bool;
 }
 
-static gboolean __mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format )
+static gboolean __mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format)
 {
-       gboolean _bool=FALSE;
+       gboolean _bool = FALSE;
 
        mm_util_debug("src_format: %d, dst_format:%d", src_format, dst_format);
 
-       if(((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
+       if (((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
                ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
                ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
                ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
@@ -222,7 +222,7 @@ static gboolean __mm_select_rotate_plugin(mm_util_img_format _format, unsigned i
        mm_util_debug("_format: %d (angle: %d)", _format, angle);
 
        if ((_format == MM_UTIL_IMG_FMT_YUV420) || (_format == MM_UTIL_IMG_FMT_I420) || (_format == MM_UTIL_IMG_FMT_NV12)
-               ||(_format == MM_UTIL_IMG_FMT_RGB888 ||_format == MM_UTIL_IMG_FMT_RGB565)) {
+               || (_format == MM_UTIL_IMG_FMT_RGB888  || _format == MM_UTIL_IMG_FMT_RGB565)) {
                return TRUE;
        }
 
@@ -269,18 +269,17 @@ int __mm_util_get_buffer_size(mm_util_img_format format, unsigned int width, uns
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       switch (format)
-       {
+       switch (format) {
                case MM_UTIL_IMG_FMT_I420:
                case MM_UTIL_IMG_FMT_YUV420:
                        x_chroma_shift = 1;
                        y_chroma_shift = 1;
-                       stride = MM_UTIL_ROUND_UP_4 (width);
-                       h2 = ROUND_UP_X (height, x_chroma_shift);
+                       stride = MM_UTIL_ROUND_UP_4(width);
+                       h2 = ROUND_UP_X(height, x_chroma_shift);
                        size = stride * h2;
-                       w2 = DIV_ROUND_UP_X (width, x_chroma_shift);
-                       stride2 = MM_UTIL_ROUND_UP_4 (w2);
-                       h2 = DIV_ROUND_UP_X (height, y_chroma_shift);
+                       w2 = DIV_ROUND_UP_X(width, x_chroma_shift);
+                       stride2 = MM_UTIL_ROUND_UP_4(w2);
+                       h2 = DIV_ROUND_UP_X(height, y_chroma_shift);
                        size2 = stride2 * h2;
                        *imgsize = size + 2 * size2;
                        break;
@@ -289,19 +288,19 @@ int __mm_util_get_buffer_size(mm_util_img_format format, unsigned int width, uns
                case MM_UTIL_IMG_FMT_UYVY:
                case MM_UTIL_IMG_FMT_NV16:
                case MM_UTIL_IMG_FMT_NV61:
-                       stride = MM_UTIL_ROUND_UP_4 (width) * 2;
+                       stride = MM_UTIL_ROUND_UP_4(width) * 2;
                        size = stride * height;
                        *imgsize = size;
                        break;
 
                case MM_UTIL_IMG_FMT_RGB565:
-                       stride = MM_UTIL_ROUND_UP_4 (width) * 2;
+                       stride = MM_UTIL_ROUND_UP_4(width) * 2;
                        size = stride * MM_UTIL_ROUND_UP_2(height);
                        *imgsize = size;
                        break;
 
                case MM_UTIL_IMG_FMT_RGB888:
-                       stride = MM_UTIL_ROUND_UP_4 (width) * 3;
+                       stride = MM_UTIL_ROUND_UP_4(width) * 3;
                        size = stride * MM_UTIL_ROUND_UP_2(height);
                        *imgsize = size;
                        break;
@@ -320,12 +319,12 @@ int __mm_util_get_buffer_size(mm_util_img_format format, unsigned int width, uns
                case MM_UTIL_IMG_FMT_NV12_TILED:
                        x_chroma_shift = 1;
                        y_chroma_shift = 1;
-                       stride = MM_UTIL_ROUND_UP_4 (width);
-                       h2 = ROUND_UP_X (height, y_chroma_shift);
+                       stride = MM_UTIL_ROUND_UP_4(width);
+                       h2 = ROUND_UP_X(height, y_chroma_shift);
                        size = stride * h2;
-                       w2 = 2 * DIV_ROUND_UP_X (width, x_chroma_shift);
-                       stride2 = MM_UTIL_ROUND_UP_4 (w2);
-                       h2 = DIV_ROUND_UP_X (height, y_chroma_shift);
+                       w2 = 2 * DIV_ROUND_UP_X(width, x_chroma_shift);
+                       stride2 = MM_UTIL_ROUND_UP_4(w2);
+                       h2 = DIV_ROUND_UP_X(height, y_chroma_shift);
                        size2 = stride2 * h2;
                        *imgsize = size + size2;
                        break;
@@ -350,17 +349,17 @@ static int __mm_confirm_dst_width_height(unsigned int src_width, unsigned int sr
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       switch(angle) {
+       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) {
+                       if (*dst_width != src_width) {
                                mm_util_debug("*dst_width: %d", *dst_width);
                                *dst_width = src_width;
                                mm_util_debug("#Confirmed# *dst_width: %d", *dst_width);
                        }
-                       if(*dst_height != src_height) {
+                       if (*dst_height != src_height) {
                                mm_util_debug("*dst_height: %d", *dst_height);
                                *dst_height = src_height;
                                mm_util_debug("#Confirmed# *dst_height: %d", *dst_height);
@@ -368,12 +367,12 @@ static int __mm_confirm_dst_width_height(unsigned int src_width, unsigned int sr
                        break;
                case MM_UTIL_ROTATE_90:
                case MM_UTIL_ROTATE_270:
-                       if(*dst_width != src_height) {
+                       if (*dst_width != src_height) {
                                mm_util_debug("*dst_width: %d", *dst_width);
                                *dst_width = src_height;
                                mm_util_debug("#Confirmed# *dst_width: %d", *dst_width);
                        }
-                       if(*dst_height != src_width) {
+                       if (*dst_height != src_width) {
                                mm_util_debug("*dst_height: %d", *dst_height);
                                *dst_height = src_width;
                                mm_util_debug("#Confirmed# *dst_height: %d", *dst_height);
@@ -393,12 +392,12 @@ static int __mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format
        int ret = MM_UTIL_ERROR_NONE;
        char *src_fmt_lable = NULL;
        char *dst_fmt_lable = NULL;
-       if(_imgp_info_s == NULL) {
+       if (_imgp_info_s == NULL) {
                mm_util_error("_imgp_info_s: 0x%2x", _imgp_info_s);
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       switch(src_format) {
+       switch (src_format) {
                case MM_UTIL_IMG_FMT_YUV420:
                        src_fmt_lable = (char *)"YV12";
                        break;
@@ -440,7 +439,7 @@ static int __mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format
                        break;
        }
 
-       switch(dst_format) {
+       switch (dst_format) {
                case MM_UTIL_IMG_FMT_YUV420:
                        dst_fmt_lable = (char *)"YV12";
                        break;
@@ -482,10 +481,10 @@ static int __mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format
                        break;
        }
 
-       if(src_fmt_lable && dst_fmt_lable) {
+       if (src_fmt_lable && dst_fmt_lable) {
                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(strlen(src_fmt_lable) + 1);
-               if(_imgp_info_s->input_format_label == NULL) {
+               if (_imgp_info_s->input_format_label == NULL) {
                        mm_util_error("[input] input_format_label is null");
                        return MM_UTIL_ERROR_OUT_OF_MEMORY;
                }
@@ -493,7 +492,7 @@ static int __mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format
                strncpy(_imgp_info_s->input_format_label, src_fmt_lable, strlen(src_fmt_lable));
 
                _imgp_info_s->output_format_label = (char*)malloc(strlen(dst_fmt_lable) + 1);
-               if(_imgp_info_s->output_format_label == NULL) {
+               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);
                        return MM_UTIL_ERROR_OUT_OF_MEMORY;
@@ -502,7 +501,7 @@ static int __mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format
                strncpy(_imgp_info_s->output_format_label, dst_fmt_lable, strlen(dst_fmt_lable));
 
                mm_util_debug("input_format_label: %s output_format_label: %s", _imgp_info_s->input_format_label, _imgp_info_s->output_format_label);
-       }else {
+       } else {
                mm_util_error("[error] src_fmt_lable && dst_fmt_lable");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -514,26 +513,26 @@ static int __mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, mm_util_img_format s
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if(_imgp_info_s == NULL) {
+       if (_imgp_info_s == NULL) {
                mm_util_error("_imgp_info_s is NULL");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
        ret = __mm_set_format_label(_imgp_info_s, src_format, dst_format);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("[input] mm_set_format_label error");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
        _imgp_info_s->src_format = src_format;
        _imgp_info_s->src_width = src_width;
-       _imgp_info_s->src_height= src_height;
+       _imgp_info_s->src_height = src_height;
 
        _imgp_info_s->dst_format = dst_format;
        _imgp_info_s->dst_width = dst_width;
        _imgp_info_s->dst_height = dst_height;
        _imgp_info_s->buffer_size = 0;
-       _imgp_info_s->angle= angle;
+       _imgp_info_s->angle = angle;
 
        mm_util_debug("[input] format label: %s width: %d height: %d [output] format label: %s width: %d height: %d rotation_value: %d",
        _imgp_info_s->input_format_label, _imgp_info_s->src_width, _imgp_info_s->src_height,
@@ -547,17 +546,17 @@ static GModule * __mm_util_imgp_initialize(imgp_plugin_type_e _imgp_plugin_type_
        GModule *module = NULL;
        mm_util_fenter();
 
-       if( _imgp_plugin_type_e == IMGP_NEON ) {
+       if (_imgp_plugin_type_e == IMGP_NEON) {
                module = g_module_open(PATH_NEON_LIB, G_MODULE_BIND_LAZY);
-       }else if( _imgp_plugin_type_e == IMGP_GSTCS) {
+       } else if (_imgp_plugin_type_e == IMGP_GSTCS) {
                module = g_module_open(PATH_GSTCS_LIB, G_MODULE_BIND_LAZY);
        }
 
-       if( module == NULL ) {
+       if (module == NULL) {
                mm_util_error("%s | %s module open failed", PATH_NEON_LIB, PATH_GSTCS_LIB);
                return NULL;
        }
-       mm_util_debug("module: %p, g_module_name: %s", module, g_module_name (module));
+       mm_util_debug("module: %p, g_module_name: %s", module, g_module_name(module));
 
        return module;
 }
@@ -567,7 +566,7 @@ static IMGPInfoFunc __mm_util_imgp_process(GModule *module)
        IMGPInfoFunc mm_util_imgp_func = NULL;
        mm_util_fenter();
 
-       if(module == NULL) {
+       if (module == NULL) {
                mm_util_error("module is NULL");
                return NULL;
        }
@@ -588,12 +587,12 @@ static int __mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if(module) {
+       if (module) {
                mm_util_debug("module : %p", module);
-               g_module_close( module );
+               g_module_close(module);
                mm_util_debug("#End g_module_close#");
                module = NULL;
-       }else {
+       } else {
                mm_util_error("#module is NULL#");
                ret = MM_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -707,14 +706,12 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_wid
 
 static bool __mm_util_check_resolution(unsigned int width, unsigned int height)
 {
-       if(width == 0)
-       {
+       if (width == 0) {
                mm_util_error("invalid width [%d]", width);
                return FALSE;
        }
 
-       if(height == 0)
-       {
+       if (height == 0) {
                mm_util_error("invalid height [%d]", height);
                return FALSE;
        }
@@ -788,41 +785,41 @@ static media_format_mimetype_e __mm_util_mapping_imgp_format_to_mime(mm_util_img
 {
        media_format_mimetype_e mimetype = -1;
 
-       switch(format) {
-               case MM_UTIL_IMG_FMT_NV12 :
+       switch (format) {
+               case MM_UTIL_IMG_FMT_NV12:
                        mimetype = MEDIA_FORMAT_NV12;
                        break;
-               case MM_UTIL_IMG_FMT_NV16 :
+               case MM_UTIL_IMG_FMT_NV16:
                        mimetype = MEDIA_FORMAT_NV16;
                        break;
-               case MM_UTIL_IMG_FMT_YUYV :
+               case MM_UTIL_IMG_FMT_YUYV:
                        mimetype = MEDIA_FORMAT_YUYV;
                        break;
-               case MM_UTIL_IMG_FMT_UYVY :
+               case MM_UTIL_IMG_FMT_UYVY:
                        mimetype = MEDIA_FORMAT_UYVY;
                        break;
-               case MM_UTIL_IMG_FMT_YUV422 :
+               case MM_UTIL_IMG_FMT_YUV422:
                        mimetype = MEDIA_FORMAT_422P;
                        break;
-               case MM_UTIL_IMG_FMT_I420 :
+               case MM_UTIL_IMG_FMT_I420:
                        mimetype = MEDIA_FORMAT_I420;
                        break;
-               case MM_UTIL_IMG_FMT_YUV420 :
+               case MM_UTIL_IMG_FMT_YUV420:
                        mimetype = MEDIA_FORMAT_YV12;
                        break;
-               case MM_UTIL_IMG_FMT_RGB565 :
+               case MM_UTIL_IMG_FMT_RGB565:
                        mimetype = MEDIA_FORMAT_RGB565;
                        break;
-               case MM_UTIL_IMG_FMT_RGB888 :
+               case MM_UTIL_IMG_FMT_RGB888:
                        mimetype = MEDIA_FORMAT_RGB888;
                        break;
-               case MM_UTIL_IMG_FMT_RGBA8888 :
+               case MM_UTIL_IMG_FMT_RGBA8888:
                        mimetype = MEDIA_FORMAT_RGBA;
                        break;
-               case MM_UTIL_IMG_FMT_ARGB8888 :
+               case MM_UTIL_IMG_FMT_ARGB8888:
                        mimetype = MEDIA_FORMAT_ARGB;
                        break;
-               case MM_UTIL_IMG_FMT_NV12_TILED :
+               case MM_UTIL_IMG_FMT_NV12_TILED:
                        mimetype = MEDIA_FORMAT_NV12T;
                        break;
                default:
@@ -840,41 +837,41 @@ static mm_util_img_format __mm_util_mapping_mime_format_to_imgp(media_format_mim
 {
        mm_util_img_format format = -1;
 
-       switch(mimetype) {
-               case MEDIA_FORMAT_NV12 :
+       switch (mimetype) {
+               case MEDIA_FORMAT_NV12:
                        format = MM_UTIL_IMG_FMT_NV12;
                        break;
-               case MEDIA_FORMAT_NV16 :
+               case MEDIA_FORMAT_NV16:
                        format = MM_UTIL_IMG_FMT_NV16;
                        break;
-               case MEDIA_FORMAT_YUYV :
+               case MEDIA_FORMAT_YUYV:
                        format = MM_UTIL_IMG_FMT_YUYV;
                        break;
-               case MEDIA_FORMAT_UYVY :
+               case MEDIA_FORMAT_UYVY:
                        format = MM_UTIL_IMG_FMT_UYVY;
                        break;
-               case MEDIA_FORMAT_422P :
+               case MEDIA_FORMAT_422P:
                        format = MM_UTIL_IMG_FMT_YUV422;
                        break;
-               case MEDIA_FORMAT_I420 :
+               case MEDIA_FORMAT_I420:
                        format = MM_UTIL_IMG_FMT_I420;
                        break;
-               case MEDIA_FORMAT_YV12 :
+               case MEDIA_FORMAT_YV12:
                        format = MM_UTIL_IMG_FMT_YUV420;
                        break;
-               case MEDIA_FORMAT_RGB565 :
+               case MEDIA_FORMAT_RGB565:
                        format = MM_UTIL_IMG_FMT_RGB565;
                        break;
-               case MEDIA_FORMAT_RGB888 :
+               case MEDIA_FORMAT_RGB888:
                        format = MM_UTIL_IMG_FMT_RGB888;
                        break;
-               case MEDIA_FORMAT_RGBA :
+               case MEDIA_FORMAT_RGBA:
                        format = MM_UTIL_IMG_FMT_RGBA8888;
                        break;
-               case MEDIA_FORMAT_ARGB :
+               case MEDIA_FORMAT_ARGB:
                        format = MM_UTIL_IMG_FMT_ARGB8888;
                        break;
-               case MEDIA_FORMAT_NV12T :
+               case MEDIA_FORMAT_NV12T:
                        format = MM_UTIL_IMG_FMT_NV12_TILED;
                        break;
                default:
@@ -902,10 +899,10 @@ gpointer _mm_util_thread_repeate(gpointer data)
        while (!handle->is_finish) {
                end_time = g_get_monotonic_time() + 1 * G_TIME_SPAN_SECOND;
                mm_util_debug("waiting...");
-               g_mutex_lock (&(handle->thread_mutex));
+               g_mutex_lock(&(handle->thread_mutex));
                g_cond_wait_until(&(handle->thread_cond), &(handle->thread_mutex), end_time);
                mm_util_debug("<=== get run transform thread signal");
-               g_mutex_unlock (&(handle->thread_mutex));
+               g_mutex_unlock(&(handle->thread_mutex));
 
                if (handle->is_finish) {
                        mm_util_debug("exit loop");
@@ -914,16 +911,16 @@ gpointer _mm_util_thread_repeate(gpointer data)
 
                media_packet_h pop_data = (media_packet_h) g_async_queue_try_pop(handle->queue);
 
-               if(!pop_data) {
+               if (!pop_data) {
                        mm_util_error("[NULL] Queue data");
                } else {
                        ret = __mm_util_transform_exec(handle, pop_data); /* Need to block */
-                       if(ret == MM_UTIL_ERROR_NONE) {
+                       if (ret == MM_UTIL_ERROR_NONE) {
                                mm_util_debug("Success - transform_exec");
                        } else{
                                mm_util_error("Error - transform_exec");
                        }
-                       if(handle->_util_cb->completed_cb) {
+                       if (handle->_util_cb->completed_cb) {
                                mm_util_debug("completed_cb");
                                handle->_util_cb->completed_cb(&handle->dst_packet, ret, handle->_util_cb->user_data);
                                mm_util_debug("completed_cb %p", &handle->dst);
@@ -950,7 +947,7 @@ static int __mm_util_create_thread(mm_util_s *handle)
        g_mutex_init(&(handle->thread_mutex));
 
        /*These are a communicator for thread*/
-       if(!handle->queue) {
+       if (!handle->queue) {
                handle->queue = g_async_queue_new();
        } else {
                mm_util_error("ERROR - async queue is already created");
@@ -960,7 +957,7 @@ static int __mm_util_create_thread(mm_util_s *handle)
 
        /*create threads*/
        handle->thread = g_thread_new("transform_thread", (GThreadFunc)_mm_util_thread_repeate, (gpointer)handle);
-       if(!handle->thread) {
+       if (!handle->thread) {
                mm_util_error("ERROR - create thread");
                return MM_UTIL_ERROR_INVALID_OPERATION;
        }
@@ -977,37 +974,37 @@ static int __mm_util_processing(mm_util_s *handle)
        mm_util_img_format src_format;
        unsigned int src_index = 0, dst_index = 0;
 
-       if(handle == NULL) {
-               mm_util_error ("Invalid arguments [tag null]");
+       if (handle == NULL) {
+               mm_util_error("Invalid arguments [tag null]");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(handle->src_packet == NULL) {
-               mm_util_error ("[src] media_packet_h");
+       if (handle->src_packet == NULL) {
+               mm_util_error("[src] media_packet_h");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(handle->dst_packet == NULL) {
-               mm_util_error ("[dst] media_packet_h");
+       if (handle->dst_packet == NULL) {
+               mm_util_error("[dst] media_packet_h");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(handle->src_buf_size) {
+       if (handle->src_buf_size) {
                handle->src = NULL;
-               if(media_packet_get_buffer_data_ptr(handle->src_packet, &handle->src) != MM_UTIL_ERROR_NONE) {
-                       mm_util_error ("[src] media_packet_get_extra");
+               if (media_packet_get_buffer_data_ptr(handle->src_packet, &handle->src) != MM_UTIL_ERROR_NONE) {
+                       mm_util_error("[src] media_packet_get_extra");
                        IMGP_FREE(handle->src);
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
                mm_util_debug("src buffer pointer: %p", handle->src);
        }
 
-       if(handle->dst_buf_size) {
+       if (handle->dst_buf_size) {
                handle->dst = NULL;
-               if(media_packet_get_buffer_data_ptr(handle->dst_packet, &handle->dst) != MM_UTIL_ERROR_NONE) {
+               if (media_packet_get_buffer_data_ptr(handle->dst_packet, &handle->dst) != MM_UTIL_ERROR_NONE) {
                        IMGP_FREE(handle->src);
                        IMGP_FREE(handle->dst);
-                       mm_util_error ("[dst] media_packet_get_extra");
+                       mm_util_error("[dst] media_packet_get_extra");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
        }
@@ -1019,7 +1016,7 @@ static int __mm_util_processing(mm_util_s *handle)
        src_height = handle->src_height;
        src_format = handle->src_format;
        if (dst_buf[src_index] == NULL) {
-               mm_util_error ("[multi func] memory allocation error");
+               mm_util_error("[multi func] memory allocation error");
                IMGP_FREE(handle->src);
                IMGP_FREE(handle->dst);
                return MM_UTIL_ERROR_INVALID_OPERATION;
@@ -1030,7 +1027,7 @@ static int __mm_util_processing(mm_util_s *handle)
                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);
                if (dst_buf[dst_index] == NULL) {
-                       mm_util_error ("[multi func] memory allocation error");
+                       mm_util_error("[multi func] memory allocation error");
                        IMGP_FREE(handle->src);
                        IMGP_FREE(handle->dst);
                        __mm_destroy_temp_buffer(dst_buf);
@@ -1053,13 +1050,13 @@ static int __mm_util_processing(mm_util_s *handle)
                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);
                if (dst_buf[dst_index] == NULL) {
-                       mm_util_error ("[multi func] memory allocation error");
+                       mm_util_error("[multi func] memory allocation error");
                        IMGP_FREE(handle->src);
                        IMGP_FREE(handle->dst);
                        __mm_destroy_temp_buffer(dst_buf);
                        return MM_UTIL_ERROR_INVALID_OPERATION;
                }
-               ret = mm_util_resize_image(dst_buf[src_index], src_width, src_height,src_format, dst_buf[dst_index], &handle->dst_width, &handle->dst_height);
+               ret = mm_util_resize_image(dst_buf[src_index], src_width, src_height, src_format, dst_buf[dst_index], &handle->dst_width, &handle->dst_height);
                if (ret != MM_UTIL_ERROR_NONE) {
                        IMGP_FREE(handle->src);
                        IMGP_FREE(handle->dst);
@@ -1077,7 +1074,7 @@ static int __mm_util_processing(mm_util_s *handle)
                mm_util_get_image_size(handle->dst_format, handle->dst_width, handle->dst_height, &dst_buf_size);
                dst_buf[dst_index] = g_malloc(dst_buf_size);
                if (dst_buf[dst_index] == NULL) {
-                       mm_util_error ("[multi func] memory allocation error");
+                       mm_util_error("[multi func] memory allocation error");
                        IMGP_FREE(handle->src);
                        IMGP_FREE(handle->dst);
                        __mm_destroy_temp_buffer(dst_buf);
@@ -1097,9 +1094,9 @@ static int __mm_util_processing(mm_util_s *handle)
 
        if (handle->set_rotate) {
                dst_index++;
-               if(handle->set_resize || handle->set_crop) {
+               if (handle->set_resize || handle->set_crop) {
                        unsigned int temp_swap = 0;
-                       switch(handle->dst_rotation) {
+                       switch (handle->dst_rotation) {
                                case  MM_UTIL_ROTATION_90:
                                case MM_UTIL_ROTATION_270:
                                        temp_swap = handle->dst_width;
@@ -1113,7 +1110,7 @@ static int __mm_util_processing(mm_util_s *handle)
                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);
                if (dst_buf[dst_index] == NULL) {
-                       mm_util_error ("[multi func] memory allocation error");
+                       mm_util_error("[multi func] memory allocation error");
                        IMGP_FREE(handle->src);
                        IMGP_FREE(handle->dst);
                        __mm_destroy_temp_buffer(dst_buf);
@@ -1153,20 +1150,20 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
        unsigned int dst_width = 0, dst_height = 0;
        uint64_t size = 0;
 
-       if(media_packet_get_format(src_packet, &src_fmt) != MM_UTIL_ERROR_NONE) {
+       if (media_packet_get_format(src_packet, &src_fmt) != MM_UTIL_ERROR_NONE) {
                mm_util_error("Imedia_packet_get_format)");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(media_format_get_video_info(src_fmt, &src_mimetype, &src_width, &src_height, &src_avg_bps, &src_max_bps) == MEDIA_FORMAT_ERROR_NONE) {
+       if (media_format_get_video_info(src_fmt, &src_mimetype, &src_width, &src_height, &src_avg_bps, &src_max_bps) == MEDIA_FORMAT_ERROR_NONE) {
                mm_util_debug("[Fotmat: %d] W x H : %d x %d", src_mimetype, src_width, src_height);
        }
 
-       if(__mm_util_check_resolution(src_width, src_height)) {
+       if (__mm_util_check_resolution(src_width, src_height)) {
                /* src */
                handle->src_packet = src_packet;
                mm_util_debug("src_packet: %p handle->src_packet: %p 0x%2x [W X H] %d X %d", src_packet, handle->src_packet, src_fmt, src_width, src_height);
-               if(handle->src_packet) {
+               if (handle->src_packet) {
                        handle->src_format = __mm_util_mapping_mime_format_to_imgp(src_mimetype);
                        handle->src_width = src_width;
                        handle->src_height = src_height;
@@ -1176,14 +1173,14 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_packet_get_buffer_size(handle->src_packet, &size) == MM_UTIL_ERROR_NONE) {
+               if (media_packet_get_buffer_size(handle->src_packet, &size) == MM_UTIL_ERROR_NONE) {
                        handle->src_buf_size = (guint)size;
                        mm_util_debug("src buffer(%p) %d size: %d", handle->src_packet, handle->src_packet, handle->src_buf_size);
                } else {
                        mm_util_error("Error buffer size");
                }
 
-               if(handle->dst_format == MM_UTIL_IMG_FMT_NUM) {
+               if (handle->dst_format == MM_UTIL_IMG_FMT_NUM) {
                        mm_util_debug("dst format is changed");
                        handle->dst_format = handle->src_format;
                        handle->dst_format_mime = src_mimetype;
@@ -1192,7 +1189,7 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
                mm_util_debug("src: %p handle->src_packet: %p (%d),(%d X %d)", src_packet, handle->src_packet, handle->src_packet, handle->src_width, handle->src_height);
                if (handle->set_rotate) {
                        if ((handle->set_crop) || (handle->set_resize)) {
-                               switch(handle->dst_rotation) {
+                               switch (handle->dst_rotation) {
                                        case MM_UTIL_ROTATION_90:
                                        case MM_UTIL_ROTATION_270:
                                                dst_width = handle->dst_height;
@@ -1204,7 +1201,7 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
                                                break;
                                }
                        } else {
-                               switch(handle->dst_rotation) {
+                               switch (handle->dst_rotation) {
                                        case MM_UTIL_ROTATION_90:
                                        case MM_UTIL_ROTATION_270:
                                                dst_width = handle->dst_width  = handle->src_height;
@@ -1232,55 +1229,55 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
                        }
                }
                mm_util_debug("dst (%d X %d)", dst_width, dst_height);
-               if(media_format_make_writable(src_fmt, &dst_fmt) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_make_writable(src_fmt, &dst_fmt) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(src_fmt);
                        mm_util_error("[Error] Writable - dst format");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_mime(dst_fmt, handle->dst_format_mime) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_mime(dst_fmt, handle->dst_format_mime) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(src_fmt);
                        media_format_unref(dst_fmt);
                        mm_util_error("[Error] Set - video mime");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_width(dst_fmt, dst_width) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_width(dst_fmt, dst_width) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(src_fmt);
                        media_format_unref(dst_fmt);
                        mm_util_error("[Error] Set - video width");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_height(dst_fmt, dst_height) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_height(dst_fmt, dst_height) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(src_fmt);
                        media_format_unref(dst_fmt);
                        mm_util_error("[Error] Set - video height");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_avg_bps(dst_fmt, src_avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_avg_bps(dst_fmt, src_avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(src_fmt);
                        media_format_unref(dst_fmt);
                        mm_util_error("[Error] Set - video avg bps");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_max_bps(dst_fmt, src_max_bps) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_max_bps(dst_fmt, src_max_bps) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(src_fmt);
                        media_format_unref(dst_fmt);
                        mm_util_error("[Error] Set - video max bps");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_packet_create_alloc(dst_fmt, (media_packet_finalize_cb)_mm_util_transform_packet_finalize_callback, NULL, &handle->dst_packet) != MM_UTIL_ERROR_NONE) {
+               if (media_packet_create_alloc(dst_fmt, (media_packet_finalize_cb)_mm_util_transform_packet_finalize_callback, NULL, &handle->dst_packet) != MM_UTIL_ERROR_NONE) {
                        mm_util_error("[Error] Create allocation memory");
                        media_format_unref(src_fmt);
                        media_format_unref(dst_fmt);
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                } else {
                        mm_util_debug("Success - dst media packet");
-                       if(media_packet_get_buffer_size(handle->dst_packet, &size) != MM_UTIL_ERROR_NONE) {
+                       if (media_packet_get_buffer_size(handle->dst_packet, &size) != MM_UTIL_ERROR_NONE) {
                                mm_util_error("Imedia_packet_get_format)");
                                media_format_unref(src_fmt);
                                media_format_unref(dst_fmt);
@@ -1289,9 +1286,9 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
                        handle->dst_buf_size = (guint)size;
                        mm_util_debug("handle->src_packet: %p [%d] %d X %d (%d) => handle->dst_packet: %p [%d] %d X %d (%d)",
                                handle->src_packet, handle->src_format, handle->src_width, handle->src_height, handle->src_buf_size,
-                               handle->dst_packet, handle->dst_format,dst_width, dst_height, handle->dst_buf_size);
+                               handle->dst_packet, handle->dst_format, dst_width, dst_height, handle->dst_buf_size);
                }
-       }else {
+       } else {
                mm_util_error("%d %d", src_width, src_height);
                media_format_unref(src_fmt);
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1299,7 +1296,7 @@ static int __mm_util_transform_exec(mm_util_s * handle, media_packet_h src_packe
 
        ret = __mm_util_processing(handle);
 
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_util_processing failed");
                IMGP_FREE(handle);
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1322,17 +1319,17 @@ _mm_util_handle_finalize(mm_util_s *handle)
        }
 
        /* g_thread_exit(handle->thread); */
-       if(handle->thread) {
+       if (handle->thread) {
                handle->is_finish = TRUE;
-               g_mutex_lock (&(handle->thread_mutex));
+               g_mutex_lock(&(handle->thread_mutex));
                g_cond_signal(&(handle->thread_cond));
                mm_util_debug("===> send signal(finish) to transform_thread");
-               g_mutex_unlock (&(handle->thread_mutex));
+               g_mutex_unlock(&(handle->thread_mutex));
 
                g_thread_join(handle->thread);
        }
 
-       if(handle->queue) {
+       if (handle->queue) {
                g_async_queue_unref(handle->queue);
                handle->queue = NULL;
        }
@@ -1352,20 +1349,20 @@ int mm_util_create(MMHandleType* MMHandle)
 
        TTRACE_BEGIN("MM_UTILITY:IMGP:CREATE");
 
-       if(MMHandle == NULL) {
-               mm_util_error ("Invalid arguments [tag null]");
+       if (MMHandle == NULL) {
+               mm_util_error("Invalid arguments [tag null]");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       mm_util_s *handle = calloc(1,sizeof(mm_util_s));
+       mm_util_s *handle = calloc(1, sizeof(mm_util_s));
        if (!handle) {
                mm_util_error("[ERROR] - _handle");
                ret = MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       ret = __mm_util_handle_init (handle);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       ret = __mm_util_handle_init(handle);
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("_mm_util_handle_init failed");
                IMGP_FREE(handle);
                TTRACE_END();
@@ -1373,7 +1370,7 @@ int mm_util_create(MMHandleType* MMHandle)
        }
 
        ret = __mm_util_create_thread(handle);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("ERROR - Create thread");
                TTRACE_END();
                return ret;
@@ -1506,7 +1503,7 @@ int mm_util_transform(MMHandleType MMHandle, media_packet_h src_packet, mm_util_
                return MM_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       if(!src_packet) {
+       if (!src_packet) {
                mm_util_error("[ERROR] - src_packet");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1514,7 +1511,7 @@ int mm_util_transform(MMHandleType MMHandle, media_packet_h src_packet, mm_util_
                mm_util_debug("src: %p", src_packet);
        }
 
-       if(!completed_callback) {
+       if (!completed_callback) {
                mm_util_error("[ERROR] - completed_callback");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1522,20 +1519,20 @@ int mm_util_transform(MMHandleType MMHandle, media_packet_h src_packet, mm_util_
 
        IMGP_FREE(handle->_util_cb);
        handle->_util_cb = (mm_util_cb_s *)malloc(sizeof(mm_util_cb_s));
-       if(handle->_util_cb) {
-               handle->_util_cb->completed_cb= completed_callback;
+       if (handle->_util_cb) {
+               handle->_util_cb->completed_cb = completed_callback;
                handle->_util_cb->user_data = user_data;
        } else {
                mm_util_error("[ERROR] _util_cb_s");
        }
 
-       if(handle->queue) {
+       if (handle->queue) {
                mm_util_debug("g_async_queue_push");
-               g_async_queue_push (handle->queue, GINT_TO_POINTER(src_packet));
-               g_mutex_lock (&(handle->thread_mutex));
+               g_async_queue_push(handle->queue, GINT_TO_POINTER(src_packet));
+               g_mutex_lock(&(handle->thread_mutex));
                g_cond_signal(&(handle->thread_cond));
                mm_util_debug("===> send signal to transform_thread");
-               g_mutex_unlock (&(handle->thread_mutex));
+               g_mutex_unlock(&(handle->thread_mutex));
        }
 
        TTRACE_END();
@@ -1583,7 +1580,7 @@ int mm_util_destroy(MMHandleType MMHandle)
        }
 
        /* Close */
-       if(_mm_util_handle_finalize(handle) != MM_UTIL_ERROR_NONE) {
+       if (_mm_util_handle_finalize(handle) != MM_UTIL_ERROR_NONE) {
                mm_util_error("_mm_util_handle_finalize)");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1627,7 +1624,7 @@ EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int
 
        mm_util_debug("[src] 0x%2x (%d x %d) [dst] 0x%2x", src, src_width, src_height, dst);
 
-       imgp_info_s* _imgp_info_s=(imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
+       imgp_info_s* _imgp_info_s = (imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
        if (_imgp_info_s == NULL) {
                mm_util_error("ERROR - alloc handle");
                TTRACE_END();
@@ -1650,7 +1647,7 @@ EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int
        _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
        mm_util_debug("__mm_util_imgp_initialize: %p", _module);
 
-       if(_module == NULL) { /* when IMGP_NEON is NULL */
+       if (_module == NULL) { /* when IMGP_NEON is NULL */
                _imgp_plugin_type_e = IMGP_GSTCS;
                mm_util_debug("You use %s module", PATH_GSTCS_LIB);
                _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
@@ -1658,7 +1655,7 @@ EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int
        mm_util_debug("mm_util_imgp_func: %p", _module);
 
        ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_set_imgp_info_s failed");
                __mm_util_imgp_finalize(_module, _imgp_info_s);
                TTRACE_END();
@@ -1688,9 +1685,8 @@ EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int
        mm_util_debug("Sucess __mm_util_imgp_process");
 
        if (_mm_util_imgp_func) {
-               ret=_mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_CSC);
-               if (ret != MM_UTIL_ERROR_NONE)
-               {
+               ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_CSC);
+               if (ret != MM_UTIL_ERROR_NONE) {
                        mm_util_error("image processing failed");
                        __mm_util_imgp_finalize(_module, _imgp_info_s);
                        IMGP_FREE(output_buffer);
@@ -1707,7 +1703,7 @@ EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int
 
        if ((_imgp_info_s->dst_width != _imgp_info_s->output_stride || _imgp_info_s->dst_height != _imgp_info_s->output_elevation) && __mm_is_rgb_format(src_format)) {
                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) {
+               if (ret != MM_UTIL_ERROR_NONE) {
                        mm_util_error("__mm_util_imgp_finalize failed");
                        IMGP_FREE(output_buffer);
                        TTRACE_END();
@@ -1723,7 +1719,7 @@ EXPORT_API int mm_util_convert_colorspace(const unsigned char *src, unsigned int
 
        /* Finalize */
        ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_util_imgp_finalize failed");
                IMGP_FREE(output_buffer);
                TTRACE_END();
@@ -1761,7 +1757,7 @@ EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_w
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if (!dst_width || !dst_height ) {
+       if (!dst_width || !dst_height) {
                mm_util_error("#ERROR# dst width/height buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1775,8 +1771,8 @@ EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_w
 
        mm_util_debug("[src] 0x%2x (%d x %d) [dst] 0x%2x", src, src_width, src_height, dst);
 
-       imgp_info_s* _imgp_info_s=(imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
-       if(_imgp_info_s == NULL) {
+       imgp_info_s* _imgp_info_s = (imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
+       if (_imgp_info_s == NULL) {
                mm_util_error("ERROR - alloc handle");
                TTRACE_END();
                return MM_UTIL_ERROR_OUT_OF_MEMORY;
@@ -1787,25 +1783,25 @@ EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_w
        imgp_plugin_type_e _imgp_plugin_type_e = 0;
 
        /* Initialize */
-       if(__mm_select_resize_plugin(src_format)) {
+       if (__mm_select_resize_plugin(src_format)) {
                _imgp_plugin_type_e = IMGP_NEON;
-       }else {
+       } else {
                _imgp_plugin_type_e = IMGP_GSTCS;
        }
        mm_util_debug("plugin type: %d", _imgp_plugin_type_e);
 
        _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
        mm_util_debug("__mm_util_imgp_initialize: %p", _module);
-       if(_module == NULL) /* when IMGP_NEON is NULL */
-       {
+       /* when IMGP_NEON is NULL */
+       if (_module == NULL) {
                _imgp_plugin_type_e = IMGP_GSTCS;
                mm_util_debug("You use %s module", PATH_GSTCS_LIB);
                _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
        }
 
        mm_util_debug("__mm_set_imgp_info_s");
-       ret =__mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_set_imgp_info_s failed [%d]", ret);
                __mm_util_imgp_finalize(_module, _imgp_info_s);
                TTRACE_END();
@@ -1814,8 +1810,8 @@ EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_w
 
        mm_util_debug("Sucess __mm_set_imgp_info_s");
 
-       if(g_strrstr(g_module_name (_module), GST)) {
-               if(__mm_gst_can_resize_format(_imgp_info_s->input_format_label) == FALSE) {
+       if (g_strrstr(g_module_name(_module), GST)) {
+               if (__mm_gst_can_resize_format(_imgp_info_s->input_format_label) == FALSE) {
                        mm_util_error("[%s][%05d] #RESIZE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
                        __mm_util_imgp_finalize(_module, _imgp_info_s);
                        TTRACE_END();
@@ -1845,10 +1841,9 @@ EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_w
        _mm_util_imgp_func = __mm_util_imgp_process(_module);
        mm_util_debug("Sucess __mm_util_imgp_process");
        if (_mm_util_imgp_func) {
-               ret=_mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_RSZ);
+               ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_RSZ);
                mm_util_debug("_mm_util_imgp_func, ret: %d", ret);
-               if (ret != MM_UTIL_ERROR_NONE)
-               {
+               if (ret != MM_UTIL_ERROR_NONE) {
                        mm_util_error("image processing failed");
                        __mm_util_imgp_finalize(_module, _imgp_info_s);
                        IMGP_FREE(output_buffer);
@@ -1879,7 +1874,7 @@ EXPORT_API int mm_util_resize_image(const unsigned char *src, unsigned int src_w
 
        /* Finalize */
        ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_util_imgp_finalize failed");
                IMGP_FREE(output_buffer);
                TTRACE_END();
@@ -1917,13 +1912,13 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if ( !dst_width || !dst_height ) {
+       if (!dst_width || !dst_height) {
                mm_util_error("#ERROR# dst width/height buffer is NUL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if ( !src_width || !src_height) {
+       if (!src_width || !src_height) {
                mm_util_error("#ERROR# src_width || src_height value is 0 ");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1937,8 +1932,8 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
 
        mm_util_debug("[src] 0x%2x (%d x %d) [dst] 0x%2x", src, src_width, src_height, dst);
 
-       imgp_info_s* _imgp_info_s=(imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
-       if(_imgp_info_s == NULL) {
+       imgp_info_s* _imgp_info_s = (imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
+       if (_imgp_info_s == NULL) {
                mm_util_error("ERROR - alloc handle");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1948,16 +1943,16 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
        imgp_plugin_type_e _imgp_plugin_type_e = 0;
 
        /* Initialize */
-       if__mm_select_rotate_plugin(src_format, src_width, src_height, angle)) {
+       if (__mm_select_rotate_plugin(src_format, src_width, src_height, angle)) {
                _imgp_plugin_type_e = IMGP_NEON;
-       }else {
+       } else {
                _imgp_plugin_type_e = IMGP_GSTCS;
        }
        mm_util_debug("plugin type: %d", _imgp_plugin_type_e);
 
        _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
        mm_util_debug("__mm_util_imgp_initialize: %p", _module);
-       if(_module == NULL) { /* when IMGP_NEON is NULL */
+       if (_module == NULL) { /* when IMGP_NEON is NULL */
                _imgp_plugin_type_e = IMGP_GSTCS;
                mm_util_debug("You use %s module", PATH_GSTCS_LIB);
                _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
@@ -1965,7 +1960,7 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
 
        mm_util_debug("__mm_confirm_dst_width_height");
        ret = __mm_confirm_dst_width_height(src_width, src_height, dst_width, dst_height, angle);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("dst_width || dest_height size Error");
                __mm_util_imgp_finalize(_module, _imgp_info_s);
                TTRACE_END();
@@ -1974,7 +1969,7 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
 
        ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle);
        mm_util_debug("__mm_set_imgp_info_s");
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_set_imgp_info_s failed");
                __mm_util_imgp_finalize(_module, _imgp_info_s);
                TTRACE_END();
@@ -1982,8 +1977,8 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
        }
        mm_util_debug("Sucess __mm_set_imgp_info_s");
 
-       if(g_strrstr(g_module_name (_module), GST)) {
-               if(__mm_gst_can_rotate_format(_imgp_info_s->input_format_label) == FALSE) {
+       if (g_strrstr(g_module_name(_module), GST)) {
+               if (__mm_gst_can_rotate_format(_imgp_info_s->input_format_label) == FALSE) {
                        mm_util_error("[%s][%05d] #gstreamer ROTATE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
                        __mm_util_imgp_finalize(_module, _imgp_info_s);
                        TTRACE_END();
@@ -2013,8 +2008,8 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
        _mm_util_imgp_func = __mm_util_imgp_process(_module);
        mm_util_debug("Sucess __mm_util_imgp_process");
        if (_mm_util_imgp_func) {
-               ret=_mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_ROT);
-               if (ret!= MM_UTIL_ERROR_NONE)   {
+               ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_ROT);
+               if (ret != MM_UTIL_ERROR_NONE) {
                        mm_util_error("image processing failed");
                        __mm_util_imgp_finalize(_module, _imgp_info_s);
                        IMGP_FREE(output_buffer);
@@ -2057,7 +2052,7 @@ EXPORT_API int mm_util_rotate_image(const unsigned char *src, unsigned int src_w
 
        /* Finalize */
        ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
-       if(ret != MM_UTIL_ERROR_NONE) {
+       if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("__mm_util_imgp_finalize failed");
                IMGP_FREE(output_buffer);
                TTRACE_END();
@@ -2086,13 +2081,13 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int *crop_dest_wi
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM) ) {
+       if ((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM)) {
                mm_util_error("#ERROR# src_format value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (crop_start_x +*crop_dest_width > src_width) || (crop_start_y +*crop_dest_height > src_height) ) {
+       if ((crop_start_x + *crop_dest_width > src_width) || (crop_start_y + *crop_dest_height > src_height)) {
                mm_util_error("#ERROR# dest width | height value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -2116,16 +2111,16 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int *crop_dest_wi
                        }
                case MM_UTIL_IMG_FMT_I420:
                case MM_UTIL_IMG_FMT_YUV420: {
-                       if((*crop_dest_width %2) !=0) {
+                       if ((*crop_dest_width % 2) != 0) {
                                mm_util_warn("#YUV Width value(%d) must be even at least# ", *crop_dest_width);
                                *crop_dest_width = ((*crop_dest_width+1)>>1)<<1;
-                               mm_util_debug("Image isplay is suceeded when YUV crop width value %d ",*crop_dest_width);
+                               mm_util_debug("Image isplay is suceeded when YUV crop width value %d", *crop_dest_width);
                        }
 
-                       if((*crop_dest_height%2) !=0) { /* height value must be also even when crop yuv image */
+                       if ((*crop_dest_height % 2) != 0) { /* height value must be also even when crop yuv image */
                                mm_util_warn("#YUV Height value(%d) must be even at least# ", *crop_dest_height);
                                *crop_dest_height = ((*crop_dest_height+1)>>1)<<1;
-                               mm_util_debug("Image isplay is suceeded when YUV crop height value %d ",*crop_dest_height);
+                               mm_util_debug("Image isplay is suceeded when YUV crop height value %d", *crop_dest_height);
                        }
 
                        ret = __mm_util_crop_yuv420(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
@@ -2164,18 +2159,17 @@ EXPORT_API int mm_util_get_image_size(mm_util_img_format format, unsigned int wi
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       switch (format)
-       {
+       switch (format) {
                case MM_UTIL_IMG_FMT_I420:
                case MM_UTIL_IMG_FMT_YUV420:
                        x_chroma_shift = 1;
                        y_chroma_shift = 1;
-                       stride = MM_UTIL_ROUND_UP_4 (width);
-                       h2 = ROUND_UP_X (height, x_chroma_shift);
+                       stride = MM_UTIL_ROUND_UP_4(width);
+                       h2 = ROUND_UP_X(height, x_chroma_shift);
                        size = stride * h2;
-                       w2 = DIV_ROUND_UP_X (width, x_chroma_shift);
-                       stride2 = MM_UTIL_ROUND_UP_4 (w2);
-                       h2 = DIV_ROUND_UP_X (height, y_chroma_shift);
+                       w2 = DIV_ROUND_UP_X(width, x_chroma_shift);
+                       stride2 = MM_UTIL_ROUND_UP_4(w2);
+                       h2 = DIV_ROUND_UP_X(height, y_chroma_shift);
                        size2 = stride2 * h2;
                        *imgsize = size + 2 * size2;
                        break;
@@ -2184,19 +2178,19 @@ EXPORT_API int mm_util_get_image_size(mm_util_img_format format, unsigned int wi
                case MM_UTIL_IMG_FMT_UYVY:
                case MM_UTIL_IMG_FMT_NV16:
                case MM_UTIL_IMG_FMT_NV61:
-                       stride = MM_UTIL_ROUND_UP_4 (width) * 2;
+                       stride = MM_UTIL_ROUND_UP_4(width) * 2;
                        size = stride * height;
                        *imgsize = size;
                        break;
 
                case MM_UTIL_IMG_FMT_RGB565:
-                       stride = MM_UTIL_ROUND_UP_4 (width) * 2;
+                       stride = MM_UTIL_ROUND_UP_4(width) * 2;
                        size = stride * height;
                        *imgsize = size;
                        break;
 
                case MM_UTIL_IMG_FMT_RGB888:
-                       stride = MM_UTIL_ROUND_UP_4 (width) * 3;
+                       stride = MM_UTIL_ROUND_UP_4(width) * 3;
                        size = stride * height;
                        *imgsize = size;
                        break;
@@ -2215,12 +2209,12 @@ EXPORT_API int mm_util_get_image_size(mm_util_img_format format, unsigned int wi
                case MM_UTIL_IMG_FMT_NV12_TILED:
                        x_chroma_shift = 1;
                        y_chroma_shift = 1;
-                       stride = MM_UTIL_ROUND_UP_4 (width);
-                       h2 = ROUND_UP_X (height, y_chroma_shift);
+                       stride = MM_UTIL_ROUND_UP_4(width);
+                       h2 = ROUND_UP_X(height, y_chroma_shift);
                        size = stride * h2;
-                       w2 = 2 * DIV_ROUND_UP_X (width, x_chroma_shift);
-                       stride2 = MM_UTIL_ROUND_UP_4 (w2);
-                       h2 = DIV_ROUND_UP_X (height, y_chroma_shift);
+                       w2 = 2 * DIV_ROUND_UP_X(width, x_chroma_shift);
+                       stride2 = MM_UTIL_ROUND_UP_4(w2);
+                       h2 = DIV_ROUND_UP_X(height, y_chroma_shift);
                        size2 = stride2 * h2;
                        *imgsize = size + size2;
                        break;
index 8377c09ce314c5813128ba76a2b71789347380f5..e5d781f66c218ac821eb22fbef1d65fa15b5aeba 100755 (executable)
@@ -45,38 +45,38 @@ transform_completed_cb(media_packet_h *packet, int error, void *user_param)
        int dst_width, dst_height, dst_avg_bps, dst_max_bps;
        char *output_fmt = NULL;
 
-       if(error == MM_UTIL_ERROR_NONE) {
+       if (error == MM_UTIL_ERROR_NONE) {
                mm_util_debug("completed");
                output_fmt = (char*)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
-               if(output_fmt) {
-                       if(media_packet_get_format(*packet, &dst_fmt) != MM_UTIL_ERROR_NONE) {
+               if (output_fmt) {
+                       if (media_packet_get_format(*packet, &dst_fmt) != MM_UTIL_ERROR_NONE) {
                                mm_util_error("Imedia_packet_get_format");
                                IMGP_FREE(output_fmt);
                                return FALSE;
                        }
 
-                       if(media_format_get_video_info(dst_fmt, &dst_mimetype, &dst_width, &dst_height, &dst_avg_bps, &dst_max_bps) ==MEDIA_FORMAT_ERROR_NONE) {
+                       if (media_format_get_video_info(dst_fmt, &dst_mimetype, &dst_width, &dst_height, &dst_avg_bps, &dst_max_bps) == MEDIA_FORMAT_ERROR_NONE) {
                                memset(output_fmt, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
-                               if(dst_mimetype  ==MEDIA_FORMAT_YV12 || dst_mimetype == MEDIA_FORMAT_422P ||dst_mimetype == MEDIA_FORMAT_I420
-                                       || dst_mimetype == MEDIA_FORMAT_NV12 || dst_mimetype == MEDIA_FORMAT_UYVY ||dst_mimetype == MEDIA_FORMAT_YUYV) {
+                               if (dst_mimetype == MEDIA_FORMAT_YV12 || dst_mimetype == MEDIA_FORMAT_422P || dst_mimetype == MEDIA_FORMAT_I420
+                                       || dst_mimetype == MEDIA_FORMAT_NV12 || dst_mimetype == MEDIA_FORMAT_UYVY || dst_mimetype == MEDIA_FORMAT_YUYV) {
                                        strncpy(output_fmt, "yuv", strlen("yuv"));
                                } else {
-                                       strncpy(output_fmt,"rgb", strlen("rgb"));
+                                       strncpy(output_fmt, "rgb", strlen("rgb"));
                                }
                                mm_util_debug("[mimetype: %d] W x H : %d x %d", dst_mimetype, dst_width, dst_height);
-                               snprintf(output_file, 25, "result_%dx%d.%s", dst_width,dst_height, output_fmt);
+                               snprintf(output_file, 25, "result_%dx%d.%s", dst_width, dst_height, output_fmt);
                        }
                }
 
                FILE *fpout = fopen(output_file, "w");
-               if(fpout) {
+               if (fpout) {
                        media_packet_get_buffer_size(*packet, &size);
                        void *dst = NULL;
-                       if(media_packet_get_buffer_data_ptr(*packet, &dst) != MM_UTIL_ERROR_NONE) {
+                       if (media_packet_get_buffer_data_ptr(*packet, &dst) != MM_UTIL_ERROR_NONE) {
                                IMGP_FREE(dst);
                                IMGP_FREE(output_fmt);
                                fclose(fpout);
-                               mm_util_error ("[dst] media_packet_get_extra");
+                               mm_util_error("[dst] media_packet_get_extra");
                                return FALSE;
                        }
                        mm_util_debug("dst: %p [%d]", dst, size);
@@ -113,8 +113,8 @@ int main(int argc, char *argv[])
        }
 
        /* Create Transform */
-       ret = mm_util_create (&MMHandle);
-       if(ret == MM_UTIL_ERROR_NONE) {
+       ret = mm_util_create(&MMHandle);
+       if (ret == MM_UTIL_ERROR_NONE) {
                mm_util_debug("Success - Create Transcode Handle [MMHandle: 0x%2x]", MMHandle);
        } else {
                mm_util_debug("ERROR - Create Transcode Handle");
@@ -124,47 +124,46 @@ int main(int argc, char *argv[])
        handle = (mm_util_s*) MMHandle;
 
        media_format_h fmt;
-       if(media_format_create(&fmt) == MEDIA_FORMAT_ERROR_NONE) {
-               if(media_format_set_video_mime(fmt, MEDIA_FORMAT_I420) != MEDIA_FORMAT_ERROR_NONE) {
+       if (media_format_create(&fmt) == MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_mime(fmt, MEDIA_FORMAT_I420) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(fmt);
                        mm_util_error("[Error] Set - video mime");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_width(fmt, 320) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_width(fmt, 320) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(fmt);
                        mm_util_error("[Error] Set - video width");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_height(fmt, 240) != MEDIA_FORMAT_ERROR_NONE) {
+               if (media_format_set_video_height(fmt, 240) != MEDIA_FORMAT_ERROR_NONE) {
                        media_format_unref(fmt);
                        mm_util_error("[Error] Set - video height");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_avg_bps(fmt, 15000000) != MEDIA_FORMAT_ERROR_NONE) {
+               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");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
-               if(media_format_set_video_max_bps(fmt, 20000000) != MEDIA_FORMAT_ERROR_NONE) {
+               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");
                        return MM_UTIL_ERROR_INVALID_PARAMETER;
                }
 
                mm_util_debug("media_format_set_video_info success! w:320, h:240, MEDIA_FORMAT_I420\n");
-       }
-       else {
+       } else {
                mm_util_error("media_format_create failed...");
        }
 
        ret = media_packet_create_alloc(fmt, (media_packet_finalize_cb)packet_finalize_callback, NULL, &src_packet);
-       if(ret == MM_UTIL_ERROR_NONE) {
+       if (ret == MM_UTIL_ERROR_NONE) {
                mm_util_debug("Success - Create Media Packet(%p)", src_packet);
-               uint64_t size =0;
+               uint64_t size = 0;
                if (media_packet_get_buffer_size(src_packet, &size) == MEDIA_PACKET_ERROR_NONE) {
                        ptr = malloc(size);
                        if (ptr == NULL) {
@@ -182,7 +181,7 @@ int main(int argc, char *argv[])
                                        mm_util_debug("\tmemory allocation failed\n");
                                        return MM_UTIL_ERROR_INVALID_OPERATION;
                                }
-                               if(fread(src, 1, (int)size, fp)) {
+                               if (fread(src, 1, (int)size, fp)) {
                                        mm_util_debug("#Success# fread");
                                        memcpy(ptr, src, (int)size);
                                        mm_util_debug("memcpy");
@@ -198,7 +197,7 @@ int main(int argc, char *argv[])
 
        /* Set Source */
        ret = mm_util_set_hardware_acceleration(MMHandle, atoi(argv[2]));
-       if(ret == MM_UTIL_ERROR_NONE) {
+       if (ret == MM_UTIL_ERROR_NONE) {
                mm_util_debug("Success - Set hardware_acceleration");
        } else {
                mm_util_debug("ERROR - Set hardware_acceleration");
@@ -206,7 +205,7 @@ int main(int argc, char *argv[])
        }
 
        ret = mm_util_set_resolution(MMHandle, 176, 144);
-       if(ret == MM_UTIL_ERROR_NONE) {
+       if (ret == MM_UTIL_ERROR_NONE) {
                mm_util_debug("Success - Set Convert Info");
        } else {
                media_format_unref(fmt);
@@ -216,7 +215,7 @@ int main(int argc, char *argv[])
 
        /* Transform */
        ret = mm_util_transform(MMHandle, src_packet, (mm_util_completed_callback) transform_completed_cb, handle);
-       if(ret == MM_UTIL_ERROR_NONE) {
+       if (ret == MM_UTIL_ERROR_NONE) {
                mm_util_debug("Success - Transform");
        } else {
                media_format_unref(fmt);
@@ -228,7 +227,7 @@ int main(int argc, char *argv[])
        while (false == completed) {} // polling
 
        ret = mm_util_destroy(MMHandle);
-       if(ret == MM_UTIL_ERROR_NONE) {
+       if (ret == MM_UTIL_ERROR_NONE) {
                mm_util_debug("Success - Destroy");
        } else {
                media_format_unref(fmt);
index fa90514682bd55dd93b58ca83c469ce3e0374c4e..d648c96b951f266a7644e5084655e5e9e30fd2df 100755 (executable)
                        mm_util_error(fmt" : standard error= [%s]", buf); \
                } while (0)
 
-#define IMG_JPEG_FREE(src) { if(src != NULL) {free(src); src = NULL;} }
+#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());}
-#define _tj(f) {if((f)==-1) _throwtj();}
+#define _throwtj() {printf("TurboJPEG ERROR:\n%s\n", tjGetErrorStr()); }
+#define _tj(f) {if ((f) == -1) _throwtj(); }
 
-const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440"};
+const char *subName[TJ_NUMSAMP] = {"444", "422", "420", "GRAY", "440"};
 
 void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
 {
-       int roffset=tjRedOffset[pf];
-       int goffset=tjGreenOffset[pf];
-       int boffset=tjBlueOffset[pf];
-       int ps=tjPixelSize[pf];
-       int index, row, col, halfway=16;
+       int roffset = tjRedOffset[pf];
+       int goffset = tjGreenOffset[pf];
+       int boffset = tjBlueOffset[pf];
+       int ps = tjPixelSize[pf];
+       int index, row, col, halfway = 16;
 
        memset(buf, 0, w*h*ps);
-       if(pf==TJPF_GRAY) {
-               for(row=0; row<h; row++) {
-                       for(col=0; col<w; col++) {
-                               if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
-                               else index=row*w+col;
-                               if(((row/8)+(col/8))%2==0) buf[index]=(row<halfway)? 255:0;
-                               else buf[index]=(row<halfway)? 76:226;
+       if (pf == TJPF_GRAY) {
+               for (row = 0; row < h; row++) {
+                       for (col = 0; col < w; col++) {
+                               if (flags&TJFLAG_BOTTOMUP) index = (h-row-1)*w+col;
+                               else index = row*w+col;
+                               if (((row/8) + (col/8)) % 2 == 0) buf[index] = (row < halfway) ? 255 : 0;
+                               else buf[index] = (row < halfway) ? 76 : 226;
                        }
                }
        } else {
-               for(row=0; row<h; row++) {
-                       for(col=0; col<w; col++) {
-                               if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
-                               else index=row*w+col;
-                               if(((row/8)+(col/8))%2==0) {
-                                       if(row<halfway) {
-                                               buf[index*ps+roffset]=255;
-                                               buf[index*ps+goffset]=255;
-                                               buf[index*ps+boffset]=255;
+               for (row = 0; row < h; row++) {
+                       for (col = 0; col < w; col++) {
+                               if (flags&TJFLAG_BOTTOMUP) index = (h-row-1)*w+col;
+                               else index = row*w+col;
+                               if (((row/8) + (col/8))%2 == 0) {
+                                       if (row < halfway) {
+                                               buf[index*ps+roffset] = 255;
+                                               buf[index*ps+goffset] = 255;
+                                               buf[index*ps+boffset] = 255;
                                        }
                                } else {
-                                       buf[index*ps+roffset]=255;
-                                       if(row>=halfway) buf[index*ps+goffset]=255;
+                                       buf[index*ps+roffset] = 255;
+                                       if (row >= halfway) buf[index*ps + goffset] = 255;
                                }
                        }
                }
        }
 }
 
-static void
-mm_image_codec_writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize, char *filename)
+static void mm_image_codec_writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize, char *filename)
 {
-       FILE *file=fopen(filename, "wb");
-       if(!file || fwrite(jpegBuf, jpegSize, 1, file)!=1) {
+       FILE *file = fopen(filename, "wb");
+       if (!file || fwrite(jpegBuf, jpegSize, 1, file) != 1) {
                mm_util_error("ERROR: Could not write to %s", filename);
                mm_util_stderror("ERROR: Could not write");
        }
 
-       if(file) fclose(file);
+       if (file) fclose(file);
 }
 
-static void
-_mm_decode_libjpeg_turbo_decompress(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int TD_BU,mm_util_jpeg_yuv_data* decoded_data, mm_util_jpeg_yuv_format input_fmt)
+static void _mm_decode_libjpeg_turbo_decompress(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int TD_BU, mm_util_jpeg_yuv_data* decoded_data, mm_util_jpeg_yuv_format input_fmt)
 {
-       int _hdrw=0, _hdrh=0, _hdrsubsamp=-1;
-       int scaledWidth=0;
-       int scaledHeight=0;
-       unsigned long dstSize=0;
-       int i=0,n=0;
+       int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1;
+       int scaledWidth = 0;
+       int scaledHeight = 0;
+       unsigned long dstSize = 0;
+       int i = 0, n = 0;
        tjscalingfactor _sf;
-       tjscalingfactor*sf=tjGetScalingFactors(&n), sf1={1, 1};
+       tjscalingfactor*sf = tjGetScalingFactors(&n), sf1 = {1, 1};
 
-       if(jpegBuf == NULL) {
+       if (jpegBuf == NULL) {
                mm_util_error("jpegBuf is NULL");
                return;
        }
@@ -156,155 +154,147 @@ _mm_decode_libjpeg_turbo_decompress(tjhandle handle, unsigned char *jpegBuf, uns
 
        _tj(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh, &_hdrsubsamp));
 
-       if(!sf || !n) {
+       if (!sf || !n) {
                mm_util_error(" scaledfactor is NULL");
                return;
        }
 
-       if((_hdrsubsamp==TJSAMP_444 || _hdrsubsamp==TJSAMP_GRAY) || input_fmt==MM_UTIL_JPEG_FMT_RGB888) {
-               _sf= sf[i];
+       if ((_hdrsubsamp == TJSAMP_444 || _hdrsubsamp == TJSAMP_GRAY) || input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               _sf = sf[i];
        } else {
-               _sf=sf1;
+               _sf = sf1;
        }
 
-       scaledWidth=TJSCALED(_hdrw, _sf);
-       scaledHeight=TJSCALED(_hdrh, _sf);
-       mm_util_debug("_hdrw:%d _hdrh:%d, _hdrsubsamp:%d, scaledWidth:%d, scaledHeight:%d",  _hdrw, _hdrh, _hdrsubsamp, scaledWidth, scaledHeight);
+       scaledWidth = TJSCALED(_hdrw, _sf);
+       scaledHeight = TJSCALED(_hdrh, _sf);
+       mm_util_debug("_hdrw:%d _hdrh:%d, _hdrsubsamp:%d, scaledWidth:%d, scaledHeight:%d", _hdrw, _hdrh, _hdrsubsamp, scaledWidth, scaledHeight);
 
-       if(input_fmt==MM_UTIL_JPEG_FMT_YUV420 || input_fmt==MM_UTIL_JPEG_FMT_YUV422) {
+       if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
                mm_util_debug("JPEG -> YUV %s ... ", subName[_hdrsubsamp]);
-       } else if(input_fmt==MM_UTIL_JPEG_FMT_RGB888) {
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
                mm_util_debug("JPEG -> RGB %d/%d ... ", _sf.num, _sf.denom);
        }
 
-       if(input_fmt==MM_UTIL_JPEG_FMT_YUV420 || input_fmt==MM_UTIL_JPEG_FMT_YUV422) {
-               dstSize=TJBUFSIZEYUV(_hdrw, _hdrh, _hdrsubsamp);
-               mm_util_debug("MM_UTIL_JPEG_FMT_YUV420 dstSize: %d  _hdrsubsamp:%d TJBUFSIZEYUV(w, h, _hdrsubsamp): %d",
+       if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+               dstSize = TJBUFSIZEYUV(_hdrw, _hdrh, _hdrsubsamp);
+               mm_util_debug("MM_UTIL_JPEG_FMT_YUV420 dstSize: %d _hdrsubsamp:%d TJBUFSIZEYUV(w, h, _hdrsubsamp): %d",
                        dstSize, _hdrsubsamp, TJBUFSIZEYUV(_hdrw, _hdrh, _hdrsubsamp));
-       }
-       else if(input_fmt==MM_UTIL_JPEG_FMT_RGB888)
-       {
-               dstSize=scaledWidth*scaledHeight*tjPixelSize[TJPF_RGB];
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               dstSize = scaledWidth*scaledHeight*tjPixelSize[TJPF_RGB];
                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*)malloc(dstSize)) == NULL) {
                mm_util_error("dstBuf is NULL");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
        mm_util_debug("dstBuf:%p", decoded_data->data);
 
-       if(input_fmt==MM_UTIL_JPEG_FMT_YUV420 || input_fmt==MM_UTIL_JPEG_FMT_YUV422) {
+       if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
                _tj(tjDecompressToYUV(handle, jpegBuf, jpegSize, decoded_data->data, TD_BU));
                mm_util_debug("MM_UTIL_JPEG_FMT_YUV420, dstBuf: %d", decoded_data->data);
-               decoded_data->format=input_fmt;
-       }
-       else if(input_fmt==MM_UTIL_JPEG_FMT_RGB888) {
+               decoded_data->format = input_fmt;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
                _tj(tjDecompress2(handle, jpegBuf, jpegSize, decoded_data->data, scaledWidth, 0, scaledHeight, TJPF_RGB, TD_BU));
                mm_util_debug("MM_UTIL_JPEG_FMT_RGB888, dstBuf: %p", decoded_data->data);
-               decoded_data->format=MM_UTIL_JPEG_FMT_RGB888;
+               decoded_data->format = MM_UTIL_JPEG_FMT_RGB888;
        } else {
                mm_util_error("[%s][%05d] We can't support the IMAGE format");
                return;
        }
 
-       decoded_data->size=dstSize;
-       if(input_fmt==MM_UTIL_JPEG_FMT_RGB888)
-       {
-               decoded_data->width=scaledWidth;
-               decoded_data->height=scaledHeight;
+       decoded_data->size = dstSize;
+       if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               decoded_data->width = scaledWidth;
+               decoded_data->height = scaledHeight;
                decoded_data->size = dstSize;
-       }
-       else if(input_fmt==MM_UTIL_JPEG_FMT_YUV420 ||input_fmt==MM_UTIL_JPEG_FMT_YUV422)
-       {
-               if(_hdrsubsamp == TJSAMP_422) {
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+               if (_hdrsubsamp == TJSAMP_422) {
                        mm_util_debug("_hdrsubsamp == TJSAMP_422", decoded_data->width, _hdrw);
-                       decoded_data->width=MM_JPEG_ROUND_UP_2(_hdrw);
+                       decoded_data->width = MM_JPEG_ROUND_UP_2(_hdrw);
                } else {
-                       if(_hdrw% 4 != 0) {
-                               decoded_data->width=MM_JPEG_ROUND_UP_4(_hdrw);
+                       if (_hdrw % 4 != 0) {
+                               decoded_data->width = MM_JPEG_ROUND_UP_4(_hdrw);
                        } else {
-                               decoded_data->width=_hdrw;
+                               decoded_data->width = _hdrw;
                        }
                }
 
-               if(_hdrsubsamp == TJSAMP_420) {
+               if (_hdrsubsamp == TJSAMP_420) {
                        mm_util_debug("_hdrsubsamp == TJSAMP_420", decoded_data->width, _hdrw);
-                       if(_hdrh% 4 != 0) {
-                               decoded_data->height=MM_JPEG_ROUND_UP_4(_hdrh);
+                       if (_hdrh % 4 != 0) {
+                               decoded_data->height = MM_JPEG_ROUND_UP_4(_hdrh);
                        } else {
-                       decoded_data->height=_hdrh;
+                       decoded_data->height = _hdrh;
                        }
                } else {
-                       decoded_data->height=_hdrh;
+                       decoded_data->height = _hdrh;
                }
                decoded_data->size = dstSize;
        }
 }
 
-static int
-mm_image_decode_from_jpeg_file_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt)
+static int mm_image_decode_from_jpeg_file_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
-       tjhandle dhandle=NULL;
-       unsigned char *srcBuf=NULL;
+       tjhandle dhandle = NULL;
+       unsigned char *srcBuf = NULL;
        int jpegSize;
-       int TD_BU=0;
+       int TD_BU = 0;
 
-       void *src = fopen(pFileName, "rb" );
-       if(src == NULL) {
+       void *src = fopen(pFileName, "rb");
+       if (src == NULL) {
                mm_util_error("Error [%s] failed", pFileName);
                mm_util_stderror("Error file open failed");
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
-       fseek (src, 0,  SEEK_END);
+       fseek(src, 0, SEEK_END);
        jpegSize = ftell(src);
        rewind(src);
 
-       if((dhandle=tjInitDecompress())==NULL) {
+       if ((dhandle = tjInitDecompress()) == NULL) {
                fclose(src);
                mm_util_error("dhandle=tjInitDecompress()) is NULL");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
-       srcBuf=(unsigned char *)malloc(sizeof(char) * jpegSize);
-       if(srcBuf==NULL) {
+       srcBuf = (unsigned char *)malloc(sizeof(char) * jpegSize);
+       if (srcBuf == NULL) {
                fclose(src);
                tjDestroy(dhandle);
                mm_util_error("srcBuf is NULL");
                return MM_UTIL_ERROR_OUT_OF_MEMORY;
        }
 
-       fread(srcBuf,1, jpegSize, src);
+       fread(srcBuf, 1, jpegSize, src);
        mm_util_debug("srcBuf[0]: 0x%2x, srcBuf[1]: 0x%2x, jpegSize:%d", srcBuf[0], srcBuf[1], jpegSize);
        _mm_decode_libjpeg_turbo_decompress(dhandle, srcBuf, jpegSize, TD_BU, decoded_data, input_fmt);
        fclose(src);
        mm_util_debug("fclose");
 
-       if(dhandle) {
+       if (dhandle) {
                tjDestroy(dhandle);
        }
-       if(srcBuf) {
+       if (srcBuf) {
                tjFree(srcBuf);
        }
 
        return iErrorCode;
 }
 
-static int
-mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, void *src, int size, mm_util_jpeg_yuv_format input_fmt)
+static int mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(mm_util_jpeg_yuv_data * decoded_data, void *src, int size, mm_util_jpeg_yuv_format input_fmt)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
-       tjhandle dhandle=NULL;
-       unsigned char *srcBuf=NULL;
-       int TD_BU=0;
+       tjhandle dhandle = NULL;
+       unsigned char *srcBuf = NULL;
+       int TD_BU = 0;
 
-       if((dhandle=tjInitDecompress())==NULL) {
+       if ((dhandle = tjInitDecompress()) == NULL) {
                mm_util_error("dhandle=tjInitDecompress()) is NULL");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
-       srcBuf=(unsigned char *)malloc(sizeof(char) * size);
-       if(srcBuf==NULL) {
+       srcBuf = (unsigned char *)malloc(sizeof(char) * size);
+       if (srcBuf == NULL) {
                fclose(src);
                tjDestroy(dhandle);
                mm_util_error("srcBuf is NULL");
@@ -314,33 +304,32 @@ mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(mm_util_jpeg_yuv_data * deco
        mm_util_debug("srcBuf[0]: 0x%2x, srcBuf[1]: 0x%2x, jpegSize:%d", srcBuf[0], srcBuf[1], size);
        _mm_decode_libjpeg_turbo_decompress(dhandle, src, size, TD_BU, decoded_data, input_fmt);
 
-       if(dhandle) {
+       if (dhandle) {
                tjDestroy(dhandle);
        }
-       if(srcBuf) {
+       if (srcBuf) {
                tjFree(srcBuf);
        }
 
        return iErrorCode;
 }
 
-static void
-_mm_encode_libjpeg_turbo_compress(tjhandle handle, void *src, unsigned char **dstBuf, unsigned long *dstSize, int w, int h, int jpegQual, int flags, mm_util_jpeg_yuv_format fmt)
+static void _mm_encode_libjpeg_turbo_compress(tjhandle handle, void *src, unsigned char **dstBuf, unsigned long *dstSize, int w, int h, int jpegQual, int flags, mm_util_jpeg_yuv_format fmt)
 {
-       unsigned char *srcBuf=NULL;
-       unsigned long jpegSize=0;
+       unsigned char *srcBuf = NULL;
+       unsigned long jpegSize = 0;
 
-       jpegSize=w*h*tjPixelSize[TJPF_RGB];
-       srcBuf=(unsigned char *)malloc(jpegSize);
+       jpegSize = w*h*tjPixelSize[TJPF_RGB];
+       srcBuf = (unsigned char *)malloc(jpegSize);
 
-       if(srcBuf==NULL) {
+       if (srcBuf == NULL) {
                mm_util_error("srcBuf is NULL");
                return;
        } else {
                mm_util_debug("srcBuf: 0x%2x", srcBuf);
-               if(fmt==MM_UTIL_JPEG_FMT_RGB888) {
+               if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                        initBuf(srcBuf, w, h, TJPF_RGB, flags);
-               } else if(fmt==MM_UTIL_JPEG_FMT_YUV420 || fmt==MM_UTIL_JPEG_FMT_YUV422) {
+               } 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);
@@ -350,51 +339,50 @@ _mm_encode_libjpeg_turbo_compress(tjhandle handle, void *src, unsigned char **ds
                memcpy(srcBuf, src, jpegSize);
        }
 
-       if(*dstBuf && *dstSize>0) memset(*dstBuf, 0, *dstSize);
+       if (*dstBuf && *dstSize > 0) memset(*dstBuf, 0, *dstSize);
        mm_util_debug("Done.");
-       *dstSize=TJBUFSIZE(w, h);
-       if(fmt==MM_UTIL_JPEG_FMT_RGB888) {
+       *dstSize = TJBUFSIZE(w, h);
+       if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                _tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_RGB, dstBuf, dstSize, TJPF_RGB, jpegQual, flags));
                mm_util_debug("*dstSize: %d", *dstSize);
-       } else if(fmt==MM_UTIL_JPEG_FMT_YUV420) {
-               *dstSize=TJBUFSIZEYUV(w, h, TJSAMP_420);
+       } else if (fmt == MM_UTIL_JPEG_FMT_YUV420) {
+               *dstSize = TJBUFSIZEYUV(w, h, TJSAMP_420);
                _tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_RGB, *dstBuf, TJSAMP_420, flags));
                mm_util_debug("*dstSize: %d \t decode_yuv_subsample: %d TJBUFSIZE(w, h):%d", *dstSize, TJSAMP_420, TJBUFSIZE(w, h));
-       } else if(fmt==MM_UTIL_JPEG_FMT_YUV422) {
-               *dstSize=TJBUFSIZEYUV(w, h, TJSAMP_422);
+       } else if (fmt == MM_UTIL_JPEG_FMT_YUV422) {
+               *dstSize = TJBUFSIZEYUV(w, h, TJSAMP_422);
                _tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_RGB, *dstBuf, TJSAMP_422, flags));
                mm_util_debug("*dstSize: %d \t decode_yuv_subsample: %d TJBUFSIZE(w, h):%d", *dstSize, TJSAMP_422, TJBUFSIZE(w, h));
        } else {
-               mm_util_error("fmt:%d  is wrong", fmt);
+               mm_util_error("fmt:%d is wrong", fmt);
        }
 
        IMG_JPEG_FREE(srcBuf);
 }
 
-static int
-mm_image_encode_to_jpeg_file_with_libjpeg_turbo(char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+static int mm_image_encode_to_jpeg_file_with_libjpeg_turbo(char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
-       tjhandle chandle=NULL;
-       unsigned char *dstBuf=NULL;
-       unsigned long size=0;
-       int TD_BU=0;
-       FILE *fout=fopen(filename, "w+");
-       if(fout == NULL) {
+       tjhandle chandle = NULL;
+       unsigned char *dstBuf = NULL;
+       unsigned long size = 0;
+       int TD_BU = 0;
+       FILE *fout = fopen(filename, "w+");
+       if (fout == NULL) {
                mm_util_error("FILE OPEN FAIL [%s] failed", filename);
                mm_util_stderror("FILE OPEN FAIL");
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
        mm_util_debug("fmt: %d", fmt);
 
-       size=TJBUFSIZE(width, height);
-       if((dstBuf=(unsigned char *)tjAlloc(size))==NULL) {
+       size = TJBUFSIZE(width, height);
+       if ((dstBuf = (unsigned char *)tjAlloc(size)) == NULL) {
                fclose(fout);
                mm_util_error("dstBuf is NULL");
                return MM_UTIL_ERROR_OUT_OF_MEMORY;
        }
 
-       if((chandle=tjInitCompress())==NULL) {
+       if ((chandle = tjInitCompress()) == NULL) {
                fclose(fout);
                tjFree(dstBuf);
                mm_util_error("dstBuf is NULL");
@@ -404,39 +392,38 @@ mm_image_encode_to_jpeg_file_with_libjpeg_turbo(char *filename, void* src, int w
        mm_util_debug("dstBuf: %p\t size: %d", dstBuf, size);
        fwrite(dstBuf, 1, size, fout);
        fclose(fout);
-       if(chandle) {
+       if (chandle) {
                tjDestroy(chandle);
        }
-       if(dstBuf) {
+       if (dstBuf) {
                tjFree(dstBuf);
        }
        mm_util_debug("Done");
        return iErrorCode;
 }
 
-static int
-mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, int *csize, void *rawdata,  int w, int h, mm_util_jpeg_yuv_format fmt,int quality)
+static int mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, int *csize, void *rawdata, int w, int h, mm_util_jpeg_yuv_format fmt, int quality)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
-       tjhandle chandle=NULL;
-       int TD_BU=0;
+       tjhandle chandle = NULL;
+       int TD_BU = 0;
 
-       *csize=TJBUFSIZE(w, h);
-       if(fmt==MM_UTIL_JPEG_FMT_RGB888) {
+       *csize = TJBUFSIZE(w, h);
+       if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                mm_util_debug("MM_UTIL_JPEG_FMT_RGB888 size: %d", *csize);
-       }else if(fmt==MM_UTIL_JPEG_FMT_YUV420 ||fmt==MM_UTIL_JPEG_FMT_YUV422) {
-               mm_util_debug("TJSAMP_420 ||TJSAMP_422 size: %d",*csize);
-       }else {
+       } else if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422) {
+               mm_util_debug("TJSAMP_420 ||TJSAMP_422 size: %d", *csize);
+       } else {
                        mm_util_error("We can't support the IMAGE format");
                        return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        }
 
-       if((*mem=(unsigned char *)tjAlloc(*csize))==NULL) {
+       if ((*mem = (unsigned char *)tjAlloc(*csize)) == NULL) {
                mm_util_error("dstBuf is NULL");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if((chandle=tjInitCompress())==NULL) {
+       if ((chandle = tjInitCompress()) == NULL) {
                tjFree(*mem);
                mm_util_error("chandle is NULL");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -445,7 +432,7 @@ mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, int *csize, void *
        mm_util_debug("width: %d height: %d, size: %d", w, h, *csize);
        _mm_encode_libjpeg_turbo_compress(chandle, rawdata, mem, csize, w, h, quality, TD_BU, fmt);
        mm_util_debug("dstBuf: %p &dstBuf:%p size: %d", *mem, mem, *csize);
-       if(chandle) {
+       if (chandle) {
                tjDestroy(chandle);
        }
        return iErrorCode;
@@ -453,8 +440,7 @@ mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, int *csize, void *
 #endif
 
 /* OPEN SOURCE */
-struct my_error_mgr_s
-{
+struct my_error_mgr_s {
        struct jpeg_error_mgr pub; /* "public" fields */
        jmp_buf setjmp_buffer; /* for return to caller */
 } my_error_mgr_s;
@@ -467,7 +453,7 @@ struct {
        JOCTET * buffer; /* start of buffer */
 } my_destination_mgr_s;
 
-typedef struct  my_destination_mgr_s * my_dest_ptr;
+typedef struct my_destination_mgr_s * my_dest_ptr;
 
 #define OUTPUT_BUF_SIZE  4096  /* choose an efficiently fwrite'able size */
 
@@ -485,12 +471,11 @@ struct {
 
 typedef struct my_mem_destination_mgr * my_mem_dest_ptr;
 
-static void
-my_error_exit (j_common_ptr cinfo)
+static void my_error_exit(j_common_ptr cinfo)
 {
        my_error_ptr myerr = (my_error_ptr) cinfo->err; /* cinfo->err really points to a my_error_mgr_s struct, so coerce pointer */
-       (*cinfo->err->output_message) (cinfo); /*  Always display the message. We could postpone this until after returning, if we chose. */
-       longjmp(myerr->setjmp_buffer, 1); /*  Return control to the setjmp point */
+       (*cinfo->err->output_message) (cinfo); /* Always display the message. We could postpone this until after returning, if we chose. */
+       longjmp(myerr->setjmp_buffer, 1); /* Return control to the setjmp point */
 }
 
 static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
@@ -502,9 +487,9 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
        int i, j, flag, _height;
        FILE * fpWriter;
 
-       JSAMPROW y[16],cb[16],cr[16]; /* y[2][5] = color sample of row 2 and pixel column 5; (one plane) */
+       JSAMPROW y[16], cb[16], cr[16]; /* y[2][5] = color sample of row 2 and pixel column 5; (one plane) */
        JSAMPARRAY data[3]; /* t[0][2][5] = color sample 0 of row 2 and column 5 */
-       if(!pFileName) {
+       if (!pFileName) {
                mm_util_error("pFileName");
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
@@ -528,7 +513,7 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
        jpeg_stdio_dest(&cinfo, fpWriter);
        cinfo.image_width = width;
        cinfo.image_height = height;
-       if (fmt ==MM_UTIL_JPEG_FMT_YUV420 ||fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+       if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY) {
                mm_util_debug("[mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for YUV");
                mm_util_debug("[Height] %d", height);
                _height = MM_JPEG_ROUND_DOWN_16(height);
@@ -541,13 +526,13 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
                jpeg_set_defaults(&cinfo);
                mm_util_debug("jpeg_set_defaults");
 
-               cinfo.raw_data_in = TRUE; /*  Supply downsampled data */
+               cinfo.raw_data_in = TRUE; /* Supply downsampled data */
                cinfo.do_fancy_downsampling = FALSE;
 
                cinfo.comp_info[0].h_samp_factor = 2;
-               if (fmt ==MM_UTIL_JPEG_FMT_YUV420) {
+               if (fmt == MM_UTIL_JPEG_FMT_YUV420) {
                        cinfo.comp_info[0].v_samp_factor = 2;
-               } else if (fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY) {
                        cinfo.comp_info[0].v_samp_factor = 1;
                }
                cinfo.comp_info[1].h_samp_factor = 1;
@@ -562,17 +547,17 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
                jpeg_start_compress(&cinfo, TRUE);
                mm_util_debug("jpeg_start_compress");
 
-               if(flag) {
-                       void *large_rect = malloc (width);
-                       void *small_rect = malloc (width);
-                       if(large_rect) {
+               if (flag) {
+                       void *large_rect = malloc(width);
+                       void *small_rect = malloc(width);
+                       if (large_rect) {
                                memset(large_rect, 0x10, width);
                        } else {
                                IMG_JPEG_FREE(small_rect);
                                mm_util_error("large rectangle memory");
                                return MM_UTIL_ERROR_INVALID_PARAMETER;
                        }
-                       if(small_rect) {
+                       if (small_rect) {
                                memset(small_rect, 0x80, width);
                        } else {
                                IMG_JPEG_FREE(large_rect);
@@ -626,29 +611,29 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
 
                jpeg_destroy_compress(&cinfo);
                mm_util_debug("jpeg_destroy_compress");
-       } 
+       }
 
-       else if (fmt == MM_UTIL_JPEG_FMT_RGB888 ||fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+       else if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                JSAMPROW row_pointer[1];
                int iRowStride = 0;
 
-               if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                        cinfo.input_components = 3;
                        cinfo.in_color_space = JCS_RGB;
                        mm_util_debug("JCS_RGB");
-               } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_GraySacle) {
                        cinfo.input_components = 1; /* one colour component */
                        cinfo.in_color_space = JCS_GRAYSCALE;
                        mm_util_debug("JCS_GRAYSCALE");
-               } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
                        cinfo.input_components = 4; /* one colour component */
                        cinfo.in_color_space = JCS_EXT_RGBA;
                        mm_util_debug("JCS_EXT_RGBA");
-               } else if(fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
                        cinfo.input_components = 4;
                        cinfo.in_color_space = JCS_EXT_BGRA;
                        mm_util_debug("JCS_EXT_BGRA");
-               } else if(fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                        cinfo.input_components = 4;
                        cinfo.in_color_space = JCS_EXT_ARGB;
                        mm_util_debug("JCS_EXT_ARGB");
@@ -660,11 +645,11 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
                mm_util_debug("jpeg_set_quality");
                jpeg_start_compress(&cinfo, TRUE);
                mm_util_debug("jpeg_start_compress");
-               if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                        iRowStride = width * 3;
-               } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_GraySacle) {
                        iRowStride = width;
-               } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                        iRowStride = width * 4;
                }
 
@@ -690,13 +675,12 @@ static int mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void
        return iErrorCode;
 }
 
-static int
-mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt,int quality)
+static int mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
 
-       JSAMPROW y[16],cb[16],cr[16]; /*  y[2][5] = color sample of row 2 and pixel column 5; (one plane) */
-       JSAMPARRAY data[3]; /*  t[0][2][5] = color sample 0 of row 2 and column 5 */
+       JSAMPROW y[16], cb[16], cr[16]; /* y[2][5] = color sample of row 2 and pixel column 5; (one plane) */
+       JSAMPARRAY data[3]; /* t[0][2][5] = color sample 0 of row 2 and column 5 */
 
        struct jpeg_compress_struct cinfo;
        struct jpeg_error_mgr jerr;
@@ -711,7 +695,7 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
        mm_util_debug("#Before Enter#, mem: %p\t rawdata:%p\t width: %d\t height: %d\t fmt: %d\t quality: %d"
                , mem, rawdata, width, height, fmt, quality);
 
-       if(rawdata == NULL) {
+       if (rawdata == NULL) {
                mm_util_error("Exit on error -rawdata");
                return MM_UTIL_ERROR_OUT_OF_MEMORY;
        }
@@ -731,7 +715,7 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
        jpeg_mem_dest(&cinfo, (unsigned char **)mem, &size);
        cinfo.image_width = width;
        cinfo.image_height = height;
-       if (fmt ==MM_UTIL_JPEG_FMT_YUV420 ||fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+       if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY) {
                mm_util_debug("[mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for YUV");
                _height = MM_JPEG_ROUND_DOWN_16(height);
                flag = height - _height;
@@ -745,9 +729,9 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
                cinfo.do_fancy_downsampling = FALSE;
 
                cinfo.comp_info[0].h_samp_factor = 2;
-               if (fmt ==MM_UTIL_JPEG_FMT_YUV420) {
+               if (fmt == MM_UTIL_JPEG_FMT_YUV420) {
                        cinfo.comp_info[0].v_samp_factor = 2;
-               } else if (fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY) {
                        cinfo.comp_info[0].v_samp_factor = 1;
                }
                cinfo.comp_info[1].h_samp_factor = 1;
@@ -762,17 +746,17 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
                jpeg_start_compress(&cinfo, TRUE);
                mm_util_debug("jpeg_start_compress");
 
-               if(flag) {
-                       void *large_rect = malloc (width);
-                       void *small_rect = malloc (width);
-                       if(large_rect) {
+               if (flag) {
+                       void *large_rect = malloc(width);
+                       void *small_rect = malloc(width);
+                       if (large_rect) {
                                memset(large_rect, 0x10, width);
                        } else {
                                IMG_JPEG_FREE(small_rect);
                                mm_util_error("large rectangle memory");
                                return MM_UTIL_ERROR_INVALID_PARAMETER;
                        }
-                       if(small_rect) {
+                       if (small_rect) {
                                memset(small_rect, 0x80, width);
                        } else {
                                IMG_JPEG_FREE(large_rect);
@@ -827,28 +811,28 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
                mm_util_debug("Exit jpeg_destroy_compress, mem: %p\t size:%d", *mem, *csize);
        }
 
-       else if (fmt == MM_UTIL_JPEG_FMT_RGB888 ||fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+       else if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                JSAMPROW row_pointer[1];
                int iRowStride = 0;
 
                mm_util_debug("MM_UTIL_JPEG_FMT_RGB888");
-               if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                        cinfo.input_components = 3;
                        cinfo.in_color_space = JCS_RGB;
                        mm_util_debug("JCS_RGB");
-               } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_GraySacle) {
                        cinfo.input_components = 1; /* one colour component */
                        cinfo.in_color_space = JCS_GRAYSCALE;
                        mm_util_debug("JCS_GRAYSCALE");
-               } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
                        cinfo.input_components = 4;
                        cinfo.in_color_space = JCS_EXT_RGBA;
                        mm_util_debug("JCS_EXT_RGBA");
-               } else if(fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
                        cinfo.input_components = 4;
                        cinfo.in_color_space = JCS_EXT_BGRA;
                        mm_util_debug("JCS_EXT_BGRA");
-               } else if(fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                        cinfo.input_components = 4;
                        cinfo.in_color_space = JCS_EXT_ARGB;
                        mm_util_debug("JCS_EXT_ARGB");
@@ -860,11 +844,11 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
                mm_util_debug("jpeg_set_quality");
                jpeg_start_compress(&cinfo, TRUE);
                mm_util_debug("jpeg_start_compress");
-               if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
+               if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
                        iRowStride = width * 3;
-               } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_GraySacle) {
                        iRowStride = width;
-               } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               } else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                        iRowStride = width * 4;
                }
 
@@ -889,8 +873,7 @@ mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, int *csize, void *rawdat
        return iErrorCode;
 }
 
-static int
-mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
+static int mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
        FILE *infile = NULL;
@@ -903,20 +886,20 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
 
        mm_util_debug("Enter");
 
-       if(!pFileName) {
+       if (!pFileName) {
                mm_util_error("pFileName");
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
-       if(decoded_data == NULL) {
+       if (decoded_data == NULL) {
                mm_util_error("decoded_data");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
-       if(decoded_data) {
+       if (decoded_data) {
                decoded_data->data = NULL;
        }
 
        infile = fopen(pFileName, "rb");
-       if(infile == NULL) {
+       if (infile == NULL) {
                mm_util_error("[infile] file open [%s]", pFileName);
                mm_util_stderror("file open failed");
                return MM_UTIL_ERROR_NO_SUCH_FILE;
@@ -939,7 +922,7 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       mm_util_debug("if(setjmp)");
+       mm_util_debug("if (setjmp)");
        /* Now we can initialize the JPEG decompression object. */
        jpeg_create_decompress(&dinfo);
        mm_util_debug("jpeg_create_decompress");
@@ -952,7 +935,7 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
        jpeg_read_header(&dinfo, TRUE);
 #if PARTIAL_DECODE
        mm_util_debug("image width: %d height: %d", dinfo.image_width, dinfo.image_height);
-       if(dinfo.image_width > ENC_MAX_LEN || dinfo.image_height > ENC_MAX_LEN) {
+       if (dinfo.image_width > ENC_MAX_LEN || dinfo.image_height > ENC_MAX_LEN) {
                dinfo.scale_num = 1;
                dinfo.scale_denom = 8;
                dinfo.do_fancy_upsampling = FALSE;
@@ -970,23 +953,23 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
 
        /* set parameters for decompression */
        if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
-               dinfo.out_color_space=JCS_RGB;
-               mm_util_debug("cinfo.out_color_space=JCS_RGB");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
-               dinfo.out_color_space=JCS_YCbCr;
-               mm_util_debug("cinfo.out_color_space=JCS_YCbCr");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
-               dinfo.out_color_space=JCS_GRAYSCALE;
-               mm_util_debug("cinfo.out_color_space=JCS_GRAYSCALE");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
-               dinfo.out_color_space=JCS_EXT_RGBA;
-               mm_util_debug("cinfo.out_color_space=JCS_EXT_RGBA");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
-               dinfo.out_color_space=JCS_EXT_BGRA;
-               mm_util_debug("cinfo.out_color_space=JCS_EXT_BGRA");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
-               dinfo.out_color_space=JCS_EXT_ARGB;
-               mm_util_debug("cinfo.out_color_space=JCS_EXT_ARGB");
+               dinfo.out_color_space = JCS_RGB;
+               mm_util_debug("cinfo.out_color_space = JCS_RGB");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+               dinfo.out_color_space = JCS_YCbCr;
+               mm_util_debug("cinfo.out_color_space = JCS_YCbCr");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               dinfo.out_color_space = JCS_GRAYSCALE;
+               mm_util_debug("cinfo.out_color_space = JCS_GRAYSCALE");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+               dinfo.out_color_space = JCS_EXT_RGBA;
+               mm_util_debug("cinfo.out_color_space = JCS_EXT_RGBA");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+               dinfo.out_color_space = JCS_EXT_BGRA;
+               mm_util_debug("cinfo.out_color_space = JCS_EXT_BGRA");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               dinfo.out_color_space = JCS_EXT_ARGB;
+               mm_util_debug("cinfo.out_color_space = JCS_EXT_ARGB");
        }
        decoded_data->format = input_fmt;
 
@@ -995,10 +978,10 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
 
        /* byte-align for YUV format */
        if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
-               if(dinfo.output_width% 2 != 0) {
+               if (dinfo.output_width % 2 != 0) {
                        dinfo.output_width = MM_JPEG_ROUND_DOWN_2(dinfo.output_width);
                }
-               if(dinfo.output_height% 2 != 0) {
+               if (dinfo.output_height % 2 != 0) {
                        dinfo.output_height = MM_JPEG_ROUND_DOWN_2(dinfo.output_height);
                }
        }
@@ -1010,15 +993,15 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
        buffer = (*dinfo.mem->alloc_sarray) ((j_common_ptr) &dinfo, JPOOL_IMAGE, row_stride, 1);
        mm_util_debug("JPOOL_IMAGE BUFFER");
        decoded_data->width = dinfo.output_width;
-       decoded_data->height= dinfo.output_height;
-       if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
-               decoded_data->size= dinfo.output_height * row_stride;
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
-               decoded_data->size= dinfo.output_height * row_stride / 2;
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
-               decoded_data->size= dinfo.output_height * dinfo.output_width * 2;
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
-               decoded_data->size= dinfo.output_height * dinfo.output_width;
+       decoded_data->height = dinfo.output_height;
+       if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               decoded_data->size = dinfo.output_height * row_stride;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
+               decoded_data->size = dinfo.output_height * row_stride / 2;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+               decoded_data->size = dinfo.output_height * dinfo.output_width * 2;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               decoded_data->size = dinfo.output_height * dinfo.output_width;
        } else{
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("[%d] We can't decode the IMAGE format", input_fmt);
@@ -1026,10 +1009,10 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
                return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        }
 
-       decoded_data->data= (void*) g_malloc0(decoded_data->size);
+       decoded_data->data = (void*) g_malloc0(decoded_data->size);
        decoded_data->format = input_fmt;
 
-       if(decoded_data->data == NULL) {
+       if (decoded_data->data == NULL) {
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("decoded_data->data is NULL");
                fclose(infile);
@@ -1037,20 +1020,20 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
        }
        mm_util_debug("decoded_data->data");
 
-       if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+       if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
                image = decoded_data->data;
                u_image = image + (dinfo.output_width * dinfo.output_height);
                v_image = u_image + (dinfo.output_width*dinfo.output_height) / 4;
-               row= buffer[0];
+               row = buffer[0];
                int i = 0;
                int y = 0;
                while (dinfo.output_scanline < dinfo.output_height) {
                        jpeg_read_scanlines(&dinfo, buffer, 1);
                        for (i = 0; i < row_stride; i += 3) {
-                               image[i/3]=row[i];
+                               image[i/3] = row[i];
                                if (i & 1) {
-                                       u_image[(i/3)/2]=row[i+1];
-                                       v_image[(i/3)/2]=row[i+2];
+                                       u_image[(i/3)/2] = row[i+1];
+                                       v_image[(i/3)/2] = row[i+2];
                                }
                        }
                        image += row_stride/3;
@@ -1059,7 +1042,7 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
                                v_image += dinfo.output_width / 2;
                        }
                }
-       }else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                int state = 0;
                /* while (scan lines remain to be read) jpeg_read_scanlines(...); */
                while (dinfo.output_scanline < dinfo.output_height) {
@@ -1083,8 +1066,7 @@ mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data
        return iErrorCode;
 }
 
-static int
-mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, void *src, int size, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
+static int mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_data, void *src, int size, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
        struct jpeg_decompress_struct dinfo;
@@ -1096,16 +1078,16 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
 
        mm_util_debug("Enter");
 
-       if(src == NULL) {
+       if (src == NULL) {
                mm_util_error("[infile] Exit on error");
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
        mm_util_debug("infile");
-       if(decoded_data == NULL) {
+       if (decoded_data == NULL) {
                mm_util_error("decoded_data");
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
-       if(decoded_data) {
+       if (decoded_data) {
                decoded_data->data = NULL;
        }
 
@@ -1124,7 +1106,7 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
 
-       mm_util_debug("if(setjmp)");
+       mm_util_debug("if (setjmp)");
        /* Now we can initialize the JPEG decompression object. */
        jpeg_create_decompress(&dinfo);
        mm_util_debug("jpeg_create_decompress");
@@ -1138,7 +1120,7 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
        mm_util_debug("jpeg_read_header");
 #if PARTIAL_DECODE
        mm_util_debug("image width: %d height: %d", dinfo.image_width, dinfo.image_height);
-       if(dinfo.image_width > ENC_MAX_LEN || dinfo.image_height > ENC_MAX_LEN) {
+       if (dinfo.image_width > ENC_MAX_LEN || dinfo.image_height > ENC_MAX_LEN) {
                dinfo.scale_num = 1;
                dinfo.scale_denom = 8;
                dinfo.do_fancy_upsampling = FALSE;
@@ -1156,23 +1138,23 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
 
        /* set parameters for decompression */
        if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
-               dinfo.out_color_space=JCS_RGB;
-               mm_util_debug("cinfo.out_color_space=JCS_RGB");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
-               dinfo.out_color_space=JCS_YCbCr;
-               mm_util_debug("cinfo.out_color_space=JCS_YCbCr");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
-               dinfo.out_color_space=JCS_GRAYSCALE;
-               mm_util_debug("cinfo.out_color_space=JCS_GRAYSCALE");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
-               dinfo.out_color_space=JCS_EXT_RGBA;
-               mm_util_debug("cinfo.out_color_space=JCS_EXT_RGBA");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
-               dinfo.out_color_space=JCS_EXT_BGRA;
-               mm_util_debug("cinfo.out_color_space=JCS_EXT_BGRA");
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
-               dinfo.out_color_space=JCS_EXT_ARGB;
-               mm_util_debug("cinfo.out_color_space=JCS_EXT_ARGB");
+               dinfo.out_color_space = JCS_RGB;
+               mm_util_debug("cinfo.out_color_space = JCS_RGB");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+               dinfo.out_color_space = JCS_YCbCr;
+               mm_util_debug("cinfo.out_color_space = JCS_YCbCr");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               dinfo.out_color_space = JCS_GRAYSCALE;
+               mm_util_debug("cinfo.out_color_space = JCS_GRAYSCALE");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+               dinfo.out_color_space = JCS_EXT_RGBA;
+               mm_util_debug("cinfo.out_color_space = JCS_EXT_RGBA");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+               dinfo.out_color_space = JCS_EXT_BGRA;
+               mm_util_debug("cinfo.out_color_space = JCS_EXT_BGRA");
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               dinfo.out_color_space = JCS_EXT_ARGB;
+               mm_util_debug("cinfo.out_color_space = JCS_EXT_ARGB");
        }
        decoded_data->format = input_fmt;
 
@@ -1182,10 +1164,10 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
 
        /* byte-align for YUV format */
        if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
-               if(dinfo.output_width% 2 != 0) {
+               if (dinfo.output_width % 2 != 0) {
                        dinfo.output_width = MM_JPEG_ROUND_DOWN_2(dinfo.output_width);
                }
-               if(dinfo.output_height% 2 != 0) {
+               if (dinfo.output_height % 2 != 0) {
                        dinfo.output_height = MM_JPEG_ROUND_DOWN_2(dinfo.output_height);
                }
        }
@@ -1197,25 +1179,25 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
        buffer = (*dinfo.mem->alloc_sarray) ((j_common_ptr) &dinfo, JPOOL_IMAGE, row_stride, 1);
        mm_util_debug("JPOOL_IMAGE BUFFER");
        decoded_data->width = dinfo.output_width;
-       decoded_data->height= dinfo.output_height;
-       if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
-               decoded_data->size= dinfo.output_height * row_stride;
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
-               decoded_data->size= dinfo.output_height * row_stride / 2;
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
-               decoded_data->size= dinfo.output_height * dinfo.output_width * 2;
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
-               decoded_data->size= dinfo.output_height * dinfo.output_width;
+       decoded_data->height = dinfo.output_height;
+       if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+               decoded_data->size = dinfo.output_height * row_stride;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
+               decoded_data->size = dinfo.output_height * row_stride / 2;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+               decoded_data->size = dinfo.output_height * dinfo.output_width * 2;
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+               decoded_data->size = dinfo.output_height * dinfo.output_width;
        } else{
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("[%d] We can't decode the IMAGE format", input_fmt);
                return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        }
 
-       decoded_data->data= (void*) g_malloc0(decoded_data->size);
+       decoded_data->data = (void*) g_malloc0(decoded_data->size);
        decoded_data->format = input_fmt;
 
-       if(decoded_data->data == NULL) {
+       if (decoded_data->data == NULL) {
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("decoded_data->data is NULL");
                return MM_UTIL_ERROR_OUT_OF_MEMORY;
@@ -1223,20 +1205,20 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
        mm_util_debug("decoded_data->data");
 
        /* while (scan lines remain to be read) jpeg_read_scanlines(...); */
-       if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+       if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
                image = decoded_data->data;
                u_image = image + (dinfo.output_width * dinfo.output_height);
                v_image = u_image + (dinfo.output_width*dinfo.output_height)/4;
-               row= buffer[0];
+               row = buffer[0];
                int i = 0;
                int y = 0;
                while (dinfo.output_scanline < dinfo.output_height) {
                        jpeg_read_scanlines(&dinfo, buffer, 1);
                        for (i = 0; i < row_stride; i += 3) {
-                               image[i/3]=row[i];
+                               image[i/3] = row[i];
                                if (i & 1) {
-                                       u_image[(i/3)/2]=row[i+1];
-                                       v_image[(i/3)/2]=row[i+2];
+                                       u_image[(i/3)/2] = row[i+1];
+                                       v_image[(i/3)/2] = row[i+2];
                                }
                        }
                        image += row_stride/3;
@@ -1245,7 +1227,7 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
                                v_image += dinfo.output_width / 2;
                        }
                }
-       } else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+       } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                int state = 0;
                while (dinfo.output_scanline < dinfo.output_height) {
                        /* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
@@ -1271,7 +1253,7 @@ mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data * decoded_da
 }
 
 #if 0
-static int _mm_util_set_exif_entry(ExifData *exif, ExifIfd ifd, ExifTag tag,ExifFormat format, unsigned long components, unsigned char* data)
+static int _mm_util_set_exif_entry(ExifData *exif, ExifIfd ifd, ExifTag tag, ExifFormat format, unsigned long components, unsigned char* data)
 {
        ExifData *ed = (ExifData *)exif;
        ExifEntry *e = NULL;
@@ -1312,7 +1294,7 @@ static int _mm_util_set_exif_entry(ExifData *exif, ExifIfd ifd, ExifTag tag,Exif
        }
 
        e->size = exif_format_get_size(format) * e->components;
-       memcpy(e->data,data,e->size);
+       memcpy(e->data, data, e->size);
        exif_content_add_entry(ed->ifd[ifd], e);
        exif_entry_unref(e);
 
@@ -1320,32 +1302,31 @@ static int _mm_util_set_exif_entry(ExifData *exif, ExifIfd ifd, ExifTag tag,Exif
 }
 #endif
 
-EXPORT_API int
-mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+EXPORT_API int mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
        TTRACE_BEGIN("MM_UTILITY:JPEG:ENCODE_TO_FILE");
 
-       if!filename || !src) {
+       if (!filename || !src) {
                mm_util_error("#ERROR# filename || src buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(width <= 0) || (height <= 0)) {
+       if ((width <= 0) || (height <= 0)) {
                mm_util_error("#ERROR# src_width || src_height value ");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
+       if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (quality < 1 ) || (quality>100) ) {
+       if ((quality < 1) || (quality > 100)) {
                mm_util_error("#ERROR# quality vaule");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1353,25 +1334,25 @@ mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int heig
 
 #if LIBJPEG_TURBO
        mm_util_debug("#START# LIBJPEG_TURBO");
-       ret=mm_image_encode_to_jpeg_file_with_libjpeg_turbo(filename, src, width, height, fmt, quality);
+       ret = mm_image_encode_to_jpeg_file_with_libjpeg_turbo(filename, src, width, height, fmt, quality);
        mm_util_debug("#End# libjpeg, Success!! ret: %d", ret);
 
 #else
        mm_util_debug("#START# LIBJPEG");
-       if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+       if (fmt == MM_UTIL_JPEG_FMT_NV12) {
                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);
-               if(dst) {
-                       ret = mm_util_convert_colorspace(src, width, height,MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
+               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);
                } else {
                        TTRACE_END();
                        return MM_UTIL_ERROR_OUT_OF_MEMORY;
                }
-       } else if(fmt == MM_UTIL_JPEG_FMT_NV21) {
+       } else if (fmt == MM_UTIL_JPEG_FMT_NV21) {
                TTRACE_END();
                return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        } else {
@@ -1383,32 +1364,31 @@ mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int heig
        return ret;
 }
 
-EXPORT_API int
-mm_util_jpeg_encode_to_memory(void **mem, int *size, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+EXPORT_API int mm_util_jpeg_encode_to_memory(void **mem, int *size, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
        TTRACE_BEGIN("MM_UTILITY:JPEG:ENCODE_TO_MEMORY");
 
-       if!mem || !size || !src) {
-               mm_util_error("#ERROR# filename ||size ||  src buffer is NULL");
+       if (!mem || !size || !src) {
+               mm_util_error("#ERROR# filename ||size || src buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(width <= 0) || (height <= 0)) {
+       if ((width <= 0) || (height <= 0)) {
                mm_util_error("#ERROR# src_width || src_height value ");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
+       if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(  (quality < 1 ) || (quality>100) ) {
+       if ((quality < 1) || (quality > 100)) {
                mm_util_error("#ERROR# quality vaule");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1416,24 +1396,24 @@ mm_util_jpeg_encode_to_memory(void **mem, int *size, void* src, int width, int h
 
        #if LIBJPEG_TURBO
        mm_util_debug("#START# libjpeg-turbo");
-       ret=mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(mem, size, src, width, height, fmt, quality);
+       ret = mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(mem, size, src, width, height, fmt, quality);
        mm_util_debug("#END# libjpeg-turbo, Success!! ret: %d", ret);
        #else /* LIBJPEG_TURBO */
        mm_util_debug("#START# libjpeg");
-       if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+       if (fmt == MM_UTIL_JPEG_FMT_NV12) {
                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);
-               if(dst) {
-                       ret = mm_util_convert_colorspace(src, width, height,MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
+               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);
                } else {
                        TTRACE_END();
                        return MM_UTIL_ERROR_OUT_OF_MEMORY;
                }
-       } else if(fmt == MM_UTIL_JPEG_FMT_NV21) {
+       } else if (fmt == MM_UTIL_JPEG_FMT_NV21) {
                TTRACE_END();
                return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        } else {
@@ -1446,8 +1426,7 @@ mm_util_jpeg_encode_to_memory(void **mem, int *size, void* src, int width, int h
        return ret;
 }
 
-EXPORT_API int
-mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt)
+EXPORT_API int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
@@ -1455,13 +1434,13 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
 
        TTRACE_BEGIN("MM_UTILITY:JPEG:DECODE_FROM_JPEG_FILE");
 
-       if!decoded || !filename) {
+       if (!decoded || !filename) {
                mm_util_error("#ERROR# decoded || filename buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
+       if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1470,7 +1449,7 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
        FILE *fp = fopen(filename, "rb");
        unsigned char magic[2] = {0};
        size_t read_size = 0;
-       if(fp) {
+       if (fp) {
                read_size = fread((void *)magic, 1, 2, fp);
                if (read_size > 0)
                        mm_util_debug("Success fread");
@@ -1484,7 +1463,7 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
                return MM_UTIL_ERROR_NO_SUCH_FILE;
        }
 
-       if(magic[0] == 0xff && magic[1] == 0xd8) {
+       if (magic[0] == 0xff && magic[1] == 0xd8) {
                #if LIBJPEG_TURBO
                mm_util_debug("#START# LIBJPEG_TURBO");
                ret = mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
@@ -1492,7 +1471,7 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
                mm_util_debug("#End# LIBJPEG_TURBO, Success!! ret: %d", ret);
                #else
                mm_util_debug("#START# libjpeg");
-               if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+               if (fmt == MM_UTIL_JPEG_FMT_NV12) {
                        unsigned int dst_size = 0;
                        ret = mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_IMG_FMT_YUV420, downscale);
                        if (ret == MM_UTIL_ERROR_NONE) {
@@ -1503,7 +1482,7 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
 
                                unsigned char *dst = NULL;
                                dst = malloc(dst_size);
-                               if(dst) {
+                               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);
@@ -1529,13 +1508,13 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
                mm_util_debug("decoded->data: %p\t width: %d\t height:%d\t size: %d\n", decoded->data, decoded->width, decoded->height, decoded->size);
                mm_util_debug("#End# libjpeg, Success!! ret: %d", ret);
                #endif
-       } else if(magic[0] == 0x47 && magic[1] == 0x49) {
+       } else if (magic[0] == 0x47 && magic[1] == 0x49) {
                mm_util_error("Not JPEG IMAGE - GIF");
                ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if(magic[0] == 0x89 && magic[1] == 0x50) {
+       } else if (magic[0] == 0x89 && magic[1] == 0x50) {
                mm_util_error("Not JPEG IMAGE - PNG");
                ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if(magic[0] == 0x49 && magic[1] == 0x49) {
+       } else if (magic[0] == 0x49 && magic[1] == 0x49) {
                mm_util_error("Not JPEG IMAGE - TIFF");
                ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        } else {
@@ -1547,8 +1526,7 @@ mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filena
        return ret;
 }
 
-EXPORT_API int
-mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data* decoded, void* src, int size, mm_util_jpeg_yuv_format fmt)
+EXPORT_API int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data* decoded, void* src, int size, mm_util_jpeg_yuv_format fmt)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
@@ -1556,19 +1534,19 @@ mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data* decoded, void* src, int s
 
        mm_util_jpeg_decode_downscale downscale = MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1;
 
-       if!decoded || !src) {
+       if (!decoded || !src) {
                mm_util_error("#ERROR# decoded || src buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(size < 0) {
+       if (size < 0) {
                mm_util_error("#ERROR# size");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
+       if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
@@ -1583,7 +1561,7 @@ mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data* decoded, void* src, int s
 
        #else
        mm_util_debug("#START# libjpeg");
-       if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+       if (fmt == MM_UTIL_JPEG_FMT_NV12) {
                unsigned int dst_size = 0;
                unsigned char *dst = NULL;
 
@@ -1595,7 +1573,7 @@ mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data* decoded, void* src, int s
                                        mm_util_error("fail mm_util_get_image_size");
 
                        dst = malloc(dst_size);
-                       if(dst) {
+                       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);
@@ -1626,26 +1604,25 @@ mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data* decoded, void* src, int s
        return ret;
 }
 
-EXPORT_API int
-mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale)
+EXPORT_API int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
        TTRACE_BEGIN("MM_UTILITY:JPEG:DECODE_FROM_JPEG_FILE_WITH_DOWNSCALE");
 
-       if!decoded || !filename) {
+       if (!decoded || !filename) {
                mm_util_error("#ERROR# decoded || filename buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
+       if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_2)
+       if ((downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_2)
                 && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_4) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_8)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
@@ -1655,7 +1632,7 @@ mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, con
        FILE *fp = fopen(filename, "rb");
        unsigned char magic[2] = {0};
        size_t read_size = 0;
-       if(fp) {
+       if (fp) {
                read_size = fread((void *)magic, 1, 2, fp);
                if (read_size > 0)
                        mm_util_debug("Success fread");
@@ -1663,7 +1640,7 @@ mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, con
                mm_util_debug("%x %x", magic[0], magic[1]);
                fclose(fp);
        }
-       if(magic[0] == 0xff && magic[1] == 0xd8) {
+       if (magic[0] == 0xff && magic[1] == 0xd8) {
                #if LIBJPEG_TURBO
                mm_util_debug("#START# LIBJPEG_TURBO");
                ret = mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
@@ -1671,7 +1648,7 @@ mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, con
                mm_util_debug("#End# LIBJPEG_TURBO, Success!! ret: %d", ret);
                #else
                mm_util_debug("#START# libjpeg");
-               if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+               if (fmt == MM_UTIL_JPEG_FMT_NV12) {
                        unsigned int dst_size = 0;
                        ret = mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_IMG_FMT_YUV420, downscale);
                        if (ret == MM_UTIL_ERROR_NONE) {
@@ -1682,7 +1659,7 @@ mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, con
 
                                unsigned char *dst = NULL;
                                dst = malloc(dst_size);
-                               if(dst) {
+                               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);
@@ -1708,13 +1685,13 @@ mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, con
                mm_util_debug("decoded->data: %p\t width: %d\t height:%d\t size: %d\n", decoded->data, decoded->width, decoded->height, decoded->size);
                mm_util_debug("#End# libjpeg, Success!! ret: %d", ret);
                #endif
-       } else if(magic[0] == 0x47 && magic[1] == 0x49) {
+       } else if (magic[0] == 0x47 && magic[1] == 0x49) {
                mm_util_error("Not JPEG IMAGE - GIF");
                ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if(magic[0] == 0x89 && magic[1] == 0x50) {
+       } else if (magic[0] == 0x89 && magic[1] == 0x50) {
                mm_util_error("Not JPEG IMAGE - PNG");
                ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if(magic[0] == 0x49 && magic[1] == 0x49) {
+       } else if (magic[0] == 0x49 && magic[1] == 0x49) {
                mm_util_error("Not JPEG IMAGE - TIFF");
                ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        } else {
@@ -1726,32 +1703,31 @@ mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, con
        return ret;
 }
 
-EXPORT_API int
-mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data* decoded, void* src, int size, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale)
+EXPORT_API int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data* decoded, void* src, int size, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
        TTRACE_BEGIN("MM_UTILITY:JPEG:DECODE_FROM_JPEG_MEMORY_WITH_DOWNSCALE");
 
-       if!decoded || !src) {
+       if (!decoded || !src) {
                mm_util_error("#ERROR# decoded || src buffer is NULL");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(size < 0) {
+       if (size < 0) {
                mm_util_error("#ERROR# size");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
+       if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
                return MM_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if(downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_2)
+       if ((downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_2)
                 && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_4) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_8)) {
                mm_util_error("#ERROR# fmt value");
                TTRACE_END();
@@ -1767,7 +1743,7 @@ mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data* decoded, v
 
        #else
        mm_util_debug("#START# libjpeg");
-       if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+       if (fmt == MM_UTIL_JPEG_FMT_NV12) {
                unsigned int dst_size = 0;
                unsigned char *dst = NULL;
 
@@ -1779,7 +1755,7 @@ mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data* decoded, v
                                        mm_util_error("fail mm_util_get_image_size");
 
                        dst = malloc(dst_size);
-                       if(dst) {
+                       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);
index 290e2f939229574c9b8c59123eb3fdedb11ef89b..38eb5ef08bb6c7d6d0791365afb91d3eedfd01f9 100755 (executable)
@@ -39,7 +39,7 @@
 static inline void flush_stdin()
 {
        int ch;
-       while((ch=getchar()) != EOF && ch != '\n');
+       while ((ch = getchar()) != EOF && ch != '\n');
 }
 
 
@@ -63,7 +63,7 @@ static int _read_file(char *file_name, void **data, int *data_size)
 
        fseek(fp, 0, SEEK_END);
        file_size = ftell(fp);
-       if(file_size > -1L) {
+       if (file_size > -1L) {
                rewind(fp);
                *data = (void *)malloc(file_size);
                if (*data == NULL) {
@@ -72,7 +72,7 @@ static int _read_file(char *file_name, void **data, int *data_size)
                        fp = NULL;
                        return FALSE;
                } else {
-                       if(fread(*data, 1, file_size, fp)) {
+                       if (fread(*data, 1, file_size, fp)) {
                                fprintf(stderr, "#Success# fread\n");
                        } else {
                                fprintf(stderr, "#Error# fread\n");
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
 
        if (ret != MM_UTIL_ERROR_NONE) {
                fprintf(stderr, "\tERROR is occurred %x\n", ret);
-       }else {
+       } else {
                fprintf(stderr, "\tJPEG OPERATION SUCCESS\n");
                if (!strcmp("encode", argv[1])) {
                        if (dst) {
@@ -218,14 +218,13 @@ int main(int argc, char *argv[])
                                fprintf(stderr, "\tENCODED data is NULL\n");
                        }
                } else {
-                       if(decoded_data.data) {
-                               fprintf(stderr, "\t##Decoded data##: %p\t width: %d\t height:%d\t size: %d\n",
-                                               decoded_data.data, decoded_data.width, decoded_data.height, decoded_data.size);
+                       if (decoded_data.data) {
+                               fprintf(stderr, "\t##Decoded data##: %p\t width: %d\t height:%d\t size: %d\n", decoded_data.data, decoded_data.width, decoded_data.height, decoded_data.size);
                                char filename[BUFFER_SIZE] = {0, };
                                memset(filename, 0, BUFFER_SIZE);
-                               if(fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+                               if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
                                        snprintf(filename, BUFFER_SIZE, "%s%s", DECODE_RESULT_PATH, "rgb");
-                               } else if((fmt == MM_UTIL_JPEG_FMT_YUV420) ||
+                               } else if ((fmt == MM_UTIL_JPEG_FMT_YUV420) ||
                                        (fmt == MM_UTIL_JPEG_FMT_YUV422) ||
                                        (fmt == MM_UTIL_JPEG_FMT_NV12) ||
                                        (fmt == MM_UTIL_JPEG_FMT_NV21) ||
index 8904a6c75a38a0d9323548488e20e903962982ac..28b711d9a77c5b2e4263dff049ea533b92a131a4 100755 (executable)
 /**
  *  Image file format
  */
-typedef enum
-{
-    /* Image file format */
-    MM_UTILITY_IMAGE_FILE_FMT_NONE,                    /**< Nothing or not supported image file format */
-    MM_UTILITY_IMAGE_FILE_FMT_BMP,                     /**< Windows bitmap : .bmp, .dib, .rle, .2bp */
-    MM_UTILITY_IMAGE_FILE_FMT_GIF,                     /**< Graphics Interchange Format : .gif, .gfa, .giff  */
-    MM_UTILITY_IMAGE_FILE_FMT_PNG,                     /**< Portable Network Graphics : .png */
-    MM_UTILITY_IMAGE_FILE_FMT_JPG,                     /**< Joint Photographic Experts Group : .jpg, .jpeg, .jpe */
+typedef enum {
+       /* Image file format */
+       MM_UTILITY_IMAGE_FILE_FMT_NONE,                 /**< Nothing or not supported image file format */
+       MM_UTILITY_IMAGE_FILE_FMT_BMP,                  /**< Windows bitmap : .bmp, .dib, .rle, .2bp */
+       MM_UTILITY_IMAGE_FILE_FMT_GIF,                          /**< Graphics Interchange Format : .gif, .gfa, .giff  */
+       MM_UTILITY_IMAGE_FILE_FMT_PNG,                  /**< Portable Network Graphics : .png */
+       MM_UTILITY_IMAGE_FILE_FMT_JPG,                  /**< Joint Photographic Experts Group : .jpg, .jpeg, .jpe */
 } mm_utility_image_file_format;
 
 
-
 /**
  * YUV format for gif
  */
-typedef enum
-{
-    /* YUV planar format */
-    MM_UTILITY_GIF_FMT_YUV420 = 0x00,  /**< YUV420 format - planer */
-    MM_UTILITY_GIF_FMT_YUV422,         /**< YUV422 format - planer */
-    /* YUV packed format */
-    MM_UTILITY_GIF_FMT_UYVY,            /**< UYVY format - YUV packed format */
+typedef enum {
+       /* YUV planar format */
+       MM_UTILITY_GIF_FMT_YUV420 = 0x00,  /**< YUV420 format - planer */
+       MM_UTILITY_GIF_FMT_YUV422,         /**< YUV422 format - planer */
+       /* YUV packed format */
+       MM_UTILITY_GIF_FMT_UYVY,            /**< UYVY format - YUV packed format */
 } mm_utility_gif_yuv_format;
 
 /**
  * YUV data for gif
  */
-typedef struct 
-{
-    mm_utility_gif_yuv_format format;     /**< pixel format*/
-    int width;                          /**< width */
-    int height;                         /**< heigt */
-    int size;                           /**< size */
-    void *data;                         /**< data */
+typedef struct {
+       mm_utility_gif_yuv_format format;     /**< pixel format*/
+       int width;                          /**< width */
+       int height;                         /**< heigt */
+       int size;                           /**< size */
+       void *data;                         /**< data */
 } mm_utility_decoded_data;
 
-static int get_file_format ( const char * input_file )
+static int get_file_format(const char * input_file)
 {
        mm_utility_image_file_format file_format = MM_UTILITY_IMAGE_FILE_FMT_NONE;
 
-       if ( g_str_has_suffix( input_file, "bmp" )
-               || g_str_has_suffix ( input_file, "dib" )
-               || g_str_has_suffix ( input_file, "rle" )
-               || g_str_has_suffix ( input_file, "2bp" )
-               || g_str_has_suffix( input_file, "BMP" )
-               || g_str_has_suffix ( input_file, "DIB" )
-               || g_str_has_suffix ( input_file, "RLE" )
-               || g_str_has_suffix ( input_file, "2BP" ) )
-       {
-               printf ( "Image file format is BMP. \n" );
+       if (g_str_has_suffix(input_file, "bmp")
+               || g_str_has_suffix(input_file, "dib")
+               || g_str_has_suffix(input_file, "rle")
+               || g_str_has_suffix(input_file, "2bp")
+               || g_str_has_suffix(input_file, "BMP")
+               || g_str_has_suffix(input_file, "DIB")
+               || g_str_has_suffix(input_file, "RLE")
+               || g_str_has_suffix(input_file, "2BP")) {
+               printf("Image file format is BMP. \n");
                file_format = MM_UTILITY_IMAGE_FILE_FMT_BMP;
-       }
-       else if ( g_str_has_suffix ( input_file, "gif" )
-               || g_str_has_suffix ( input_file, "gfa" )
-               || g_str_has_suffix ( input_file, "giff" )
-               || g_str_has_suffix ( input_file, "GIF" )
-               || g_str_has_suffix ( input_file, "GFA" )
-               || g_str_has_suffix ( input_file, "GIFF" ))
-       {
-               printf ( "Image file format is GIF. \n" );
+       } else if (g_str_has_suffix(input_file, "gif")
+               || g_str_has_suffix(input_file, "gfa")
+               || g_str_has_suffix(input_file, "giff")
+               || g_str_has_suffix(input_file, "GIF")
+               || g_str_has_suffix(input_file, "GFA")
+               || g_str_has_suffix(input_file, "GIFF")) {
+               printf("Image file format is GIF. \n");
                file_format = MM_UTILITY_IMAGE_FILE_FMT_GIF;
-       }
-       else if ( g_str_has_suffix ( input_file, "png" )
-               ||  g_str_has_suffix ( input_file, "PNG" ))
-       {
-               printf ( "Image file format is PNG. \n" );
+       } else if (g_str_has_suffix(input_file, "png")
+               ||  g_str_has_suffix(input_file, "PNG")) {
+               printf("Image file format is PNG. \n");
                file_format = MM_UTILITY_IMAGE_FILE_FMT_PNG;
-       }
-       else if ( g_str_has_suffix ( input_file, "jpg" )
-               || g_str_has_suffix ( input_file, "jpeg" )
-               || g_str_has_suffix ( input_file, "jpe" )
-               || g_str_has_suffix ( input_file, "JPG" )
-               || g_str_has_suffix ( input_file, "JPEG" )
-               || g_str_has_suffix ( input_file, "JPE" ) )
-       {
-               printf ( "Image file format is JPG. \n" );
+       } else if (g_str_has_suffix(input_file, "jpg")
+               || g_str_has_suffix(input_file, "jpeg")
+               || g_str_has_suffix(input_file, "jpe")
+               || g_str_has_suffix(input_file, "JPG")
+               || g_str_has_suffix(input_file, "JPEG")
+               || g_str_has_suffix(input_file, "JPE")) {
+               printf("Image file format is JPG. \n");
                file_format = MM_UTILITY_IMAGE_FILE_FMT_JPG;
-       }
-       else
-       {
-               printf ( "Not supported image file format. \n" );
+       } else {
+               printf("Not supported image file format. \n");
        }
 
        return file_format;
 
 }
 
-static int  malloc_decoded_picture ( SCMN_IMGB * img )
+static int  malloc_decoded_picture(SCMN_IMGB * img)
 {
        int ret = 0;
        int malloc_size = 0;
 
-       switch ( img->cs )      {
-               case SCMN_CS_YUV444 :
-                       printf ("colorspace is YUV444.\n");
+       switch (img->cs)        {
+               case SCMN_CS_YUV444:
+                       printf("colorspace is YUV444.\n");
                        img->w[1] = img->w[2] = img->w[0];
                        img->h[1] = img->h[2] = img->h[0];
                        img->s[0] = img->s[1] = img->s[2] = img->w[0];
@@ -137,8 +124,8 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               case SCMN_CS_YUV422 :
-                       printf ("colorspace is YUV422 or YUV422N.\n");
+               case SCMN_CS_YUV422:
+                       printf("colorspace is YUV422 or YUV422N.\n");
 
                        img->w[1] = img->w[2] = (img->w[0]+1) >> 1;
                        img->h[1] = img->h[2] = img->h[0];
@@ -150,8 +137,8 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               case SCMN_CS_YUV422W :
-                       printf ("colorspace is YUV422W.\n");
+               case SCMN_CS_YUV422W:
+                       printf("colorspace is YUV422W.\n");
 
                        img->w[1] = img->w[2] = img->w[0];
                        img->h[1] = img->h[2] = (img->h[0]+1) >> 1;
@@ -163,8 +150,8 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               case SCMN_CS_YUV420 :
-                       printf ("colorspace is YUV420.\n");
+               case SCMN_CS_YUV420:
+                       printf("colorspace is YUV420.\n");
 
                        /* plus 1 for rounding */
                        img->w[1] = img->w[2] = (img->w[0]+1) >> 1;
@@ -178,8 +165,8 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               case SCMN_CS_YUV400 :
-                       printf ("colorspace is YUV400.\n");
+               case SCMN_CS_YUV400:
+                       printf("colorspace is YUV400.\n");
 
                        img->s[0] = img->w[0];
                        img->e[0] = img->h[0];
@@ -188,8 +175,8 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               case SCMN_CS_RGB565 :
-                       printf ("colorspace is RGB565.\n");
+               case SCMN_CS_RGB565:
+                       printf("colorspace is RGB565.\n");
 
                        img->s[0] = img->w[0];
                        img->e[0] = img->h[0];
@@ -198,19 +185,19 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               case SCMN_CS_RGB888 :
-                       printf ("colorspace is RGB888.\n");
+               case SCMN_CS_RGB888:
+                       printf("colorspace is RGB888.\n");
 
                        img->s[0] = img->w[0]*3;
                        img->e[0] = img->h[0];
 
-                       printf ( "%d x %d \n", img->s[0], img->e[0] );
+                       printf("%d x %d \n", img->s[0], img->e[0]);
                        malloc_size = img->s[0]*img->e[0]*sizeof(unsigned char) * 3 ;
 
                        break;
 
-               case SCMN_CS_RGBA8888 :
-                       printf ("colorspace is RGBA8888.\n");
+               case SCMN_CS_RGBA8888:
+                       printf("colorspace is RGBA8888.\n");
 
                        img->s[0] = img->w[0];
                        img->e[0] = img->h[0];
@@ -219,827 +206,753 @@ static int  malloc_decoded_picture ( SCMN_IMGB * img )
 
                        break;
 
-               default :
-                       printf ( "Not supported colorspace[%d].\n", img->cs );
+               default:
+                       printf("Not supported colorspace[%d].\n", img->cs);
                        ret = -1;
                        break;
        }
 
        /* allocate buffer */
-       if ( SCMN_CS_IS_YUV ( img->cs ) )
-       {
-               if(img->cs == SCMN_CS_YUV400) {
+       if (SCMN_CS_IS_YUV(img->cs)) {
+               if (img->cs == SCMN_CS_YUV400) {
                        img->a[0] = malloc(img->s[0]*img->e[0]*sizeof(unsigned char));
                } else {
                        img->a[0] = malloc(img->s[0]*img->e[0]*sizeof(unsigned char));
                        img->a[1] = malloc(img->s[1]*img->e[1]*sizeof(unsigned char));
                        img->a[2] = malloc(img->s[2]*img->e[2]*sizeof(unsigned char));
                }
-       }
-       else if ( SCMN_CS_IS_RGB16_PACK ( img->cs ) )
-       {
-               img->a[0] = malloc(img->s[0]*img->e[0]*sizeof(unsigned char) * 2 );
-       }
-       else if ( SCMN_CS_IS_RGB24_PACK ( img->cs ) )
-       {
+       } else if (SCMN_CS_IS_RGB16_PACK(img->cs)) {
+               img->a[0] = malloc(img->s[0]*img->e[0]*sizeof(unsigned char) * 2);
+       } else if (SCMN_CS_IS_RGB24_PACK(img->cs)) {
                img->a[0] = malloc(img->s[0]*img->e[0]*sizeof(unsigned char) * 3);
-       }
-       else if ( SCMN_CS_IS_RGB32_PACK ( img->cs ) )
-       {
+       } else if (SCMN_CS_IS_RGB32_PACK(img->cs)) {
                img->a[0] = malloc(img->s[0]*img->e[0]*sizeof(unsigned char) * 4);
-       }
-       else
-       {
-               printf ( "Fail to allocate memory.\n" );
+       } else {
+               printf("Fail to allocate memory.\n");
                ret = -1;
        }
 
-       if ( !img->a[0]  )
+       if (!img->a[0])
                ret = -1;
 
        return ret;
 }
 
 
-static void write_decoded_image ( const char *filename,  SCMN_IMGB imgb )
+static void write_decoded_image(const char *filename,  SCMN_IMGB imgb)
 {
-       printf ( "Write decoded image to %s.\n",  filename );
+       printf("Write decoded image to %s.\n",  filename);
 
-       FILE *fp = fopen( filename, "wb");
-       fwrite ( imgb.a[0], sizeof(unsigned char), imgb.s[0]*imgb.e[0], fp );
-       fwrite ( imgb.a[1], sizeof(unsigned char), imgb.s[1]*imgb.e[1], fp );
-       fwrite ( imgb.a[2], sizeof(unsigned char), imgb.s[2]*imgb.e[2], fp );
+       FILE *fp = fopen(filename, "wb");
+       fwrite(imgb.a[0], sizeof(unsigned char), imgb.s[0]*imgb.e[0], fp);
+       fwrite(imgb.a[1], sizeof(unsigned char), imgb.s[1]*imgb.e[1], fp);
+       fwrite(imgb.a[2], sizeof(unsigned char), imgb.s[2]*imgb.e[2], fp);
 
-       fclose ( fp );
+       fclose(fp);
 
        return;
 }
 
 
-static int decode_bmp ( const char * input_file, int width, int height,  const char * output_file )
+static int decode_bmp(const char * input_file, int width, int height,  const char * output_file)
 {
-       SCMN_IMGB imgb;
+       SCMN_IMGB imgb;
        SBMPD_INIT_DSC init_dsc;
-       SBMPD bmpd_hnd = NULL;
-       SBMPD_STAT bmpd_stat = {0,};
-       SBMPD_INFO bmpd_info = {0,};
+       SBMPD bmpd_hnd = NULL;
+       SBMPD_STAT bmpd_stat = {0,};
+       SBMPD_INFO bmpd_info = {0,};
 
        FILE *input_fp = NULL;
-       unsigned char *filebuffer = NULL;
-       unsigned char *bufp = NULL;
-       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
-       struct stat statbuf;
+       unsigned char *filebuffer = NULL;
+       unsigned char *bufp = NULL;
+       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
+       struct stat statbuf;
 
-       int sret = SBMP_OK;
-       int ret = 0;
+       int sret = SBMP_OK;
+       int ret = 0;
        int err = 0;
 
+       /* initialize struct variable */
+       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
+       memset(&init_dsc, 0x00, sizeof(SBMPD_INIT_DSC));
+       memset(&bmpd_stat, 0x00, sizeof(SBMPD_STAT));
+       memset(&bmpd_info, 0x00, sizeof(SBMPD_INFO));
 
-       /* initialize struct variable */
-       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
-       memset(&init_dsc, 0x00, sizeof(SBMPD_INIT_DSC));
-       memset(&bmpd_stat, 0x00, sizeof(SBMPD_STAT));
-       memset(&bmpd_info, 0x00, sizeof(SBMPD_INFO));
-
-       /* init bmp codec */
-       sret = sbmp_init();
-       if (SBMP_IS_ERR(sret))
-       {
-               printf ( "Fail to init bmp library\n");
-               ret = -1;
-               goto exit;
-       }
+       /* init bmp codec */
+       sret = sbmp_init();
+       if (SBMP_IS_ERR(sret)) {
+               printf("Fail to init bmp library\n");
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Initialize bmp library is success.\n" );
+       printf("Initialize bmp library is success.\n");
 
-       /* read data from gif file */
-       input_fp = fopen( input_file, "rb");
-       if (input_fp == NULL)
-       {
-               printf ( "Fail to read bmp file \n" );
-               goto exit;
-       }
+       /* read data from gif file */
+       input_fp = fopen(input_file, "rb");
+       if (input_fp == NULL) {
+               printf("Fail to read bmp file \n");
+               goto exit;
+       }
 
        fstat(fileno(input_fp), &statbuf);
 
-       if (!(statbuf.st_mode & S_IFREG))
-       {
-               printf ( "Input file is not regular file\n" );
+       if (!(statbuf.st_mode & S_IFREG)) {
+               printf("Input file is not regular file\n");
                ret = -1;
-               goto exit;
-       }
+               goto exit;
+       }
 
-       filebuffer = malloc(statbuf.st_size);
-       if (!filebuffer)
-       {
-               printf ( "fail to allocate file buffer\n" );
+       filebuffer = malloc(statbuf.st_size);
+       if (!filebuffer) {
+               printf("fail to allocate file buffer\n");
                ret = -1;
-               goto exit;
-       }
+               goto exit;
+       }
 
        toread = statbuf.st_size;
-       totalread = 0;
-       bufp = filebuffer;
+       totalread = 0;
+       bufp = filebuffer;
 
-       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0)
-       {
-               totalread += nread;
-               toread -= nread;
-       }
+       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0) {
+               totalread += nread;
+               toread -= nread;
+       }
 
-       if ( totalread != statbuf.st_size )
-       {
-               printf ( "BMP read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread );
-               ret = -1;
-               goto exit;
-       }
+       if (totalread != statbuf.st_size) {
+               printf("BMP read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread);
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Reading bmp image is success.\n" );
+       printf("Reading bmp image is success.\n");
 
 
-       /* set init data */
-       init_dsc.bitb.addr = filebuffer;
-       init_dsc.bitb.size = totalread;
-       init_dsc.bitb.mt = SCMN_MT_IMG_BMP;
-       init_dsc.use_accel = 0;
+       /* set init data */
+       init_dsc.bitb.addr = filebuffer;
+       init_dsc.bitb.size = totalread;
+       init_dsc.bitb.mt = SCMN_MT_IMG_BMP;
+       init_dsc.use_accel = 0;
 
        /* create BMP decoder's handle */
-       /* create BMP decoder's handle */
-       bmpd_hnd = sbmpd_create(&init_dsc, &bmpd_info, &err);
-       if ( bmpd_hnd == NULL || SBMP_IS_ERR(err))
-       {
-               printf ( "fail in sbmpd_create, erro=%d\n", err );
-               ret = -1;
-               goto exit;
-       }
+       /* create BMP decoder's handle */
+       bmpd_hnd = sbmpd_create(&init_dsc, &bmpd_info, &err);
+       if (bmpd_hnd == NULL || SBMP_IS_ERR(err)) {
+               printf("fail in sbmpd_create, erro=%d\n", err);
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Create bmp decoder is success.\n" );
+       printf("Create bmp decoder is success.\n");
 
        /* malloc for decoded picture */
-       if ( ( width > 0 ) && ( height > 0 ) )
-       {
+       if ((width > 0) && (height > 0)) {
                /* Resize the image */
                imgb.w[0] = width;
-               imgb.h[0] = height;
-       }
-       else
-       {
+               imgb.h[0] = height;
+       } else {
                /* original image size */
                imgb.w[0] = bmpd_info.w;
                imgb.h[0] = bmpd_info.h;
        }
        imgb.cs = bmpd_info.cs;
 
-       printf ( "%d x %d --------> %d x %d \n" , bmpd_info.w, bmpd_info.h , imgb.w[0], imgb.h[0]  );
+       printf("%d x %d --------> %d x %d \n" , bmpd_info.w, bmpd_info.h , imgb.w[0], imgb.h[0]);
 
 
-       ret = malloc_decoded_picture ( &imgb );
-       if ( ret == -1 )
-       {
-               printf ( "Fail to malloc decoded data\n");
+       ret = malloc_decoded_picture(&imgb);
+       if (ret == -1) {
+               printf("Fail to malloc decoded data\n");
                goto exit;
        }
 
-       printf ( "Success to malloc decoded data.\n" );
+       printf("Success to malloc decoded data.\n");
 
        /* decoding gif image */
-       sret = sbmpd_decode(bmpd_hnd, &imgb, &bmpd_stat);
-       if (SBMP_IS_ERR(sret))
-       {
-               printf("Fail to decode, erro=%d\n", sret);
-               ret = -1;
-               goto exit;
-       }
-
-       if (!bmpd_stat.pa)
-       {
-               printf("decoded buffer is not available\n");
-               ret = -1;
-               goto exit;
-       }
+       sret = sbmpd_decode(bmpd_hnd, &imgb, &bmpd_stat);
+       if (SBMP_IS_ERR(sret)) {
+               printf("Fail to decode, erro=%d\n", sret);
+               ret = -1;
+               goto exit;
+       }
+
+       if (!bmpd_stat.pa) {
+               printf("decoded buffer is not available\n");
+               ret = -1;
+               goto exit;
+       }
 
 
        /* Write decoded image if output_file name is set. */
-       if ( output_file )
-       {
-               printf ( "Write decoded image. \n" );
-               write_decoded_image ( output_file, imgb );
+       if (output_file) {
+               printf("Write decoded image. \n");
+               write_decoded_image(output_file, imgb);
        }
 
 
 exit:
-       if ( bufp ) {
-               free ( bufp );
+       if (bufp) {
+               free(bufp);
                bufp = NULL;
        }
 
-       if ( input_fp )
-               fclose ( input_fp );
+       if (input_fp)
+               fclose(input_fp);
 
-       if ( bmpd_hnd )
-               sbmpd_delete ( bmpd_hnd );
+       if (bmpd_hnd)
+               sbmpd_delete(bmpd_hnd);
 
 
-       sbmp_deinit();
+       sbmp_deinit();
 
-       printf("ret=%d\n", ret);
+       printf("ret=%d\n", ret);
 
        return ret;
 }
 
-static int decode_png ( const char * input_file, int width, int height,  const char * output_file )
+static int decode_png(const char * input_file, int width, int height,  const char * output_file)
 {
-       SCMN_IMGB imgb;
+       SCMN_IMGB imgb;
        SPNGD_INIT_DSC init_dsc;
-       SPNGD pngd_hnd = NULL;
-       SPNGD_STAT pngd_stat = {0,};
-       SPNGD_INFO pngd_info = {0,};
+       SPNGD pngd_hnd = NULL;
+       SPNGD_STAT pngd_stat = {0,};
+       SPNGD_INFO pngd_info = {0,};
 
        FILE *input_fp = NULL;
-       unsigned char *filebuffer = NULL;
-       unsigned char *bufp = NULL;
-       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
-       struct stat statbuf;
+       unsigned char *filebuffer = NULL;
+       unsigned char *bufp = NULL;
+       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
+       struct stat statbuf;
 
-       int sret = SPNG_OK;
-       int ret = 0;
+       int sret = SPNG_OK;
+       int ret = 0;
        int err = 0;
 
 
-       /* initialize struct variable */
-       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
-       memset(&init_dsc, 0x00, sizeof(SPNGD_INIT_DSC));
-       memset(&pngd_stat, 0x00, sizeof(SPNGD_STAT));
-       memset(&pngd_info, 0x00, sizeof(SPNGD_INFO));
+       /* initialize struct variable */
+       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
+       memset(&init_dsc, 0x00, sizeof(SPNGD_INIT_DSC));
+       memset(&pngd_stat, 0x00, sizeof(SPNGD_STAT));
+       memset(&pngd_info, 0x00, sizeof(SPNGD_INFO));
 
-       /* init png codec */
-       sret = spng_init();
-       if (SPNG_IS_ERR(sret))
-       {
-               printf ( "Fail to init png library\n");
-               ret = -1;
-               goto exit;
-       }
+       /* init png codec */
+       sret = spng_init();
+       if (SPNG_IS_ERR(sret)) {
+               printf("Fail to init png library\n");
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Initialize png library is success.\n" );
+       printf("Initialize png library is success.\n");
 
-       /* read data from png file */
-       input_fp = fopen( input_file, "rb");
-       if (input_fp == NULL)
-       {
-               printf ( "Fail to read png file \n" );
-               goto exit;
-       }
+       /* read data from png file */
+       input_fp = fopen(input_file, "rb");
+       if (input_fp == NULL) {
+               printf("Fail to read png file \n");
+               goto exit;
+       }
 
        fstat(fileno(input_fp), &statbuf);
 
-       if (!(statbuf.st_mode & S_IFREG))
-       {
-               printf ( "Input file is not regular file\n" );
-               goto exit;
-       }
+       if (!(statbuf.st_mode & S_IFREG)) {
+               printf("Input file is not regular file\n");
+               goto exit;
+       }
 
-       filebuffer = malloc(statbuf.st_size);
-       if (!filebuffer)
-       {
-               printf ( "fail to allocate file buffer\n" );
-               goto exit;
-       }
+       filebuffer = malloc(statbuf.st_size);
+       if (!filebuffer) {
+               printf("fail to allocate file buffer\n");
+               goto exit;
+       }
 
        toread = statbuf.st_size;
-       totalread = 0;
-       bufp = filebuffer;
+       totalread = 0;
+       bufp = filebuffer;
 
-       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0)
-       {
-               totalread += nread;
-               toread -= nread;
-       }
+       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0) {
+               totalread += nread;
+               toread -= nread;
+       }
 
-       if (totalread != statbuf.st_size)
-       {
-               printf ( "PNG read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread );
-               goto exit;
-       }
+       if (totalread != statbuf.st_size) {
+               printf("PNG read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread);
+               goto exit;
+       }
 
-       printf ( "Reading png image is success.\n" );
+       printf("Reading png image is success.\n");
 
 
-       /* set init data */
-       init_dsc.bitb.addr = filebuffer;
-       init_dsc.bitb.size = totalread;
-       init_dsc.bitb.mt = SCMN_MT_IMG_PNG;
-       init_dsc.use_accel = 0;
+       /* set init data */
+       init_dsc.bitb.addr = filebuffer;
+       init_dsc.bitb.size = totalread;
+       init_dsc.bitb.mt = SCMN_MT_IMG_PNG;
+       init_dsc.use_accel = 0;
 
-       /* create PNG decoder's handle */
-       pngd_hnd = spngd_create(&init_dsc, &pngd_info, &err);
-       if (pngd_hnd == NULL || SPNG_IS_ERR(err))
-       {
-               printf ( "fail in spngd_create, erro=%d\n", err);
-               ret = -1;
-               goto exit;
-       }
+       /* create PNG decoder's handle */
+       pngd_hnd = spngd_create(&init_dsc, &pngd_info, &err);
+       if (pngd_hnd == NULL || SPNG_IS_ERR(err)) {
+               printf("fail in spngd_create, erro=%d\n", err);
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Create png decoder is success.\n" );
+       printf("Create png decoder is success.\n");
 
        /* malloc for decoded picture */
-       if ( ( width > 0 ) && ( height > 0 ) )
-       {
+       if ((width > 0) && (height > 0)) {
                /* Resize the image */
                imgb.w[0] = width;
-               imgb.h[0] = height;
-       }
-       else
-       {
+               imgb.h[0] = height;
+       } else {
                /* original image size */
                imgb.w[0] = pngd_info.img_dsc[0].w;
                imgb.h[0] = pngd_info.img_dsc[0].h;
        }
        imgb.cs = pngd_info.cs;
 
-       printf ( "%d x %d --------> %d x %d \n" , pngd_info.img_dsc[0].w, pngd_info.img_dsc[0].h, imgb.w[0], imgb.h[0]  );
+       printf("%d x %d --------> %d x %d \n" , pngd_info.img_dsc[0].w, pngd_info.img_dsc[0].h, imgb.w[0], imgb.h[0]);
 
 
-       ret = malloc_decoded_picture ( &imgb );
-       if ( ret == -1 )
-       {
-               printf ( "Fail to malloc decoded data\n");
+       ret = malloc_decoded_picture(&imgb);
+       if (ret == -1) {
+               printf("Fail to malloc decoded data\n");
                goto exit;
        }
 
 
-       printf ( "Success to malloc decoded data.\n" );
+       printf("Success to malloc decoded data.\n");
 
        /* decoding png image */
-       sret = spngd_decode(pngd_hnd, 0,&imgb, &pngd_stat);
-       if (SPNG_IS_ERR(sret))
-       {
-               printf("Fail to decode, erro=%d\n", sret);
-               ret = -1;
-               goto exit;
-       }
+       sret = spngd_decode(pngd_hnd, 0, &imgb, &pngd_stat);
+       if (SPNG_IS_ERR(sret)) {
+               printf("Fail to decode, erro=%d\n", sret);
+               ret = -1;
+               goto exit;
+       }
 
-       printf("Success to decode, erro=%d\n", sret);
+       printf("Success to decode, erro=%d\n", sret);
 
-       if (!pngd_stat.pa)
-       {
-               printf("decoded buffer is not available\n");
-               ret = -1;
-               goto exit;
-       }
+       if (!pngd_stat.pa) {
+               printf("decoded buffer is not available\n");
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Decoding success.\n" );
+       printf("Decoding success.\n");
 
 
        /* Write decoded image if output_file name is set. */
-       if ( output_file )
-       {
-               printf ( "Write decoded image. \n" );
-               write_decoded_image ( output_file, imgb );
+       if (output_file) {
+               printf("Write decoded image. \n");
+               write_decoded_image(output_file, imgb);
        }
 
 
 exit:
 
-       if ( bufp ) {
-               free ( bufp );
+       if (bufp) {
+               free(bufp);
                bufp = NULL;
        }
 
-       if ( input_fp )
-               fclose ( input_fp );
+       if (input_fp)
+               fclose(input_fp);
 
-       if ( pngd_hnd )
-               spngd_delete ( pngd_hnd );
+       if (pngd_hnd)
+               spngd_delete(pngd_hnd);
 
 
-       spng_deinit();
+       spng_deinit();
 
-       printf("ret=%d\n", ret);
+       printf("ret=%d\n", ret);
 
        return ret;
 }
 
-static int decode_gif ( const char * input_file, int width, int height,  const char * output_file )
+static int decode_gif(const char * input_file, int width, int height,  const char * output_file)
 {
-       SCMN_IMGB imgb;
+       SCMN_IMGB imgb;
        SGIFD_INIT_DSC init_dsc;
-       SGIFD gifd_hnd = NULL;
-       SGIFD_STAT gifd_stat = {0,};
-       SGIFD_INFO gifd_info = {0,};
+       SGIFD gifd_hnd = NULL;
+       SGIFD_STAT gifd_stat = {0,};
+       SGIFD_INFO gifd_info = {0,};
 
        FILE *input_fp = NULL;
-       unsigned char *filebuffer = NULL;
-       unsigned char *bufp = NULL;
-       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
-       struct stat statbuf;
+       unsigned char *filebuffer = NULL;
+       unsigned char *bufp = NULL;
+       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
+       struct stat statbuf;
 
-       int sret = SGIF_OK;
-       int ret = 0;
+       int sret = SGIF_OK;
+       int ret = 0;
        int err = 0;
 
 
-       /* initialize struct variable */
-       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
-       memset(&init_dsc, 0x00, sizeof(SGIFD_INIT_DSC));
-       memset(&gifd_stat, 0x00, sizeof(SGIFD_STAT));
-       memset(&gifd_info, 0x00, sizeof(SGIFD_INFO));
+       /* initialize struct variable */
+       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
+       memset(&init_dsc, 0x00, sizeof(SGIFD_INIT_DSC));
+       memset(&gifd_stat, 0x00, sizeof(SGIFD_STAT));
+       memset(&gifd_info, 0x00, sizeof(SGIFD_INFO));
 
-       /* init gif codec */
-       sret = sgif_init();
-       if (SGIF_IS_ERR(sret))
-       {
-               printf ( "Fail to init gif library\n");
-               ret = -1;
-               goto exit;
-       }
+       /* init gif codec */
+       sret = sgif_init();
+       if (SGIF_IS_ERR(sret)) {
+               printf("Fail to init gif library\n");
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Initialize gif library is success.\n" );
+       printf("Initialize gif library is success.\n");
 
-       /* read data from gif file */
-       input_fp = fopen( input_file, "rb");
-       if (input_fp == NULL)
-       {
-               printf ( "Fail to read gif file \n" );
-               goto exit;
-       }
+       /* read data from gif file */
+       input_fp = fopen(input_file, "rb");
+       if (input_fp == NULL) {
+               printf("Fail to read gif file \n");
+               goto exit;
+       }
 
        fstat(fileno(input_fp), &statbuf);
 
-       if (!(statbuf.st_mode & S_IFREG))
-       {
-               printf ( "Input file is not regular file\n" );
-               goto exit;
-       }
+       if (!(statbuf.st_mode & S_IFREG)) {
+               printf("Input file is not regular file\n");
+               goto exit;
+       }
 
-       filebuffer = malloc(statbuf.st_size);
-       if (!filebuffer)
-       {
-               printf ( "fail to allocate file buffer\n" );
-               goto exit;
-       }
+       filebuffer = malloc(statbuf.st_size);
+       if (!filebuffer) {
+               printf("fail to allocate file buffer\n");
+               goto exit;
+       }
 
        toread = statbuf.st_size;
-       totalread = 0;
-       bufp = filebuffer;
+       totalread = 0;
+       bufp = filebuffer;
 
-       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0)
-       {
-               totalread += nread;
-               toread -= nread;
-       }
+       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0) {
+               totalread += nread;
+               toread -= nread;
+       }
 
-       if (totalread != statbuf.st_size)
-       {
-               printf ( "GIF read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread );
-               goto exit;
-       }
+       if (totalread != statbuf.st_size) {
+               printf("GIF read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread);
+               goto exit;
+       }
 
-       printf ( "Reading gif image is success.\n" );
+       printf("Reading gif image is success.\n");
 
 
-       /* set init data */
-       init_dsc.bitb.addr = filebuffer;
-       init_dsc.bitb.size = totalread;
-       init_dsc.bitb.mt = SCMN_MT_IMG_GIF;
-       init_dsc.use_accel = 0;
+       /* set init data */
+       init_dsc.bitb.addr = filebuffer;
+       init_dsc.bitb.size = totalread;
+       init_dsc.bitb.mt = SCMN_MT_IMG_GIF;
+       init_dsc.use_accel = 0;
 
-       /* create GIF decoder's handle */
-       gifd_hnd = sgifd_create(&init_dsc, &gifd_info, &err);
-       if (gifd_hnd == NULL || SGIF_IS_ERR(err))
-       {
-               printf ( "fail in sgifd_create, erro=%d\n", err);
-               ret = -1;
-               goto exit;
-       }
+       /* create GIF decoder's handle */
+       gifd_hnd = sgifd_create(&init_dsc, &gifd_info, &err);
+       if (gifd_hnd == NULL || SGIF_IS_ERR(err)) {
+               printf("fail in sgifd_create, erro=%d\n", err);
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Create gif decoder is success.\n" );
+       printf("Create gif decoder is success.\n");
 
        /* malloc for decoded picture */
-       if ( ( width > 0 ) && ( height > 0 ) )
-       {
+       if ((width > 0) && (height > 0)) {
                /* Resize the image */
                imgb.w[0] = width;
-               imgb.h[0] = height;
-       }
-       else
-       {
+               imgb.h[0] = height;
+       } else {
                /* original image size */
                imgb.w[0] = gifd_info.w;
                imgb.h[0] = gifd_info.h;
        }
        imgb.cs = gifd_info.cs;
 
-       printf ( "%d x %d --------> %d x %d \n" , gifd_info.w, gifd_info.h , imgb.w[0], imgb.h[0]  );
+       printf("%d x %d --------> %d x %d \n" , gifd_info.w, gifd_info.h , imgb.w[0], imgb.h[0]);
 
 
-       ret = malloc_decoded_picture ( &imgb );
-       if ( ret == -1 )
-       {
-               printf ( "Fail to malloc decoded data\n");
+       ret = malloc_decoded_picture(&imgb);
+       if (ret == -1) {
+               printf("Fail to malloc decoded data\n");
                goto exit;
        }
 
-       printf ( "Success to malloc decoded data.\n" );
+       printf("Success to malloc decoded data.\n");
 
        /* decoding gif image */
-       sret = sgifd_decode(gifd_hnd, 0,&imgb, &gifd_stat);
-       if (SGIF_IS_ERR(sret))
-       {
-               printf("Fail to decode, erro=%d\n", sret);
-               ret = -1;
-               goto exit;
-       }
+       sret = sgifd_decode(gifd_hnd, 0, &imgb, &gifd_stat);
+       if (SGIF_IS_ERR(sret)) {
+               printf("Fail to decode, erro=%d\n", sret);
+               ret = -1;
+               goto exit;
+       }
 
-       printf("Success to decode, erro=%d\n", sret);
+       printf("Success to decode, erro=%d\n", sret);
 
-       if (!gifd_stat.pa)
-       {
-               printf("decoded buffer is not available\n");
-               ret = -1;
-               goto exit;
-       }
+       if (!gifd_stat.pa) {
+               printf("decoded buffer is not available\n");
+               ret = -1;
+               goto exit;
+       }
 
 
        /* Write decoded image if output_file name is set. */
-       if ( output_file )
-       {
-               printf ( "Write decoded image. \n" );
-               write_decoded_image ( output_file, imgb );
+       if (output_file) {
+               printf("Write decoded image. \n");
+               write_decoded_image(output_file, imgb);
        }
 
 
 exit:
 
-       if ( bufp ) {
-               free ( bufp );
+       if (bufp) {
+               free(bufp);
                bufp = NULL;
        }
 
-       if ( input_fp )
-               fclose ( input_fp );
+       if (input_fp)
+               fclose(input_fp);
 
-       if ( gifd_hnd )
-               sgifd_delete ( gifd_hnd );
+       if (gifd_hnd)
+               sgifd_delete(gifd_hnd);
 
 
-       sgif_deinit();
+       sgif_deinit();
 
-       printf("ret=%d\n", ret);
+       printf("ret=%d\n", ret);
 
        return ret;
 
 }
-static int decode_jpg ( const char * input_file, int width, int height,  const char * output_file )
+static int decode_jpg(const char * input_file, int width, int height,  const char * output_file)
 {
-       SCMN_IMGB imgb;
+       SCMN_IMGB imgb;
        SJPGD_INIT_DSC init_dsc;
-       SJPGD jpgd_hnd = NULL;
-       SJPGD_STAT jpgd_stat = {0,};
-       SJPGD_INFO jpgd_info = {0,};
+       SJPGD jpgd_hnd = NULL;
+       SJPGD_STAT jpgd_stat = {0,};
+       SJPGD_INFO jpgd_info = {0,};
 
        FILE *input_fp = NULL;
-       unsigned char *filebuffer = NULL;
-       unsigned char *bufp = NULL;
-       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
-       struct stat statbuf;
+       unsigned char *filebuffer = NULL;
+       unsigned char *bufp = NULL;
+       unsigned int nread = 0, toread = 0, totalread = 0,  decoded_size = 0;
+       struct stat statbuf;
 
-       int sret = SJPG_OK;
-       int ret = 0;
+       int sret = SJPG_OK;
+       int ret = 0;
        int err = 0;
 
 
-       /* initialize struct variable */
-       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
-       memset(&init_dsc, 0x00, sizeof(SJPGD_INIT_DSC));
-       memset(&jpgd_stat, 0x00, sizeof(SJPGD_STAT));
-       memset(&jpgd_info, 0x00, sizeof(SJPGD_INFO));
+       /* initialize struct variable */
+       memset(&imgb, 0x00, sizeof(SCMN_IMGB));
+       memset(&init_dsc, 0x00, sizeof(SJPGD_INIT_DSC));
+       memset(&jpgd_stat, 0x00, sizeof(SJPGD_STAT));
+       memset(&jpgd_info, 0x00, sizeof(SJPGD_INFO));
 
-       /* init jpg codec */
-       sret = sjpg_init();
-       if (SJPG_IS_ERR(sret))
-       {
-               printf ( "Fail to init jpg library\n");
-               ret = -1;
-               goto exit;
-       }
+       /* init jpg codec */
+       sret = sjpg_init();
+       if (SJPG_IS_ERR(sret)) {
+               printf("Fail to init jpg library\n");
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Initialize jpg library is success.\n" );
+       printf("Initialize jpg library is success.\n");
 
-       /* read data from jpg file */
-       input_fp = fopen( input_file, "rb");
-       if (input_fp == NULL)
-       {
-               printf ( "Fail to read jpg file \n" );
-               goto exit;
-       }
+       /* read data from jpg file */
+       input_fp = fopen(input_file, "rb");
+       if (input_fp == NULL) {
+               printf("Fail to read jpg file \n");
+               goto exit;
+       }
 
        fstat(fileno(input_fp), &statbuf);
 
-       if (!(statbuf.st_mode & S_IFREG))
-       {
-               printf ( "Input file is not regular file\n" );
-               goto exit;
-       }
+       if (!(statbuf.st_mode & S_IFREG)) {
+               printf("Input file is not regular file\n");
+               goto exit;
+       }
 
-       filebuffer = malloc(statbuf.st_size);
-       if (!filebuffer)
-       {
-               printf ( "fail to allocate file buffer\n" );
-               goto exit;
-       }
+       filebuffer = malloc(statbuf.st_size);
+       if (!filebuffer) {
+               printf("fail to allocate file buffer\n");
+               goto exit;
+       }
 
        toread = statbuf.st_size;
-       totalread = 0;
-       bufp = filebuffer;
+       totalread = 0;
+       bufp = filebuffer;
 
-       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0)
-       {
-               totalread += nread;
-               toread -= nread;
-       }
+       while ((nread = fread(bufp+totalread, 1, toread, input_fp)) > 0) {
+               totalread += nread;
+               toread -= nread;
+       }
 
-       if (totalread != statbuf.st_size)
-       {
-               printf ( "JPG read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread );
-               goto exit;
-       }
+       if (totalread != statbuf.st_size) {
+               printf("JPG read error, file size=%ld, read size=%d\n", statbuf.st_size, totalread);
+               goto exit;
+       }
 
-       printf ( "Reading jpg image is success.\n" );
+       printf("Reading jpg image is success.\n");
 
 
-       /* set init data */
-       init_dsc.bitb.addr = filebuffer;
-       init_dsc.bitb.size = totalread;
-       init_dsc.bitb.mt = SCMN_MT_IMG_JPG;
-       init_dsc.use_accel = 0;
+       /* set init data */
+       init_dsc.bitb.addr = filebuffer;
+       init_dsc.bitb.size = totalread;
+       init_dsc.bitb.mt = SCMN_MT_IMG_JPG;
+       init_dsc.use_accel = 0;
 
-       /* create JPG decoder's handle */
-       jpgd_hnd = sjpgd_create(&init_dsc, &jpgd_info, &err);
-       if (jpgd_hnd == NULL || SJPG_IS_ERR(err))
-       {
-               printf ( "fail in sjpgd_create, erro=%d\n", err);
-               ret = -1;
-               goto exit;
-       }
+       /* create JPG decoder's handle */
+       jpgd_hnd = sjpgd_create(&init_dsc, &jpgd_info, &err);
+       if (jpgd_hnd == NULL || SJPG_IS_ERR(err)) {
+               printf("fail in sjpgd_create, erro=%d\n", err);
+               ret = -1;
+               goto exit;
+       }
 
-       printf ( "Create jpg decoder is success.\n" );
+       printf("Create jpg decoder is success.\n");
 
        /* malloc for decoded picture */
-       if ( ( width > 0 ) && ( height > 0 ) )
-       {
+       if ((width > 0) && (height > 0)) {
                /* Resize the image */
                imgb.w[0] = width;
-               imgb.h[0] = height;
-       }
-       else
-       {
+               imgb.h[0] = height;
+       } else {
                /* original image size */
                imgb.w[0] = jpgd_info.w;
                imgb.h[0] = jpgd_info.h;
        }
        imgb.cs = jpgd_info.cs;
 
-       printf ( "%d x %d --------> %d x %d \n" , jpgd_info.w, jpgd_info.h , imgb.w[0], imgb.h[0]  );
+       printf("%d x %d --------> %d x %d \n" , jpgd_info.w, jpgd_info.h , imgb.w[0], imgb.h[0]);
 
 
-       ret = malloc_decoded_picture ( &imgb );
-       if ( ret == -1 )
-       {
-               printf ( "Fail to malloc decoded data\n");
+       ret = malloc_decoded_picture(&imgb);
+       if (ret == -1) {
+               printf("Fail to malloc decoded data\n");
                goto exit;
        }
 
-       printf ( "Success to malloc decoded data.\n" );
+       printf("Success to malloc decoded data.\n");
 
 
        /* decoding jpg image */
-       sret = sjpgd_decode(jpgd_hnd, &imgb, &jpgd_stat);
-       if (SJPG_IS_ERR(sret))
-       {
-               printf("Fail to decode, erro=%d\n", sret);
-               ret = -1;
-               goto exit;
-       }
-
-       if (!jpgd_stat.pa)
-       {
-               printf("decoded buffer is not available\n");
-               ret = -1;
-               goto exit;
-       }
-
-       printf ( "jpgd_stat.w=%d, jpgd_stat.h=%d, jpgd_stat.read=%d \n", jpgd_stat.w, jpgd_stat.h, jpgd_stat.read );
+       sret = sjpgd_decode(jpgd_hnd, &imgb, &jpgd_stat);
+       if (SJPG_IS_ERR(sret)) {
+               printf("Fail to decode, erro=%d\n", sret);
+               ret = -1;
+               goto exit;
+       }
 
-       /* Write decoded image if output_file name is set. */
-       if ( output_file )
-       {
-               printf ( "Write decoded image. \n" );
-               write_decoded_image ( output_file, imgb );
+       if (!jpgd_stat.pa) {
+               printf("decoded buffer is not available\n");
+               ret = -1;
+               goto exit;
        }
 
+       printf("jpgd_stat.w=%d, jpgd_stat.h=%d, jpgd_stat.read=%d \n", jpgd_stat.w, jpgd_stat.h, jpgd_stat.read);
+
+       /* Write decoded image if output_file name is set. */
+       if (output_file) {
+               printf("Write decoded image. \n");
+               write_decoded_image(output_file, imgb);
+       }
 
 exit:
-       if ( bufp ) {
-               free ( bufp );
+       if (bufp) {
+               free(bufp);
                bufp = NULL;
        }
 
-       if ( input_fp )
-               fclose ( input_fp );
+       if (input_fp)
+               fclose(input_fp);
 
-       if ( jpgd_hnd )
-               sjpgd_delete ( jpgd_hnd );
+       if (jpgd_hnd)
+               sjpgd_delete(jpgd_hnd);
 
 
-       sjpg_deinit();
+       sjpg_deinit();
 
-       printf("ret=%d\n", ret);
+       printf("ret=%d\n", ret);
 
        return ret;
 }
 
 int main(int argc, char *argv[])
 {
-
        mm_utility_image_file_format file_format;
        char *input_file, *output_file;
        int output_width, output_height;
-       int ret = 0;
+       int ret = 0;
 
        file_format = MM_UTILITY_IMAGE_FILE_FMT_NONE;
        input_file = output_file = NULL;
        output_width = output_height = 0;
 
        /* Check image file path */
-       if ( !argv[1] )
-       {
-               printf ( "Please input image file path. \n" );
+       if (!argv[1]) {
+               printf("Please input image file path. \n");
                goto exit;
        }
 
-       input_file = g_strdup ( (const char *) argv[1] );
+       input_file = g_strdup((const char *) argv[1]);
 
-       printf ( "Input file name is %s\n", input_file );
+       printf("Input file name is %s\n", input_file);
 
        /* Check outpue decoded image size. if not set, use original image size. */
-       if ( argv[2] && argv[3] )
-       {
+       if (argv[2] && argv[3]) {
                output_width = atoi(argv[2]);
                output_height = atoi(argv[3]);
-               
-               printf ( "Resize decoded image : %dX%d\n", output_width, output_height );
+
+               printf("Resize decoded image : %dX%d\n", output_width, output_height);
        }
 
        /* Check output decoded image file path */
-       if ( argc>3 && argv[4] )
-       {
-               output_file = g_strdup ( (const char *)argv[4] );
-               printf ( "Output decoded image file path [%s]. \n",  output_file );
+       if (argc > 3 && argv[4]) {
+               output_file = g_strdup((const char *)argv[4]);
+               printf("Output decoded image file path [%s]. \n",  output_file);
        }
 
        /* Get image file format : bmp, gif, png, jpg */
-       file_format = get_file_format ( input_file );
+       file_format = get_file_format(input_file);
 
 
        /* Decode image file */
-       switch ( file_format )
-       {
+       switch (file_format) {
                case MM_UTILITY_IMAGE_FILE_FMT_BMP:
-                       ret = decode_bmp ( input_file, output_width, output_height, output_file );
+                       ret = decode_bmp(input_file, output_width, output_height, output_file);
                        break;
                case MM_UTILITY_IMAGE_FILE_FMT_GIF:
-                       ret = decode_gif ( input_file, output_width, output_height, output_file );
+                       ret = decode_gif(input_file, output_width, output_height, output_file);
                        break;
                case MM_UTILITY_IMAGE_FILE_FMT_PNG:
-                       ret = decode_png ( input_file, output_width, output_height, output_file);
+                       ret = decode_png(input_file, output_width, output_height, output_file);
                        break;
                case MM_UTILITY_IMAGE_FILE_FMT_JPG:
-                       ret = decode_jpg ( input_file, output_width, output_height, output_file );
+                       ret = decode_jpg(input_file, output_width, output_height, output_file);
                        break;
                default:
-                       printf ( " This image file is not supported. \n" );
+                       printf(" This image file is not supported. \n");
                        ret = -1;
                        break;
-                       
+
        }
 
-       if ( ret == -1 )
-               printf ( "Fail to decode [%s]. \n", input_file );
+       if (ret == -1)
+               printf("Fail to decode [%s]. \n", input_file);
 
 exit:
-       if ( input_file )
-       {
-               g_free ( input_file );
+       if (input_file) {
+               g_free(input_file);
                input_file = NULL;
        }
 
-       if ( output_file )
-       {
-               g_free ( output_file );
+       if (output_file) {
+               g_free(output_file);
                output_file = NULL;
        }
-       
+
        return ret;
 
 }