diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/codec/AGifFrameInfo.h | 65 | ||||
-rw-r--r-- | src/include/codec/IfegDecodeAGIF.h | 57 | ||||
-rw-r--r-- | src/include/codec/img-codec-agif.h | 28 | ||||
-rw-r--r-- | src/include/codec/img-codec-common.h | 304 | ||||
-rw-r--r-- | src/include/codec/img-codec-config.h | 26 | ||||
-rw-r--r-- | src/include/codec/img-codec-osal.h | 129 | ||||
-rw-r--r-- | src/include/codec/img-codec-parser.h | 48 | ||||
-rw-r--r-- | src/include/codec/img-codec.h | 49 | ||||
-rwxr-xr-x | src/include/ipc/media-thumb-ipc.h | 125 | ||||
-rwxr-xr-x | src/include/media-thumb-internal.h | 81 | ||||
-rwxr-xr-x | src/include/util/media-thumb-db.h | 79 | ||||
-rwxr-xr-x | src/include/util/media-thumb-debug.h | 81 | ||||
-rwxr-xr-x | src/include/util/media-thumb-util.h | 146 |
13 files changed, 1218 insertions, 0 deletions
diff --git a/src/include/codec/AGifFrameInfo.h b/src/include/codec/AGifFrameInfo.h new file mode 100644 index 0000000..0f5aa81 --- /dev/null +++ b/src/include/codec/AGifFrameInfo.h @@ -0,0 +1,65 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _AGIFFRAMEINFO_H_ +#define _AGIFFRAMEINFO_H_ + +typedef struct tagFrameInfo +{ + int height; + int width; + unsigned int backcolor; + unsigned int ui_backcolor; + int imgCount; + int inputSize; + + unsigned char *pEncodedData; + void *pOutBits; + + unsigned char *pPrevImg; + unsigned int *pGlobal_table; + unsigned short *pPrefix; + unsigned char *pDstack; + unsigned char *pSuffix; + + int flag; + int size; + int useBuffer; + int bLoop; + int global_numcol; + int resizedwidth; + int resizedheight; + int logi_wdt; + int logi_hgt; + int offset; + int firstpos; + + unsigned short delay; + +#ifdef INTERNAL_IMGCODEC + unsigned int nRepeatCount; + unsigned int nLoopCount; + + unsigned char bOneFrame; +#endif +}AGifFrameInfo; + +#endif // _AGIFFRAMEINFO_H_ diff --git a/src/include/codec/IfegDecodeAGIF.h b/src/include/codec/IfegDecodeAGIF.h new file mode 100644 index 0000000..9510c64 --- /dev/null +++ b/src/include/codec/IfegDecodeAGIF.h @@ -0,0 +1,57 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IFEG_DECODE_GIF_H_ +#define _IFEG_DECODE_GIF_H_ + + + +#include "AGifFrameInfo.h" +#include "img-codec-common.h" + + + +#define MODE 0 + +#define MAX_GIF_HEADER_SIZE 4096 + +#if MODE == 2 +#define MAXBUFFMEMORY 330000 +#endif + +#define MAXWIDTH 4096 +#define MAXHEIGHT 4096 + +#ifdef __cplusplus +extern "C" { +#endif + + +int FastImgGetNextFrameAGIF (AGifFrameInfo* pFrameData, BOOL bCenterAlign); +AGifFrameInfo* FastImgCreateAGIFFrameData(unsigned int width, unsigned int height, unsigned char *pEncodedData, unsigned int file_size, unsigned int ui_backcolor, BOOL bLoop); +void FastImgDestroyAGIFFrameData(AGifFrameInfo* pFrameData); + +#ifdef __cplusplus +} +#endif + + +#endif /*_IFEG_DECODER_H_*/ diff --git a/src/include/codec/img-codec-agif.h b/src/include/codec/img-codec-agif.h new file mode 100644 index 0000000..4480bd8 --- /dev/null +++ b/src/include/codec/img-codec-agif.h @@ -0,0 +1,28 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IMGCODEC_AGIF_H_ +#define _IMGCODEC_AGIF_H_ + +#include "IfegDecodeAGIF.h" + +#endif /*_IMGCODEC_AGIF_H_*/ + diff --git a/src/include/codec/img-codec-common.h b/src/include/codec/img-codec-common.h new file mode 100644 index 0000000..4cb8922 --- /dev/null +++ b/src/include/codec/img-codec-common.h @@ -0,0 +1,304 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IMGCODEC_COMMON_H_ +#define _IMGCODEC_COMMON_H_ + +#include "img-codec-config.h" +#include "img-codec-osal.h" +#include <stdio.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +////////////////////////////////////////////////////////////// + +/* Maximum Image File Size Supported */ +#define IMG_MAX_IMAGE_FILE_SIZE (10 * 1024 * 1024) + +////////////////////////////////////////////////////////////// +#define ImgDebug(type, fmt, arg...) \ + do { \ + fprintf(stderr, "[Media-SVC]"fmt, ##arg); \ + }while(0) + +#if 1 +#define SysRequireEx(expr, retValue) \ + if (!(expr)) { \ + fprintf(stderr, "[Media-SVC][%s] INVALID_PARAM (%d lines in %s)\n",__FUNCTION__, __LINE__, __FILE__); \ + return (retValue); \ + } +#define SysDebug(X) ImgDebug X + +#define SysAssert(expr) +#else +#define SysRequireEx(expr, retValue) +#define SysDebug(expr, retValue) +#define SysAssert(expr) +#endif + +////////////////////////////////////////////////////////////// + + +typedef enum +{ + IMG_INFO_DECODING_FAIL = 0, + IMG_INFO_DECODING_SUCCESS = 1, + IMG_INFO_AGIF_LAST_FRAME = 2, + IMG_INFO_TOO_BIG_FILE_SIZE = -1, + IMG_INFO_TOO_LARGE_SCALE = -2, + IMG_INFO_TOO_BIG_PROGRESSIVE= -3, + IMG_INFO_UNKNOWN_FORMAT = -4, + IMG_INFO_FILE_ERR = -5, + IMG_INFO_MEM_ALLOC_FAIL = -6 +}ImgFastCodecInfo; + + + +typedef enum +{ + IMG_CODEC_UNKNOWN_TYPE = -2, + IMG_CODEC_BIG_PROGRESSIVE_JPEG = -1, + IMG_CODEC_NONE = 0, + IMG_CODEC_GIF = ( 1 << 0), + IMG_CODEC_PNG = ( 1 << 1), + IMG_CODEC_WBMP = ( 1 << 2), + IMG_CODEC_JPEG = ( 1 << 3), + IMG_CODEC_BMP = ( 1 << 4), + IMG_CODEC_TIF = ( 1 << 5), + IMG_CODEC_AGIF = ( 1 << 6), + IMG_CODEC_PROGRESSIVE_JPEG = ( 1 << 7), + IMG_CODEC_DRM = ( 1 << 8), +} ImgCodecType; + +typedef enum inputFlag +{ + IMG_RGB_888_OUTPUT = 0x0001, + IMG_RGB_OUTPUT = 0x0002, + IMG_YUV_OUTPUT = 0x0005 +}ImgInputFlag; + +typedef enum resize +{ + /* During resizing aspect ratio will be maintained */ + IMG_RESIZE_MAINTAIN_ASPECT_RATIO = 0x0001, + IMG_RESIZE = 0x0002 +} ImgResizeInput; + + +typedef struct tagImgImageInfo +{ + unsigned int width; + unsigned int height; + unsigned int numberOfFrame; + unsigned int delay; //deprecated. + unsigned int bOrientation; //deprecated. +}ImgImageInfo; + +typedef struct tagImgBitmap +{ + int width; + int height; + UCHAR bitsPerPixel; /* For TIF it should be 8 or 4 or 1 always + * If coming directly from camera and + * bitsperpixel is 16 then its assumed as 8 + * & color type as RGBC and compression + * type as NO_COMP and encode it. + */ + + void *pBits; + BOOL bChromaKeyFlag; /* Flag to indicate chroma key + * Default: FALSE + */ + ULONG chromaKey; /* This is the colour which needs to be (or is) transparent. + * This colour will be in 5, 5, 5 RGB format as below. + * First 16 MS Bits 0, R (5), G (5), 0 (1), B (5) + */ + UCHAR disposal; /* Disposal action to take during + * display of current flag + * Default: 0 + */ + USHORT delay; /* Delay before display of + * next frame. Default: 0 + */ + BOOL inputFlag; /* User input required befflag used + * Default: FALSE + */ + + BOOL interlace; /* Interlace indicator flag + * Default: FALSE + */ + BYTE *pLocalColorMap;/* Local color palette pointer + * Default: NULL + */ + /* For TIF :Should be given if PALETTE color type. + */ + USHORT localColorMapSize; + /* Local color palette size */ + /* In TIF: Should be given if PALETTE color type. + */ + void *pAlphaChannel; /* An alpha channel, representing transparency + * information on a per-pixel basis + */ + BYTE colorType ; /* Indicates the color type of image. It can be + * GRAY, COLOR, PALETTED, GRAY_WITH_ALPHA_CHANNEL or + * COLOR_WITH_ALPHA_CHANNEL + */ + /* For TIF: IT could be TIF_COLORTYPE_BILEVEL, + * TIF_COLORTYPE_GRAY ,TIF_COLORTYPE_RGB, + * TIF_COLORTYPE_PALETTE or + * TIF_COLORTYPE_RGBPALETTE. + */ + BYTE filter ; /* Type of filter to apply. Could be one of NONE, + * SUB, UP, AVERAGE or PAETH + */ + BYTE compressionMethod ; /* Type of compression in zLib to apply. Could be + * one of NONE, FIXED or DYANMIC + */ + /* For TIF : IT could be TIF_COMP_NOCOMP , + * TIF_COMP_PACKBIT or TIF_COMP_HUFFMAN (only for bilevel) + */ + + UCHAR colorConversion; /* Indicates whether color conversion has to + * be done or not + */ + /* For TIF :This represents white is zero or + * black is zero in case of bilevel & gray. + */ + UCHAR downSampling; /* Indicates whether down sampling needs to + * be done or not + */ + + UCHAR downSamplingMethod[3]; + /* Down sampling offsets for every component. Possible + * combinations are + * 1, 1, 1 + * 1, 2, 1 + * 1, 2, 2 + */ +} ImgBitmap; + +typedef struct tagImgCodecColor +{ + UINT16 red; + UINT16 green; + UINT16 blue; +} ImgCodecColor; + + +typedef struct +{ + int width, height, bpp; + + BOOL tRNSFlag; + ImgCodecColor tRNSColor; + + BOOL bKGDFlag; + ImgCodecColor bKGDColor; + + BOOL AlphaChannelFlag; + unsigned short *pAlphaChannel; +} ImgTrnsInfo; + +typedef struct tagImgBitmapElem ImgBitmapElem; + +struct tagImgBitmapElem +{ + int x; + int y; + ImgBitmap *pbmBitmap; + ImgBitmapElem *pNext; +}; + +typedef struct gifDecode ImgGIFFrame ; + +typedef struct tagImgImage +{ + int dataSize; /* Holds the total number of bytes required + * to hold the image + */ + int width; + int height; + + USHORT flag; /* This contains flags as defined + * in ImgCodecFlagType + */ + ULONG backGroundColor; /* The backgroundColor specifies a default background + * color to present the image against. + * Note that viewers are not bound to honor this color. + * A viewer can choose to use a different background. + */ + BYTE *pGlobalColorMap; /* Global color palette pointer + * Default: NULL + */ + USHORT globalColorMapSize; /* Local color palette size */ + ULONG gamma; /* The value is encoded as a 4-byte unsigned integer, + * representing gamma times 100000. For example, a + * gamma of 0.45 would be stored as the integer 45000. + */ + int bitmapCount; /* This will hold the number of bitmaps in the + * ImgImage structure + */ + BYTE function ; /* This will be set as TRUE if this structure is + * used for encoder + */ + + ImgBitmapElem *pHead; + ImgBitmapElem *pTail; + + + ULONG decodedSize ; /* 1 => Same as in the encoded stream + * 0 => Resize to QQVGA if size is more + * than 176 x 144 + */ + + BOOL memAllocEx ; /* TRUE => MemAllocEx is used, + * FALSE => MemAlloc is used + */ + + USHORT loopCount ; /* This will contain the number of times to repeat + * the animation + */ + BOOL bLoopCount ; /* If GIF LoopCount is present then this will be + * TRUE, otherwise it will be false + */ + + ImgGIFFrame *pGifFrame ; /* Stores the intermediate GIF Frame */ + + ImgInputFlag inputFlag; + ImgResizeInput resizeMethod ; + + /* Flag to identify whether image is AGIF or not */ + BOOL bAGIFImage ; + unsigned char *pEncodedData ; + INT32 cFileSize ; + BOOL bFirstFrame ; + BOOL bReservedMemoryFlag; + unsigned int offset ; +} ImgImage; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // _IMGCODEC_COMMON_H_ diff --git a/src/include/codec/img-codec-config.h b/src/include/codec/img-codec-config.h new file mode 100644 index 0000000..a918e16 --- /dev/null +++ b/src/include/codec/img-codec-config.h @@ -0,0 +1,26 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IMGCODEC_CONFIG_H_ +#define _IMGCODEC_CONFIG_H_ +#define INTERNAL_IMGCODEC + +#endif // _IMGCODEC_CONFIG_H_ diff --git a/src/include/codec/img-codec-osal.h b/src/include/codec/img-codec-osal.h new file mode 100644 index 0000000..67b6921 --- /dev/null +++ b/src/include/codec/img-codec-osal.h @@ -0,0 +1,129 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IMGCODEC_OSAL_H_ +#define _IMGCODEC_OSAL_H_ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef BOOL + +#define BOOL bool//unsigned short +#endif + +#ifndef UCHAR + +#define UCHAR unsigned char +#endif + +#ifndef BYTE + +#define BYTE unsigned char +#endif + +#ifndef USHORT + +#define USHORT unsigned short +#endif + +#ifndef UINT16 + +#define UINT16 unsigned short +#endif + +#ifndef UINT32 + +#define UINT32 unsigned short +#endif + +#ifndef UINT + +#define UINT unsigned int +#endif + +#ifndef INT32 + +#define INT32 unsigned int +#endif + +#ifndef ULONG + +#define ULONG unsigned long +#endif + +#ifndef TRUE +#define TRUE true +#endif + +#ifndef FALSE +#define FALSE false +#endif + +#ifndef INVALID_HOBJ +//#define INVALID_HOBJ (-1) +#define INVALID_HOBJ NULL +#endif + + +typedef void* HFile; + +#define AcMemalloc IfegMemAlloc +#define AcMemfree IfegMemFree +#define AcMemcmp IfegMemcmp +#define AcMemset IfegMemset +#define AcMemcpy IfegMemcpy + +typedef struct +{ + ULONG fileSize; // File size + ULONG* startAddr; // Only used at LFS + ULONG attribute; // file attribute like directory or file, hidden, readonly, system, ... + int iVol; // positioned volume + ULONG allocatedSize; // real allocated size of file & directory in sub System +} FmFileAttribute; + +void * IfegMemAlloc(unsigned int size); +void IfegMemFree(void* pMem); +void * IfegMemcpy( void *dest, const void *src, unsigned int count ); +void * IfegMemset( void *dest, int c, unsigned int count ); +int IfegMemcmp(const void* pMem1, const void* pMem2, size_t length); + +ULONG IfegGetAvailableMemSize(void); + +HFile DrmOpenFile(const char* szPathName); +BOOL DrmReadFile(HFile hFile, void* pBuffer, ULONG bufLen, ULONG* pReadLen); +long DrmTellFile(HFile hFile); +BOOL DrmSeekFile(HFile hFile, long position, long offset); +BOOL DrmGetFileAttributes(const char* szPathName, FmFileAttribute* pFileAttr); +BOOL DrmCloseFile(HFile hFile); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // _IMGCODEC_OSAL_H_ + + diff --git a/src/include/codec/img-codec-parser.h b/src/include/codec/img-codec-parser.h new file mode 100644 index 0000000..097f24d --- /dev/null +++ b/src/include/codec/img-codec-parser.h @@ -0,0 +1,48 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IMGCODEC_PARSER_H_ +#define _IMGCODEC_PARSER_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define MINIMUM_HEADER_BYTES 8 + +#define PNG_HEADER_LENGTH 8 +#define JPG_HEADER_LENGTH 2 +#define GIF_HEADER_LENGTH 3 +#define TIFF_HEADER_LENGTH 2 +#define BMP_HEADER_LENGTH 2 +#define TIFF_IMAGE_WIDTH 0x100 +#define TIFF_IMAGE_HEIGHT 0x101 + +ImgCodecType ImgGetInfo(unsigned char* pEncodedData, unsigned long fileSize, ImgImageInfo* imgInfo); +ImgCodecType ImgGetInfoFile(const char*filePath, ImgImageInfo *imgInfo); +ImgCodecType ImgGetInfoHFile(HFile hFile, unsigned long fileSize, ImgImageInfo* imgInfo); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/src/include/codec/img-codec.h b/src/include/codec/img-codec.h new file mode 100644 index 0000000..07f3a6b --- /dev/null +++ b/src/include/codec/img-codec.h @@ -0,0 +1,49 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _IMGCODEC_H_ +#define _IMGCODEC_H_ + +#include "img-codec-common.h" +#include "img-codec-parser.h" +#include "img-codec-agif.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +unsigned int* ImgGetFirstFrameAGIFAtSize(const char *szFileName, ImgImageInfo *image_info); + +int ImgConvertRGB565ToRGB888(void *pBuf_rgb565, void **pBuf_rgb888, int width, int height); + + +AGifFrameInfo* ImgCreateAGIFFrame(const char *szFileName, unsigned int width, unsigned int height, unsigned int bgColor, BOOL bLoop); + +void ImgDestroyAGIFFrame(AGifFrameInfo* pFrameData); + +ImgFastCodecInfo ImgGetNextAGIFFrame (AGifFrameInfo *gFrameData, BOOL bCenterAlign); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif // _IMGCODEC_H_ diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h new file mode 100755 index 0000000..f91925f --- /dev/null +++ b/src/include/ipc/media-thumb-ipc.h @@ -0,0 +1,125 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include "media-thumb-error.h" +#include "media-thumb-debug.h" +#include "media-thumb-types.h" +#include "media-thumb-internal.h" + +#ifdef _USE_MEDIA_UTIL_ +#include "media-util-ipc.h" +#include "media-server-ipc.h" +#endif + +#include <sys/socket.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <signal.h> + +#ifndef _MEDIA_THUMB_IPC_H_ +#define _MEDIA_THUMB_IPC_H_ + +#ifndef _USE_MEDIA_UTIL_ +#define THUMB_DAEMON_PORT 10000 +#endif +#define MAX_PATH_SIZE 4096 + +#ifndef _USE_MEDIA_UTIL_ +#define TIMEOUT_SEC 10 +#endif + +#define MAX_TRIES 3 + +enum { + THUMB_REQUEST_DB_INSERT, + THUMB_REQUEST_SAVE_FILE, + THUMB_REQUEST_ALL_MEDIA, + THUMB_REQUEST_CANCEL_MEDIA, + THUMB_REQUEST_CANCEL_ALL, + THUMB_REQUEST_KILL_SERVER, + THUMB_RESPONSE +}; + +enum { + THUMB_SUCCESS, + THUMB_FAIL +}; + +#ifndef _USE_MEDIA_UTIL_ +enum { + CLIENT_SOCKET, + SERVER_SOCKET +}; + +typedef struct _thumbMsg{ + int msg_type; + media_thumb_type thumb_type; + int status; + int pid; + int thumb_size; + int thumb_width; + int thumb_height; + int origin_width; + int origin_height; + int origin_path_size; + int dest_path_size; + char org_path[MAX_PATH_SIZE]; + char dst_path[MAX_PATH_SIZE]; +} thumbMsg; +#endif + +int +_media_thumb_create_socket(int sock_type, int *sock); + +int +_media_thumb_create_udp_socket(int *sock); + +int +_media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg); + +int +_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_in *from_addr, unsigned int *from_size); + +int +_media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size); + +int +_media_thumb_request(int msg_type, + media_thumb_type thumb_type, + const char *origin_path, + char *thumb_path, + int max_length, + media_thumb_info *thumb_info); + +int +_media_thumb_request_async(int msg_type, + media_thumb_type thumb_type, + const char *origin_path, + thumbUserData *userData); + +int +_media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg); + +#endif /*_MEDIA_THUMB_IPC_H_*/ diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h new file mode 100755 index 0000000..0180a29 --- /dev/null +++ b/src/include/media-thumb-internal.h @@ -0,0 +1,81 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include "media-thumbnail.h" +#include "media-thumb-error.h" +#include "media-thumb-types.h" +#include "media-thumb-debug.h" + +#ifndef _MEDIA_THUMB_INTERNAL_H_ +#define _MEDIA_THUMB_INTERNAL_H_ + +#define THUMB_WIDTH_MAX +/* The maximum of resolution to be able to get thumbnail is 3000 x 3000, except for only jpeg */ +#define THUMB_MAX_ALLOWED_MEM_FOR_THUMB 9000000 + +#define THUMB_LARGE_WIDTH 320 +#define THUMB_LARGE_HEIGHT 240 +#define THUMB_SMALL_WIDTH 160 +#define THUMB_SMALL_HEIGHT 120 + +typedef struct { + int size; + int width; + int height; + int origin_width; + int origin_height; + int alpha; + unsigned char *data; +} media_thumb_info; + +enum Exif_Orientation { + NOT_AVAILABLE=0, + NORMAL =1, + HFLIP =2, + ROT_180 =3, + VFLIP =4, + TRANSPOSE =5, + ROT_90 =6, + TRANSVERSE =7, + ROT_270 =8 +}; + +typedef struct { + ThumbFunc func; + void *user_data; +} thumbUserData; + +int +_media_thumb_image(const char *origin_path, + int thumb_width, + int thumb_height, + media_thumb_format format, + media_thumb_info *thumb_info); + +int +_media_thumb_video(const char *origin_path, + int thumb_width, + int thumb_height, + media_thumb_format format, + media_thumb_info *thumb_info); + +#endif /*_MEDIA_THUMB_INTERNAL_H_*/ diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h new file mode 100755 index 0000000..f8e37f9 --- /dev/null +++ b/src/include/util/media-thumb-db.h @@ -0,0 +1,79 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <sqlite3.h> +#include <media-util.h> +#include "media-thumb-error.h" +#include "media-thumb-types.h" +#include "media-thumb-debug.h" + +#ifndef _MEDIA_THUMB_DB_H_ +#define _MEDIA_THUMB_DB_H_ + +#define MEDIA_DATABASE_NAME MEDIA_DB_NAME /* defined in media-util.h */ + +#ifndef _USE_NEW_MEDIA_DB_ +#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from visual_media where thumbnail_path='' and valid=1;" +#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM visual_media WHERE path='%q';" +#define SELECT_TYPE_BY_PATH "SELECT content_type FROM visual_media WHERE path='%q';" +#define UPDATE_THUMB_BY_PATH "UPDATE visual_media SET thumbnail_path = '%q' WHERE path='%q';" +#define UPDATE_WH_BY_PATH "UPDATE image_meta SET width=%d,height=%d WHERE visual_uuid=(SELECT visual_uuid FROM visual_media WHERE path='%q');" + +#else +#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1);" +#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM media WHERE path='%q';" +#define SELECT_TYPE_BY_PATH "SELECT media_type FROM media WHERE path='%q';" +#define SELECT_WH_BY_PATH "SELECT width, height FROM media WHERE path='%q';" +#define UPDATE_THUMB_BY_PATH "UPDATE media SET thumbnail_path = '%q' WHERE path='%q';" +#define UPDATE_WH_BY_PATH "UPDATE media SET width=%d,height=%d WHERE path='%q';" +#define UPDATE_THUMB_WH_BY_PATH "UPDATE media SET thumbnail_path = '%q', width=%d,height=%d WHERE path='%q';" +#endif + +sqlite3 *_media_thumb_db_get_handle(); + +int +_media_thumb_db_connect(); + +int +_media_thumb_db_disconnect(); + +int +_media_thumb_get_thumb_from_db(const char *origin_path, + char *thumb_path, + int max_length, + int *need_update_db); + +int +_media_thumb_get_thumb_from_db_with_size(const char *origin_path, + char *thumb_path, + int max_length, + int *need_update_db, + int *width, + int *height); + +int +_media_thumb_update_db(const char *origin_path, + char *thumb_path, + int width, + int height); + +#endif /*_MEDIA_THUMB_DB_H_*/ + diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h new file mode 100755 index 0000000..65ca53f --- /dev/null +++ b/src/include/util/media-thumb-debug.h @@ -0,0 +1,81 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _MEDIA_THUMB_DEBUG_H_ +#define _MEDIA_THUMB_DEBUG_H_ + +#include <stdio.h> +#include <stdlib.h> +#include <dlog.h> + +#include <unistd.h> +#include <asm/unistd.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + + +#define _PERFORMANCE_CHECK_ + + +#define LOG_TAG "MEDIA_THUMBNAIL" + +static pid_t gettid(void) +{ + return syscall(__NR_gettid); +} + +#define FONT_COLOR_RESET "\033[0m" +#define FONT_COLOR_RED "\033[31m" +#define FONT_COLOR_GREEN "\033[32m" +#define FONT_COLOR_YELLOW "\033[33m" +#define FONT_COLOR_BLUE "\033[34m" +#define FONT_COLOR_PURPLE "\033[35m" +#define FONT_COLOR_CYAN "\033[36m" +#define FONT_COLOR_GRAY "\033[37m" + +#define thumb_dbg(fmt, arg...) LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg) +#define thumb_warn(fmt, arg...) LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg) +#define thumb_err(fmt, arg...) LOGE(FONT_COLOR_RED"[%d] " fmt "\n", gettid(), ##arg) + +#ifdef _USE_LOG_FILE_ +void thumb_init_file_debug(); +void thumb_close_file_debug(); +FILE* get_fp(); +#define thumb_file_dbg(fmt,arg...) fprintf( get_fp(), "[%s: %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg) + +#endif + + +#ifdef _PERFORMANCE_CHECK_ +long +thumb_get_debug_time(void); +void +thumb_reset_debug_time(void); +void +thumb_print_debug_time(char* time_string); +void +thumb_print_debug_time_ex(long start, long end, const char* func_name, char* time_string); +#endif + +#endif /*_MEDIA_THUMB_DEBUG_H_*/ + diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h new file mode 100755 index 0000000..335c4a5 --- /dev/null +++ b/src/include/util/media-thumb-util.h @@ -0,0 +1,146 @@ +/* + * libmedia-thumbnail + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hyunjun Ko <zzoon.ko@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "media-thumb-error.h" +#include "media-thumb-types.h" +#include "media-thumb-debug.h" +#include "media-util.h" + +#ifndef _MEDIA_THUMB_UTIL_H_ +#define _MEDIA_THUMB_UTIL_H_ + +#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} + +#ifndef _USE_NEW_MEDIA_DB_ +#define THUMB_NONE_TYPE 0x00000000 /* None */ +#define THUMB_IMAGE_TYPE 0x00000001 /* Image */ +#define THUMB_VIDEO_TYPE 0x00000002 /* Video */ +#else +#define THUMB_NONE_TYPE -1 /* None */ +#define THUMB_IMAGE_TYPE 0 /* Image */ +#define THUMB_VIDEO_TYPE 1 /* Video */ +#endif + +#define THUMB_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */ +#define THUMB_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */ + +#define THUMB_PHONE_PATH MEDIA_DATA_PATH"/.thumb/phone" +#define THUMB_MMC_PATH MEDIA_DATA_PATH"/.thumb/mmc" + +#define THUMB_DEFAULT_PATH MEDIA_DATA_PATH"/.thumb/thumb_default.png" + +typedef enum +{ + THUMB_PHONE, /**< Stored only in phone */ + THUMB_MMC /**< Stored only in MMC */ +} media_thumb_store_type; + +int _media_thumb_get_length(media_thumb_type thumb_type); + +int _media_thumb_get_store_type_by_path(const char *full_path); + +int +_media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len); + +int +_media_thumb_get_file_type(const char *file_full_path); + +int +_media_thumb_remove_file(const char *path); + +char +*_media_thumb_generate_hash_name(const char *file); + +int +_media_thumb_get_hash_name(const char *file_full_path, + char *thumb_hash_path, size_t max_thumb_path); + +int +_media_thumb_save_to_file_with_evas(unsigned char *data, + int w, + int h, + int alpha, + char *thumb_path); + +int +_media_thumb_get_width(media_thumb_type thumb_type); + +int +_media_thumb_get_height(media_thumb_type thumb_type); + +/** + * _thumbnail_get_data: + * This function generates thumbnail raw data, which is wanted by user + * This api is closed for a while until being independent from evas object to be thread-safe + * + * @return This function returns zero(MEDIA_THUMB_ERROR_NONE) on success, or negative value with error code. + * Please refer 'media-thumb-error.h' to know the exact meaning of the error. + * @param[in] origin_path The path of the original image + * @param[in] thumb_type The type of the returned thumbnail data + * @param[in] format The format of the returned data + * @param[out] data The data of generated thumbnail. + * @param[out] size The size of generated thumbnail. + * @param[out] width The width of generated thumbnail. + * @param[out] height The height of generated thumbnail. + * @param[out] origin_width The width of original image. + * @param[out] origin_height The height of original image. + * @see None. + * @pre None. + * @post None. + * @remark None. + * @par example + * @code + +#include <media-thumbnail.h> + +void test_get_thumb_data() +{ + int ret = MEDIA_THUMB_ERROR_NONE; + int thumb_type = 0; + const char *origin_path = "/opt/usr/media/test.jpg"; + void *data = NULL; + + + ret = _thumbnail_get_data(origin_path, thumb_type, thumb_path, &data); + + if (ret < 0) + { + printf( "_thumbnail_get_data fails. error code->%d", ret); + } + + return; +} + + * @endcode +*/ +int _thumbnail_get_data(const char *origin_path, + media_thumb_type thumb_type, + media_thumb_format format, + unsigned char **data, + int *size, + int *width, + int *height, + int *origin_width, + int *origin_height, + int *alpha); + +#endif /*_MEDIA_THUMB_UTIL_H_*/ + |