Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: core/fxcodec/lgif/fx_gif.h

Issue 2060913003: Make code compile with clang_use_chrome_plugin (part II) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: revert some string changes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FXCODEC_LGIF_FX_GIF_H_ 7 #ifndef CORE_FXCODEC_LGIF_FX_GIF_H_
8 #define CORE_FXCODEC_LGIF_FX_GIF_H_ 8 #define CORE_FXCODEC_LGIF_FX_GIF_H_
9 9
10 #include <setjmp.h> 10 #include <setjmp.h>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 #pragma pack() 100 #pragma pack()
101 typedef struct tagGifImage { 101 typedef struct tagGifImage {
102 GifGCE* image_gce_ptr; 102 GifGCE* image_gce_ptr;
103 GifPalette* local_pal_ptr; 103 GifPalette* local_pal_ptr;
104 GifImageInfo* image_info_ptr; 104 GifImageInfo* image_info_ptr;
105 uint8_t image_code_size; 105 uint8_t image_code_size;
106 uint32_t image_data_pos; 106 uint32_t image_data_pos;
107 uint8_t* image_row_buf; 107 uint8_t* image_row_buf;
108 int32_t image_row_num; 108 int32_t image_row_num;
109 } GifImage; 109 } GifImage;
110
110 typedef struct tagGifPlainText { 111 typedef struct tagGifPlainText {
111 GifGCE* gce_ptr; 112 GifGCE* gce_ptr;
112 GifPTE* pte_ptr; 113 GifPTE* pte_ptr;
113 CFX_ByteString* string_ptr; 114 CFX_ByteString* string_ptr;
114 } GifPlainText; 115 } GifPlainText;
116
115 class CGifLZWDecoder { 117 class CGifLZWDecoder {
116 public: 118 public:
117 struct tag_Table { 119 struct tag_Table {
118 uint16_t prefix; 120 uint16_t prefix;
119 uint8_t suffix; 121 uint8_t suffix;
120 }; 122 };
121 CGifLZWDecoder(FX_CHAR* error_ptr = nullptr) { err_msg_ptr = error_ptr; } 123
124 explicit CGifLZWDecoder(FX_CHAR* error_ptr);
125 ~CGifLZWDecoder();
126
122 void InitTable(uint8_t code_len); 127 void InitTable(uint8_t code_len);
123
124 int32_t Decode(uint8_t* des_buf, uint32_t& des_size); 128 int32_t Decode(uint8_t* des_buf, uint32_t& des_size);
125
126 void Input(uint8_t* src_buf, uint32_t src_size); 129 void Input(uint8_t* src_buf, uint32_t src_size);
127 uint32_t GetAvailInput(); 130 uint32_t GetAvailInput();
128 131
129 private: 132 private:
130 void ClearTable(); 133 void ClearTable();
131 void AddCode(uint16_t prefix_code, uint8_t append_char); 134 void AddCode(uint16_t prefix_code, uint8_t append_char);
132 void DecodeString(uint16_t code); 135 void DecodeString(uint16_t code);
136
133 uint8_t code_size; 137 uint8_t code_size;
134 uint8_t code_size_cur; 138 uint8_t code_size_cur;
135 uint16_t code_clear; 139 uint16_t code_clear;
136 uint16_t code_end; 140 uint16_t code_end;
137 uint16_t code_next; 141 uint16_t code_next;
138 uint8_t code_first; 142 uint8_t code_first;
139 uint8_t stack[GIF_MAX_LZW_CODE]; 143 uint8_t stack[GIF_MAX_LZW_CODE];
140 uint16_t stack_size; 144 uint16_t stack_size;
141 tag_Table code_table[GIF_MAX_LZW_CODE]; 145 tag_Table code_table[GIF_MAX_LZW_CODE];
142 uint16_t code_old; 146 uint16_t code_old;
143 147
144 uint8_t* next_in; 148 uint8_t* next_in;
145 uint32_t avail_in; 149 uint32_t avail_in;
146 150
147 uint8_t bits_left; 151 uint8_t bits_left;
148 uint32_t code_store; 152 uint32_t code_store;
149 153
150 FX_CHAR* err_msg_ptr; 154 FX_CHAR* err_msg_ptr;
151 }; 155 };
156
152 class CGifLZWEncoder { 157 class CGifLZWEncoder {
153 public: 158 public:
154 struct tag_Table { 159 struct tag_Table {
155 uint16_t prefix; 160 uint16_t prefix;
156 uint8_t suffix; 161 uint8_t suffix;
157 }; 162 };
163
158 CGifLZWEncoder(); 164 CGifLZWEncoder();
159 ~CGifLZWEncoder(); 165 ~CGifLZWEncoder();
166
160 void Start(uint8_t code_len, 167 void Start(uint8_t code_len,
161 const uint8_t* src_buf, 168 const uint8_t* src_buf,
162 uint8_t*& dst_buf, 169 uint8_t*& dst_buf,
163 uint32_t& offset); 170 uint32_t& offset);
164 FX_BOOL Encode(const uint8_t* src_buf, 171 FX_BOOL Encode(const uint8_t* src_buf,
165 uint32_t src_len, 172 uint32_t src_len,
166 uint8_t*& dst_buf, 173 uint8_t*& dst_buf,
167 uint32_t& dst_len, 174 uint32_t& dst_len,
168 uint32_t& offset); 175 uint32_t& offset);
169 void Finish(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset); 176 void Finish(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset);
170 177
171 private: 178 private:
172 void ClearTable(); 179 void ClearTable();
173 FX_BOOL LookUpInTable(const uint8_t* buf, 180 FX_BOOL LookUpInTable(const uint8_t* buf,
174 uint32_t& offset, 181 uint32_t& offset,
175 uint8_t& bit_offset); 182 uint8_t& bit_offset);
176 void EncodeString(uint32_t index, 183 void EncodeString(uint32_t index,
177 uint8_t*& dst_buf, 184 uint8_t*& dst_buf,
178 uint32_t& dst_len, 185 uint32_t& dst_len,
179 uint32_t& offset); 186 uint32_t& offset);
180 void WriteBlock(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset); 187 void WriteBlock(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset);
188
181 jmp_buf jmp; 189 jmp_buf jmp;
182 uint32_t src_offset; 190 uint32_t src_offset;
183 uint8_t src_bit_offset; 191 uint8_t src_bit_offset;
184 uint8_t src_bit_cut; 192 uint8_t src_bit_cut;
185 uint32_t src_bit_num; 193 uint32_t src_bit_num;
186 uint8_t code_size; 194 uint8_t code_size;
187 uint16_t code_clear; 195 uint16_t code_clear;
188 uint16_t code_end; 196 uint16_t code_end;
189 uint16_t index_num; 197 uint16_t index_num;
190 uint8_t bit_offset; 198 uint8_t bit_offset;
191 uint8_t index_bit_cur; 199 uint8_t index_bit_cur;
192 uint8_t index_buf[GIF_DATA_BLOCK]; 200 uint8_t index_buf[GIF_DATA_BLOCK];
193 uint8_t index_buf_len; 201 uint8_t index_buf_len;
194 tag_Table code_table[GIF_MAX_LZW_CODE]; 202 tag_Table code_table[GIF_MAX_LZW_CODE];
195 uint16_t table_cur; 203 uint16_t table_cur;
196 }; 204 };
205
197 typedef struct tag_gif_decompress_struct gif_decompress_struct; 206 typedef struct tag_gif_decompress_struct gif_decompress_struct;
198 typedef gif_decompress_struct* gif_decompress_struct_p; 207 typedef gif_decompress_struct* gif_decompress_struct_p;
199 typedef gif_decompress_struct_p* gif_decompress_struct_pp; 208 typedef gif_decompress_struct_p* gif_decompress_struct_pp;
200 static const int32_t s_gif_interlace_step[4] = {8, 8, 4, 2}; 209 static const int32_t s_gif_interlace_step[4] = {8, 8, 4, 2};
201 struct tag_gif_decompress_struct { 210 struct tag_gif_decompress_struct {
202 jmp_buf jmpbuf; 211 jmp_buf jmpbuf;
203 FX_CHAR* err_ptr; 212 FX_CHAR* err_ptr;
204 void (*gif_error_fn)(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg); 213 void (*gif_error_fn)(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
205 void* context_ptr; 214 void* context_ptr;
206 int width; 215 int width;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 uint8_t* src_buf, 296 uint8_t* src_buf,
288 uint32_t src_size); 297 uint32_t src_size);
289 uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr, 298 uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr,
290 uint8_t** avail_buf_ptr); 299 uint8_t** avail_buf_ptr);
291 void interlace_buf(const uint8_t* buf, uint32_t width, uint32_t height); 300 void interlace_buf(const uint8_t* buf, uint32_t width, uint32_t height);
292 FX_BOOL gif_encode(gif_compress_struct_p gif_ptr, 301 FX_BOOL gif_encode(gif_compress_struct_p gif_ptr,
293 uint8_t*& dst_buf, 302 uint8_t*& dst_buf,
294 uint32_t& dst_len); 303 uint32_t& dst_len);
295 304
296 #endif // CORE_FXCODEC_LGIF_FX_GIF_H_ 305 #endif // CORE_FXCODEC_LGIF_FX_GIF_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698