tcp: Add APICall trace entry and move TRACEs into locked parts.
[haiku.git] / src / add-ons / translators / gif / GIFLoad.h
blobac63a1a2aeb0fd91d1300e75363c99f0ad413b81
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: GIFLoad.h
4 //
5 // Date: December 1999
6 //
7 // Author: Daniel Switkin
8 //
9 // Copyright 2003 (c) by Daniel Switkin. This file is made publically available
10 // under the BSD license, with the stipulations that this complete header must
11 // remain at the top of the file indefinitely, and credit must be given to the
12 // original author in any about box using this software.
14 ////////////////////////////////////////////////////////////////////////////////
16 // Additional authors: John Scipione, <jscipione@gmail.com>
18 #ifndef GIF_LOAD_H
19 #define GIF_LOAD_H
22 #include <DataIO.h>
23 #include "LoadPalette.h"
26 #define GIF_INTERLACED 0x40
27 #define GIF_LOCALCOLORMAP 0x80
29 #define ENTRY_COUNT 4354
30 // 4354 = 4096 + 256 + 1 + 1
31 // 4096 for the image data, 256 for the color codes,
32 // 1 for the clear code, 1 for the end code
35 typedef struct Memblock {
36 unsigned char data[ENTRY_COUNT];
37 int offset;
38 Memblock* next;
39 } Memblock;
42 const int gl_pass_starts_at[] = { 0, 4, 2, 1, 0 };
43 const int gl_increment_pass_by[] = { 8, 8, 4, 2, 0 };
46 class GIFLoad {
47 public:
48 GIFLoad(BPositionIO* input,
49 BPositionIO* output);
50 virtual ~GIFLoad();
52 bool fatalerror;
54 private:
55 bool ReadGIFHeader();
56 bool ReadGIFLoopBlock();
57 bool ReadGIFControlBlock();
58 bool ReadGIFImageHeader();
59 bool ReadGIFImageData();
60 bool ReadGIFCommentBlock();
61 bool ReadGIFUnknownBlock(unsigned char c);
63 bool InitFrame(int codeSize);
64 short NextCode();
65 void ResetTable();
67 unsigned char* MemblockAllocate(int size);
68 void MemblockDeleteAll();
70 inline bool OutputColor(unsigned char* string, int size);
72 BPositionIO* fInput;
73 BPositionIO* fOutput;
74 LoadPalette* fPalette;
76 bool fInterlaced;
78 int fPass;
79 int fRow;
81 int fWidth;
82 int fHeight;
84 unsigned char fOldCode[ENTRY_COUNT];
85 unsigned int fOldCodeLength;
87 short fNewCode;
88 int fBits;
89 int fMaxCode;
90 int fCodeSize;
92 short fClearCode;
93 short fEndCode;
94 short fNextCode;
96 unsigned char* fTable[ENTRY_COUNT];
97 short fEntrySize[ENTRY_COUNT];
98 Memblock* fHeadMemblock;
100 int fBitCount;
101 unsigned int fBitBuffer;
102 unsigned char fByteCount;
103 unsigned char fByteBuffer[255];
105 uint32* fScanLine;
106 int fScanlinePosition;
110 #endif // GIF_LOAD_H