OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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/jbig2/JBig2_TrdProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_TrdProc.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 pIARI = IARI.get(); | 259 pIARI = IARI.get(); |
260 pIARDW = IARDW.get(); | 260 pIARDW = IARDW.get(); |
261 pIARDH = IARDH.get(); | 261 pIARDH = IARDH.get(); |
262 pIARDX = IARDX.get(); | 262 pIARDX = IARDX.get(); |
263 pIARDY = IARDY.get(); | 263 pIARDY = IARDY.get(); |
264 pIAID = IAID.get(); | 264 pIAID = IAID.get(); |
265 } | 265 } |
266 std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); | 266 std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); |
267 SBREG->fill(SBDEFPIXEL); | 267 SBREG->fill(SBDEFPIXEL); |
268 int32_t STRIPT; | 268 int32_t STRIPT; |
269 pIADT->decode(pArithDecoder, &STRIPT); | 269 if (!pIADT->decode(pArithDecoder, &STRIPT)) |
| 270 return nullptr; |
270 STRIPT *= SBSTRIPS; | 271 STRIPT *= SBSTRIPS; |
271 STRIPT = -STRIPT; | 272 STRIPT = -STRIPT; |
272 int32_t FIRSTS = 0; | 273 int32_t FIRSTS = 0; |
273 uint32_t NINSTANCES = 0; | 274 uint32_t NINSTANCES = 0; |
274 while (NINSTANCES < SBNUMINSTANCES) { | 275 while (NINSTANCES < SBNUMINSTANCES) { |
275 int32_t CURS = 0; | 276 int32_t CURS = 0; |
276 int32_t DT; | 277 int32_t DT; |
277 pIADT->decode(pArithDecoder, &DT); | 278 if (!pIADT->decode(pArithDecoder, &DT)) |
| 279 return nullptr; |
278 DT *= SBSTRIPS; | 280 DT *= SBSTRIPS; |
279 STRIPT += DT; | 281 STRIPT += DT; |
280 bool bFirst = true; | 282 bool bFirst = true; |
281 for (;;) { | 283 for (;;) { |
282 if (bFirst) { | 284 if (bFirst) { |
283 int32_t DFS; | 285 int32_t DFS; |
284 pIAFS->decode(pArithDecoder, &DFS); | 286 pIAFS->decode(pArithDecoder, &DFS); |
285 FIRSTS += DFS; | 287 FIRSTS += DFS; |
286 CURS = FIRSTS; | 288 CURS = FIRSTS; |
287 bFirst = false; | 289 bFirst = false; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 CURS += WI - 1; | 398 CURS += WI - 1; |
397 } else if (TRANSPOSED == 1 && ((REFCORNER == JBIG2_CORNER_TOPLEFT) || | 399 } else if (TRANSPOSED == 1 && ((REFCORNER == JBIG2_CORNER_TOPLEFT) || |
398 (REFCORNER == JBIG2_CORNER_TOPRIGHT))) { | 400 (REFCORNER == JBIG2_CORNER_TOPRIGHT))) { |
399 CURS += HI - 1; | 401 CURS += HI - 1; |
400 } | 402 } |
401 ++NINSTANCES; | 403 ++NINSTANCES; |
402 } | 404 } |
403 } | 405 } |
404 return SBREG.release(); | 406 return SBREG.release(); |
405 } | 407 } |
OLD | NEW |