< prev index next >

lib/dgif_lib.c

Print this page


























   1 /******************************************************************************
   2 
   3 dgif_lib.c - GIF decoding
   4 
   5 The functions here and in egif_lib.c are partitioned carefully so that
   6 if you only require one of read and write capability, only one of these
   7 two modules will be linked.  Preserve this property!
   8 
   9 *****************************************************************************/
  10 
  11 #include <stdlib.h>
  12 #include <limits.h>
  13 #include <stdint.h>
  14 #include <fcntl.h>
  15 #include <unistd.h>
  16 #include <stdio.h>
  17 #include <string.h>
  18 
  19 #ifdef _WIN32
  20 #include <io.h>


  21 #endif /* _WIN32 */
  22 
  23 #include "gif_lib.h"
  24 #include "gif_lib_private.h"
  25 
  26 /* compose unsigned little endian value */
  27 #define UNSIGNED_LITTLE_ENDIAN(lo, hi)  ((lo) | ((hi) << 8))
  28 
  29 /* avoid extra function call in case we use fread (TVT) */
  30 #define READ(_gif,_buf,_len)                                     \
  31   (((GifFilePrivateType*)_gif->Private)->Read ?                   \
  32     ((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \
  33     fread(_buf,1,_len,((GifFilePrivateType*)_gif->Private)->File))
  34 
  35 static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
  36 static int DGifSetupDecompress(GifFileType *GifFile);
  37 static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
  38                               int LineLen);
  39 static int DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode);
  40 static int DGifDecompressInput(GifFileType *GifFile, int *Code);


   1 /*
   2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.  Oracle designates this
   7  * particular file as subject to the "Classpath" exception as provided
   8  * by Oracle in the LICENSE file that accompanied this code.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 /******************************************************************************
  26 
  27 dgif_lib.c - GIF decoding
  28 
  29 The functions here and in egif_lib.c are partitioned carefully so that
  30 if you only require one of read and write capability, only one of these
  31 two modules will be linked.  Preserve this property!
  32 
  33 *****************************************************************************/
  34 
  35 #include <stdlib.h>
  36 #include <limits.h>
  37 #include <stdint.h>
  38 #include <fcntl.h>

  39 #include <stdio.h>
  40 #include <string.h>
  41 
  42 #ifdef _WIN32
  43 #include <io.h>
  44 #else
  45 #include <unistd.h>
  46 #endif /* _WIN32 */
  47 
  48 #include "gif_lib.h"
  49 #include "gif_lib_private.h"
  50 
  51 /* compose unsigned little endian value */
  52 #define UNSIGNED_LITTLE_ENDIAN(lo, hi)  ((lo) | ((hi) << 8))
  53 
  54 /* avoid extra function call in case we use fread (TVT) */
  55 #define READ(_gif,_buf,_len)                                     \
  56   (((GifFilePrivateType*)_gif->Private)->Read ?                   \
  57     ((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \
  58     fread(_buf,1,_len,((GifFilePrivateType*)_gif->Private)->File))
  59 
  60 static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
  61 static int DGifSetupDecompress(GifFileType *GifFile);
  62 static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
  63                               int LineLen);
  64 static int DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode);
  65 static int DGifDecompressInput(GifFileType *GifFile, int *Code);


< prev index next >