| OLD | NEW |
| 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 #include "core/fxcodec/lgif/fx_gif.h" | 7 #include "core/fxcodec/lgif/fx_gif.h" |
| 8 | 8 |
| 9 #include "core/fxcodec/lbmp/fx_bmp.h" | 9 #include "core/fxcodec/lbmp/fx_bmp.h" |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 avail_in--; | 111 avail_in--; |
| 112 bits_left += 8; | 112 bits_left += 8; |
| 113 } | 113 } |
| 114 while (bits_left >= code_size_cur) { | 114 while (bits_left >= code_size_cur) { |
| 115 code = (uint16_t)code_store & ((1 << code_size_cur) - 1); | 115 code = (uint16_t)code_store & ((1 << code_size_cur) - 1); |
| 116 code_store >>= code_size_cur; | 116 code_store >>= code_size_cur; |
| 117 bits_left -= code_size_cur; | 117 bits_left -= code_size_cur; |
| 118 if (code == code_clear) { | 118 if (code == code_clear) { |
| 119 ClearTable(); | 119 ClearTable(); |
| 120 continue; | 120 continue; |
| 121 } else if (code == code_end) { | 121 } else if (code >= code_end) { |
| 122 des_size = i; | 122 des_size = i; |
| 123 return 1; | 123 return 1; |
| 124 } else { | 124 } else { |
| 125 if (code_old != (uint16_t)-1) { | 125 if (code_old != (uint16_t)-1) { |
| 126 if (code_next < GIF_MAX_LZW_CODE) { | 126 if (code_next < GIF_MAX_LZW_CODE) { |
| 127 if (code == code_next) { | 127 if (code == code_next) { |
| 128 AddCode(code_old, code_first); | 128 AddCode(code_old, code_first); |
| 129 DecodeString(code); | 129 DecodeString(code); |
| 130 } else if (code > code_next) { | 130 } else if (code > code_next) { |
| 131 if (err_msg_ptr) { | 131 if (err_msg_ptr) { |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 gif_ptr->cur_offset = cur_offset; | 1234 gif_ptr->cur_offset = cur_offset; |
| 1235 res = false; | 1235 res = false; |
| 1236 } | 1236 } |
| 1237 dst_len = gif_ptr->cur_offset; | 1237 dst_len = gif_ptr->cur_offset; |
| 1238 dst_buf[dst_len - 1] = GIF_SIG_TRAILER; | 1238 dst_buf[dst_len - 1] = GIF_SIG_TRAILER; |
| 1239 if (res) { | 1239 if (res) { |
| 1240 gif_ptr->frames++; | 1240 gif_ptr->frames++; |
| 1241 } | 1241 } |
| 1242 return res; | 1242 return res; |
| 1243 } | 1243 } |
| OLD | NEW |