summaryrefslogtreecommitdiff
path: root/src/codec/img-codec.c
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-08-07 09:40:46 +0900
committerMinje Ahn <minje.ahn@samsung.com>2015-08-07 10:10:15 +0900
commit7adbb6954d7f05fd02b9cded3741ce6ed2c9226b (patch)
tree5315a9e75f2283f559b18a8375f093b6eca10a3e /src/codec/img-codec.c
parent41f405edc8f31d877615c580ed6eb308d7eaebec (diff)
downloadlibmedia-thumbnail-7adbb6954d7f05fd02b9cded3741ce6ed2c9226b.tar.gz
libmedia-thumbnail-7adbb6954d7f05fd02b9cded3741ce6ed2c9226b.tar.bz2
libmedia-thumbnail-7adbb6954d7f05fd02b9cded3741ce6ed2c9226b.zip
Separate CMakeFiles for apply fPIE option Remove unused code Remove thumb_type Modify jpeg thumbnail creation logic when exif thumbnail is smaller than request thumbnail size Add scale down logic when request huge size image Fix bugs, memory leaks Remove unused parameters in function Change thumb path creation API position Remove thumbnail folder creation API Rename some functions Change-Id: I0e13d393dd524b61bcf44722c33b6f270649b732 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src/codec/img-codec.c')
-rwxr-xr-x[-rw-r--r--]src/codec/img-codec.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/codec/img-codec.c b/src/codec/img-codec.c
index fadd8c2..a27495c 100644..100755
--- a/src/codec/img-codec.c
+++ b/src/codec/img-codec.c
@@ -25,7 +25,7 @@
#include <mm_util_imgp.h>
unsigned int *ImgGetFirstFrameAGIFAtSize(const char *szFileName,
- ImgImageInfo *image_info)
+ unsigned int width, unsigned int height)
{
AGifFrameInfo *pFrameInfo = 0;
void *pDecodedRGB888Buf = 0;
@@ -37,15 +37,15 @@ unsigned int *ImgGetFirstFrameAGIFAtSize(const char *szFileName,
return NULL;
}
- if (image_info == NULL) {
+ if (width == 0 || height == 0) {
thumb_err
- ("ImgGetFirstFrameAGIFAtSize: Input ImgImageInfo is NULL");
+ ("ImgGetFirstFrameAGIFAtSize: Input width or height is zero");
return NULL;
}
pFrameInfo =
- ImgCreateAGIFFrame(szFileName, image_info->width,
- image_info->height, 0, FALSE);
+ ImgCreateAGIFFrame(szFileName, width,
+ height, 0, FALSE);
if (pFrameInfo && pFrameInfo->pOutBits) {
ImgGetNextAGIFFrame(pFrameInfo, TRUE);
@@ -61,13 +61,17 @@ unsigned int *ImgGetFirstFrameAGIFAtSize(const char *szFileName,
unsigned int i = 0;
- if (mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, image_info->width, image_info->height, &i) < 0) {
+ if (mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, width, height, &i) < 0) {
thumb_err("ImgGetFirstFrameAGIFAtSize: Failed to get buffer size");
return NULL;
}
thumb_dbg("ImgGetFirstFrameAGIFAtSize: raw data size : %d)", i);
raw_data = (unsigned char *)malloc(i);
+ if (raw_data == NULL) {
+ thumb_err("ImgGetFirstFrameAGIFAtSize: Failed to allocate memory");
+ return NULL;
+ }
memset(raw_data, 0, i);
unsigned char *dest = raw_data;
while (i--) {
@@ -162,8 +166,6 @@ AGifFrameInfo *ImgCreateAGIFFrame(const char *szFileName, unsigned int width,
return FALSE;
}
- SysRequireEx(szFileName != NULL, FALSE);
-
hFile = DrmOpenFile(szFileName);
if (hFile == (HFile) INVALID_HOBJ) {
thumb_err("ImgCreateAGIFFrame: Cannot open file");
@@ -180,13 +182,14 @@ AGifFrameInfo *ImgCreateAGIFFrame(const char *szFileName, unsigned int width,
cFileSize = fileAttrib.fileSize;
/* A size of allocated memory - w * h *2 means RGB565 and 4096 means the max of header length */
- mem_alloc_size = width * height * 2 + MAX_GIF_HEADER_SIZE;
-
+// mem_alloc_size = width * height * 2 + MAX_GIF_HEADER_SIZE;
+ mem_alloc_size = cFileSize;
if ((pEncodedData = (unsigned char *)malloc(mem_alloc_size)) == NULL) {
thumb_err("Memory Allocation to pEncodedData failed");
DrmCloseFile(hFile);
return NULL;
}
+ memset(pEncodedData,0,mem_alloc_size);
/* coverity[ -tainted_data_argument : pEncodedData ] */
if (DrmReadFile(hFile, pEncodedData, mem_alloc_size, &size) == FALSE) {
thumb_err("DrmReadFile was failed");