Remove unneccessary code to check jpeg 72/172272/1
authorJiyong Min <jiyong.min@samsung.com>
Tue, 13 Mar 2018 05:37:08 +0000 (14:37 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 13 Mar 2018 05:38:21 +0000 (14:38 +0900)
Change-Id: Iea21e1309f5d177353e6e074baf3d91035859717

jpeg/mm_util_jpeg.c

index 93bae3d..7dd7656 100755 (executable)
@@ -544,62 +544,27 @@ int mm_util_decode_from_jpeg_file_with_downscale(const char *filename, mm_util_c
                return ret;
        }
 
-       unsigned char magic[2] = {0};
-       size_t read_size = 0;
-       if (fp) {
-               read_size = fread((void *)magic, 1, 2, fp);
-               if (read_size > 0)
-                       mm_util_debug("Success fread");
-
-               mm_util_debug("%x %x", magic[0], magic[1]);
-       } else {
-               mm_util_error("[infile] file open [%s]", filename);
-               mm_util_stderror("file open failed");
-               return MM_UTIL_ERROR_NO_SUCH_FILE;
-       }
+       mm_util_debug("#START# libjpeg fmt [%d]", fmt);
+       if (fmt == MM_UTIL_COLOR_NV12) {
+               ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, 0, MM_UTIL_COLOR_YUV420, downscale, decoded);
+               if (ret == MM_UTIL_ERROR_NONE) {
+                       unsigned int res_w = 0;
+                       unsigned int res_h = 0;
+                       size_t res_buffer_size = 0;
+                       unsigned char *dst = NULL;
 
-       fseek(fp, 0, SEEK_SET);
+                       ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
 
-       if (magic[0] == 0xff && magic[1] == 0xd8) {
-#ifdef LIBJPEG_TURBO
-               mm_util_debug("#START# LIBJPEG_TURBO");
-               ret = __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
-#else
-               mm_util_debug("#START# libjpeg fmt [%d]", fmt);
-               if (fmt == MM_UTIL_COLOR_NV12) {
-                       ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, 0, MM_UTIL_COLOR_YUV420, downscale, decoded);
-                       if (ret == MM_UTIL_ERROR_NONE) {
-                               unsigned int res_w = 0;
-                               unsigned int res_h = 0;
-                               size_t res_buffer_size = 0;
-                               unsigned char *dst = NULL;
-
-                               ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, MM_UTIL_COLOR_NV12, &dst, &res_w, &res_h, &res_buffer_size);
-
-                               MMUTIL_SAFE_FREE(decoded->data);
-
-                               decoded->data = dst;
-                               decoded->size = res_buffer_size;
-                       }
-               } else {
-                       ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, 0, fmt, downscale, decoded);
+                       MMUTIL_SAFE_FREE(decoded->data);
+
+                       decoded->data = dst;
+                       decoded->size = res_buffer_size;
                }
-#endif
-               mm_util_debug("decoded->data: %p\t width: %d\t height: %d\t size: %u", decoded->data, decoded->width, decoded->height, decoded->size);
-               mm_util_debug("#End# libjpeg, Success!! ret: %d", ret);
-       } 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) {
-               mm_util_error("Not JPEG IMAGE - PNG");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       } else if (magic[0] == 0x49 && magic[1] == 0x49) {
-               mm_util_error("Not JPEG IMAGE - TIFF");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
        } else {
-               mm_util_error("Not JPEG IMAGE");
-               ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+               ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, fp, NULL, 0, fmt, downscale, decoded);
        }
+       mm_util_debug("decoded->data: %p\t width: %d\t height: %d\t size: %u", decoded->data, decoded->width, decoded->height, decoded->size);
+       mm_util_debug("#End# libjpeg, Success!! ret: %d", ret);
 
        mm_util_safe_fclose(fp);