Thumbnail-server code refactoring 98/168798/6
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 31 Jan 2018 04:22:50 +0000 (13:22 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Wed, 31 Jan 2018 06:11:14 +0000 (06:11 +0000)
Remove the code related with agif
Refactoring functions for getting media type and original w/h
Remove unused dependency

Change-Id: I08162ecfd41e1e3dd25833bf625d3206639d1e32
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
20 files changed:
CMakeLists.txt
packaging/libmedia-thumbnail.spec
server/thumb-server-internal.c
server/thumb-server.c
src/codec/IfegDecodeAGIF.c [deleted file]
src/codec/img-codec-osal.c [deleted file]
src/codec/img-codec-parser.c
src/codec/img-codec.c [deleted file]
src/include/codec/AGifFrameInfo.h [deleted file]
src/include/codec/IfegDecodeAGIF.h [deleted file]
src/include/codec/img-codec-agif.h [deleted file]
src/include/codec/img-codec-common.h [deleted file]
src/include/codec/img-codec-config.h [deleted file]
src/include/codec/img-codec-osal.h [deleted file]
src/include/codec/img-codec-parser.h
src/include/codec/img-codec.h [deleted file]
src/include/util/media-thumb-debug.h
src/include/util/media-thumb-util.h
src/media-thumb-internal.c
src/media-thumbnail.c

index 3966844..43af632 100755 (executable)
@@ -9,9 +9,6 @@ SET(SRCS
        src/media-thumbnail.c
        src/util/media-thumb-util.c
        src/ipc/media-thumb-ipc.c
-       src/codec/IfegDecodeAGIF.c
-       src/codec/img-codec.c
-       src/codec/img-codec-osal.c
        src/codec/img-codec-parser.c
        )
 SET(HASH_SRCS
@@ -38,7 +35,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/codec ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/ipc ${CMAKE_SOURCE_DIR}/server/include ${CMAKE_SOURCE_DIR}/md5)
 
 INCLUDE(FindPkgConfig)
-       pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 mm-fileinfo aul capi-media-image-util libmedia-utils libtzplatform-config db-util mmutil-magick)
+       pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 mm-fileinfo aul libmedia-utils libtzplatform-config db-util mmutil-magick)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index a6e1691..6e2b021 100644 (file)
@@ -13,7 +13,6 @@ Requires: media-server
 BuildRequires: cmake
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(mm-fileinfo)
-BuildRequires: pkgconfig(capi-media-image-util)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(libmedia-utils)
 BuildRequires: pkgconfig(libtzplatform-config)
index 22a0ff8..a4b1142 100755 (executable)
@@ -331,7 +331,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
        thumb_path = res_msg->dst_path;
        res_msg->status = MS_MEDIA_ERR_NONE;
 
-       if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+       if (!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR)) {
                thumb_err("origin_path does not exist in file system.");
                res_msg->status = MS_MEDIA_ERR_FILE_NOT_EXIST;
                return MS_MEDIA_ERR_FILE_NOT_EXIST;
index 4a24e0a..4bb521f 100755 (executable)
@@ -68,13 +68,10 @@ int main(void)
        g_source_set_callback(source_evas_init, _thumb_daemon_start_jobs, NULL, NULL);
        g_source_attach(source_evas_init, context);
 
-       thumb_dbg("************************************");
-       thumb_dbg("*** Thumbnail server is running ***");
-       thumb_dbg("************************************");
-
+       thumb_info("Thumbnail server is running");
        g_main_loop_run(g_thumb_server_mainloop);
 
-       thumb_dbg("Thumbnail server is shutting down...");
+       thumb_info("Thumbnail server is shutting down");
        g_io_channel_shutdown(channel,  FALSE, NULL);
        g_io_channel_unref(channel);
        /*close socket*/
diff --git a/src/codec/IfegDecodeAGIF.c b/src/codec/IfegDecodeAGIF.c
deleted file mode 100755 (executable)
index 34e6326..0000000
+++ /dev/null
@@ -1,4198 +0,0 @@
-/*
- * 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-debug.h"
-#include "img-codec-common.h"
-#include "IfegDecodeAGIF.h"
-
-
-
-#define MAX_CODES      4096
-
-int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAlign);
-int __FastImgGetNextFrameAGIF_UseBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAlign);
-
-int image_left_pos_N = 0;      /* left position of image in Logical screeen */
-int image_top_pos_N = 0;
-
-AGifFrameInfo *FastImgCreateAGIFFrameData(unsigned int width, unsigned int height, unsigned char *pEncodedData, unsigned int file_size, unsigned int ui_backcolor, BOOL bLoop)
-{
-       unsigned int header_temp;
-       int backcolor_index;
-       unsigned int image_backcolor;
-       unsigned int backcolor_parsing;
-       int transparent = 0;
-       int transIndex = 0;
-       int inputPos = 0;
-
-       AGifFrameInfo *pFrameData;
-       if (0 == (pFrameData = IfegMemAlloc(sizeof(AGifFrameInfo)))) {
-               return 0;
-       }
-
-       IfegMemset(pFrameData, 0, sizeof(AGifFrameInfo));
-
-       inputPos += 13;
-
-       pFrameData->logi_wdt = pEncodedData[6] | (pEncodedData[7]<<8);
-       pFrameData->logi_hgt = pEncodedData[8] | (pEncodedData[9]<<8);
-#ifdef INTERNAL_IMGCODEC
-       thumb_dbg("logi_wdt:%d, logi_hgt:%d", pFrameData->logi_wdt, pFrameData->logi_hgt);
-#else
-       thumb_dbg("logi_wdt:%d, logi_hgt:%d", pFrameData->logi_wdt, pFrameData->logi_hgt);
-       if ((pFrameData->logi_wdt > MAXWIDTH) || (pFrameData->logi_hgt > MAXHEIGHT)) {
-               if (pFrameData) {
-                               IfegMemFree(pFrameData);
-                               pFrameData = 0;
-               }
-               return 0;
-       }
-#endif
-
-       /* save nReapeatCount assigned by content */
-
-       if ((pEncodedData[10]&0x80) == 0x80) {
-               header_temp = 3 * (1<<((pEncodedData[10] & 0x07) + 1));
-       } else {
-               header_temp = 0;
-       }
-
-       if (file_size > 30+header_temp && pEncodedData[14+header_temp] == 0xFF) {
-               pFrameData->nLoopCount = pEncodedData[30+header_temp]<<8 | pEncodedData[29+header_temp];
-       } else if (file_size > 30+8+header_temp && pEncodedData[14+8+header_temp] == 0xFF) {
-               pFrameData->nLoopCount = pEncodedData[30+8+header_temp]<<8 | pEncodedData[29+8+header_temp];
-       } else {
-               pFrameData->nLoopCount = -1;
-       }
-
-       pFrameData->nRepeatCount = 0;
-
-       thumb_dbg("10st data : 0x%x , global color table num : %d", pEncodedData[10], header_temp);
-       thumb_dbg("13: 0x%x ,14: 0x%x, 15: 0x%x, nRepeatCount : %d, nLoopCount : %d", pEncodedData[13+header_temp], pEncodedData[14+header_temp], pEncodedData[15+header_temp], pFrameData->nRepeatCount, pFrameData->nLoopCount);
-
-       backcolor_index = pEncodedData[11];
-
-       if (pEncodedData[14+header_temp] == 0xF9) {
-               transparent = pEncodedData[16+header_temp] & 0x01;
-               transIndex = pEncodedData[19+header_temp];
-
-               backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
-       } else if (pEncodedData[14+19+header_temp] == 0xF9) {
-               transparent = pEncodedData[35+header_temp] & 0x01;
-               transIndex = pEncodedData[38+header_temp];
-
-               backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
-       } else if ((pEncodedData[10]&0x80) != 0x80) { /* global color table */
-               backcolor_parsing = ui_backcolor;
-       } else {
-               backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
-       }
-
-       /* graphic extension block */
-       if (pEncodedData[14+header_temp] == 0xF9 || pEncodedData[14+19+header_temp] == 0xF9) {
-
-               if (transparent == 1 && backcolor_index == transIndex) {
-                       image_backcolor = ui_backcolor;
-               } else {
-                       image_backcolor = backcolor_parsing;
-               }
-       } else {
-               image_backcolor = backcolor_parsing;
-       }
-
-#if MODE == 0
-       if (0 == (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned char)*width*height*2))) {
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-       pFrameData->useBuffer = 0;
-#endif
-
-#if MODE == 1
-       if (0 == (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned int)*pFrameData->logi_wdt*pFrameData->logi_hgt))) {
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-       pFrameData->useBuffer = 1;
-#endif
-
-
-#if MODE == 2
-       if (((pFrameData->logi_wdt <= width) && (pFrameData->logi_hgt <= height))) {
-               if (0 == (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned char)*width*height*2))) {
-                       if (pFrameData) {
-                               IfegMemFree(pFrameData);
-                               pFrameData = 0;
-                       }
-                       return 0;
-               }
-               pFrameData->useBuffer = 0;
-       } else {
-               if (0 == (pFrameData->pPrevImg = IfegMemAlloc(sizeof(unsigned int)*pFrameData->logi_wdt*pFrameData->logi_hgt))) {
-                       if (pFrameData) {
-                               IfegMemFree(pFrameData);
-                               pFrameData = 0;
-                       }
-                       return 0;
-               }
-               pFrameData->useBuffer = 1;
-       }
-#endif
-
-       if (0 == (pFrameData->pOutBits = IfegMemAlloc(sizeof(unsigned char)*width*height*2))) {
-               if (pFrameData->pPrevImg) {
-                       IfegMemFree(pFrameData->pPrevImg);
-                       pFrameData->pPrevImg = 0;
-               }
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-
-       pFrameData->inputSize = file_size;
-       pFrameData->pEncodedData = pEncodedData;
-
-       if (0 == (pFrameData->pGlobal_table = IfegMemAlloc(sizeof(unsigned int)*256))) {
-               if (pFrameData->pPrevImg) {
-                       IfegMemFree(pFrameData->pPrevImg);
-                       pFrameData->pPrevImg = 0;
-               }
-
-               if (pFrameData->pOutBits) {
-                       IfegMemFree(pFrameData->pOutBits);
-                       pFrameData->pOutBits = 0;
-               }
-
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-
-       if (0 == (pFrameData->pPrefix = IfegMemAlloc(sizeof(unsigned short)*4097))) {
-               if (pFrameData->pPrevImg) {
-                       IfegMemFree(pFrameData->pPrevImg);
-                       pFrameData->pPrevImg = 0;
-               }
-               if (pFrameData->pOutBits) {
-                       IfegMemFree(pFrameData->pOutBits);
-                       pFrameData->pOutBits = 0;
-               }
-               if (pFrameData->pGlobal_table) {
-                       IfegMemFree(pFrameData->pGlobal_table);
-                       pFrameData->pGlobal_table = 0;
-               }
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-
-       if (0 == (pFrameData->pDstack = IfegMemAlloc(sizeof(unsigned char)*4097))) {
-               if (pFrameData->pPrevImg) {
-                       IfegMemFree(pFrameData->pPrevImg);
-                       pFrameData->pPrevImg = 0;
-               }
-               if (pFrameData->pOutBits) {
-                       IfegMemFree(pFrameData->pOutBits);
-                       pFrameData->pOutBits = 0;
-               }
-               if (pFrameData->pGlobal_table) {
-                       IfegMemFree(pFrameData->pGlobal_table);
-                       pFrameData->pGlobal_table = 0;
-               }
-               if (pFrameData->pPrefix) {
-                       IfegMemFree(pFrameData->pPrefix);
-                       pFrameData->pPrefix = 0;
-               }
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-
-       if (0 == (pFrameData->pSuffix = IfegMemAlloc(sizeof(unsigned char)*4097))) {
-               if (pFrameData->pPrevImg) {
-                       IfegMemFree(pFrameData->pPrevImg);
-                       pFrameData->pPrevImg = 0;
-               }
-               if (pFrameData->pOutBits) {
-                       IfegMemFree(pFrameData->pOutBits);
-                       pFrameData->pOutBits = 0;
-               }
-               if (pFrameData->pGlobal_table) {
-                       IfegMemFree(pFrameData->pGlobal_table);
-                       pFrameData->pGlobal_table = 0;
-               }
-               if (pFrameData->pPrefix) {
-                       IfegMemFree(pFrameData->pPrefix);
-                       pFrameData->pPrefix = 0;
-               }
-               if (pFrameData->pDstack) {
-                       IfegMemFree(pFrameData->pDstack);
-                       pFrameData->pDstack = 0;
-               }
-               if (pFrameData) {
-                       IfegMemFree(pFrameData);
-                       pFrameData = 0;
-               }
-               return 0;
-       }
-
-       pFrameData->width = width;
-       pFrameData->height = height;
-       pFrameData->imgCount = -1;
-       pFrameData->offset = 0;
-       pFrameData->backcolor = image_backcolor;
-       pFrameData->ui_backcolor = ui_backcolor;
-       pFrameData->delay = 10;
-       pFrameData->bLoop = bLoop;
-       return pFrameData;
-}
-
-void FastImgDestroyAGIFFrameData(AGifFrameInfo *pFrameData)
-{
-       if (pFrameData == NULL) {
-               return;
-       }
-
-       if (pFrameData->pPrevImg) {
-               IfegMemFree(pFrameData->pPrevImg);
-               pFrameData->pPrevImg = 0;
-       }
-
-       if (pFrameData->pEncodedData) {
-               IfegMemFree(pFrameData->pEncodedData);
-               pFrameData->pEncodedData = 0;
-       }
-       if (pFrameData->pOutBits) {
-               IfegMemFree(pFrameData->pOutBits);
-               pFrameData->pOutBits = 0;
-       }
-
-       if (pFrameData->pGlobal_table) {
-               IfegMemFree(pFrameData->pGlobal_table);
-               pFrameData->pGlobal_table = 0;
-       }
-
-       if (pFrameData->pPrefix) {
-               IfegMemFree(pFrameData->pPrefix);
-               pFrameData->pPrefix = 0;
-       }
-
-       if (pFrameData->pDstack) {
-               IfegMemFree(pFrameData->pDstack);
-               pFrameData->pDstack = 0;
-       }
-
-       if (pFrameData->pSuffix) {
-               IfegMemFree(pFrameData->pSuffix);
-               pFrameData->pSuffix = 0;
-       }
-
-       if (pFrameData) {
-               IfegMemFree(pFrameData);
-               pFrameData = 0;
-       }
-}
-
-/* macro */
-#define __get_next_code_first_nbits_left_0(pInputStream) \
-{\
-       {\
-               if (navail_bytes == 0) {\
-                       navail_bytes = (pInputStream)[inputPos++];\
-                       if ((inputPos + navail_bytes) > filesize) {\
-                               if (decoderline) {\
-                                       IfegMemFree(decoderline);\
-                                       decoderline = 0;\
-                               } \
-                               if (pDecBuf) {\
-                                       IfegMemFree(pDecBuf);\
-                                       pDecBuf = 0;\
-                               } \
-                               return -1;\
-                       } \
-               } \
-               b1 = (pInputStream)[inputPos++];\
-               ret = b1;\
-               nbits_left = 8;\
-               --navail_bytes;\
-       } \
-}
-
-#define __get_next_code_first_nbits_left_0_nobuffer(pInputStream) \
-{\
-       {\
-               if (navail_bytes == 0) {\
-                       navail_bytes = (pInputStream)[inputPos++];\
-                       if ((inputPos + navail_bytes) > filesize) {\
-                               if (decoderline) {\
-                                       IfegMemFree(decoderline);\
-                                       decoderline = 0;\
-                               } \
-                               if (pDecBuf) {\
-                                       IfegMemFree(pDecBuf);\
-                                       pDecBuf = 0;\
-                               } \
-                               if (done_prefix) {\
-                                       IfegMemFree(done_prefix);\
-                                       done_prefix = 0;\
-                               } \
-                               return -1;\
-                       } \
-               } \
-               b1 = (pInputStream)[inputPos++];\
-               ret = b1;\
-               nbits_left = 8;\
-               --navail_bytes;\
-       } \
-}
-
-#define __get_next_code_first_nbits_left_not_0(pInputStream) \
-{\
-       {\
-               ret = b1 >> (8 - nbits_left); \
-       } \
-}
-
-#define __get_next_code_first_while(pInputStream) \
-{\
-       while (curr_size > nbits_left) {\
-               if (navail_bytes == 0) {\
-                       navail_bytes = (pInputStream)[inputPos++];\
-                       if ((inputPos + navail_bytes) > filesize) {\
-                               if (decoderline) {\
-                                       IfegMemFree(decoderline);\
-                                       decoderline = 0;\
-                               } \
-                               if (pDecBuf) {\
-                                       IfegMemFree(pDecBuf);\
-                                       pDecBuf = 0;\
-                               } \
-                               return -1;\
-                       } \
-               } \
-               b1 = (pInputStream)[inputPos++];\
-               ret |= b1 << nbits_left;\
-               nbits_left += 8;\
-               --navail_bytes;\
-       } \
-       nbits_left -= curr_size;\
-       ret &= (1<<curr_size)-1;\
-       c = ret;\
-}
-
-#define __get_next_code_first_while_nobuffer(pInputStream) \
-{\
-       while (curr_size > nbits_left) {\
-               if (navail_bytes == 0) {\
-                       navail_bytes = (pInputStream)[inputPos++];\
-                       if ((inputPos + navail_bytes) > filesize) {\
-                               if (decoderline) {\
-                                       IfegMemFree(decoderline);\
-                                       decoderline = 0;\
-                               } \
-                               if (pDecBuf) {\
-                                       IfegMemFree(pDecBuf);\
-                                       pDecBuf = 0;\
-                               } \
-                               if (done_prefix) {\
-                                       IfegMemFree(done_prefix);\
-                                       done_prefix = 0;\
-                               } \
-                               return -1;\
-                       } \
-               } \
-               b1 = (pInputStream)[inputPos++];\
-               ret |= b1 << nbits_left;\
-               nbits_left += 8;\
-               --navail_bytes;\
-       } \
-       nbits_left -= curr_size;\
-       ret &= (1<<curr_size)-1;\
-       c = ret;\
-}
-
-#define __get_next_code_second_nbits_left_0(pInputStream) \
-{\
-       {\
-               b1 = (pInputStream)[inputPos++];\
-               ret = b1;\
-               nbits_left = 8;\
-               --navail_bytes;\
-       } \
-}
-
-#define __get_next_code_second_nbits_left_not_0(pInputStream) \
-{\
-       {\
-               ret = b1 >> (8 - nbits_left);\
-       } \
-}
-
-#define __get_next_code_second_while(pInputStream) \
-{\
-       while (curr_size > nbits_left) {\
-               b1 = (pInputStream)[inputPos++];\
-               ret |= b1 << nbits_left;\
-               nbits_left += 8;\
-               --navail_bytes;\
-       } \
-       nbits_left -= curr_size;\
-       ret &= (1 << curr_size)-1;\
-       c = ret;\
-}
-
-int FastImgGetNextFrameAGIF(AGifFrameInfo *pFrameData, BOOL bCenterAlign)
-{
-       if (pFrameData->useBuffer) {
-               return __FastImgGetNextFrameAGIF_UseBuffer(pFrameData, bCenterAlign);
-       } else {
-               return __FastImgGetNextFrameAGIF_NoBuffer(pFrameData, bCenterAlign);
-       }
-}
-
-int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAlign)
-{
-       unsigned int *pImage32, *pImage32_2;
-       unsigned short *pImage16;
-       unsigned char *sp;
-       unsigned char *bufptr;
-       unsigned int code, fc, oc, bufcnt;
-       unsigned char buffer[16];
-       unsigned char val1;
-       unsigned char *buf;
-       unsigned int *pDacbox;
-       unsigned char *decoderline = 0;
-       unsigned int size;
-
-       unsigned int c = 0;
-       unsigned int clear;
-       unsigned int ending;
-       unsigned int newcodes;
-       unsigned int top_slot;
-       unsigned int slot;
-
-       int     numcolors;
-       int     i, j, k;
-       int     rowcount;
-       int orgwdt_1, orgwdt, orghgt;
-       int decwdt, dechgt;
-       int len;
-       int inter_step, interLaced;
-       int transparent = 0;
-       int startloc = 0;
-       int transIndex = 0;
-       int spCount = 0;
-       int logi_wdt;           /* logical screen width */
-       int logi_hgt;
-       int image_backcolor;
-       int ui_backcolor;
-       int backcolor;
-       int image_left_pos;     /* left position of image in Logical screeen */
-       int image_top_pos;
-       int disposal_method = 0;
-       int margin_wdt1_2, margin_hgt1_2;
-       int inputPos;
-
-       unsigned int dacbox[256];
-
-       /* Variable for Resize */
-       unsigned int a_x, a_y;
-       unsigned int b_x, b_y;
-       unsigned int c_x, c_y;
-       unsigned int d_x, d_y;
-       int out_x = 0, out_y = 0;
-       int d1, d2;
-       int flag = 0;
-       unsigned int end;
-
-       unsigned char *pDecBuf = 0;
-
-       int expected_width = pFrameData->width;
-       int expected_height = pFrameData->height;
-       int resized_width;
-       int resized_height;
-
-       /* macro */
-       register unsigned int curr_size;
-       register int navail_bytes = 0;
-       register unsigned int nbits_left = 0;
-       register unsigned int b1 = 0;
-       register unsigned int ret;
-
-       /* parameter */
-       int filesize = pFrameData->inputSize;
-       unsigned int *global_dacbox = pFrameData->pGlobal_table;
-       register unsigned char *pInputStream = pFrameData->pEncodedData;
-       void *pOutBits = pFrameData->pOutBits;
-       unsigned short *prefix = pFrameData->pPrefix;
-       unsigned char *dstack = pFrameData->pDstack;
-       unsigned char *suffix = pFrameData->pSuffix;
-       unsigned char *done_prefix = 0;
-
-       inputPos = pFrameData->offset;
-
-       done_prefix = IfegMemAlloc(sizeof(unsigned char)*(MAX_CODES+1));
-       if (done_prefix == 0) {
-               thumb_err("Failed to allocate memory for check buffer.");
-               return -1;
-       }
-       IfegMemset(prefix, 0, sizeof(unsigned short)*(MAX_CODES+1));
-       IfegMemset(dstack, 0, sizeof(unsigned char)*(MAX_CODES+1));
-       IfegMemset(suffix, 0, sizeof(unsigned char)*(MAX_CODES+1));
-
-       image_backcolor = pFrameData->backcolor;
-       ui_backcolor = pFrameData->ui_backcolor;
-
-       backcolor = image_backcolor;
-
-       if (pFrameData->imgCount == -1) {
-               /* Input stream index set to 0 */
-               inputPos = 0;
-               inter_step = 1;
-               interLaced = 0;
-               transparent = 0;
-
-               /* read a GIF HEADER */
-               IfegMemcpy(buffer, pInputStream, 13);
-               inputPos += 13;
-
-               /* wheather GIF file or not */
-               if (buffer[0] != 'G' || buffer[1] != 'I' || buffer[2] != 'F' ||
-                       buffer[3] < '0' || buffer[3] > '9' ||
-                       buffer[4] < '0' || buffer[4] > '9' ||
-                       buffer[5] < 'A' || buffer[5] > 'z') {
-                       if (decoderline != 0) {
-                               IfegMemFree(decoderline);
-                               decoderline = 0;
-                       }
-                       if (pDecBuf != 0) {
-                               IfegMemFree(pDecBuf);
-                               pDecBuf = 0;
-                       }
-                       IfegMemFree(done_prefix);
-                       done_prefix = 0;
-                       return -1;
-               }
-
-               /* Regard the width/height of image block as the size of thumbnails. */
-               pFrameData->logi_wdt = logi_wdt = expected_width;
-               pFrameData->logi_hgt = logi_hgt = expected_height;
-
-               /* ouput resized image size */
-               if (logi_wdt <= expected_width && logi_hgt <= expected_height) {
-                       resized_width = logi_wdt;
-                       resized_height = logi_hgt;
-                       pFrameData->flag = flag = 1;
-               } else {
-                       if ((logi_wdt/(float)expected_width) >= (logi_hgt/(float)expected_height)) {
-                               resized_height = logi_hgt * expected_width / logi_wdt;
-                               resized_width = expected_width;
-                       } else {
-                               resized_width = logi_wdt * expected_height / logi_hgt;
-                               resized_height = expected_height;
-                       }
-               }
-               if (!resized_width || !resized_height) {
-                       if (pDecBuf != 0) {
-                               IfegMemFree(pDecBuf);
-                               pDecBuf = 0;
-                       }
-                       IfegMemFree(done_prefix);
-                       done_prefix = 0;
-                       return 0;
-               }
-
-               /* ouput resized image size */
-               pFrameData->resizedwidth = resized_width;
-               pFrameData->resizedheight = resized_height;
-
-               /* Color Resolution */
-               IfegMemset(global_dacbox, 0, 1024);
-               numcolors = (buffer[10] & 0x7) + 1;
-               if ((buffer[10] & 0x80) == 0) { /* Global color table */
-                       global_dacbox[0] = 0x000000;
-                       global_dacbox[1] = 0x3f3f3f;
-                       numcolors = 2;
-               } else { /* Global color table */
-                       numcolors = 1 << numcolors;
-
-                       /* Make color table */
-                       for (i = 0 ; i < numcolors; i++) {
-                               global_dacbox[i] = ((pInputStream[inputPos++] >> 2)<<16);
-                               global_dacbox[i] |= ((pInputStream[inputPos++] >> 2)<<8);
-                               global_dacbox[i] |= (pInputStream[inputPos++] >> 2);
-                       }
-               }
-
-               /* Background Color */
-               pImage16 = (unsigned short *)pFrameData->pPrevImg;
-               for (i = 0; i < expected_width * expected_height; i++) {
-                       *pImage16++ = ui_backcolor;
-               }
-
-               if (numcolors > 16) {
-                       numcolors = 256;
-               }
-               if (numcolors > 2 && numcolors < 16) {
-                       numcolors = 16;
-               }
-
-               pFrameData->global_numcol = numcolors;
-               pFrameData->imgCount++;
-               pFrameData->firstpos = inputPos;
-       } else {
-
-               logi_wdt = pFrameData->logi_wdt;
-               logi_hgt = pFrameData->logi_hgt;
-               resized_width = pFrameData->resizedwidth;
-               resized_height = pFrameData->resizedheight;
-
-               flag = pFrameData->flag ;
-
-               numcolors = pFrameData->global_numcol;
-       }
-
-
-       while (1) {
-               if (inputPos > filesize) {
-                       if (decoderline) {
-                               IfegMemFree(decoderline);
-                               decoderline = 0;
-                       }
-                       if (pDecBuf) {
-                               IfegMemFree(pDecBuf);
-                               pDecBuf = 0;
-                       }
-                       pFrameData->imgCount = 0;
-                       pFrameData->offset = pFrameData->firstpos;
-
-                       if (pFrameData->bLoop) {
-                               /* Background Color */
-                               pImage16 = (unsigned short *)pFrameData->pPrevImg;
-                               for (i = 0; i < expected_width * expected_height; i++) {
-                                       *pImage16++ = ui_backcolor;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 1;
-                       } else {
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 0;
-                       }
-               }
-
-               switch (pInputStream[inputPos++]) {
-               case 0x3b: /* End of the GIF dataset */
-                       if (decoderline) {
-                               IfegMemFree(decoderline);
-                               decoderline = 0;
-                       }
-                       if (pDecBuf) {
-                               IfegMemFree(pDecBuf);
-                               pDecBuf = 0;
-                       }
-                       if (pFrameData->imgCount == 0) {
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return -1;
-                       }
-                       pFrameData->imgCount = 0;
-                       pFrameData->offset = pFrameData->firstpos;
-
-#ifdef INTERNAL_IMGCODEC
-                       pFrameData->nRepeatCount++;
-                       thumb_dbg("(no_buffer) bLoop : %d, nRepeatCount : %d, nLoopCount : %d" , pFrameData->bLoop, pFrameData->nRepeatCount , pFrameData->nLoopCount);
-
-                       if (pFrameData->nLoopCount == -1) {
-                               break;
-                       } else if (pFrameData->bLoop || (pFrameData->nRepeatCount <= pFrameData->nLoopCount) || (pFrameData->nLoopCount == 0)) {
-                               /* Background Color */
-                               pImage16 = (unsigned short *)pFrameData->pPrevImg;
-
-                               for (i = 0; i < expected_width * expected_height; i++) {
-                                       *pImage16++ = ui_backcolor;
-                               }
-
-                               inputPos = pFrameData->offset;
-                               continue;
-                       } else {
-                               /* if there is last frame and bLoop is FALSE, return 2. */
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 2;
-                       }
-#else
-                       if (pFrameData->bLoop) {
-                               /* Background Color */
-                               pImage16 = (unsigned short *)pFrameData->pPrevImg;
-                               for (i = 0; i < expected_width * expected_height; i++) {
-                                       *pImage16++ = backcolor;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 1;
-                       } else {
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 0;
-                       }
-#endif
-                       break;
-               case 0x21: /* Extension Block */
-                       switch (pInputStream[inputPos++]) {
-                       case 0xf9: /* Graphic control extension block */
-                               if (4 != pInputStream[inputPos++]) { /* data length : fixed 4 bytes */
-                                       if (decoderline != 0) {
-                                               IfegMemFree(decoderline);
-                                               decoderline = 0;
-                                       }
-                                       if (pDecBuf != 0) {
-                                               IfegMemFree(pDecBuf);
-                                               pDecBuf = 0;
-                                       }
-                                       IfegMemFree(done_prefix);
-                                       done_prefix = 0;
-                                       return -1;
-                               }
-
-                               disposal_method = ((pInputStream[inputPos] & 0x1c) >> 2);
-                               transparent = pInputStream[inputPos++] & 0x01;  /* does it use? 1:on 0:off */
-                               pFrameData->delay = (pInputStream[inputPos] | (pInputStream[inputPos+1] << 8))*10;
-                               inputPos += 2; /* Delay time (skip) */
-                               transIndex = pInputStream[inputPos++];
-                               inputPos++; /* block end */
-                               break;
-
-                       case 0x01: /* Plain Text block */
-                               while ((i = pInputStream[inputPos++]) > 0) {/* get the data length */
-                                       inputPos += i;
-                                       if (inputPos > filesize) {
-                                               if (decoderline) {
-                                                       IfegMemFree(decoderline);
-                                                       decoderline = 0;
-                                               }
-                                               if (pDecBuf) {
-                                                       IfegMemFree(pDecBuf);
-                                                       pDecBuf = 0;
-                                               }
-                                               IfegMemFree(done_prefix);
-                                               done_prefix = 0;
-                                               return -1;
-                                       }
-                               }
-                               break;
-
-                       case 0xfe: /* Comment Extension block */
-                               while ((i = pInputStream[inputPos++]) > 0) { /* get the data length */
-                                       inputPos += i;
-                                       if (inputPos > filesize) {
-                                               if (decoderline) {
-                                                       IfegMemFree(decoderline);
-                                                       decoderline = 0;
-                                               }
-                                               if (pDecBuf) {
-                                                       IfegMemFree(pDecBuf);
-                                                       pDecBuf = 0;
-                                               }
-                                               IfegMemFree(done_prefix);
-                                               done_prefix = 0;
-                                               return -1;
-                                       }
-                               }
-                               break;
-
-                       case 0xff: /* Appliation Extension block */
-                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
-                                       inputPos += i;
-                                       if (inputPos > filesize) {
-                                               if (decoderline) {
-                                                       IfegMemFree(decoderline);
-                                                       decoderline = 0;
-                                               }
-
-                                               if (pDecBuf) {
-                                                       IfegMemFree(pDecBuf);
-                                                       pDecBuf = 0;
-                                               }
-                                               IfegMemFree(done_prefix);
-                                               done_prefix = 0;
-                                               return -1;
-                                       }
-                               }
-                               break;
-
-                       default:
-                               break;
-                       }
-                       break;
-
-               case 0x2c: /* Start of an image object. Read the image description. */
-
-                       /* initialize */
-                       IfegMemcpy(pOutBits, pFrameData->pPrevImg, expected_width * expected_height * 2);
-                       pDacbox = global_dacbox;
-
-                       IfegMemcpy(buffer, pInputStream+inputPos, 9);
-                       inputPos += 9;
-
-                       image_left_pos = (buffer[0] | (buffer[1]<<8));
-                       image_top_pos = (buffer[2] | (buffer[3]<<8));
-                       orgwdt_1 = orgwdt = (buffer[4] | (buffer[5] << 8));
-                       orghgt = (buffer[6] | (buffer[7] << 8));
-
-#ifdef INTERNAL_IMGCODEC
-#else
-                       if ((orgwdt > MAXWIDTH) || (orghgt > MAXHEIGHT)) {
-                               if (decoderline != 0) {
-                                       IfegMemFree(decoderline);
-                                       decoderline = 0;
-                               }
-                               if (pDecBuf != 0) {
-                                       IfegMemFree(pDecBuf);
-                                       pDecBuf = 0;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return -1;
-                       }
-#endif
-
-                       /* Interlaced check */
-                       interLaced = buffer[8] & 0x40;
-                       if (interLaced) {
-                               startloc = -8;
-                       }
-
-                       inter_step = 1;
-
-                       if (decoderline) {
-                               IfegMemFree(decoderline);
-                       }
-                       decoderline = (unsigned char *)IfegMemAlloc(orgwdt);
-                       if (!decoderline) {
-                               if (pDecBuf != 0) {
-                                       IfegMemFree(pDecBuf);
-                                       pDecBuf = 0;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 0;
-                       }
-                       IfegMemset(decoderline, 0, orgwdt);
-
-                       decwdt = ((orgwdt * resized_width+logi_wdt-1) / logi_wdt);
-                       dechgt = ((orghgt * resized_height+logi_hgt-1) / logi_hgt);
-
-                       if (!decwdt || !dechgt) {
-                               if (decoderline != 0) {
-                                       IfegMemFree(decoderline);
-                                       decoderline = 0;
-                               }
-                               if (pDecBuf != 0) {
-                                       IfegMemFree(pDecBuf);
-                                       pDecBuf = 0;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 0;
-                       }
-
-                       if (pDecBuf) {
-                               IfegMemFree(pDecBuf);
-                       }
-                       pDecBuf = (unsigned char *)IfegMemAlloc(decwdt * dechgt * 4);
-                       if (!pDecBuf) {
-                               if (decoderline != 0) {
-                                       IfegMemFree(decoderline);
-                                       decoderline = 0;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return 0;
-                       }
-                       IfegMemset(pDecBuf, 0, decwdt * dechgt * 4);
-
-                       /* assign out_888_image plane */
-                       pImage32 = (unsigned int *)(pDecBuf);
-
-                       /* Initialize */
-                       a_x = orgwdt>>2, a_y = orghgt>>2;
-                       b_x = ((orgwdt*3)>>2), b_y = orghgt>>2;
-                       c_x = orgwdt>>2, c_y = ((orghgt*3)>>2);
-                       d_x = ((orgwdt*3)>>2), d_y = ((orghgt*3)>>2);
-
-                       end = dechgt * orghgt;
-                       out_x = 0, out_y = -dechgt;
-
-                       /* Color Resolution */
-                       if ((buffer[8] & 0x80) == 0) { /* Logical color table */
-                               /* use global table */
-                       } else { /* Logical color table */
-                               IfegMemset(dacbox, 0, 1024);
-
-                               numcolors = (buffer[8] & 0x7) + 1;
-                               numcolors = 1 << numcolors;
-
-                               /* Make color table */
-                               for (i = 0 ; i < numcolors; i++) {
-                                       dacbox[i] = ((pInputStream[inputPos++] >> 2)<<16);
-                                       dacbox[i] |= ((pInputStream[inputPos++] >> 2)<<8);
-                                       dacbox[i] |= (pInputStream[inputPos++] >> 2);
-                               }
-                               pDacbox = dacbox;
-                       }
-
-                       if (numcolors > 16) {
-                               numcolors = 256;
-                       }
-                       if (numcolors > 2 && numcolors < 16) {
-                               numcolors = 16;
-                       }
-
-                       /****************************************************************************
-                       decoder(WDT, pInputStream, pBitmapElem->pBits);
-                       int decoder(int linewidth, UCHAR* pInputStream, UCHAR *pBitmapElem->pBits)
-                       ****************************************************************************/
-
-                       size = pInputStream[inputPos++];
-                       if (size < 2 || 9 < size) {
-                               if (decoderline != 0) {
-                                       IfegMemFree(decoderline);
-                                       decoderline = 0;
-                               }
-                               if (pDecBuf != 0) {
-                                       IfegMemFree(pDecBuf);
-                                       pDecBuf = 0;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-                               return -1;
-                       }
-
-                       rowcount = oc = fc = 0;
-                       buf = decoderline;
-                       sp = dstack;
-                       bufptr = buf;
-                       bufcnt = orgwdt_1;
-
-                       /************************
-                       init_exp(size);
-                       int init_exp(int size)
-                       ************************/
-                       curr_size = size + 1;
-                       top_slot = 1 << curr_size;
-                       clear = 1 << size;
-                       ending = clear + 1;
-                       slot = newcodes = ending + 1;
-                       navail_bytes = nbits_left = 0;
-                       /************************/
-
-
-                       /* __get_next_code(pInputStream) */
-                       __get_next_code_first_nbits_left_0_nobuffer(pInputStream)
-                       __get_next_code_first_while_nobuffer(pInputStream)
-
-                       if (c == ending) {
-                               break;
-                       }
-                       /**********************************************************/
-
-                       if (c == clear) {
-                               curr_size = size + 1;
-                               slot = newcodes;
-                               top_slot = 1 << curr_size;
-
-                               do {
-                                       /* __get_next_code(pInputStream); */
-                                       if (navail_bytes < 2) {
-                                               if (nbits_left == 0)
-                                                       __get_next_code_first_nbits_left_0_nobuffer(pInputStream)
-                                               else
-                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
-
-                                               __get_next_code_first_while_nobuffer(pInputStream)
-                                       } else {
-                                               if (nbits_left == 0)
-                                                       __get_next_code_second_nbits_left_0(pInputStream)
-                                               else
-                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                               __get_next_code_second_while(pInputStream)
-                                       }
-
-                               } while (c == clear);
-
-                               if (c == ending) {
-                                       break;
-                               }
-
-                               if (c >= slot) {
-                                       c = 0;
-                               }
-
-                               oc = fc = c;
-                               *sp++ = (unsigned char)c;
-                       } else {
-                               if (c >= slot) {
-                                       c = 0;
-                               }
-
-                               oc = fc = c;
-                               *sp++ = (unsigned char)c;
-                       }
-
-                       while (rowcount < orghgt) {
-                               if ((sp - dstack) > 0) {
-                                       spCount = sp - dstack;
-                               }
-                               /* Now that we've pushed the decoded string (in reverse order)
-                               * onto the stack, lets pop it off and put it into our decode
-                               * buffer... And when the decode buffer is full, write another
-                               * line...
-                               */
-                               while (sp > dstack) {
-                                       --sp;
-                                       *bufptr++ = *sp;
-
-                                       if (--bufcnt == 0) {
-
-                                               /********************************************************************************
-                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
-                                               ********************************************************************************/
-                                               rowcount++;
-                                               len = bufptr - buf;
-                                               if (len >= orgwdt) {
-                                                       len = orgwdt;
-                                               }
-
-                                               if (interLaced == 0) { /* interlaced image */
-                                                       if (!flag) {
-                                                               out_x = 0, out_y += dechgt;
-                                                       }
-                                               } else { /* interlaced image */
-                                                       if (inter_step == 1) {
-                                                               startloc += 8;
-                                                       } else if (inter_step == 2) {
-                                                               startloc += 8;
-                                                       } else if (inter_step == 3) {
-                                                               startloc += 4;
-                                                       } else if (inter_step == 4) {
-                                                               startloc += 2;
-                                                       }
-
-                                                       if (startloc >= orghgt) {
-                                                               inter_step++;
-                                                               if (inter_step == 2) {
-                                                                       startloc = 4;
-                                                               } else if (inter_step == 3) {
-                                                                       startloc = 2;
-                                                               } else if (inter_step == 4) {
-                                                                       startloc = 1;
-                                                               }
-                                                       }
-
-                                                       /* gif to rgb 565 */
-                                                       if (flag) {
-                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
-                                                       } else {
-                                                               out_x = 0, out_y = startloc * dechgt;
-                                                               a_x = orgwdt>>2;
-                                                               b_x = ((orgwdt*3)>>2);
-                                                               c_x = orgwdt>>2;
-                                                               d_x = ((orgwdt*3)>>2);
-                                                               if (out_y <= (orghgt >> 2)) {
-                                                                       a_y = orghgt>>2;
-                                                                       b_y = orghgt>>2;
-                                                                       c_y = ((orghgt*3)>>2);
-                                                                       d_y = ((orghgt*3)>>2);
-                                                               } else {
-                                                                       if (((out_y%orghgt) - (orghgt>>2)) > 0) {
-                                                                               a_y = ((out_y/orghgt)+1) * orghgt + (orghgt>>2);
-                                                                       } else if (((out_y%orghgt) - (orghgt>>2)) < 0 || !(out_y%orghgt)) {
-                                                                               a_y = ((out_y/orghgt)) * orghgt + (orghgt>>2);
-                                                                       } else {
-                                                                               a_y = out_y;
-                                                                       }
-
-                                                                       if (((out_y % orghgt) - ((orghgt * 3) >> 2)) > 0) {
-                                                                               c_y = ((out_y/orghgt)+1) * orghgt + ((orghgt*3)>>2);
-                                                                       } else if (((out_y%orghgt) - ((orghgt*3)>>2)) < 0 || !(out_y%orghgt)) {
-                                                                               c_y = ((out_y/orghgt)) * orghgt + ((orghgt * 3) >> 2);
-                                                                       } else {
-                                                                               c_y = out_y;
-                                                                       }
-                                                                       b_y = a_y, d_y = c_y;
-                                                               }
-                                                       }
-                                               }
-
-                                               if (transparent == 1) {
-                                                       if (flag) {
-                                                               for (i = 0; i < len; i++) {
-                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                       if (val1 == transIndex) {
-                                                                               *pImage32++ = 0x4000000; /* Set *pImage32 MSB 1 */
-                                                                       } else {
-                                                                               *pImage32++ = pDacbox[val1]<<2;
-                                                                       }
-                                                               }
-                                                       } else {
-                                                               if (c_y < end) {
-                                                                       d1 = a_y - out_y;
-                                                                       d2 = c_y - out_y;
-                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
-                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
-
-                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       d1 = a_x - out_x;
-                                                                                       d2 = b_x - out_x;
-
-                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                               if (val1 == transIndex) {
-                                                                                                       *(pImage32 + (a_x/orgwdt)) += 0x1000000;
-                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += 0x1000000;
-                                                                                                       a_x += orgwdt, c_x += orgwdt;
-                                                                                               } else {
-                                                                                                       *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
-                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
-                                                                                                       a_x += orgwdt, c_x += orgwdt;
-                                                                                               }
-                                                                                       }
-                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                               if (val1 == transIndex) {
-                                                                                                       *(pImage32 + (b_x/orgwdt)) += 0x1000000;
-                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += 0x1000000;
-                                                                                                       b_x += orgwdt, d_x += orgwdt;
-                                                                                               } else {
-                                                                                                       *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
-                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
-                                                                                                       b_x += orgwdt, d_x += orgwdt;
-                                                                                               }
-                                                                                       }
-                                                                                       out_x += decwdt;
-                                                                               }
-                                                                               if (!interLaced) {
-                                                                                       a_x = orgwdt>>2, a_y += orghgt;
-                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
-                                                                                       c_x = orgwdt>>2, c_y += orghgt;
-                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
-                                                                               }
-                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
-
-                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       d1 = a_x - out_x;
-                                                                                       d2 = b_x - out_x;
-                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                               if (val1 == transIndex) {
-                                                                                                       *(pImage32 + (a_x/orgwdt)) += 0x1000000;
-                                                                                                       a_x += orgwdt;
-                                                                                               } else {
-                                                                                                       *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
-                                                                                                       a_x += orgwdt;
-                                                                                               }
-                                                                                       } if (0 <= d2 && d2 < decwdt) {
-                                                                                               if (val1 == transIndex) {
-                                                                                                       *(pImage32 + (b_x/orgwdt)) += 0x1000000;
-                                                                                                       b_x += orgwdt;
-                                                                                               } else {
-                                                                                                       *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
-                                                                                                       b_x += orgwdt;
-                                                                                               }
-                                                                                       }
-                                                                                       out_x += decwdt;
-                                                                               }
-                                                                               if (!interLaced) {
-                                                                                       a_x = orgwdt>>2, a_y += orghgt;
-                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
-                                                                               }
-                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
-                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       d1 = c_x - out_x;
-                                                                                       d2 = d_x - out_x;
-                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                               if (val1 == transIndex) {
-                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += 0x1000000;
-                                                                                                       c_x += orgwdt;
-                                                                                               } else {
-                                                                                                       *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
-                                                                                                       c_x += orgwdt;
-                                                                                               }
-                                                                                       }
-                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                               if (val1 == transIndex) {
-                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += 0x1000000;
-                                                                                                       d_x += orgwdt;
-                                                                                               } else {
-                                                                                                       *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
-                                                                                                       d_x += orgwdt;
-                                                                                               }
-                                                                                       }
-                                                                                       out_x += decwdt;
-                                                                               }
-                                                                               if (!interLaced) {
-                                                                                       c_x = orgwdt>>2, c_y += orghgt;
-                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                               } else {
-                                                       if (flag) {
-                                                               for (i = 0; i < len; i++) {
-                                                                       val1 = buf[i] & (numcolors-1);
-                                                                       *pImage32++ = pDacbox[val1]<<2;
-                                                               }
-                                                       } else {
-                                                               if (c_y < end) {
-                                                                       d1 = a_y - out_y;
-                                                                       d2 = c_y - out_y;
-                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
-                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
-                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       d1 = a_x - out_x;
-                                                                                       d2 = b_x - out_x;
-                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                               *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
-                                                                                               *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
-                                                                                               a_x += orgwdt, c_x += orgwdt;
-                                                                                       }
-                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                               *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
-                                                                                               *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
-                                                                                               b_x += orgwdt, d_x += orgwdt;
-                                                                                       }
-                                                                                       out_x += decwdt;
-                                                                               }
-                                                                               if (!interLaced) {
-                                                                                       a_x = orgwdt>>2, a_y += orghgt;
-                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
-                                                                                       c_x = orgwdt>>2, c_y += orghgt;
-                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
-                                                                               }
-                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/orghgt) * decwdt;
-                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       d1 = a_x - out_x;
-                                                                                       d2 = b_x - out_x;
-                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                               *(pImage32 + (a_x/orgwdt)) += pDacbox[val1];
-                                                                                               a_x += orgwdt;
-                                                                                       }
-                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                               *(pImage32 + (b_x/orgwdt)) += pDacbox[val1];
-                                                                                               b_x += orgwdt;
-                                                                                       }
-                                                                                       out_x += decwdt;
-                                                                               }
-                                                                               if (!interLaced) {
-                                                                                       a_x = orgwdt>>2, a_y += orghgt;
-                                                                                       b_x = ((orgwdt*3)>>2), b_y += orghgt;
-                                                                               }
-                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/orghgt) * decwdt;
-                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       d1 = c_x - out_x;
-                                                                                       d2 = d_x - out_x;
-                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                               *(pImage32_2 + (c_x/orgwdt)) += pDacbox[val1];
-                                                                                               c_x += orgwdt;
-                                                                                       }
-                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                               *(pImage32_2 + (d_x/orgwdt)) += pDacbox[val1];
-                                                                                               d_x += orgwdt;
-                                                                                       }
-                                                                                       out_x += decwdt;
-                                                                               }
-
-                                                                               if (!interLaced) {
-                                                                                       c_x = orgwdt>>2, c_y += orghgt;
-                                                                                       d_x = ((orgwdt*3)>>2), d_y += orghgt;
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                                               bufptr = buf;
-                                                               bufcnt = orgwdt_1;
-                                       }
-                               }
-
-                               if (rowcount == orghgt) {
-                                       break;
-                               }
-
-                               /* __get_next_code(pInputStream) */
-                               if (navail_bytes < 2) {
-                                       if (nbits_left == 0)
-                                               __get_next_code_first_nbits_left_0_nobuffer(pInputStream)
-                                       else
-                                               __get_next_code_first_nbits_left_not_0(pInputStream)
-                                       __get_next_code_first_while_nobuffer(pInputStream)
-                               } else {
-                                       if (nbits_left == 0)
-                                               __get_next_code_second_nbits_left_0(pInputStream)
-                                       else
-                                               __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                       __get_next_code_second_while(pInputStream)
-                               }
-
-                               if (c == ending) {
-                                       break;
-                               }
-                               /*************************************************************/
-
-                               if (c == clear) {
-                                       curr_size = size + 1;
-                                       slot = newcodes;
-                                       top_slot = 1 << curr_size;
-
-                                       do {
-                                               /* __get_next_code(pInputStream); */
-                                               if (navail_bytes < 2) {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_first_nbits_left_0_nobuffer(pInputStream)
-                                                       else
-                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                       __get_next_code_first_while_nobuffer(pInputStream)
-                                               } else {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_second_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                       __get_next_code_second_while(pInputStream)
-                                               }
-                                       } while (c == clear);
-
-                                       if (c == ending) {
-                                               break;
-                                       }
-
-                                       if (c >= slot) {
-                                               c = 0;
-                                       }
-
-                                               oc = fc = c;
-                                               *sp++ = (unsigned char)c;
-                                       } else {
-                                               code = c;
-
-                                               if (code >= slot) {
-                                                       code = oc;
-                                                       *sp++ = (unsigned char)fc;
-                                               }
-
-                                               IfegMemset(done_prefix, 0, sizeof(unsigned char)*(MAX_CODES+1));
-                                               while (code >= newcodes) {
-                                                       *sp++ = suffix[code];
-                                                       if ((code == prefix[code]) || (done_prefix[code] == 1)) {
-                                                               thumb_err("Circular entry in table.");
-                                                               if (decoderline != 0) {
-                                                                       IfegMemFree(decoderline);
-                                                                       decoderline = 0;
-                                                               }
-                                                               if (pDecBuf != 0) {
-                                                                       IfegMemFree(pDecBuf);
-                                                                       pDecBuf = 0;
-                                                               }
-                                                               IfegMemFree(done_prefix);
-                                                               done_prefix = 0;
-                                                               return 0;
-                                                       }
-                                                       done_prefix[code] = 1;
-                                                       code = prefix[code];
-                                               }
-
-                                               *sp++ = (unsigned char)code;
-                                               spCount++;
-                                               if (slot < top_slot) {
-                                                       fc = code;
-                                                       suffix[slot] = (unsigned char)fc;
-                                                       prefix[slot++] = oc;
-                                                       oc = c;
-                                               }
-                                               if (slot >= top_slot) {
-                                                       if (curr_size < 12) {
-                                                               top_slot <<= 1;
-                                                               ++curr_size;
-                                                       }
-                                               }
-                                       }
-                               }
-                               /*************************************************************/
-
-                               if (bCenterAlign) {
-                                       margin_wdt1_2 = (expected_width - resized_width)>>1;
-                                       margin_hgt1_2 = (expected_height - resized_height)>>1;
-                               } else {
-                                       margin_wdt1_2 = 0;
-                                       margin_hgt1_2 = 0;
-                               }
-
-                               pImage32 = (unsigned int *)(pDecBuf);
-
-                               /* Only make a first image frame as a thumbnail */
-                               image_left_pos = 0;
-                               image_top_pos = 0;
-                               len = decwdt;
-
-                               if (orgwdt > logi_wdt) {
-                                       decwdt = resized_width;
-                               }
-                               if (orghgt > logi_hgt) {
-                                       dechgt = resized_height;
-                               }
-
-                               if ((image_left_pos + decwdt) > resized_width) {
-                                       decwdt = resized_width - image_left_pos;
-                                       if (decwdt < 0) {
-                                               decwdt = 0;
-                                       }
-                               }
-                               if ((image_top_pos+dechgt) > resized_height) {
-                                       dechgt = resized_height - image_top_pos;
-                                       if (dechgt < 0) {
-                                               dechgt = 0;
-                                       }
-                               }
-
-                               if (pFrameData->imgCount == 0) {
-                                       for (i = 0, k = margin_hgt1_2; i < resized_height; i++) {
-                                               pImage16 = (unsigned short *)((unsigned char *)pOutBits + ((margin_wdt1_2 + expected_width * k) << 1));
-                                               for (j = 0; j < resized_width; j++) {
-                                                       *pImage16++ = backcolor;
-                                               }
-                                               k++;
-                                       }
-                                       if (transparent == 1) {
-                                       for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
-                                               pImage16 = (unsigned short *)((unsigned char *)pOutBits + ((image_left_pos+margin_wdt1_2 + expected_width * k) << 1));
-                                               for (j = 0; j < decwdt; j++) {
-                                                       *pImage16++ = ui_backcolor;
-                                               }
-                                               k++;
-                                       }
-                                       }
-                               }
-
-                               for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
-                                       pImage16 = (unsigned short *)((unsigned char*)pOutBits + ((image_left_pos+margin_wdt1_2 + (expected_width) * k) << 1));
-                                       pImage32 = (unsigned int *)(pDecBuf) + (i * len);
-
-                                       for (j = 0; j < decwdt; j++) {
-                                               if ((*pImage32>>24) == 0) {
-                                                       *(pImage16++) = ((*pImage32 & 0xf80000) >> 8) | ((*pImage32 & 0xfc00) >> 5) | ((*pImage32 & 0xf8) >> 3);
-                                               } else if ((*pImage32 >> 24) == 4) {
-                                                       pImage16++;
-                                               } else if ((*pImage32 >> 24) == 3) {
-                                                       *pImage16 =
-                                                               (((*pImage32 & 0xf80000) >> 8)+(((((*pImage16) & 0xf800) * 3) >> 2) & 0xf800)) |
-                                                               (((*pImage32 & 0xfc00) >> 5)+(((((*pImage16) & 0x07c0) * 3) >> 2) & 0x07c0)) |
-                                                               (((*pImage32 & 0xf8) >> 3)+((((*pImage16) & 0x001f) * 3) >> 2));
-                                                       pImage16++;
-                                               } else if ((*pImage32 >> 24) == 1) {
-                                                       *pImage16 =
-                                                               (((*pImage32 & 0xf80000) >> 8)+((((*pImage16) & 0xf800) >> 2) & 0xf800)) |
-                                                               (((*pImage32 & 0xfc00) >> 5)+((((*pImage16) & 0x07c0) >> 2) & 0x07c0)) |
-                                                               (((*pImage32 & 0xf8) >> 3)+((((*pImage16) & 0x001f) >> 2)));
-                                                       pImage16++;
-                                               } else {
-                                                       *pImage16 =
-                                                               (((*pImage32 & 0xf80000) >> 8)+((((*pImage16) & 0xf800) >> 1) & 0xf800)) |
-                                                               (((*pImage32 & 0xfc00) >> 5)+((((*pImage16) & 0x07c0) >> 1) & 0x07c0)) |
-                                                               (((*pImage32 & 0xf8) >> 3)+((((*pImage16) & 0x001f) >> 1)));
-                                                       pImage16++;
-                                               }
-                                               pImage32++;
-                                       }
-                                       k++;
-                               }
-
-                               switch (disposal_method) {
-                                       /* No disposal specified. The decoder is not required to take any action */
-                               case 0:
-
-                                       /* Do not dispose. The graphic is to be left in place. */
-                               case 1:
-                                       IfegMemcpy(pFrameData->pPrevImg, pOutBits, expected_width * expected_height * 2);
-                                       break;
-
-                                       /* Restore to background color. The area used by the graphic must be restored to the background color. */
-                               case 2:
-                                       IfegMemcpy(pFrameData->pPrevImg, pOutBits, expected_width * expected_height * 2);
-
-                                       if (transparent == 1) {
-                                       for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
-                                               pImage16 = (unsigned short *)((pFrameData->pPrevImg) + ((image_left_pos+margin_wdt1_2 + expected_width * k) << 1));
-                                               for (j = 0; j < decwdt; j++) {
-                                                       *pImage16++ = ui_backcolor;
-                                               }
-                                               k++;
-                                       }
-                                       } else {
-                                       for (i = 0, k = image_top_pos+margin_hgt1_2; i < dechgt; i++) {
-                                               pImage16 = (unsigned short *)((pFrameData->pPrevImg) + ((image_left_pos+margin_wdt1_2 + expected_width * k) << 1));
-                                               for (j = 0; j < decwdt; j++) {
-                                                       *pImage16++ = image_backcolor;
-                                               }
-                                               k++;
-                                       }
-                                       }
-                                       break;
-
-                                       /* Restore to previous. The decoder is required to restore the area overwritten by the graphic with what was there prior to rendering the graphic.*/
-                               case 3:
-                                       break;
-
-                               default:
-                                       IfegMemcpy(pFrameData->pPrevImg, pOutBits, expected_width * expected_height * 2);
-                                       /* same with case 1 */
-                                       break;
-                               }
-
-                               if (decoderline) {
-                                       IfegMemFree(decoderline);
-                                       decoderline = 0;
-                               }
-                               if (pDecBuf) {
-                                       IfegMemFree(pDecBuf);
-                                       pDecBuf = 0;
-                               }
-                               IfegMemFree(done_prefix);
-                               done_prefix = 0;
-
-                               pFrameData->offset = inputPos;
-                               pFrameData->imgCount++;
-
-                               return 1;
-
-                               break;
-
-                               default:
-                                       break;
-
-               }
-       }
-}
-
-
-/* use buffer */
-int __FastImgGetNextFrameAGIF_UseBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAlign)
-{
-       unsigned int *pImage32, *pImage32_2, *backGround;
-       unsigned short *pImage16;
-       unsigned char   *sp;
-       unsigned char   *bufptr;
-       unsigned int    code, fc, oc, bufcnt;
-       unsigned char                   buffer[16];
-       unsigned char                   val1;
-       unsigned char                   *buf;
-       unsigned int                    *pDacbox;
-       unsigned char                   *decoderline = 0;
-       unsigned int size;
-       unsigned int c = 0;
-
-       unsigned int clear;
-       unsigned int ending;
-       unsigned int newcodes;
-       unsigned int top_slot;
-       unsigned int slot;
-
-       int     numcolors;
-       int     i, j, k;
-       int     rowcount;
-       int orgwdt_1, orgwdt, orghgt;
-       int decwdt, dechgt;
-       int len;
-       int inter_step, interLaced, intercount;
-       int transparent = 0;
-       int startloc = 0;
-       int backgroundIndex = 0;
-       int transIndex = 0;
-       int spCount = 0;
-       int logi_wdt;           /* logical screen width */
-       int logi_hgt;
-       int ui_backcolor565;
-       int backcolor565;
-
-       int backcolor888;
-
-       int image_left_pos;     /* left position of image in Logical screeen */
-       int image_top_pos;
-       int disposal_method = 0;
-       int margin_wdt1_2, margin_hgt1_2;
-
-       int inputPos;
-
-
-       unsigned int dacbox[256];
-
-       /* Variable for Resize */
-
-       unsigned int a_x, a_y;
-       unsigned int b_x, b_y;
-       unsigned int c_x, c_y;
-       unsigned int d_x, d_y;
-       int out_x = 0, out_y = 0;
-       int d1, d2;
-       int flag = 0;
-       unsigned int end;
-
-       unsigned char *pDecBuf = 0;
-
-       int expected_width = pFrameData->width;
-       int expected_height = pFrameData->height;
-       int resized_width;
-       int resized_height;
-
-       /* macro */
-       register unsigned int curr_size;
-       register int navail_bytes = 0;
-       register unsigned int nbits_left = 0;
-       register unsigned int b1 = 0;
-       register unsigned int ret;
-
-       /* parameter */
-       unsigned int *global_dacbox = pFrameData->pGlobal_table;
-       unsigned char *pInputStream = pFrameData->pEncodedData;
-       void *pOutBits = pFrameData->pOutBits;
-       unsigned short *prefix = pFrameData->pPrefix;
-       unsigned char *dstack = pFrameData->pDstack;
-       unsigned char *suffix = pFrameData->pSuffix;
-       int filesize = pFrameData->inputSize;
-
-       inputPos = pFrameData->offset;
-
-       IfegMemset(prefix, 0, sizeof(unsigned short)*(MAX_CODES+1));
-       IfegMemset(dstack, 0, sizeof(unsigned char)*(MAX_CODES+1));
-       IfegMemset(suffix, 0, sizeof(unsigned char)*(MAX_CODES+1));
-
-       ui_backcolor565 = pFrameData->ui_backcolor;
-
-       backcolor565 = pFrameData->backcolor;
-       backcolor888 =
-               ((backcolor565&0xf800) << 6)|
-               ((backcolor565&0x7e0) << 3)|
-               ((backcolor565&0x1f) << 1);
-
-       backGround = (unsigned int *)pFrameData->pPrevImg;
-
-       intercount = 0;
-
-       if (pFrameData->imgCount == -1) {
-               /* Input stream index set to 0 */
-               inputPos = 0;
-               inter_step = 1;
-               interLaced = 0;
-               transparent = 0;
-
-               /* read a GIF HEADER */
-               IfegMemcpy(buffer, pInputStream, 13);
-               inputPos += 13;
-
-               /* wheather GIF file or not */
-               if (buffer[0] != 'G' || buffer[1] != 'I' || buffer[2] != 'F' ||
-                       buffer[3] < '0' || buffer[3] > '9' ||
-                       buffer[4] < '0' || buffer[4] > '9' ||
-                       buffer[5] < 'A' || buffer[5] > 'z') {
-                       return -1;
-               }
-
-               /* get Logical width, height */
-               pFrameData->logi_wdt = logi_wdt = buffer[6] | (buffer[7] << 8);
-               pFrameData->logi_hgt = logi_hgt = buffer[8] | (buffer[9] << 8);
-
-               /* ouput resized image size */
-               if (logi_wdt <= expected_width && logi_hgt <= expected_height) {
-                       resized_width = logi_wdt;
-                       resized_height = logi_hgt;
-                       pFrameData->flag = flag = 1;
-               } else {
-                       if ((logi_wdt/(float)expected_width) >= (logi_hgt/(float)expected_height)) {
-                               resized_height = logi_hgt * expected_width / logi_wdt;
-                               resized_width = expected_width;
-                       } else {
-                               resized_width = logi_wdt * expected_height / logi_hgt;
-                               resized_height = expected_height;
-                       }
-               }
-               if (!resized_width || !resized_height) {
-                       if (decoderline != 0) {
-                               IfegMemFree(decoderline);
-                               decoderline = 0;
-                       }
-                       return 0;
-               }
-
-               /* ouput resized image size */
-               pFrameData->resizedwidth = resized_width;
-               pFrameData->resizedheight = resized_height;
-
-               /* Color Resolution */
-               IfegMemset(global_dacbox, 0, 1024);
-               numcolors = (buffer[10] & 0x7) + 1;
-               if ((buffer[10] & 0x80) == 0) { /* Global color table */
-                       global_dacbox[0] = 0x000000;
-                       global_dacbox[1] = 0x3f3f3f;
-                       numcolors = 2;
-               } else { /* Global color table */
-                       numcolors = 1 << numcolors;
-
-                       /* Make color table */
-                       for (i = 0; i < numcolors; i++) {
-                               global_dacbox[i] = ((pInputStream[inputPos++] >> 2) << 16);
-                               global_dacbox[i] |= ((pInputStream[inputPos++] >> 2) << 8);
-                               global_dacbox[i] |= (pInputStream[inputPos++] >> 2);
-                       }
-               }
-
-               backgroundIndex = buffer[11];
-               /* Background Color */
-               backcolor888 = global_dacbox[backgroundIndex];
-               backcolor565 = pFrameData->backcolor = (((backcolor888 & 0xff0000) >> 17) << 11) | (((backcolor888 & 0x00ff00) >> 8) << 5) | (((backcolor888 & 0xff) >> 1));
-
-               pImage16 = pOutBits;
-
-               ui_backcolor565 = pFrameData->ui_backcolor ;
-               for (i = 0; i < expected_width * expected_height; i++) {
-                       *pImage16++ = ui_backcolor565;
-               }
-
-               pImage32 = (unsigned int *)pFrameData->pPrevImg;
-
-               if (numcolors > 16)     {
-                       numcolors = 256;
-               }
-               if (numcolors > 2 && numcolors < 16) {
-                       numcolors = 16;
-               }
-               pFrameData->global_numcol = numcolors;
-               pFrameData->imgCount++;
-               pFrameData->firstpos = inputPos;
-       } else {
-               logi_wdt = pFrameData->logi_wdt;
-               logi_hgt = pFrameData->logi_hgt;
-               resized_width = pFrameData->resizedwidth;
-               resized_height = pFrameData->resizedheight;
-               flag = pFrameData->flag ;
-
-               numcolors = pFrameData->global_numcol;
-       }
-
-       /* still gif image (image_cnt = 1) */
-       while (1) {
-               if (inputPos > filesize) {
-
-                       if (decoderline) {
-                               IfegMemFree(decoderline);
-                               decoderline = 0;
-                       }
-                       if (pDecBuf) {
-                               IfegMemFree(pDecBuf);
-                               pDecBuf = 0;
-                       }
-                       pFrameData->imgCount = 0;
-                       pFrameData->offset = pFrameData->firstpos;
-
-                       if (pFrameData->bLoop) {
-                               return 1;
-                       } else {
-                               return 0;
-                       }
-               }
-
-               switch (pInputStream[inputPos++]) {
-               case 0x3b:/* End of the GIF dataset */
-                       if (decoderline) {
-                               IfegMemFree(decoderline);
-                               decoderline = 0;
-                       }
-                       if (pDecBuf) {
-                               IfegMemFree(pDecBuf);
-                               pDecBuf = 0;
-                       }
-                       if (pFrameData->imgCount == 0) {
-                               return -1;
-                       }
-                       pFrameData->imgCount = 0;
-                       pFrameData->offset = pFrameData->firstpos;
-#ifdef INTERNAL_IMGCODEC
-                       pFrameData->nRepeatCount++;
-
-                       if (pFrameData->nLoopCount == -1) {
-                               break;
-                       } else if (pFrameData->bLoop || (pFrameData->nRepeatCount <= pFrameData->nLoopCount) || (pFrameData->nLoopCount == 0)) {
-                               inputPos = pFrameData->offset;
-                               continue;
-                       } else {
-                               return 2;
-                       }
-#else
-                       if (pFrameData->bLoop) {
-                               return 1;
-                       } else {
-                               return 0;
-                       }
-
-#endif
-                       break;
-               case 0x21: /* Extension Block */
-                       switch (pInputStream[inputPos++]) {
-                       case 0xf9: /* Graphic control extension block */
-                               if (4 != pInputStream[inputPos++]) { /* data length : fixed 4 bytes */
-                                       if (decoderline != 0) {
-                                               IfegMemFree(decoderline);
-                                               decoderline = 0;
-                                       }
-                                       if (pDecBuf != 0) {
-                                               IfegMemFree(pDecBuf);
-                                               pDecBuf = 0;
-                                       }
-                                       return -1;
-                               }
-
-                               disposal_method = ((pInputStream[inputPos] & 0x1c) >> 2);
-                               transparent = pInputStream[inputPos++] & 0x01;  /* does it use? 1:on 0:off */
-                               pFrameData->delay = (pInputStream[inputPos] | (pInputStream[inputPos+1] << 8))*10;
-                               inputPos += 2; /* Delay time (skip) */
-                               transIndex = pInputStream[inputPos++];
-                               inputPos++; /* block end */
-
-                               if (backgroundIndex == transIndex && transparent == 1) {
-                                       backcolor888 = 0x1000000;
-                                       backcolor565 = pFrameData->ui_backcolor;
-                               }
-
-                               break;
-                       case 0x01: /* Plain Text block */
-                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
-                                       inputPos += i;
-                                       if (inputPos > filesize) {
-                                               if (decoderline) {
-                                                       IfegMemFree(decoderline);
-                                                       decoderline = 0;
-                                               }
-                                               if (pDecBuf) {
-                                                       IfegMemFree(pDecBuf);
-                                                       pDecBuf = 0;
-                                               }
-                                               return -1;
-                                       }
-                               }
-                               break;
-                       case 0xfe: /* Comment Extension block */
-                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
-                                       inputPos += i;
-                                       if (inputPos > filesize) {
-                                               if (decoderline) {
-                                                       IfegMemFree(decoderline);
-                                                       decoderline = 0;
-                                               }
-                                               if (pDecBuf) {
-                                                       IfegMemFree(pDecBuf);
-                                                       pDecBuf = 0;
-                                               }
-                                               return -1;
-                                       }
-                               }
-                               break;
-                       case 0xff: /* Appliation Extension block */
-
-                               while ((i = pInputStream[inputPos++]) > 0) {    /* get the data length */
-                                       inputPos += i;
-                                       if (inputPos > filesize) {
-                                               if (decoderline) {
-                                                       IfegMemFree(decoderline);
-                                                       decoderline = 0;
-                                               }
-                                               if (pDecBuf) {
-                                                       IfegMemFree(pDecBuf);
-                                                       pDecBuf = 0;
-                                               }
-                                               return -1;
-                                       }
-                               }
-                               break;
-                       default:
-                               break;
-                       }
-
-                       break;
-
-                       case 0x2c: /* Start of an image object. Read the image description. */
-
-                               /* initialize */
-                               pDacbox = global_dacbox;
-
-                               IfegMemcpy(buffer, pInputStream+inputPos, 9);
-                               inputPos += 9;
-
-                               if (pFrameData->imgCount == 0) {
-                                       image_left_pos_N = (buffer[0] | (buffer[1] << 8));
-                                       image_top_pos_N = (buffer[2] | (buffer[3] << 8));
-
-                                       image_left_pos = image_left_pos_N;
-                                       image_top_pos = image_top_pos_N;
-                               }
-                               image_left_pos = (buffer[0] | (buffer[1] << 8));
-                               image_top_pos = (buffer[2] | (buffer[3] << 8));
-                               orgwdt_1 = orgwdt = (buffer[4] | (buffer[5] << 8));
-                               orghgt = (buffer[6] | (buffer[7] << 8));
-
-
-#ifdef INTERNAL_IMGCODEC
-#else
-                               if ((orgwdt > MAXWIDTH) || (orghgt > MAXHEIGHT)) {
-                                       if (decoderline != 0) {
-                                               IfegMemFree(decoderline);
-                                               decoderline = 0;
-                                       }
-                                       if (pDecBuf != 0) {
-                                               IfegMemFree(pDecBuf);
-                                               pDecBuf = 0;
-                                       }
-                                       return -1;
-                               }
-#endif
-
-                               /* Initialize */
-                               a_x = logi_wdt >> 2, a_y = logi_hgt >> 2;
-                               b_x = ((logi_wdt*3) >> 2), b_y = logi_hgt >> 2;
-                               c_x = logi_wdt >> 2, c_y = ((logi_hgt*3) >> 2);
-                               d_x = ((logi_wdt*3) >> 2), d_y = ((logi_hgt*3) >> 2);
-
-                               /* Interlaced check */
-                               interLaced = buffer[8] & 0x40;
-                               if (interLaced) {
-                                       startloc = -8+image_top_pos;
-                               }
-
-                               inter_step = 1;
-
-                               if (decoderline) {
-                                       IfegMemFree(decoderline);
-                               }
-                               decoderline = (unsigned char *)IfegMemAlloc(orgwdt);
-                               if (!decoderline) {
-                                       if (pDecBuf != 0) {
-                                               IfegMemFree(pDecBuf);
-                                               pDecBuf = 0;
-                                       }
-                                       return 0;
-                               }
-                               IfegMemset(decoderline, 0, orgwdt);
-
-                               decwdt = resized_width;
-                               dechgt = resized_height;
-
-                               if (!decwdt || !dechgt) {
-                                       if (decoderline != 0) {
-                                               IfegMemFree(decoderline);
-                                               decoderline = 0;
-                                       }
-                                       if (pDecBuf != 0) {
-                                               IfegMemFree(pDecBuf);
-                                               pDecBuf = 0;
-                                       }
-                                       return 0;
-                               }
-
-                               if (pDecBuf) {
-                                       IfegMemFree(pDecBuf);
-                               }
-                               pDecBuf = (unsigned char *)IfegMemAlloc(decwdt * dechgt * 4);
-                               if (!pDecBuf) {
-                                       if (decoderline != 0) {
-                                               IfegMemFree(decoderline);
-                                               decoderline = 0;
-                                       }
-                                       return 0;
-                               }
-
-                               IfegMemset(pDecBuf, 0, decwdt * dechgt * 4);
-
-                               /* assign out_888_image plane */
-                               pImage32 = (unsigned int *)(pDecBuf);
-
-                               end = dechgt * logi_hgt;
-                               out_x = 0, out_y = -dechgt;
-
-                               /* Color Resolution */
-                               if ((buffer[8] & 0x80) == 0) { /* Logical color table */
-                                       ;/* use global table */
-                               } else { /* Logical color table */
-                                       IfegMemset(dacbox, 0, 1024);
-
-                                       numcolors = (buffer[8] & 0x7) + 1;
-                                       numcolors = 1 << numcolors;
-
-                                       /* Make color table */
-                                       for (i = 0; i < numcolors; i++) {
-                                               dacbox[i] = ((pInputStream[inputPos++] >> 2) << 16);
-                                               dacbox[i] |= ((pInputStream[inputPos++] >> 2) << 8);
-                                               dacbox[i] |= (pInputStream[inputPos++] >> 2);
-                                       }
-                                       pDacbox = dacbox;
-                               }
-
-                               if (numcolors > 16) {
-                                       numcolors = 256;
-                               }
-                               if (numcolors > 2 && numcolors < 16) {
-                                       numcolors = 16;
-                               }
-
-                               if (logi_wdt < (image_left_pos + orgwdt)) {
-                                       if (image_left_pos > logi_wdt) {
-                                               image_left_pos = logi_wdt;
-                                       }
-                                       orgwdt = logi_wdt - image_left_pos;
-                                       flag = 0;
-                               }
-                               if (logi_hgt < (image_top_pos + orghgt)) {
-                                       flag = 0;
-                               }
-
-                               if (pFrameData->imgCount == 0) {
-                                       if (disposal_method == 3) {
-                                               pImage32 = (unsigned int *)pFrameData->pPrevImg;
-                                               for (i = 0; i < logi_wdt * logi_hgt; i++) {
-                                                       *pImage32++ = 0x1000000;
-                                               }
-                                       } else {
-                                               pImage32 = (unsigned int *)pFrameData->pPrevImg;
-                                               for (i = 0; i < logi_wdt * logi_hgt; i++) {
-                                                       *pImage32++ = backcolor888;
-                                               }
-                                       }
-                                       if (transparent == 1) {
-                                               /* Background Color */
-                                               pImage32 = (unsigned int *)pFrameData->pPrevImg;
-                                               pImage32 += image_top_pos * logi_wdt + image_left_pos;
-                                               if (logi_hgt < (image_top_pos + orghgt)) {
-                                                       for (i = 0; i < logi_hgt - image_top_pos; i++) {
-                                                               for (j = 0; j < orgwdt; j++) {
-                                                                       pImage32[j] = 0x1000000; /* set ui color */
-                                                               }
-                                                               pImage32 += logi_wdt;
-                                                       }
-                                               } else {
-                                                       for (i = 0; i < orghgt; i++) {
-                                                               for (j = 0; j < orgwdt; j++) {
-                                                                       pImage32[j] = 0x1000000; /* set ui color */
-                                                               }
-                                                               pImage32 += logi_wdt;
-                                                       }
-                                               }
-                                       }
-                               }
-
-                               /* assign out_888_image plane */
-                               pImage32 = (unsigned int *)(pDecBuf);
-
-                               for (rowcount = 0; rowcount < image_top_pos; rowcount++) {
-                                       if (flag) {
-                                               for (i = 0; i < logi_wdt; i++) {
-                                                       *pImage32++ = backGround[i] << 2;
-                                               }
-                                       } else {
-                                               out_x = 0, out_y += dechgt;
-                                               if (c_y < end) {
-                                                       d1 = a_y - out_y;
-                                                       d2 = c_y - out_y;
-                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                               for (i = 0; i < logi_wdt; i++) {
-                                                                       d1 = a_x - out_x;
-                                                                       d2 = b_x - out_x;
-                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                       }
-                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                       }
-                                                                       out_x += decwdt;
-                                                               }
-                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                               for (i = 0; i < logi_wdt; i++) {
-                                                                       d1 = a_x - out_x;
-                                                                       d2 = b_x - out_x;
-                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                               a_x += logi_wdt;
-                                                                       }
-                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                               b_x += logi_wdt;
-                                                                       }
-                                                                       out_x += decwdt;
-                                                               }
-                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                               for (i = 0; i < logi_wdt; i++) {
-                                                                       d1 = c_x - out_x;
-                                                                       d2 = d_x - out_x;
-                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                               c_x += logi_wdt;
-                                                                       }
-                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                               d_x += logi_wdt;
-                                                                       }
-                                                                       out_x += decwdt;
-                                                               }
-                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                       }
-                                               }
-                                       }
-                                       backGround += logi_wdt;
-                               }
-
-
-                               /***************************************************************************
-                               decoder(WDT, pInputStream, pBitmapElem->pBits); //this does the grunt work
-                               int decoder(int linewidth, UCHAR* pInputStream, UCHAR *pBitmapElem->pBits)
-                               ***************************************************************************/
-
-                               size = pInputStream[inputPos++];
-                               if (size < 2 || 9 < size) {
-                                       if (decoderline != 0) {
-                                               IfegMemFree(decoderline);
-                                               decoderline = 0;
-                                       }
-                                       if (pDecBuf != 0) {
-                                               IfegMemFree(pDecBuf);
-                                               pDecBuf = 0;
-                                       }
-                                       return -1;
-                               }
-                               rowcount = oc = fc = 0;
-                               buf = decoderline;
-                               sp = dstack;
-                               bufptr = buf;
-                               bufcnt = orgwdt_1;
-
-                               /************************
-                               init_exp(size);
-                               int init_exp(int size)
-                               ************************/
-                               curr_size = size + 1;
-                               top_slot = 1 << curr_size;
-                               clear = 1 << size;
-                               ending = clear + 1;
-                               slot = newcodes = ending + 1;
-                               navail_bytes = nbits_left = 0;
-                               /************************/
-
-
-                               /* __get_next_code(pInputStream) */
-                               __get_next_code_first_nbits_left_0(pInputStream)
-                               __get_next_code_first_while(pInputStream)
-
-                               if (c == ending) {
-                                       break;
-                               }
-
-                               if (c == clear) {
-                                       curr_size = size + 1;
-                                       slot = newcodes;
-                                       top_slot = 1 << curr_size;
-
-                                       do {
-                                               /* __get_next_code(pInputStream); */
-                                               if (navail_bytes < 2) {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_first_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                       __get_next_code_first_while(pInputStream)
-                                               } else {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_second_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                       __get_next_code_second_while(pInputStream)
-                                               }
-                                       } while (c == clear);
-
-                                       if (c == ending) {
-                                               break;
-                                       }
-
-                                       if (c >= slot) {
-                                               c = 0;
-                                       }
-
-                                       oc = fc = c;
-                                       *sp++ = (unsigned char)c;
-                               } else {
-                                       if (c >= slot) {
-                                               c = 0;
-                                       }
-
-                                       oc = fc = c;
-                                       *sp++ = (unsigned char)c;
-                               }
-
-                               switch (disposal_method) {
-
-                                       /* Restore to previous. The decoder is required to restore the area overwritten by the graphic with what was there prior to rendering the graphic. */
-                               case 3:
-                                       while (rowcount < orghgt) {
-                                               if ((sp - dstack) > 0) {
-                                                       spCount = sp - dstack;
-                                               }
-                                               /* Now that we've pushed the decoded string (in reverse order)
-                                               * onto the stack, lets pop it off and put it into our decode
-                                               * buffer... And when the decode buffer is full, write another
-                                               * line...
-                                               */
-                                               while (sp > dstack) {
-                                                       --sp;
-                                                       *bufptr++ = *sp;
-
-                                                       if (--bufcnt == 0) {
-                                                               /**********************************************************************************
-                                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
-                                                               **********************************************************************************/
-                                                               rowcount++;
-                                                               len = bufptr - buf;
-                                                               if (len >= orgwdt) {
-                                                                       len = orgwdt;
-                                                               }
-
-                                                               if (interLaced == 0) { /* interlaced image */
-                                                                       if (!flag) {
-                                                                               out_x = 0, out_y += dechgt;
-                                                                       }
-                                                               } else { /* interlaced image */
-                                                                       if (inter_step == 1) {
-                                                                               startloc += 8;
-                                                                               intercount++;
-                                                                       } else if (inter_step == 2) {
-                                                                               startloc += 8;
-                                                                               intercount++;
-                                                                       } else if (inter_step == 3) {
-                                                                               startloc += 4;
-                                                                               intercount++;
-                                                                       } else if (inter_step == 4) {
-                                                                               startloc += 2;
-                                                                               intercount++;
-                                                                       }
-
-                                                                       if (startloc >= orghgt+image_top_pos) {
-                                                                               inter_step++;
-                                                                               if (inter_step == 2) {
-                                                                                       startloc = 4+image_top_pos;
-                                                                               } else if (inter_step == 3) {
-                                                                                       startloc = 2+image_top_pos;
-                                                                               } else if (inter_step == 4) {
-                                                                                       startloc = 1+image_top_pos;
-                                                                               }
-                                                                       }
-
-                                                                       backGround = (unsigned int *)(pFrameData->pPrevImg + ((startloc * logi_wdt) << 2));
-                                                                       /* gif to rgb 565 */
-                                                                       if (flag) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
-                                                                       } else {
-                                                                               out_x = 0, out_y = startloc * dechgt;
-                                                                               a_x = logi_wdt >> 2;
-                                                                               b_x = ((logi_wdt*3) >> 2);
-                                                                               c_x = logi_wdt >> 2;
-                                                                               d_x = ((logi_wdt*3) >> 2);
-                                                                               if (out_y <= (logi_hgt >> 2)) {
-                                                                                       a_y = logi_hgt >> 2;
-                                                                                       b_y = logi_hgt >> 2;
-                                                                                       c_y = ((logi_hgt*3) >> 2);
-                                                                                       d_y = ((logi_hgt*3) >> 2);
-                                                                               } else {
-                                                                                       if (((out_y % logi_hgt) - (logi_hgt >> 2)) > 0) {
-                                                                                               a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
-                                                                                       } else if (((out_y % logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                                                               a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt>>2);
-                                                                                       } else {
-                                                                                               a_y = out_y;
-                                                                                       }
-
-                                                                                       if (((out_y % logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
-                                                                                               c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
-                                                                                       } else if (((out_y % logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y % logi_hgt)) {
-                                                                                               c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
-                                                                                       } else {
-                                                                                               c_y = out_y;
-                                                                                       }
-                                                                                       b_y = a_y, d_y = c_y;
-                                                                               }
-                                                                       }
-                                                               }
-
-                                                               if (transparent == 1) {
-                                                                       if (flag) {
-                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                       *pImage32++ = backGround[i]<<2;
-                                                                               }
-                                                                               for (i = 0; i < len; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       if (val1 == transIndex) {
-                                                                                               *pImage32++ = backGround[i+image_left_pos] << 2;
-                                                                                       } else {
-                                                                                               *pImage32++ = pDacbox[val1] << 2;
-                                                                                       }
-                                                                               }
-                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                       } else {
-                                                                               if (c_y < end) {
-                                                                                       d1 = a_y - out_y;
-                                                                                       d2 = c_y - out_y;
-                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                                       c_x = logi_wdt>>2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       a_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       a_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       b_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       b_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       c_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       c_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       d_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       d_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               } else {
-                                                                       if (flag) {
-                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                               for (i = 0; i < len; i++) {
-                                                                                       val1 = buf[i] & (numcolors - 1);
-                                                                                       *pImage32++ = pDacbox[val1] << 2;
-                                                                               }
-                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                       } else {
-                                                                               if (c_y < end) {
-                                                                                       d1 = a_y - out_y;
-                                                                                       d2 = c_y - out_y;
-                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               }
-
-                                                               backGround += logi_wdt;
-                                                               bufptr = buf;
-                                                               bufcnt = orgwdt_1;
-                                                       }
-                                               }
-
-                                               if (rowcount == orghgt) {
-                                                       break;
-                                               }
-                                               /* __get_next_code(pInputStream) */
-                                               if (navail_bytes < 2) {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_first_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                       __get_next_code_first_while(pInputStream)
-                                               } else {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_second_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                       __get_next_code_second_while(pInputStream)
-                                               }
-
-                                                       if (c == ending) {
-                                                               break;
-                                                       }
-
-                                                       if (c == clear) {
-                                                               curr_size = size + 1;
-                                                               slot = newcodes;
-                                                               top_slot = 1 << curr_size;
-
-                                                               do {
-                                                                       /* __get_next_code(pInputStream); */
-                                                                       if (navail_bytes < 2) {
-                                                                               if (nbits_left == 0)
-                                                                                       __get_next_code_first_nbits_left_0(pInputStream)
-                                                                               else
-                                                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                                               __get_next_code_first_while(pInputStream)
-                                                                       } else {
-                                                                               if (nbits_left == 0)
-                                                                                       __get_next_code_second_nbits_left_0(pInputStream)
-                                                                               else
-                                                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                                               __get_next_code_second_while(pInputStream)
-                                                                       }
-                                                               } while (c == clear);
-
-                                                               if (c == ending) {
-                                                                       break;
-                                                               }
-
-                                                               if (c >= slot) {
-                                                                       c = 0;
-                                                               }
-
-                                                               oc = fc = c;
-
-                                                               *sp++ = (unsigned char)c;
-                                                       } else {
-                                                               code = c;
-
-                                                               if (code >= slot) {
-                                                                       code = oc;
-                                                                       *sp++ = (unsigned char)fc;
-                                                               }
-
-                                                               while (code >= newcodes) {
-                                                                       *sp++ = suffix[code];
-                                                                       code = prefix[code];
-                                                               }
-
-                                                               *sp++ = (unsigned char)code;
-                                                               spCount++;
-                                                               if (slot < top_slot) {
-                                                                       fc = code;
-                                                                       suffix[slot] = (unsigned char)fc;
-                                                                       prefix[slot++] = oc;
-                                                                       oc = c;
-                                                               }
-                                                               if (slot >= top_slot) {
-                                                                       if (curr_size < 12) {
-                                                                               top_slot <<= 1;
-                                                                               ++curr_size;
-                                                                       }
-                                                               }
-                                                       }
-                                       }
-                                       break;
-
-                                       /* Restore to background color. The area used by the graphic must be restored to the background color. */
-                               case 2:
-                                       while (rowcount < orghgt) {
-                                               if ((sp - dstack) > 0) {
-                                                       spCount = sp - dstack;
-                                               }
-                                               while (sp > dstack) {
-                                                       --sp;
-                                                       *bufptr++ = *sp;
-
-                                                       if (--bufcnt == 0) {
-                                                               /********************************************************************************
-                                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
-                                                               ********************************************************************************/
-                                                               rowcount++;
-                                                               len = bufptr - buf;
-                                                               if (len >= orgwdt) {
-                                                                       len = orgwdt;
-                                                               }
-
-                                                               if (interLaced == 0) { /* interlaced image */
-                                                                       if (!flag) {
-                                                                               out_x = 0, out_y += dechgt;
-                                                                       }
-                                                               } else { /* interlaced image */
-                                                                       if (inter_step == 1) {
-                                                                               startloc += 8;
-                                                                       } else if (inter_step == 2) {
-                                                                               startloc += 8;
-                                                                       } else if (inter_step == 3) {
-                                                                               startloc += 4;
-                                                                       } else if (inter_step == 4) {
-                                                                               startloc += 2;
-                                                                       }
-
-                                                                       if (startloc >= orghgt + image_top_pos) {
-                                                                               inter_step++;
-                                                                               if (inter_step == 2) {
-                                                                                       startloc = 4 + image_top_pos;
-                                                                               } else if (inter_step == 3) {
-                                                                                       startloc = 2+image_top_pos;
-                                                                               } else if (inter_step == 4) {
-                                                                                       startloc = 1+image_top_pos;
-                                                                               }
-                                                                       }
-                                                                       backGround = (unsigned int *)(pFrameData->pPrevImg + ((startloc * logi_wdt) << 2));
-                                                                       /* gif to rgb 565 */
-                                                                       if (flag) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
-                                                                       } else {
-                                                                               out_x = 0, out_y = startloc * dechgt;
-                                                                               a_x = logi_wdt >> 2;
-                                                                               b_x = ((logi_wdt*3) >> 2);
-                                                                               c_x = logi_wdt>>2;
-                                                                               d_x = ((logi_wdt*3) >> 2);
-                                                                               if (out_y <= (logi_hgt >> 2)) {
-                                                                                       a_y = logi_hgt>>2;
-                                                                                       b_y = logi_hgt>>2;
-                                                                                       c_y = ((logi_hgt*3)>>2);
-                                                                                       d_y = ((logi_hgt*3)>>2);
-                                                                               } else {
-                                                                                       if (((out_y % logi_hgt) - (logi_hgt >> 2)) > 0) {
-                                                                                               a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
-                                                                                       } else if (((out_y%logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                                                               a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt >> 2);
-                                                                                       } else {
-                                                                                               a_y = out_y;
-                                                                                       }
-
-                                                                                       if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
-                                                                                               c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
-                                                                                       } else if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                                                               c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
-                                                                                       } else {
-                                                                                               c_y = out_y;
-                                                                                       }
-                                                                                       b_y = a_y, d_y = c_y;
-                                                                               }
-                                                                       }
-                                                               }
-
-                                                               if (transparent == 1) {
-                                                                       if (flag) {
-                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                               for (i = 0; i < len; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       if (val1 == transIndex) {
-                                                                                               *pImage32++ = backGround[i+image_left_pos] << 2;
-                                                                                               backGround[i+image_left_pos] = 0x1000000;
-                                                                                       } else {
-                                                                                               *pImage32++ = pDacbox[val1] << 2;
-                                                                                               backGround[i+image_left_pos] = 0x1000000;
-                                                                                       }
-                                                                               }
-                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                       } else {
-                                                                               if (c_y < end) {
-                                                                                       d1 = a_y - out_y;
-                                                                                       d2 = c_y - out_y;
-                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       backGround[i+image_left_pos] = 0x1000000;
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       a_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       a_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       b_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       b_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       backGround[i+image_left_pos] = 0x1000000;
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                               d1 = a_x - out_x;
-                                                                                               d2 = b_x - out_x;
-                                                                                               if (0 <= d1 && d1 < decwdt) {
-                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                       a_x += logi_wdt;
-                                                                                               }
-                                                                                               if (0 <= d2 && d2 < decwdt) {
-                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                       b_x += logi_wdt;
-                                                                                               }
-                                                                                               out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       c_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       c_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       d_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       d_x += logi_wdt;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       backGround[i+image_left_pos] = 0x1000000;
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               } else {
-                                                                       if (flag) {
-                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                       *pImage32++ = backGround[i]<<2;
-                                                                               }
-                                                                               for (i = 0; i < len; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-                                                                                       *pImage32++ = pDacbox[val1] << 2;
-                                                                                       backGround[i+image_left_pos] = backcolor888;
-                                                                               }
-                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                       } else {
-                                                                               if (c_y < end) {
-                                                                                       d1 = a_y - out_y;
-                                                                                       d2 = c_y - out_y;
-                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = backcolor888;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = backcolor888;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               a_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = backcolor888;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               b_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = backcolor888;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               c_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = backcolor888;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               d_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = backcolor888;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               }
-
-                                                               backGround += logi_wdt;
-                                                               bufptr = buf;
-                                                               bufcnt = orgwdt_1;
-                                                       }
-                                               }
-
-                                               if (rowcount == orghgt) {
-                                                       break;
-                                               }
-                                               /* __get_next_code(pInputStream) */
-                                               if (navail_bytes < 2) {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_first_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                       __get_next_code_first_while(pInputStream)
-                                               } else {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_second_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                       __get_next_code_second_while(pInputStream)
-                                               }
-                                                       if (c == ending) {
-                                                               break;
-                                                       }
-
-                                                       if (c == clear) {
-                                                               curr_size = size + 1;
-                                                               slot = newcodes;
-                                                               top_slot = 1 << curr_size;
-
-                                                               do {
-                                                                       /* __get_next_code(pInputStream); */
-                                                                       if (navail_bytes < 2) {
-                                                                               if (nbits_left == 0)
-                                                                                       __get_next_code_first_nbits_left_0(pInputStream)
-                                                                               else
-                                                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                                               __get_next_code_first_while(pInputStream)
-                                                                       } else {
-                                                                               if (nbits_left == 0)
-                                                                                       __get_next_code_second_nbits_left_0(pInputStream)
-                                                                               else
-                                                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                                               __get_next_code_second_while(pInputStream)
-                                                                       }
-                                                               } while (c == clear);
-
-                                                               if (c == ending) {
-                                                                       break;
-                                                               }
-
-                                                               if (c >= slot) {
-                                                                       c = 0;
-                                                               }
-
-                                                               oc = fc = c;
-
-                                                               *sp++ = (unsigned char)c;
-                                                       } else {
-                                                               code = c;
-
-                                                               if (code >= slot) {
-                                                                       code = oc;
-                                                                       *sp++ = (unsigned char)fc;
-                                                               }
-
-                                                               while (code >= newcodes) {
-                                                                       *sp++ = suffix[code];
-                                                                       code = prefix[code];
-                                                               }
-
-                                                               *sp++ = (unsigned char)code;
-                                                               spCount++;
-                                                               if (slot < top_slot) {
-                                                                       fc = code;
-                                                                       suffix[slot] = (unsigned char)fc;
-                                                                       prefix[slot++] = oc;
-                                                                       oc = c;
-                                                               }
-                                                               if (slot >= top_slot) {
-                                                                       if (curr_size < 12) {
-                                                                               top_slot <<= 1;
-                                                                               ++curr_size;
-                                                                       }
-                                                               }
-                                                       }
-
-                                       }
-
-                                       break;
-
-
-                                       /* No disposal specified. The decoder is not required to take any action */
-                               case 0:
-
-                                       /* Do not dispose. The graphic is to be left in place. */
-                               case 1:
-
-                               default:
-                                       while (rowcount < orghgt) {
-                                               if ((sp - dstack) > 0) {
-                                                       spCount = sp - dstack;
-                                               }
-                                               /* Now that we've pushed the decoded string (in reverse order)
-                                               * onto the stack, lets pop it off and put it into our decode
-                                               * buffer... And when the decode buffer is full, write another
-                                               * line...
-                                               */
-                                               while (sp > dstack) {
-                                                       --sp;
-                                                       *bufptr++ = *sp;
-
-                                                       if (--bufcnt == 0) {
-                                                               /**********************************************************************************
-                                                               if ((ret = put_line(rowcount++, bufptr - buf, WDT, buf, pBitmapElem->pBits)) < 0)
-                                                               **********************************************************************************/
-                                                               rowcount++;
-                                                               len = bufptr - buf;
-                                                               if (len >= orgwdt) {
-                                                                       len = orgwdt;
-                                                               }
-
-                                                               if (interLaced == 0) { /* interlaced image */
-                                                                       if (!flag) {
-                                                                               out_x = 0, out_y += dechgt;
-                                                                       }
-                                                               } else { /* interlaced image */
-                                                                       if (inter_step == 1) {
-                                                                               startloc += 8;
-                                                                               intercount++;
-                                                                       } else if (inter_step == 2) {
-                                                                               startloc += 8;
-                                                                               intercount++;
-                                                                       } else if (inter_step == 3) {
-                                                                               startloc += 4;
-                                                                               intercount++;
-                                                                       } else if (inter_step == 4) {
-                                                                               startloc += 2;
-                                                                               intercount++;
-                                                                       }
-
-                                                                       if (startloc >= orghgt+image_top_pos) {
-                                                                               inter_step++;
-                                                                               if (inter_step == 2) {
-                                                                                       startloc = 4+image_top_pos;
-                                                                               } else if (inter_step == 3) {
-                                                                                       startloc = 2+image_top_pos;
-                                                                               } else if (inter_step == 4) {
-                                                                                       startloc = 1+image_top_pos;
-                                                                               }
-                                                                       }
-
-                                                                       backGround = (unsigned int *)(pFrameData->pPrevImg + ((startloc * logi_wdt) << 2));
-                                                                       /* gif to rgb 565 */
-                                                                       if (flag) {
-                                                                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
-                                                                       } else {
-                                                                               out_x = 0, out_y = startloc * dechgt;
-                                                                               a_x = logi_wdt >> 2;
-                                                                               b_x = ((logi_wdt*3) >> 2);
-                                                                               c_x = logi_wdt >> 2;
-                                                                               d_x = ((logi_wdt*3) >> 2);
-                                                                               if (out_y <= (logi_hgt >> 2)) {
-                                                                                       a_y = logi_hgt >> 2;
-                                                                                       b_y = logi_hgt >> 2;
-                                                                                       c_y = ((logi_hgt*3) >> 2);
-                                                                                       d_y = ((logi_hgt*3) >> 2);
-                                                                               } else {
-                                                                                       if (((out_y%logi_hgt) - (logi_hgt >> 2)) > 0) {
-                                                                                               a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
-                                                                                       } else if (((out_y%logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                                                               a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt >> 2);
-                                                                                       } else {
-                                                                                               a_y = out_y;
-                                                                                       }
-
-                                                                                       if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
-                                                                                               c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
-                                                                                       } else if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                                                               c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
-                                                                                       } else {
-                                                                                               c_y = out_y;
-                                                                                       }
-                                                                                       b_y = a_y, d_y = c_y;
-                                                                               }
-                                                                       }
-                                                               }
-
-                                                               if (transparent == 1) {
-                                                                       if (flag) {
-                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                               for (i = 0; i < len; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                       if (val1 == transIndex) {
-                                                                                               *pImage32++ = backGround[i+image_left_pos] << 2; /* Set *pImage32 MSB 1 */
-                                                                                       } else {
-                                                                                               *pImage32++ = pDacbox[val1] << 2;
-                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                       }
-                                                                               }
-                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                       } else {
-                                                                               if (c_y < end) {
-                                                                                       d1 = a_y - out_y;
-                                                                                       d2 = c_y - out_y;
-                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                               }
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       a_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       a_x += logi_wdt;
-                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       b_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       b_x += logi_wdt;
-                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                               }
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                               d1 = a_x - out_x;
-                                                                                               d2 = b_x - out_x;
-                                                                                               if (0 <= d1 && d1 < decwdt) {
-                                                                                                       *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                       a_x += logi_wdt;
-                                                                                               }
-                                                                                               if (0 <= d2 && d2 < decwdt) {
-                                                                                                       *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                       b_x += logi_wdt;
-                                                                                               }
-                                                                                               out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       c_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       c_x += logi_wdt;
-                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                               }
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               if (val1 == transIndex) {
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += backGround[i+image_left_pos];
-                                                                                                                       d_x += logi_wdt;
-                                                                                                               } else {
-                                                                                                                       *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                                       d_x += logi_wdt;
-                                                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                               }
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               } else {
-                                                                       if (flag) {
-                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                               for (i = 0; i < len; i++) {
-                                                                                       val1 = buf[i] & (numcolors-1);
-                                                                                       *pImage32++ = pDacbox[val1] << 2;
-                                                                                       backGround[i+image_left_pos] = pDacbox[val1];
-                                                                               }
-                                                                               for (i = orgwdt+image_left_pos; i < logi_wdt; i++) {
-                                                                                       *pImage32++ = backGround[i] << 2;
-                                                                               }
-                                                                       } else {
-                                                                               if (c_y < end) {
-                                                                                       d1 = a_y - out_y;
-                                                                                       d2 = c_y - out_y;
-                                                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               a_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               b_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = a_x - out_x;
-                                                                                                       d2 = b_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                                                               a_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                                                               b_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                                                                       b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                                                               }
-                                                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                                                               for (i = 0; i < image_left_pos; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = 0; i < orgwdt; i++) {
-                                                                                                       val1 = buf[i] & (numcolors-1);
-
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               c_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += pDacbox[val1];
-                                                                                                               d_x += logi_wdt;
-                                                                                                               backGround[i+image_left_pos] = pDacbox[val1];
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-                                                                                               }
-                                                                                               for (i = image_left_pos+orgwdt; i < logi_wdt; i++) {
-                                                                                                       d1 = c_x - out_x;
-                                                                                                       d2 = d_x - out_x;
-                                                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                                                               c_x += logi_wdt;
-                                                                                                       }
-                                                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                                                               d_x += logi_wdt;
-                                                                                                       }
-                                                                                                       out_x += decwdt;
-
-                                                                                               }
-                                                                                               if (!interLaced) {
-                                                                                                       c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                                                                       d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               }
-
-                                                               backGround += logi_wdt;
-                                                               bufptr = buf;
-                                                               bufcnt = orgwdt_1;
-                                                       }
-                                               }
-                                               if (rowcount == orghgt) {
-                                                       break;
-                                               }
-                                               /* __get_next_code(pInputStream) */
-                                               if (navail_bytes < 2) {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_first_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                       __get_next_code_first_while(pInputStream)
-                                               } else {
-                                                       if (nbits_left == 0)
-                                                               __get_next_code_second_nbits_left_0(pInputStream)
-                                                       else
-                                                               __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                       __get_next_code_second_while(pInputStream)
-                                               }
-                                                       if (c == ending) {
-                                                               break;
-                                                       }
-
-                                                       if (c == clear) {
-                                                               curr_size = size + 1;
-                                                               slot = newcodes;
-                                                               top_slot = 1 << curr_size;
-
-                                                               do {
-                                                                       /* __get_next_code(pInputStream); */
-                                                                       if (navail_bytes < 2) {
-                                                                               if (nbits_left == 0)
-                                                                                       __get_next_code_first_nbits_left_0(pInputStream)
-                                                                               else
-                                                                                       __get_next_code_first_nbits_left_not_0(pInputStream)
-                                                                               __get_next_code_first_while(pInputStream)
-                                                                       } else {
-                                                                               if (nbits_left == 0)
-                                                                                       __get_next_code_second_nbits_left_0(pInputStream)
-                                                                               else
-                                                                                       __get_next_code_second_nbits_left_not_0(pInputStream)
-
-                                                                               __get_next_code_second_while(pInputStream)
-                                                                       }
-                                                               } while (c == clear);
-
-                                                               if (c == ending) {
-                                                                       break;
-                                                               }
-
-                                                               if (c >= slot) {
-                                                                       c = 0;
-                                                               }
-
-                                                               oc = fc = c;
-
-                                                               *sp++ = (unsigned char)c;
-                                                       } else {
-                                                               code = c;
-
-                                                               if (code >= slot) {
-                                                                       code = oc;
-                                                                       *sp++ = (unsigned char)fc;
-                                                               }
-
-                                                               while (code >= newcodes) {
-                                                                       *sp++ = suffix[code];
-                                                                       code = prefix[code];
-                                                               }
-
-                                                               *sp++ = (unsigned char)code;
-                                                               spCount++;
-                                                               if (slot < top_slot) {
-                                                                       fc = code;
-                                                                       suffix[slot] = (unsigned char)fc;
-                                                                       prefix[slot++] = oc;
-                                                                       oc = c;
-                                                               }
-                                                               if (slot >= top_slot) {
-                                                                       if (curr_size < 12) {
-                                                                               top_slot <<= 1;
-                                                                               ++curr_size;
-                                                                       }
-                                                               }
-                                                       }
-                                       }
-
-                                       break;
-                       }
-
-                       if (interLaced) {
-                               startloc = orghgt+image_top_pos;
-                               pImage32 = (unsigned int *)(pDecBuf) + startloc * decwdt;
-                               if (!flag) {
-                                       out_x = 0, out_y = startloc * dechgt;
-                                       a_x = logi_wdt >> 2;
-                                       b_x = ((logi_wdt*3) >> 2);
-                                       c_x = logi_wdt >> 2;
-                                       d_x = ((logi_wdt*3) >> 2);
-                                       if (out_y <= (logi_hgt >> 2)) {
-                                               a_y = logi_hgt >> 2;
-                                               b_y = logi_hgt >> 2;
-                                               c_y = ((logi_hgt*3) >> 2);
-                                               d_y = ((logi_hgt*3) >> 2);
-                                       } else {
-                                               if (((out_y%logi_hgt) - (logi_hgt >> 2)) > 0) {
-                                                       a_y = ((out_y/logi_hgt)+1) * logi_hgt + (logi_hgt >> 2);
-                                               } else if (((out_y%logi_hgt) - (logi_hgt >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                       a_y = ((out_y/logi_hgt)) * logi_hgt + (logi_hgt >> 2);
-                                               } else {
-                                                       a_y = out_y;
-                                               }
-
-                                               if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) > 0) {
-                                                       c_y = ((out_y/logi_hgt+1) * logi_hgt + ((logi_hgt*3) >> 2));
-                                               } else if (((out_y%logi_hgt) - ((logi_hgt*3) >> 2)) < 0 || !(out_y%logi_hgt)) {
-                                                       c_y = ((out_y/logi_hgt)) * logi_hgt + ((logi_hgt*3) >> 2);
-                                               } else {
-                                                       c_y = out_y;
-                                               }
-                                               b_y = a_y, d_y = c_y;
-                                       }
-                               }
-                               out_y -= dechgt;
-                       }
-
-                               backGround = (unsigned int *)(pFrameData->pPrevImg + (((image_top_pos+orghgt) * logi_wdt) << 2));
-                               for (rowcount = image_top_pos+orghgt; rowcount < logi_hgt; rowcount++) {
-                                       if (flag) {
-                                               for (i = 0; i < logi_wdt; i++) {
-                                                       *pImage32++ = backGround[i] << 2;
-                                               }
-                                       } else {
-                                               out_x = 0, out_y += dechgt;
-                                               if (c_y < end) {
-                                                       d1 = a_y - out_y;
-                                                       d2 = c_y - out_y;
-                                                       if ((0 <= d1 && d1 < dechgt) && 0 <= d2 && d2 < dechgt) {
-                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                               for (i = 0; i < logi_wdt; i++) {
-                                                                       d1 = a_x - out_x;
-                                                                       d2 = b_x - out_x;
-                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                               a_x += logi_wdt, c_x += logi_wdt;
-                                                                       }
-                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                               b_x += logi_wdt, d_x += logi_wdt;
-                                                                       }
-                                                                       out_x += decwdt;
-                                                               }
-                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                       } else if (0 <= d1 && d1 < dechgt) {
-                                                               pImage32 = (unsigned int *)(pDecBuf) + (a_y/logi_hgt) * decwdt;
-                                                               for (i = 0; i < logi_wdt; i++) {
-                                                                       d1 = a_x - out_x;
-                                                                       d2 = b_x - out_x;
-                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                               *(pImage32 + (a_x/logi_wdt)) += backGround[i];
-                                                                               a_x += logi_wdt;
-                                                                       }
-                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                               *(pImage32 + (b_x/logi_wdt)) += backGround[i];
-                                                                               b_x += logi_wdt;
-                                                                       }
-                                                                       out_x += decwdt;
-                                                               }
-                                                               a_x = logi_wdt >> 2, a_y += logi_hgt;
-                                                               b_x = ((logi_wdt*3) >> 2), b_y += logi_hgt;
-                                                       } else if (0 <= d2 && d2 < dechgt) {
-                                                               pImage32_2 = (unsigned int *)(pDecBuf) + (c_y/logi_hgt) * decwdt;
-                                                               for (i = 0; i < logi_wdt; i++) {
-                                                                       d1 = c_x - out_x;
-                                                                       d2 = d_x - out_x;
-                                                                       if (0 <= d1 && d1 < decwdt) {
-                                                                               *(pImage32_2 + (c_x/logi_wdt)) += backGround[i];
-                                                                               c_x += logi_wdt;
-                                                                       }
-                                                                       if (0 <= d2 && d2 < decwdt) {
-                                                                               *(pImage32_2 + (d_x/logi_wdt)) += backGround[i];
-                                                                               d_x += logi_wdt;
-                                                                       }
-                                                                       out_x += decwdt;
-                                                               }
-                                                               c_x = logi_wdt >> 2, c_y += logi_hgt;
-                                                               d_x = ((logi_wdt*3) >> 2), d_y += logi_hgt;
-                                                       }
-                                               }
-                                       }
-                                       backGround += logi_wdt;
-                               }
-
-                               if (bCenterAlign) {
-                                       margin_wdt1_2 = (expected_width - resized_width) >> 1;
-                                       margin_hgt1_2 = (expected_height - resized_height) >> 1;
-                               } else {
-                                       margin_wdt1_2 = 0;
-                                       margin_hgt1_2 = 0;
-                               }
-
-
-                               /* 565 Conversion */
-                               pImage32 = (unsigned int *)(pDecBuf);
-
-                               for (i = 0, k = margin_hgt1_2; i < dechgt; i++) {
-                                       pImage16 = (unsigned short *)((unsigned char *)pOutBits + ((margin_wdt1_2 + (expected_width) * k) << 1));
-                                       for (j = 0; j < decwdt; j++) {
-                                               if ((*pImage32>>24) == 0) {
-                                                       *(pImage16++) = ((*pImage32 & 0xf80000) >> 8) | ((*pImage32 & 0xfc00) >> 5) | ((*pImage32 & 0xf8) >> 3);
-                                               } else if ((*pImage32 >> 24) == 1) {
-                                                       *(pImage16++) = (((*pImage32 & 0xf80000) >> 6) / 3) | (((*pImage32 & 0xfc00) >> 3)/3) | (((*pImage32 & 0xf8) >> 1)/3);
-                                               } else if ((*pImage32 >> 24) == 2) {
-                                                       *(pImage16++) = ((*pImage32 & 0xf80000) >> 7) | ((*pImage32 & 0xfc00) >> 4) | ((*pImage32 & 0xf8) >> 2);
-                                               } else {
-                                                       *(pImage16++) = ui_backcolor565;
-                                               }
-                                               pImage32++;
-                                       }
-                                       k++;
-                               }
-
-                               if (decoderline) {
-                                       IfegMemFree(decoderline);
-                                       decoderline = 0;
-                               }
-                               if (pDecBuf) {
-                                       IfegMemFree(pDecBuf);
-                                       pDecBuf = 0;
-                               }
-
-                               pFrameData->offset = inputPos;
-                               pFrameData->imgCount++;
-
-                               return 1;
-
-                               break;
-
-                               default:
-                                       break;
-
-               }
-       }
-}
diff --git a/src/codec/img-codec-osal.c b/src/codec/img-codec-osal.c
deleted file mode 100755 (executable)
index cefe59f..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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-debug.h"
-#include "img-codec-osal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-void *IfegMemAlloc(unsigned int size)
-{
-       void *pmem;
-       pmem = malloc(size);
-       return pmem;
-}
-
-void IfegMemFree(void *pMem)
-{
-       free(pMem);
-       pMem = 0;
-}
-
-void *IfegMemcpy(void *dest, const void *src, unsigned int count)
-{
-       return memcpy(dest, src, count);
-}
-
-void *IfegMemset(void *dest, int c, unsigned int count)
-{
-       return memset(dest, c, count);
-}
-
-ULONG IfegGetAvailableMemSize(void)
-{
-       return 1;
-}
-
-int IfegMemcmp(const void *pMem1, const void *pMem2, size_t length)
-{
-       return memcmp(pMem1, pMem2, length);
-}
-
-static BOOL _is_real_drm = FALSE;
-
-HFile DrmOpenFile(const char *szPathName)
-{
-       _is_real_drm = FALSE;
-
-       if (!_is_real_drm) {
-               FILE *fp = fopen(szPathName, "rb");
-
-               if (fp == NULL) {
-                       return (HFile) INVALID_HOBJ;
-                       thumb_err("file open error: %s", szPathName);
-               }
-
-               return fp;
-
-       } else {
-               return (HFile) INVALID_HOBJ;
-       }
-}
-
-BOOL DrmReadFile(HFile hFile, void *pBuffer, ULONG bufLen, ULONG * pReadLen)
-{
-       size_t readCnt = -1;
-
-       if (!_is_real_drm) {
-               readCnt = fread(pBuffer, sizeof(char), bufLen, hFile);
-               *pReadLen = (ULONG) readCnt;
-       } else {
-               return FALSE;
-       }
-       return TRUE;
-}
-
-long DrmTellFile(HFile hFile)
-{
-       if (!_is_real_drm) {
-               return ftell(hFile);
-       } else {
-               return -1;
-       }
-}
-
-BOOL DrmSeekFile(HFile hFile, long position, long offset)
-{
-       int ret = 0;
-
-       if (position < 0) {
-               return FALSE;
-       }
-       if (!_is_real_drm) {
-               ret = fseek(hFile, offset, position);
-               if (ret < 0) {
-                       thumb_stderror("fseek failed");
-                       return FALSE;
-               }
-       } else {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-BOOL DrmGetFileAttributes(const char *szPathName, FmFileAttribute * pFileAttr)
-{
-       FILE *f = NULL;
-
-       f = fopen(szPathName, "r");
-
-       if (f == NULL) {
-               return FALSE;
-       }
-
-       fseek(f, 0, SEEK_END);
-       pFileAttr->fileSize = ftell(f);
-       fclose(f);
-
-       return TRUE;
-}
-
-BOOL DrmCloseFile(HFile hFile)
-{
-       if (!_is_real_drm) {
-               fclose(hFile);
-       } else {
-               return FALSE;
-       }
-
-       return TRUE;
-}
index 498751a..182da69 100755 (executable)
  *
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include <media-util-err.h>
 #include "media-thumb-debug.h"
-#include "img-codec-common.h"
 #include "img-codec-parser.h"
 
-#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                WBMP_HEADER_LENGTH      2
-#define                TIFF_IMAGE_WIDTH        0x100
-#define                TIFF_IMAGE_HEIGHT       0x101
-
-#define                JPG_HEADER_TYPE_LENGTH 2
-#define                JPG_BLOCK_SIZE_LENGTH 2
-#define                JPG_IMAGE_SIZE_LENGTH 8
-
-#define                FILE_READ_SIZE          4096
-typedef struct _stream {
-       HFile fd;
-       unsigned int buffpos;
-       unsigned int filepos;
-       unsigned int filesize;
-       unsigned int buffend;
-       unsigned int debugpos;
-       unsigned char *buffer;
-} IFEGSTREAMCTRL;
-
 static unsigned char gIfegPNGHeader[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
 static unsigned char gIfegJPEGHeader[] = { 0xFF, 0xD8 };
 static unsigned char gIfegGIFHeader[] = { "GIF" };
 static unsigned char gIfegBMPHeader[] = { 0x42, 0x4D };
 static unsigned char gIfegWBMPHeader[] = { 0x00, 0x00 };
 
+void __ImgGetFileAttributes(const char *szPathName, unsigned long *pFileAttr)
+{
+       FILE *f = NULL;
+
+       f = fopen(szPathName, "r");
+       if (f != NULL) {
+               fseek(f, 0, SEEK_END);
+               *pFileAttr = ftell(f);
+               fclose(f);
+       }
+}
+
 static int _CheckBuffer(IFEGSTREAMCTRL *pIfegstreamctrl, unsigned int size)
 {
        unsigned long fileread;
 
        if ((size + pIfegstreamctrl->buffpos) > pIfegstreamctrl->buffend) {
-               if (pIfegstreamctrl->filepos == pIfegstreamctrl->filesize) {
-                       return 0;
-               }
+               if (pIfegstreamctrl->filepos == pIfegstreamctrl->filesize)
+                       return MS_MEDIA_ERR_INTERNAL;
 
                if (pIfegstreamctrl->buffpos == 0) {
-                       if (DrmReadFile(pIfegstreamctrl->fd, pIfegstreamctrl->buffer, FILE_READ_SIZE, &fileread) == FALSE) {
-                               return 0;
-                       }
-                       if (fileread == 0) {
-                               return 0;
-                       }
+                       fileread = fread(pIfegstreamctrl->buffer, sizeof(char), FILE_READ_SIZE, pIfegstreamctrl->fd);
+                       if (fileread == 0)
+                               return MS_MEDIA_ERR_INTERNAL;
+
                        pIfegstreamctrl->buffend = fileread;
                        pIfegstreamctrl->filepos += fileread;
                        pIfegstreamctrl->buffpos = 0;
                } else {
 
-                       if (size >= 2048 || pIfegstreamctrl->buffend - pIfegstreamctrl->buffpos > FILE_READ_SIZE) {
-                               return 0;
-                       }
-                       AcMemcpy(pIfegstreamctrl->buffer,
-                                &pIfegstreamctrl->buffer[pIfegstreamctrl->buffpos],
-                                pIfegstreamctrl->buffend -
-                                pIfegstreamctrl->buffpos);
-                       if (DrmReadFile(pIfegstreamctrl->fd, &pIfegstreamctrl->buffer[pIfegstreamctrl->buffend - pIfegstreamctrl->buffpos], pIfegstreamctrl->buffpos, &fileread) == FALSE) {
-                               return 0;
-                       }
-                       if (fileread == 0) {
-                               return 0;
-                       }
+                       if (size >= 2048 || pIfegstreamctrl->buffend - pIfegstreamctrl->buffpos > FILE_READ_SIZE)
+                               return MS_MEDIA_ERR_INTERNAL;
+
+                       memcpy(pIfegstreamctrl->buffer, &pIfegstreamctrl->buffer[pIfegstreamctrl->buffpos], pIfegstreamctrl->buffend - pIfegstreamctrl->buffpos);
+                       fileread = fread(&pIfegstreamctrl->buffer[pIfegstreamctrl->buffend - pIfegstreamctrl->buffpos], sizeof(char), pIfegstreamctrl->buffpos, pIfegstreamctrl->fd);
+                       if (fileread == 0)
+                               return MS_MEDIA_ERR_INTERNAL;
+
                        pIfegstreamctrl->buffend = pIfegstreamctrl->buffend - pIfegstreamctrl->buffpos + fileread;
                        pIfegstreamctrl->buffpos = 0;
                        pIfegstreamctrl->filepos += fileread;
                }
-               return 1;
+               return MS_MEDIA_ERR_NONE;
        }
-       return 2;
+       return MS_MEDIA_ERR_NONE;
 }
 
 static unsigned int _IfegReadUINT(unsigned char *pBuffer)
 {
-       return (((*pBuffer) << 24) | ((*(pBuffer + 1)) << 16) |
-               ((*(pBuffer + 2)) << 8) | (*(pBuffer + 3)));
+       return (((*pBuffer) << 24) | ((*(pBuffer + 1)) << 16) | ((*(pBuffer + 2)) << 8) | (*(pBuffer + 3)));
 }
 
-static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt, ImgCodecType *type, unsigned int *width, unsigned int *height, bool fast_mode)
+static int _ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt, ImgCodecType *type, unsigned int *width, unsigned int *height)
 {
        unsigned int fileleft;
        unsigned long fileread;
@@ -130,107 +102,84 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                *pHeight = 0;
        }
 
-       AcMemset(EncodedDataBuffer, 0, 4096);
+       memset(EncodedDataBuffer, 0, 4096);
 
-       SysAssert((const char *)&fileSize);
-
-       if (DrmReadFile(hFile, EncodedDataBuffer, 8, &fileread) == FALSE) {
-               thumb_err("DrmReadFile was failed");
-               return MS_MEDIA_ERR_FILE_READ_FAIL;
-       }
+       fileread = fread(EncodedDataBuffer, sizeof(char), 8, hFile);
        if (fileread < MINIMUM_HEADER_BYTES) {
                thumb_warn("IMG_CODEC_UNKNOWN_TYPE");
                return ret;
        }
 
-       if (AcMemcmp(EncodedDataBuffer, gIfegJPEGHeader, JPG_HEADER_LENGTH) == 0) {
-               if (fast_mode == FALSE) {
-                       unsigned char header_type[JPG_HEADER_TYPE_LENGTH];
-                       unsigned char block_size[JPG_BLOCK_SIZE_LENGTH];
-                       unsigned char image_size[JPG_IMAGE_SIZE_LENGTH];
+       if (memcmp(EncodedDataBuffer, gIfegJPEGHeader, JPG_HEADER_LENGTH) == 0) {
+               unsigned char header_type[JPG_HEADER_TYPE_LENGTH];
+               unsigned char block_size[JPG_BLOCK_SIZE_LENGTH];
+               unsigned char image_size[JPG_IMAGE_SIZE_LENGTH];
 
-                       rewind(hFile);
+               rewind(hFile);
 
-                       unsigned short block_length = EncodedDataBuffer[4] * 256 + EncodedDataBuffer[5];
-                       thumb_dbg("block length : %d", block_length);
-                       unsigned int i = 4;
+               unsigned short block_length = EncodedDataBuffer[4] * 256 + EncodedDataBuffer[5];
+               thumb_dbg("block length : %d", block_length);
+               unsigned int i = 4;
 
-                       if (DrmSeekFile(hFile, SEEK_CUR, block_length+4) == FALSE) {
-                               thumb_err("DrmSeekFile was failed");
-                               return MS_MEDIA_ERR_FILE_READ_FAIL;
-                       }
-
-                       while (i < fileSize) {
-                               i += block_length;
-                               if (i >= fileSize) {
-                                       thumb_warn("Failed to get w / h from jpeg at index [%d]", i);
-                                       break;
-                               }
+               if (fseek(hFile, block_length + 4, SEEK_CUR) < 0) {
+                       thumb_err("fseek was failed");
+                       return MS_MEDIA_ERR_FILE_READ_FAIL;
+               }
 
-                               AcMemset(header_type, 0, JPG_HEADER_TYPE_LENGTH);
-                               if (DrmReadFile(hFile, header_type, (ULONG)JPG_HEADER_TYPE_LENGTH, &fileread) == FALSE) {
-                                       thumb_err("DrmReadFile was failed");
-                                       return MS_MEDIA_ERR_FILE_READ_FAIL;
-                               }
+               while (i < fileSize) {
+                       i += block_length;
+                       if (i >= fileSize) {
+                               thumb_warn("Failed to get w / h from jpeg at index [%d]", i);
+                               break;
+                       }
 
-                               if (header_type[0] != 0xFF) {
-                                       thumb_warn("Failed to get w / h from jpeg at index [%d]", i);
-                                       break;
-                               }
+                       memset(header_type, 0, JPG_HEADER_TYPE_LENGTH);
+                       fileread = fread(header_type, sizeof(char), JPG_HEADER_TYPE_LENGTH, hFile);
 
-                               if (header_type[1] == 0xC0 || header_type[1] == 0xC2) {
-                                       AcMemset(image_size, 0, JPG_IMAGE_SIZE_LENGTH);
-                                       if (DrmReadFile(hFile, image_size, (ULONG)JPG_IMAGE_SIZE_LENGTH, &fileread) == FALSE) {
-                                               thumb_err("DrmReadFile was failed");
-                                               return MS_MEDIA_ERR_FILE_READ_FAIL;
-                                       }
+                       if (header_type[0] != 0xFF) {
+                               thumb_warn("Failed to get w / h from jpeg at index [%d]", i);
+                               break;
+                       }
 
-                                       *pWidth = image_size[5] * 256 + image_size[6];
-                                       *pHeight = image_size[3] * 256 + image_size[4];
-                                       break;
-                               } else {
-                                       i += 2;
-                                       AcMemset(block_size, 0, JPG_BLOCK_SIZE_LENGTH);
-                                       if (DrmReadFile(hFile, block_size, (ULONG)JPG_BLOCK_SIZE_LENGTH, &fileread) == FALSE) {
-                                               thumb_err("DrmReadFile was failed");
-                                               return MS_MEDIA_ERR_FILE_READ_FAIL;
-                                       }
+                       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);
 
-                                       block_length = block_size[0] * 256 + block_size[1];
-                                       thumb_dbg("new block length : %d", block_length);
-                                       if (DrmSeekFile(hFile, SEEK_CUR, block_length-JPG_BLOCK_SIZE_LENGTH) == FALSE) {
-                                               thumb_err("DrmSeekFile was failed");
-                                               return MS_MEDIA_ERR_FILE_READ_FAIL;
-                                       }
+                               *pWidth = image_size[5] * 256 + image_size[6];
+                               *pHeight = image_size[3] * 256 + image_size[4];
+                               break;
+                       } else {
+                               i += 2;
+                               memset(block_size, 0, JPG_BLOCK_SIZE_LENGTH);
+                               fileread = fread(block_size, sizeof(char), JPG_BLOCK_SIZE_LENGTH, hFile);
+                               block_length = block_size[0] * 256 + block_size[1];
+                               thumb_dbg("new block length : %d", block_length);
+
+                               if (fseek(hFile, block_length-JPG_BLOCK_SIZE_LENGTH, SEEK_CUR) < 0) {
+                                       thumb_err("fseek was failed");
+                                       return MS_MEDIA_ERR_FILE_READ_FAIL;
                                }
                        }
-                       thumb_dbg("Jpeg w: %d, h: %d", *pWidth, *pHeight);
                }
-               thumb_dbg("IMG_CODEC_JPEG");
+               thumb_dbg("IMG_CODEC_JPEG : W[%d] H[%d]", *pWidth, *pHeight);
                *type = IMG_CODEC_JPEG;
        }
        /*********************** PNG *************************/
-       else if (AcMemcmp(EncodedDataBuffer, gIfegPNGHeader, PNG_HEADER_LENGTH) == 0) {
+       else if (memcmp(EncodedDataBuffer, gIfegPNGHeader, PNG_HEADER_LENGTH) == 0) {
                unsigned char tmp;
 
-               if (DrmReadFile(hFile, EncodedDataBuffer, 32, &fileread) ==
-                       FALSE) {
-                       thumb_err("DrmReadFile was failed");
-                       return MS_MEDIA_ERR_FILE_READ_FAIL;
-               }
+               fileread = fread(EncodedDataBuffer, sizeof(char), 32, hFile);
                if (fileread < 32) {
                        thumb_warn("IMG_CODEC_UNKNOWN_TYPE in PNG");
                        return ret;
                }
                /* Get Image Width */
-               if (pWidth) {
+               if (pWidth)
                        *pWidth = _IfegReadUINT((EncodedDataBuffer + 8));
-               }
 
                /* Get Image Height */
-               if (pHeight) {
+               if (pHeight)
                        *pHeight = _IfegReadUINT((EncodedDataBuffer + 12));
-               }
 
                /* Read Interlace byte */
                tmp = *(EncodedDataBuffer + 20);
@@ -242,12 +191,9 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                *type = IMG_CODEC_PNG;
        }
        /*********************** BMP *************************/
-       else if (AcMemcmp(EncodedDataBuffer, gIfegBMPHeader, BMP_HEADER_LENGTH) == 0) {
+       else if (memcmp(EncodedDataBuffer, gIfegBMPHeader, BMP_HEADER_LENGTH) == 0) {
                /* Parse BMP File and get image width and image height */
-               if (DrmReadFile(hFile, &EncodedDataBuffer[8], 18, &fileread) == FALSE) {
-                       thumb_err("DrmReadFile was failed");
-                       return MS_MEDIA_ERR_FILE_READ_FAIL;
-               }
+               fileread = fread(&EncodedDataBuffer[8], sizeof(char), 18, hFile);
                if (fileread < 18) {
                        thumb_warn("IMG_CODEC_UNKNOWN_TYPE in BMP");
                        return ret;
@@ -267,7 +213,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                *type = IMG_CODEC_BMP;
        }
        /*********************** GIF *************************/
-       else if (AcMemcmp(EncodedDataBuffer, gIfegGIFHeader, GIF_HEADER_LENGTH) == 0) {
+       else if (memcmp(EncodedDataBuffer, gIfegGIFHeader, GIF_HEADER_LENGTH) == 0) {
                unsigned int tablelength = 0;
                unsigned int imagecount = 0;
                int finished = 0;
@@ -280,10 +226,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                        return ret;
                }
 
-               if (DrmReadFile(hFile, &EncodedDataBuffer[8], 5, &fileread) == FALSE) {
-                       thumb_err("DrmReadFile was failed");
-                       return MS_MEDIA_ERR_FILE_READ_FAIL;
-               }
+               fileread = fread(&EncodedDataBuffer[8], sizeof(char), 5, hFile);
                if (fileread < 5) {
                        thumb_warn("IMG_CODEC_UNKNOWN_TYPE in GIF");
                        return ret;
@@ -317,10 +260,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                return ret;
                        }
                        /* coverity[ -tainted_data_argument : EncodedDataBuffer ] */
-                       if (DrmReadFile(hFile, EncodedDataBuffer, tablelength, &fileread) == FALSE) {
-                               thumb_err("DrmReadFile was failed");
-                               return MS_MEDIA_ERR_FILE_READ_FAIL;
-                       }
+                       fileread = fread(EncodedDataBuffer, sizeof(char), tablelength, hFile);
                        if (fileread < tablelength) {
                                thumb_warn("IMG_CODEC_UNKNOWN_TYPE in GIF");
                                return ret;
@@ -339,7 +279,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                while (!finished) {
                        if (ifegstreamctrl.buffpos > ifegstreamctrl.buffend)
                                break;
-                       if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                       if (_CheckBuffer(&ifegstreamctrl, 1) != MS_MEDIA_ERR_NONE) {
                                thumb_warn("_CheckBuffer was failed");
                                return ret;
                        }
@@ -351,7 +291,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                break;
 
                        case 0x21:      /* Extension Block */
-                               if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                               if (_CheckBuffer(&ifegstreamctrl, 1) != MS_MEDIA_ERR_NONE) {
                                        thumb_warn("_CheckBuffer was failed");
                                        return ret;
                                }
@@ -359,7 +299,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                switch (EncodedDataBuffer[ifegstreamctrl.buffpos++]) {
 
                                case 0xf9:      /* Graphic control extension block */
-                                       if (_CheckBuffer(&ifegstreamctrl, 6) == 0) {
+                                       if (_CheckBuffer(&ifegstreamctrl, 6) != MS_MEDIA_ERR_NONE) {
                                                thumb_warn("_CheckBuffer was failed");
                                                return ret;
                                        }
@@ -374,7 +314,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                case 0x01:      /* Plain Text block */
                                case 0xfe:      /* Comment Extension block */
                                case 0xff:      /* Appliation Extension block */
-                                       if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                                       if (_CheckBuffer(&ifegstreamctrl, 1) != MS_MEDIA_ERR_NONE) {
                                                thumb_warn("_CheckBuffer was failed");
                                                return ret;
                                        }
@@ -386,7 +326,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
 
                                        while ((ifegstreamctrl.buffpos < sizeof(EncodedDataBuffer))
                                                && ((length = EncodedDataBuffer[ifegstreamctrl.buffpos++]) > 0)) {      /* get the data length */
-                                               if (_CheckBuffer(&ifegstreamctrl, length) == 0) {
+                                               if (_CheckBuffer(&ifegstreamctrl, length) != MS_MEDIA_ERR_NONE) {
                                                        thumb_warn("_CheckBuffer was failed");
                                                        return ret;
                                                }
@@ -410,7 +350,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
 
                        case 0x2c:      /* Start of an image object. Read the image description. */
 
-                               if (_CheckBuffer(&ifegstreamctrl, 9) == 0) {
+                               if (_CheckBuffer(&ifegstreamctrl, 9) != MS_MEDIA_ERR_NONE) {
                                        thumb_warn("_CheckBuffer was failed");
                                        return ret;
                                }
@@ -431,7 +371,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                if ((EncodedDataBuffer[ifegstreamctrl.buffpos + 8] & 0x80) != 0) {      /* Logical color table */
                                        temp = (EncodedDataBuffer[ifegstreamctrl.buffpos + 8] & 0x7) + 1;
                                        length = (1 << temp) * 3;
-                                       if (_CheckBuffer(&ifegstreamctrl, length + 9) == 0) {
+                                       if (_CheckBuffer(&ifegstreamctrl, length + 9) != MS_MEDIA_ERR_NONE) {
                                                thumb_warn("_CheckBuffer was failed");
                                                return ret;
                                        }
@@ -442,7 +382,7 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
 
                                ifegstreamctrl.buffpos += 9;
 
-                               if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                               if (_CheckBuffer(&ifegstreamctrl, 1) != MS_MEDIA_ERR_NONE) {
                                        thumb_warn("_CheckBuffer was failed");
                                        return ret;
                                }
@@ -453,18 +393,15 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                }
 
                                do {
-                                       if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
+                                       if (_CheckBuffer(&ifegstreamctrl, 1) != MS_MEDIA_ERR_NONE) {
                                                thumb_warn("_CheckBuffer was failed");
                                                return ret;
                                        }
 
                                        length = EncodedDataBuffer[ifegstreamctrl.buffpos++];
                                        if ((length + ifegstreamctrl.buffpos) > ifegstreamctrl.buffend) {
-                                               length =
-                                                       length +
-                                                       ifegstreamctrl.buffpos -
-                                                       ifegstreamctrl.buffend;
-                                               if (DrmSeekFile(ifegstreamctrl.fd, SEEK_CUR, length) == FALSE) {
+                                               length = length + ifegstreamctrl.buffpos - ifegstreamctrl.buffend;
+                                               if (fseek(ifegstreamctrl.fd, length, SEEK_CUR) < 0) {
                                                        if (imagecount) {
                                                                thumb_dbg("IMG_CODEC_AGIF");
                                                                *type = IMG_CODEC_AGIF;
@@ -500,26 +437,15 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                *type = IMG_CODEC_GIF;
        }
        /*********************** WBMP *************************/
-       else if ((AcMemcmp(EncodedDataBuffer, gIfegWBMPHeader, WBMP_HEADER_LENGTH) == 0)
-               && (strcasecmp(fileExt, "wbmp") == 0)) {
+       else if ((memcmp(EncodedDataBuffer, gIfegWBMPHeader, WBMP_HEADER_LENGTH) == 0) && (strcasecmp(fileExt, "wbmp") == 0)) {
                /* Parse BMP File and get image width and image height */
-/*             if (DrmReadFile(hFile, &EncodedDataBuffer[2], 2, &fileread) == FALSE) {
-                       thumb_err("DrmReadFile was failed");
-                       return MS_MEDIA_ERR_FILE_READ_FAIL;
-               }
-               if (fileread < 2) {
-                       thumb_warn("IMG_CODEC_UNKNOWN_TYPE in WBMP");
-                       return ret;
-               }*/
-               if (pWidth) {
+               if (pWidth)
                        *pWidth = EncodedDataBuffer[2];
-               }
-               if (pHeight) {
+
+               if (pHeight)
                        *pHeight = EncodedDataBuffer[3];
-               }
-               thumb_dbg("WBMP w: %d, h: %d", *pWidth, *pHeight);
 
-               thumb_dbg("IMG_CODEC_WBMP");
+               thumb_dbg("IMG_CODEC_WBMP W[%d] H[%d]", *pWidth, *pHeight);
                *type = IMG_CODEC_WBMP;
        }
        return ret;
@@ -532,86 +458,48 @@ static int _ImgGetFileExt(const char *file_path, char *file_ext, int max_len)
        for (i = (int)strlen(file_path); i >= 0; i--) {
                if ((file_path[i] == '.') && (i < (int)strlen(file_path))) {
                        strncpy(file_ext, &file_path[i + 1], max_len);
-                       return 0;
+                       return MS_MEDIA_ERR_NONE;
                }
 
                /* meet the dir. no ext */
-               if (file_path[i] == '/') {
-                       return -1;
-               }
+               if (file_path[i] == '/')
+                       return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       return -1;
+       return MS_MEDIA_ERR_INVALID_PARAMETER;
 }
 
 int ImgGetImageInfo(const char *filePath, ImgCodecType *type, unsigned int *width, unsigned int *height)
 {
-       HFile hFile;
-       FmFileAttribute fileAttrib;
-       char file_ext[10] = {0,};
-       int err, ret = 0;
-
-       SysAssert(filePath);
-       hFile = DrmOpenFile(filePath);
-
-       if (hFile == (HFile) INVALID_HOBJ) {
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       DrmGetFileAttributes(filePath, &fileAttrib);
+       FILE *hFile;
+       unsigned long file_size = 0;
+       char file_ext[10] = { 0, };
+       int ret = 0;
 
-       if ((fileAttrib.fileSize == 0)) {
-               DrmCloseFile(hFile);
+       if (filePath == NULL)
                return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       err = _ImgGetFileExt(filePath, file_ext, sizeof(file_ext));
-       if (err < 0) {
-               thumb_warn("_media_thumb_get_file_ext failed");
-       }
-
-       ret = _ImgGetImageInfo(hFile, fileAttrib.fileSize, file_ext, type, width, height, FALSE);
-
-       DrmSeekFile(hFile, SEEK_SET, 0);
-
-       DrmCloseFile(hFile);
-
-       return ret;
-
-}
-
-int ImgGetImageInfoForThumb(const char *filePath, ImgCodecType *type, unsigned int *width, unsigned int *height)
-{
-       HFile hFile;
-       FmFileAttribute fileAttrib;
-       char file_ext[10] = {0,};
-       int err, ret = 0;
 
-       SysAssert(filePath);
-       hFile = DrmOpenFile(filePath);
-
-       if (hFile == (HFile) INVALID_HOBJ) {
+       hFile = fopen(filePath, "rb");
+       if (hFile == NULL) {
+               thumb_err("file open error: %s", filePath);
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       DrmGetFileAttributes(filePath, &fileAttrib);
-
-       if ((fileAttrib.fileSize == 0)) {
-               DrmCloseFile(hFile);
+       __ImgGetFileAttributes(filePath, &file_size);
+       if (file_size == 0) {
+               fclose(hFile);
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       err = _ImgGetFileExt(filePath, file_ext, sizeof(file_ext));
-       if (err < 0) {
+       ret = _ImgGetFileExt(filePath, file_ext, sizeof(file_ext));
+       if (ret != MS_MEDIA_ERR_NONE) {
                thumb_warn("_media_thumb_get_file_ext failed");
-       };
-
-       ret = _ImgGetImageInfo(hFile, fileAttrib.fileSize, file_ext, type, width, height, FALSE);
+       }
 
-       DrmSeekFile(hFile, SEEK_SET, 0);
+       ret = _ImgGetImageInfo(hFile, file_size, file_ext, type, width, height);
 
-       DrmCloseFile(hFile);
+       fseek(hFile, 0, SEEK_SET);
+       fclose(hFile);
 
        return ret;
-
 }
diff --git a/src/codec/img-codec.c b/src/codec/img-codec.c
deleted file mode 100755 (executable)
index bebe05b..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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-debug.h"
-#include "media-thumb-util.h"
-#include "img-codec.h"
-#include <string.h>
-#include <image_util.h>
-
-unsigned int *ImgGetFirstFrameAGIFAtSize(const char *szFileName,
-                                        unsigned int width, unsigned int height)
-{
-       AGifFrameInfo *pFrameInfo = 0;
-       void *pDecodedRGB888Buf = 0;
-       unsigned char *raw_data = NULL;
-
-       if (szFileName == NULL) {
-               thumb_err("ImgGetFirstFrameAGIFAtSize: Input File Name is NULL");
-               return NULL;
-       }
-
-       if (width == 0 || height == 0) {
-               thumb_err("ImgGetFirstFrameAGIFAtSize: Input width or height is zero");
-               return NULL;
-       }
-
-       pFrameInfo = ImgCreateAGIFFrame(szFileName, width, height, 0, FALSE);
-
-       if (pFrameInfo && pFrameInfo->pOutBits) {
-               ImgGetNextAGIFFrame(pFrameInfo, TRUE);
-
-               if (ImgConvertRGB565ToRGB888(pFrameInfo->pOutBits, &pDecodedRGB888Buf, pFrameInfo->width, pFrameInfo->height)) {
-                       if (pDecodedRGB888Buf) {
-                               SAFE_FREE(pFrameInfo->pOutBits);
-                               pFrameInfo->pOutBits = pDecodedRGB888Buf;
-                               unsigned char *src = ((unsigned char *)(pFrameInfo->pOutBits));
-
-                               unsigned int i = 0;
-
-                               if (image_util_calculate_buffer_size(width, height, IMAGE_UTIL_COLORSPACE_RGB888, &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--) {
-                                       if (dest != NULL) {
-                                               *dest = *((unsigned char *)(src));
-                                               dest++;
-                                               src++;
-                                       }
-                               }
-                       }
-               }
-       } else {
-               thumb_warn("ImgDecodeAGIFToPixbufFromFile :: Error");
-       }
-
-       if (pFrameInfo) {
-               ImgDestroyAGIFFrame(pFrameInfo);
-       }
-
-       return (unsigned int *)raw_data;
-}
-
-int ImgConvertRGB565ToRGB888(void *pBuf_rgb565, void **pBuf_rgb888, int width, int height)
-{
-       unsigned short *rgb565buf = 0;
-       unsigned char *rgb888Buf = 0;
-       unsigned char red, green, blue;
-       int i;
-       unsigned int size;
-
-       rgb565buf = (unsigned short *)pBuf_rgb565;
-       if (rgb565buf == NULL) {
-               thumb_err("rgb565buf is NULL: Error !!!");
-               return FALSE;
-       }
-
-       if (image_util_calculate_buffer_size(width, height, IMAGE_UTIL_COLORSPACE_RGB888, &size) < 0) {
-               thumb_err("ImgGetFirstFrameAGIFAtSize: Failed to get buffer size");
-               return FALSE;
-       }
-
-       rgb888Buf = (unsigned char *)malloc(size);
-
-       if (rgb888Buf == NULL) {
-               thumb_err("rgb888Buf is NULL: Error !!!");
-               return FALSE;
-       }
-
-       memset(rgb888Buf, 0, size);
-
-       for (i = 0; i < width * height; i++) {
-               red = ((rgb565buf[i] >> 11) & 0x1F) << 3;
-               green = ((rgb565buf[i] >> 5) & 0x3F) << 2;
-               blue = (rgb565buf[i] & 0x1F) << 3;
-               rgb888Buf[3 * i] = red;
-               rgb888Buf[3 * i + 1] = green;
-               rgb888Buf[3 * i + 2] = blue;
-       }
-
-       *pBuf_rgb888 = (void *)rgb888Buf;
-
-       return TRUE;
-}
-
-AGifFrameInfo *ImgCreateAGIFFrame(const char *szFileName, unsigned int width, unsigned int height, unsigned int bgColor, BOOL bLoop)
-{
-       HFile hFile;
-       FmFileAttribute fileAttrib;
-       unsigned long size;
-       unsigned char *pEncodedData = NULL;
-       int cFileSize;
-       int mem_alloc_size;
-
-       if (szFileName == NULL) {
-               thumb_err("Input File Name is NULL");
-               return FALSE;
-       }
-
-       hFile = DrmOpenFile(szFileName);
-       if (hFile == (HFile) INVALID_HOBJ) {
-               thumb_err("ImgCreateAGIFFrame: Cannot open file");
-               return NULL;
-       }
-
-       DrmGetFileAttributes(szFileName, &fileAttrib);
-
-       if (fileAttrib.fileSize <= 0) {
-               thumb_err("Zero or below Zero File Size");
-               DrmCloseFile(hFile);
-               return NULL;
-       }
-
-       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 = cFileSize;
-       pEncodedData = (unsigned char *)malloc(mem_alloc_size);
-       if (pEncodedData == 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");
-               DrmCloseFile(hFile);
-               SAFE_FREE(pEncodedData);
-
-               return NULL;
-       }
-
-       thumb_dbg("ImgCreateAGIFFrame: file (%s) read...", szFileName);
-
-       DrmCloseFile(hFile);
-
-       return FastImgCreateAGIFFrameData(width, height, pEncodedData, cFileSize, bgColor, bLoop);
-}
-
-void ImgDestroyAGIFFrame(AGifFrameInfo *pFrameData)
-{
-       SysAssert(pFrameData);
-
-       FastImgDestroyAGIFFrameData(pFrameData);
-}
-
-ImgFastCodecInfo ImgGetNextAGIFFrame(AGifFrameInfo *gFrameData, BOOL bCenterAlign)
-{
-       int iResult;
-
-       if (gFrameData == NULL) {
-               thumb_err("Input gFrameData is NULL");
-               return IMG_INFO_DECODING_FAIL;
-       }
-
-       iResult = FastImgGetNextFrameAGIF(gFrameData, bCenterAlign);
-
-       if (iResult == 1) {
-               return IMG_INFO_DECODING_SUCCESS;
-       } else if (iResult == 2) {
-               return IMG_INFO_AGIF_LAST_FRAME;
-       } else {
-               return IMG_INFO_DECODING_FAIL;
-       }
-
-}
diff --git a/src/include/codec/AGifFrameInfo.h b/src/include/codec/AGifFrameInfo.h
deleted file mode 100755 (executable)
index e5ab7b1..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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
-       int nRepeatCount;
-       int nLoopCount;
-
-       unsigned char bOneFrame;
-#endif
-} AGifFrameInfo;
-
-#endif  //  _AGIFFRAMEINFO_H_
diff --git a/src/include/codec/IfegDecodeAGIF.h b/src/include/codec/IfegDecodeAGIF.h
deleted file mode 100755 (executable)
index 3504ff6..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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
deleted file mode 100644 (file)
index 4480bd8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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
deleted file mode 100755 (executable)
index 91c01b4..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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)
-
-//////////////////////////////////////////////////////////////
-#if 0
-#define ImgDebug(type, fmt, arg...)    \
-       do { \
-               fprintf(stderr, "[Media-SVC]"fmt, ##arg);       \
-       } while (0)
-
-
-#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 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
deleted file mode 100755 (executable)
index 7b49c56..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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
deleted file mode 100755 (executable)
index 68bcc5d..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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_
-
index 550db1b..1682d84 100755 (executable)
 #ifndef _IMGCODEC_PARSER_H_
 #define _IMGCODEC_PARSER_H_
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -31,11 +36,14 @@ extern "C" {
 #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                WBMP_HEADER_LENGTH      2
-#define                TIFF_IMAGE_WIDTH        0x100
-#define                TIFF_IMAGE_HEIGHT       0x101
+
+#define                JPG_HEADER_TYPE_LENGTH 2
+#define                JPG_BLOCK_SIZE_LENGTH 2
+#define                JPG_IMAGE_SIZE_LENGTH 8
+
+#define                FILE_READ_SIZE          4096
 
 typedef enum {
        IMG_CODEC_UNKNOWN_TYPE                  = -2,
@@ -52,9 +60,17 @@ typedef enum {
        IMG_CODEC_DRM                                   = (1 << 8),
 }  ImgCodecType;
 
-//ImgCodecType ImgGetInfoFile(const char*filePath, ImgImageInfo *imgInfo);
+typedef struct _stream {
+       FILE *fd;
+       unsigned int buffpos;
+       unsigned int filepos;
+       unsigned int filesize;
+       unsigned int buffend;
+       unsigned int debugpos;
+       unsigned char *buffer;
+} IFEGSTREAMCTRL;
+
 int ImgGetImageInfo(const char *filePath, ImgCodecType *type, unsigned int *width, unsigned int *height);
-int ImgGetImageInfoForThumb(const char *filePath, ImgCodecType *type, unsigned int *width, unsigned int *height);
 
 #ifdef __cplusplus
 }
diff --git a/src/include/codec/img-codec.h b/src/include/codec/img-codec.h
deleted file mode 100755 (executable)
index 2af624a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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, unsigned int width, unsigned int height);
-
-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_
index 82deeb0..b88ae4f 100755 (executable)
                LOGW(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
                } while (0)
 
+#define thumb_info(fmt, arg...) do { \
+               LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
+               } while (0)
+
 #define thumb_err(fmt, arg...) do { \
                 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
                } while (0)
index a166bcb..5b7b954 100755 (executable)
@@ -39,7 +39,6 @@ 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);
 
 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, uid_t uid);
 
 int _media_thumb_remove_file(const char *path);
 
index ae46eeb..693293a 100755 (executable)
 #include "media-thumb-internal.h"
 #include "media-thumb-ipc.h"
 
-#include "AGifFrameInfo.h"
-#include "IfegDecodeAGIF.h"
-#include "img-codec.h"
-#include "img-codec-agif.h"
-#include "img-codec-common.h"
-#include "img-codec-osal.h"
 #include "img-codec-parser.h"
 
 #include <sys/types.h>
 
 int _media_thumb_get_proper_thumb_size(int orig_w, int orig_h, int *thumb_w, int *thumb_h)
 {
-       BOOL portrait = FALSE;
+       bool portrait = false;
        double ratio;
 
-       if (orig_w < orig_h) {
-               portrait = TRUE;
-       }
+       if (orig_w < orig_h)
+               portrait = true;
 
        /* Set smaller length to default size */
        if (portrait) {
@@ -105,9 +98,10 @@ int _media_thumb_image(const char *origin_path, char *thumb_path, int thumb_widt
        unsigned int origin_w = 0;
        unsigned int origin_h = 0;
 
-       err = ImgGetImageInfoForThumb(origin_path, &image_type, &origin_w, &origin_h);
+       err = ImgGetImageInfo(origin_path, &image_type, &origin_w, &origin_h);
        if (err != MS_MEDIA_ERR_NONE) {
                thumb_warn("Getting image info is failed err: %d", err);
+               return MS_MEDIA_ERR_INTERNAL;
        }
 
        if ((image_type != IMG_CODEC_JPEG) && (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
@@ -174,15 +168,14 @@ int _media_thumb_video(const char *origin_path, const char *thumb_path, int thum
                        if (p == NULL) {
                                rot_type = MM_UTIL_ROTATE_0;
                        } else {
-                               if (strncmp(p, "90", size) == 0) {
+                               if (strncmp(p, "90", size) == 0)
                                        rot_type = MM_UTIL_ROTATE_90;
-                               } else if (strncmp(p, "180", size) == 0) {
+                               else if (strncmp(p, "180", size) == 0)
                                        rot_type = MM_UTIL_ROTATE_180;
-                               } else if (strncmp(p, "270", size) == 0) {
+                               else if (strncmp(p, "270", size) == 0)
                                        rot_type = MM_UTIL_ROTATE_270;
-                               } else {
+                               else
                                        rot_type = MM_UTIL_ROTATE_0;
-                               }
                        }
                        thumb_dbg("There is tag rotate : %d", rot_type);
                } else {
@@ -196,7 +189,6 @@ int _media_thumb_video(const char *origin_path, const char *thumb_path, int thum
                        cdis_value = 0;
                        SAFE_FREE(err_msg);
                }
-
        } else {
                rot_type = MM_UTIL_ROTATE_0;
                cdis_value = 0;
index 2fb3065..554988b 100755 (executable)
@@ -36,7 +36,7 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+       if (!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR)) {
                        thumb_err("Original path(%s) doesn't exist.", origin_path);
                        return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
@@ -75,9 +75,9 @@ int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
-                       thumb_err("Original path(%s) doesn't exist.", origin_path);
-                       return MS_MEDIA_ERR_INVALID_PARAMETER;
+       if (!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR)) {
+               thumb_err("Original path(%s) doesn't exist.", origin_path);
+               return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
        ms_user_storage_type_e store_type = -1;