return MM_UTIL_ERROR_NONE;
}
-int __gif_make_color_map(mm_image_info_s *gif_image, ColorMapObject **color_map, GifByteType **intermediate_image, unsigned long *intermediate_image_size)
+static int __gif_make_color_map(mm_image_info_s *gif_image, ColorMapObject **color_map, GifByteType **intermediate_image, unsigned long *intermediate_image_size)
{
int ret = MM_UTIL_ERROR_NONE;
int colormap_size = DEFAULT_COLORMAP_SIZE;
return ret;
}
-static int _gif_encode_open_mem(gif_file_s *gif_file)
+static int __gif_encode_open_mem(gif_file_s *gif_file)
{
mm_util_fenter();
mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
return MM_UTIL_ERROR_NONE;
}
-static int _gif_encode_close_file(GifFileType *gft)
+static int __gif_encode_close_file(GifFileType *gft)
{
mm_util_fenter();
mm_util_retvm_if(gft == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
return MM_UTIL_ERROR_NONE;
}
-int __write_gif_to_file(gif_file_s *handle)
+static int __write_gif_to_file(gif_file_s *handle)
{
int ret = MM_UTIL_ERROR_NONE;
FILE *fp = NULL;
return ret;
}
-int __write_gif_to_buffer(gif_file_s *handle)
+static int __write_gif_to_buffer(gif_file_s *handle)
{
unsigned char *_buffer = NULL;
return MM_UTIL_ERROR_NONE;
}
-int _gif_image_write_image(gif_file_s *gif_file, mm_image_info_s *gif_image)
+static int __gif_image_write_image(gif_file_s *gif_file, mm_image_info_s *gif_image)
{
int ret = MM_UTIL_ERROR_NONE;
ColorMapObject *color_map = NULL;
return MM_UTIL_ERROR_NONE;
}
-int _gif_image_create_ext_block(int function, int byte_count, ExtensionBlock **ext_block)
+static int __gif_image_create_ext_block(int function, int byte_count, ExtensionBlock **ext_block)
{
ExtensionBlock *_ext_block = NULL;
return MM_UTIL_ERROR_NONE;
}
-int _gif_image_write_ext_block(gif_file_s *gif_file, unsigned int delay_time)
+static int __gif_image_write_ext_block(gif_file_s *gif_file, unsigned int delay_time)
{
int ret = MM_UTIL_ERROR_NONE;
ExtensionBlock *_ext_block = NULL;
mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = _gif_image_create_ext_block(GRAPHICS_EXT_FUNC_CODE, GRAPHIC_EXT_BLOCK_SIZE, &_ext_block);
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_alloc_ext_block failed");
+ ret = __gif_image_create_ext_block(GRAPHICS_EXT_FUNC_CODE, GRAPHIC_EXT_BLOCK_SIZE, &_ext_block);
+ mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_image_create_ext_block failed");
/* use fixed graphics control */
graphic_control_block.DisposalMode = DISPOSAL_UNSPECIFIED;
mm_util_fenter();
- ret = _gif_encode_open_mem(gif_file);
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_encode_open_mem failed");
+ ret = __gif_encode_open_mem(gif_file);
+ mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_encode_open_mem failed");
/* To initialize data after GifFile opened */
EGifSetGifVersion(gif_file->GifFile, TRUE);
/* Write screen description */
if (EGifPutScreenDesc(gif_file->GifFile, width, height, 8 /* color_res */, 0 /* background_color */, NULL) == GIF_ERROR) {
mm_util_error("could not put screen description");
- _gif_encode_close_file(gif_file->GifFile);
+ __gif_encode_close_file(gif_file->GifFile);
return MM_UTIL_ERROR_INVALID_OPERATION;
}
}
/* Write graphic control block */
- ret = _gif_image_write_ext_block(gif_file, gif_image->delay_time);
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_write_ext_block failed");
+ ret = __gif_image_write_ext_block(gif_file, gif_image->delay_time);
+ mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_image_write_ext_block failed");
/* Write image description & data */
- ret = _gif_image_write_image(gif_file, gif_image);
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_write_image failed");
+ ret = __gif_image_write_image(gif_file, gif_image);
+ mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_image_write_image failed");
gif_file->GifFile->ImageCount++;
mm_util_fenter();
- ret = _gif_encode_close_file(gif_file->GifFile);
+ ret = __gif_encode_close_file(gif_file->GifFile);
gif_file->GifFile = NULL;
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_encode_close_file failed");
+ mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_encode_close_file failed");
if (gif_file->filename != NULL)
ret = __write_gif_to_file(gif_file);
mm_util_retm_if(gif_file == NULL, "Invalid parameter");
if (gif_file->GifFile != NULL) {
- ret = _gif_encode_close_file(gif_file->GifFile);
- mm_util_retm_if(ret != MM_UTIL_ERROR_NONE, "_gif_encode_close_file failed");
+ ret = __gif_encode_close_file(gif_file->GifFile);
+ mm_util_retm_if(ret != MM_UTIL_ERROR_NONE, "__gif_encode_close_file failed");
}
MMUTIL_SAFE_G_FREE(gif_file->filename);
#define DEFAULT_RANGE_SATURATION 256
#define DEFAULT_RANGE_VALUE 256
-static int _mm_util_imgcv_init(mm_util_imgcv_s *handle, int width, int height)
+static int __mm_util_imgcv_init(mm_util_imgcv_s *handle, int width, int height)
{
mm_util_fenter();
return MM_UTIL_ERROR_NONE;
}
-static void _mm_util_imgcv_uninit(mm_util_imgcv_s *handle)
+static void __mm_util_imgcv_uninit(mm_util_imgcv_s *handle)
{
mm_util_fenter();
mm_util_fleave();
}
-static int _mm_util_imgcv_set_buffer(mm_util_imgcv_s *handle, void *image_buffer)
+static int __mm_util_imgcv_set_buffer(mm_util_imgcv_s *handle, void *image_buffer)
{
mm_util_fenter();
}
-static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b)
+static int __mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b)
{
int nh = 0;
int ns = 0;
{
mm_util_fenter();
- if (image_buffer == NULL) {
- mm_util_error("#ERROR#: image buffer is NULL");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
+ mm_util_retvm_if(!image_buffer, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image_buffer");
mm_util_imgcv_s *handle = (mm_util_imgcv_s *)calloc(1, sizeof(mm_util_imgcv_s));
- if (handle == NULL) {
- mm_util_error("#ERROR#: fail to create handle");
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
+ mm_util_retvm_if(!handle, MM_UTIL_ERROR_OUT_OF_MEMORY, "fail to create handle");
- int ret = _mm_util_imgcv_init(handle, width, height);
+ int ret = __mm_util_imgcv_init(handle, width, height);
if (ret != MM_UTIL_ERROR_NONE) {
- _mm_util_imgcv_uninit(handle);
- MMUTIL_SAFE_FREE(handle);
- mm_util_error("#ERROR#: Fail to mm_util_imgcv_init: ret=%d", ret);
- return ret;
+ mm_util_error("#ERROR#: Fail to __mm_util_imgcv_init: ret=%d", ret);
+ goto ERROR;
}
- ret = _mm_util_imgcv_set_buffer(handle, image_buffer);
+ ret = __mm_util_imgcv_set_buffer(handle, image_buffer);
if (ret != MM_UTIL_ERROR_NONE) {
- _mm_util_imgcv_uninit(handle);
- MMUTIL_SAFE_FREE(handle);
- mm_util_error("#ERROR#: Fail to mm_util_imgcv_set_buffer: ret=%d", ret);
- return ret;
+ mm_util_error("#ERROR#: Fail to __mm_util_imgcv_set_buffer: ret=%d", ret);
+ goto ERROR;
}
- ret = _mm_util_imgcv_calculate_hist(handle, r_color, g_color, b_color);
+ ret = __mm_util_imgcv_calculate_hist(handle, r_color, g_color, b_color);
if (ret != MM_UTIL_ERROR_NONE) {
- _mm_util_imgcv_uninit(handle);
- MMUTIL_SAFE_FREE(handle);
- mm_util_error("#ERROR#: Fail to mm_util_imgcv_calculate_hist: ret=%d", ret);
- return ret;
+ mm_util_error("#ERROR#: Fail to __mm_util_imgcv_calculate_hist: ret=%d", ret);
+ goto ERROR;
}
- _mm_util_imgcv_uninit(handle);
+ERROR:
+ __mm_util_imgcv_uninit(handle);
MMUTIL_SAFE_FREE(handle);
mm_util_fleave();
- return MM_UTIL_ERROR_NONE;
+ return ret;
}
static int __mm_util_get_crop_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize)
{
- int ret = MM_UTIL_ERROR_NONE;
unsigned char x_chroma_shift = 0;
unsigned char y_chroma_shift = 0;
unsigned int w2, h2, stride, stride2;
mm_util_debug("format: %d, *imgsize: %zu", format, *imgsize);
- return ret;
+ return MM_UTIL_ERROR_NONE;
}
static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, unsigned int src_width, unsigned int src_height, mm_util_color_format_e dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
g_module_close(module);
MMUTIL_SAFE_FREE(_imgp_info_s);
-
- return;
}
-static int __mm_util_crop_rgb32(const unsigned char *src, unsigned int src_width, unsigned int src_height,
+static void __mm_util_crop_rgb32(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
- int ret = MM_UTIL_ERROR_NONE;
unsigned int idx = 0;
int src_bytesperline = src_width * 4;
int dst_bytesperline = crop_dest_width * 4;
src += src_bytesperline;
dst += dst_bytesperline;
}
-
- return ret;
}
-static int __mm_util_crop_rgb24(const unsigned char *src, unsigned int src_width, unsigned int src_height,
+static void __mm_util_crop_rgb24(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
- int ret = MM_UTIL_ERROR_NONE;
unsigned int idx = 0;
unsigned long src_bytesperline = src_width * 3;
unsigned long dst_bytesperline = crop_dest_width * 3;
src += src_bytesperline;
dst += dst_bytesperline;
}
-
- return ret;
}
-static int __mm_util_crop_rgb16(const unsigned char *src, unsigned int src_width, unsigned int src_height,
+static void __mm_util_crop_rgb16(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
- int ret = MM_UTIL_ERROR_NONE;
unsigned int idx = 0;
unsigned long src_bytesperline = src_width * 2;
unsigned long dst_bytesperline = crop_dest_width * 2;
src += src_bytesperline;
dst += dst_bytesperline;
}
-
- return ret;
}
-static int __mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height,
+static void __mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
- int ret = MM_UTIL_ERROR_NONE;
unsigned int idx = 0;
unsigned int start_x = crop_start_x;
unsigned int start_y = crop_start_y;
_src += src_width / 2;
dst += crop_dest_width / 2;
}
-
- return ret;
}
static IMGPInfoFunc __mm_util_initialize(imgp_type_e function, mm_util_color_format_e src_format, mm_util_color_format_e dst_format, GModule **module)
switch (_src->color) {
case MM_UTIL_COLOR_RGB16: {
- ret = __mm_util_crop_rgb16(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
+ __mm_util_crop_rgb16(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
}
case MM_UTIL_COLOR_RGB24: {
- ret = __mm_util_crop_rgb24(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
+ __mm_util_crop_rgb24(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
}
case MM_UTIL_COLOR_ARGB:
case MM_UTIL_COLOR_BGRA:
case MM_UTIL_COLOR_RGBA:
case MM_UTIL_COLOR_BGRX: {
- ret = __mm_util_crop_rgb32(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
+ __mm_util_crop_rgb32(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
}
case MM_UTIL_COLOR_I420:
case MM_UTIL_COLOR_YUV420: {
- ret = __mm_util_crop_yuv420(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
+ __mm_util_crop_yuv420(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
}
default:
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
- if (ret == MM_UTIL_ERROR_NONE)
- ret = mm_image_create_image(_width, _height, _src->color, _buffer, _buffer_size, dst);
- else
- mm_util_error("crop is failed (%d)", ret);
+ ret = mm_image_create_image(_width, _height, _src->color, _buffer, _buffer_size, dst);
MMUTIL_SAFE_FREE(_buffer);
mm_util_fleave();
int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize)
{
- int ret = MM_UTIL_ERROR_NONE;
unsigned char x_chroma_shift = 0;
unsigned char y_chroma_shift = 0;
unsigned int w2, h2, stride, stride2;
mm_util_debug("format: %u, *imgsize: %zu", format, *imgsize);
- return ret;
+ return MM_UTIL_ERROR_NONE;
}
return _bool;
}
-static gboolean _mm_util_is_supported_color_format(mm_util_color_format_e color_format)
+static gboolean __mm_util_is_supported_color_format(mm_util_color_format_e color_format)
{
gboolean _bool = FALSE;
return MM_UTIL_ERROR_NONE;
}
-static int _mm_util_jpeg_encode(mm_util_jpeg_ctrl_format_e control_format, mm_util_image_h decoded, int quality, FILE *fp, void **mem, size_t *csize)
+static int __mm_util_jpeg_encode(mm_util_jpeg_ctrl_format_e control_format, mm_util_image_h decoded, int quality, FILE *fp, void **mem, size_t *csize)
{
int ret = MM_UTIL_ERROR_NONE;
mm_image_info_s *_decoded = (mm_image_info_s *)decoded;
return ret;
}
-static int _mm_util_jpeg_decode(mm_util_jpeg_ctrl_format_e control_format, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale, mm_util_image_h *decoded)
+static int __mm_util_jpeg_decode(mm_util_jpeg_ctrl_format_e control_format, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale, mm_util_image_h *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
struct jpeg_decompress_struct dinfo;
mm_util_retvm_if(!file_path, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid file_path");
mm_util_retvm_if(!IS_VALID_IMAGE(decoded), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image");
- mm_util_retvm_if((!_mm_util_is_supported_color_format(_decoded->color)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", _decoded->color);
+ mm_util_retvm_if((!__mm_util_is_supported_color_format(_decoded->color)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", _decoded->color);
mm_util_retvm_if((quality < 1) || (quality > 100), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid quality [%d]", quality);
FILE *fp = NULL;
return ret;
}
- ret = _mm_util_jpeg_encode(MM_UTIL_JPEG_FILE, _converted_image, quality, fp, NULL, NULL);
+ ret = __mm_util_jpeg_encode(MM_UTIL_JPEG_FILE, _converted_image, quality, fp, NULL, NULL);
mm_image_destroy_image(_converted_image);
} else {
- ret = _mm_util_jpeg_encode(MM_UTIL_JPEG_FILE, decoded, quality, fp, NULL, NULL);
+ ret = __mm_util_jpeg_encode(MM_UTIL_JPEG_FILE, decoded, quality, fp, NULL, NULL);
}
fsync((int)(fp->_fileno));
mm_util_retvm_if(!buffer, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid buffer");
mm_util_retvm_if(!size, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid size");
mm_util_retvm_if(!IS_VALID_IMAGE(decoded), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image");
- mm_util_retvm_if((!_mm_util_is_supported_color_format(_decoded->color)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported color [%d]", _decoded->color);
+ mm_util_retvm_if((!__mm_util_is_supported_color_format(_decoded->color)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported color [%d]", _decoded->color);
mm_util_retvm_if((quality < 1) || (quality > 100), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid quality [%d]", quality);
if (_decoded->color == MM_UTIL_COLOR_NV12) {
ret = mm_util_convert_colorspace(decoded, MM_UTIL_COLOR_YUV420, &_converted_image);
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "mm_util_convert_image fail (%d)", ret);
- ret = _mm_util_jpeg_encode(MM_UTIL_JPEG_MEM, _converted_image, quality, NULL, buffer, size);
+ ret = __mm_util_jpeg_encode(MM_UTIL_JPEG_MEM, _converted_image, quality, NULL, buffer, size);
mm_image_destroy_image(_converted_image);
} else {
- ret = _mm_util_jpeg_encode(MM_UTIL_JPEG_MEM, decoded, quality, NULL, buffer, size);
+ ret = __mm_util_jpeg_encode(MM_UTIL_JPEG_MEM, decoded, quality, NULL, buffer, size);
}
mm_util_fleave();
mm_util_retvm_if(!MMUTIL_STRING_VALID(file_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid file_path");
mm_util_retvm_if((IS_VALID_COLOR(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
- mm_util_retvm_if((!_mm_util_is_supported_color_format(fmt)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", fmt);
+ mm_util_retvm_if((!__mm_util_is_supported_color_format(fmt)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", fmt);
mm_util_retvm_if(!decoded, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image handle");
if ((downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_2)
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "mm_util_safe_fopen fail (%d)", ret);
if (fmt == MM_UTIL_COLOR_NV12) {
- ret = _mm_util_jpeg_decode(MM_UTIL_JPEG_FILE, fp, NULL, 0, MM_UTIL_COLOR_YUV420, downscale, &_decoded);
+ ret = __mm_util_jpeg_decode(MM_UTIL_JPEG_FILE, fp, NULL, 0, MM_UTIL_COLOR_YUV420, downscale, &_decoded);
if (ret == MM_UTIL_ERROR_NONE)
ret = mm_util_convert_colorspace(_decoded, MM_UTIL_COLOR_NV12, decoded);
mm_image_destroy_image(_decoded);
} else {
- ret = _mm_util_jpeg_decode(MM_UTIL_JPEG_FILE, fp, NULL, 0, fmt, downscale, decoded);
+ ret = __mm_util_jpeg_decode(MM_UTIL_JPEG_FILE, fp, NULL, 0, fmt, downscale, decoded);
}
mm_util_safe_fclose(fp);
mm_util_retvm_if(!memory, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid jpeg image");
mm_util_retvm_if(!src_size, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_size");
mm_util_retvm_if((IS_VALID_COLOR(fmt) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", fmt);
- mm_util_retvm_if((!_mm_util_is_supported_color_format(fmt)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", fmt);
+ mm_util_retvm_if((!__mm_util_is_supported_color_format(fmt)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", fmt);
mm_util_retvm_if(!decoded, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image handle");
if ((downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1) && (downscale != MM_UTIL_JPEG_DECODE_DOWNSCALE_1_2)
}
if (fmt == MM_UTIL_COLOR_NV12) {
- ret = _mm_util_jpeg_decode(MM_UTIL_JPEG_MEM, NULL, memory, src_size, MM_UTIL_COLOR_YUV420, downscale, &_decoded);
+ ret = __mm_util_jpeg_decode(MM_UTIL_JPEG_MEM, NULL, memory, src_size, MM_UTIL_COLOR_YUV420, downscale, &_decoded);
if (ret == MM_UTIL_ERROR_NONE)
ret = mm_util_convert_colorspace(_decoded, MM_UTIL_COLOR_NV12, decoded);
mm_image_destroy_image(_decoded);
} else {
- ret = _mm_util_jpeg_decode(MM_UTIL_JPEG_MEM, NULL, memory, src_size, fmt, downscale, decoded);
+ ret = __mm_util_jpeg_decode(MM_UTIL_JPEG_MEM, NULL, memory, src_size, fmt, downscale, decoded);
}
mm_util_fleave();
static unsigned char gIfegBMPHeader[] = { 0x42, 0x4D };
static unsigned char gIfegWBMPHeader[] = { 0x00, 0x00 };
-void __ImgGetFileAttributes(const char *szPathName, unsigned long *pFileAttr)
+static void __ImgGetFileAttributes(const char *szPathName, unsigned long *pFileAttr)
{
FILE *f = NULL;
}
}
-static unsigned int _IfegReadUINT(unsigned char *pBuffer)
+static unsigned int __IfegReadUINT(unsigned char *pBuffer)
{
return (((*pBuffer) << 24) | ((*(pBuffer + 1)) << 16) | ((*(pBuffer + 2)) << 8) | (*(pBuffer + 3)));
}
-static unsigned int _ReadBE16bitsToUINT(unsigned char *pBuffer)
+static unsigned int __ReadBE16bitsToUINT(unsigned char *pBuffer)
{
return ((*pBuffer) << 8 | (*(pBuffer + 1)));
}
-static unsigned int _ReadLE16bitsToUINT(unsigned char *pBuffer)
+static unsigned int __ReadLE16bitsToUINT(unsigned char *pBuffer)
{
return ((*pBuffer) | ((*(pBuffer + 1)) << 8));
}
-static unsigned int _ReadLE32bitsToUINT(unsigned char *pBuffer)
+static unsigned int __ReadLE32bitsToUINT(unsigned char *pBuffer)
{
return ((*pBuffer) | ((*(pBuffer + 1)) << 8) | ((*(pBuffer + 2)) << 16) | ((*(pBuffer + 3)) << 24));
}
-static int _ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt, mm_util_img_codec_type *type, unsigned int *width, unsigned int *height)
+static int __ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt, mm_util_img_codec_type *type, unsigned int *width, unsigned int *height)
{
unsigned long fileread;
unsigned char EncodedDataBuffer[4096];
- int ret = MM_UTIL_ERROR_NONE;
-
mm_util_retvm_if((type == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "type is null");
mm_util_retvm_if((width == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "width is null");
mm_util_retvm_if((height == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "height is null");
memset(EncodedDataBuffer, 0, 4096);
fileread = fread(EncodedDataBuffer, sizeof(char), MINIMUM_HEADER_BYTES, hFile);
- mm_util_retvm_if((fileread < MINIMUM_HEADER_BYTES), ret, "IMG_CODEC_UNKNOWN_TYPE");
+ mm_util_retvm_if((fileread < MINIMUM_HEADER_BYTES), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE");
if (memcmp(EncodedDataBuffer, gIfegJPEGHeader, JPG_HEADER_LENGTH) == 0) {
unsigned char header_type[JPG_HEADER_TYPE_LENGTH];
memset(header_type, 0, JPG_HEADER_TYPE_LENGTH);
fileread = fread(header_type, sizeof(char), JPG_HEADER_TYPE_LENGTH, hFile);
- mm_util_retvm_if((fileread < JPG_HEADER_TYPE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
+ mm_util_retvm_if((fileread < JPG_HEADER_TYPE_LENGTH), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
if (header_type[0] != 0xFF) {
mm_util_warn("Failed to get w / h from jpeg at index [%llu] and go to next block.", i);
if (header_type[1] == 0xC0 || header_type[1] == 0xC2) {
memset(image_size, 0, JPG_IMAGE_SIZE_LENGTH);
fileread = fread(image_size, sizeof(char), JPG_IMAGE_SIZE_LENGTH, hFile);
- mm_util_retvm_if((fileread < JPG_IMAGE_SIZE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
+ mm_util_retvm_if((fileread < JPG_IMAGE_SIZE_LENGTH), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
- *width = _ReadBE16bitsToUINT(image_size + 5);
- *height = _ReadBE16bitsToUINT(image_size + 3);
+ *width = __ReadBE16bitsToUINT(image_size + 5);
+ *height = __ReadBE16bitsToUINT(image_size + 3);
break;
} else {
i += JPG_HEADER_TYPE_LENGTH;
memset(block_size, 0, JPG_BLOCK_SIZE_LENGTH);
fileread = fread(block_size, sizeof(char), JPG_BLOCK_SIZE_LENGTH, hFile);
- mm_util_retvm_if((fileread < JPG_BLOCK_SIZE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
- block_length = (unsigned short)_ReadBE16bitsToUINT(block_size);
+ mm_util_retvm_if((fileread < JPG_BLOCK_SIZE_LENGTH), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
+ block_length = (unsigned short)__ReadBE16bitsToUINT(block_size);
mm_util_sec_debug("new block length : %u", block_length);
if (fseek(hFile, block_length - JPG_BLOCK_SIZE_LENGTH, SEEK_CUR) < 0) {
/*********************** PNG *************************/
else if (memcmp(EncodedDataBuffer, gIfegPNGHeader, PNG_HEADER_LENGTH) == 0) {
fileread = fread(EncodedDataBuffer, sizeof(char), 32, hFile);
- mm_util_retvm_if((fileread < 32), ret, "IMG_CODEC_UNKNOWN_TYPE in PNG");
+ mm_util_retvm_if((fileread < 32), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in PNG");
/* Get Image width & height */
- *width = _IfegReadUINT((EncodedDataBuffer + 8));
- *height = _IfegReadUINT((EncodedDataBuffer + 12));
+ *width = __IfegReadUINT((EncodedDataBuffer + 8));
+ *height = __IfegReadUINT((EncodedDataBuffer + 12));
mm_util_sec_debug("IMG_CODEC_PNG");
*type = IMG_CODEC_PNG;
else if (memcmp(EncodedDataBuffer, gIfegBMPHeader, BMP_HEADER_LENGTH) == 0) {
/* Parse BMP File and get image width and image height */
fileread = fread(&EncodedDataBuffer[8], sizeof(char), 18, hFile);
- mm_util_retvm_if((fileread < 18), ret, "IMG_CODEC_UNKNOWN_TYPE in BMP");
+ mm_util_retvm_if((fileread < 18), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in BMP");
- *width = _ReadLE32bitsToUINT(EncodedDataBuffer + 18);
+ *width = __ReadLE32bitsToUINT(EncodedDataBuffer + 18);
// add the reference function abs(). may have negative height values in bmp header.
- *height = abs(_ReadLE32bitsToUINT(EncodedDataBuffer + 22));
+ *height = abs(__ReadLE32bitsToUINT(EncodedDataBuffer + 22));
mm_util_sec_debug("IMG_CODEC_BMP");
*type = IMG_CODEC_BMP;
}
/*********************** GIF *************************/
else if (memcmp(EncodedDataBuffer, gIfegGIFHeader, GIF_HEADER_LENGTH) == 0) {
- mm_util_retvm_if((MINIMUM_HEADER_BYTES + 4 > fileSize), ret, "IMG_CODEC_UNKNOWN_TYPE in GIF");
+ mm_util_retvm_if((MINIMUM_HEADER_BYTES + 4 > fileSize), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in GIF");
fileread = fread(&EncodedDataBuffer[8], sizeof(char), 4, hFile);
- mm_util_retvm_if((fileread < 4), ret, "IMG_CODEC_UNKNOWN_TYPE in GIF");
+ mm_util_retvm_if((fileread < 4), MM_UTIL_ERROR_INVALID_PARAMETER, "IMG_CODEC_UNKNOWN_TYPE in GIF");
if (EncodedDataBuffer[0] != 'G' || EncodedDataBuffer[1] != 'I'
|| EncodedDataBuffer[2] != 'F' || EncodedDataBuffer[3] < '0'
|| EncodedDataBuffer[4] > '9' || EncodedDataBuffer[5] < 'A'
|| EncodedDataBuffer[5] > 'z') {
mm_util_warn("IMG_CODEC_UNKNOWN_TYPE in GIF");
- return ret;
+ return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- *width = _ReadLE16bitsToUINT(EncodedDataBuffer + 6);
- *height = _ReadLE16bitsToUINT(EncodedDataBuffer + 8);
+ *width = __ReadLE16bitsToUINT(EncodedDataBuffer + 6);
+ *height = __ReadLE16bitsToUINT(EncodedDataBuffer + 8);
mm_util_sec_debug("IMG_CODEC_GIF");
*type = IMG_CODEC_GIF;
mm_util_sec_debug("IMG_CODEC_WBMP");
*type = IMG_CODEC_WBMP;
}
+
mm_util_sec_debug("Image Width : %u, Height : %u", *width, *height);
- return ret;
+
+ return MM_UTIL_ERROR_NONE;
}
-static int _ImgGetFileExt(const char *path, char *file_ext, int max_len)
+static int __ImgGetFileExt(const char *path, char *file_ext, int max_len)
{
int i = 0;
char file_ext[10] = { 0, };
int ret = MM_UTIL_ERROR_NONE;
- if (path == NULL)
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ mm_util_retvm_if(!path, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid path");
hFile = fopen(path, "rb");
- if (hFile == NULL) {
- mm_util_error("file open error: %s", path);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
+ mm_util_retvm_if(!hFile, MM_UTIL_ERROR_INVALID_PARAMETER, "file open error: %s", path);
__ImgGetFileAttributes(path, &file_size);
if (file_size == 0) {
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- ret = _ImgGetFileExt(path, file_ext, sizeof(file_ext));
+ ret = __ImgGetFileExt(path, file_ext, sizeof(file_ext));
if (ret != MM_UTIL_ERROR_NONE)
- mm_util_warn("_ImgGetFileExt failed");
+ mm_util_warn("__ImgGetFileExt failed");
- ret = _ImgGetImageInfo(hFile, file_size, file_ext, type, width, height);
+ ret = __ImgGetImageInfo(hFile, file_size, file_ext, type, width, height);
if (fseek(hFile, 0, SEEK_SET) < 0)
mm_util_stderror("fseek failed");
Name: libmm-utility
Summary: Multimedia Framework Utility Library
-Version: 0.1.34
+Version: 0.1.35
Release: 0
Group: System/Libraries
License: Apache-2.0