| 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 "JBig2_TrdProc.h" | 7 #include "JBig2_TrdProc.h" |
| 8 | 8 |
| 9 #include "../../../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
| 10 #include "JBig2_ArithDecoder.h" | 10 #include "JBig2_ArithDecoder.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 IARI = new CJBig2_ArithIntDecoder(); | 255 IARI = new CJBig2_ArithIntDecoder(); |
| 256 IARDW = new CJBig2_ArithIntDecoder(); | 256 IARDW = new CJBig2_ArithIntDecoder(); |
| 257 IARDH = new CJBig2_ArithIntDecoder(); | 257 IARDH = new CJBig2_ArithIntDecoder(); |
| 258 IARDX = new CJBig2_ArithIntDecoder(); | 258 IARDX = new CJBig2_ArithIntDecoder(); |
| 259 IARDY = new CJBig2_ArithIntDecoder(); | 259 IARDY = new CJBig2_ArithIntDecoder(); |
| 260 IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); | 260 IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); |
| 261 bRetained = FALSE; | 261 bRetained = FALSE; |
| 262 } | 262 } |
| 263 nonstd::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); | 263 nonstd::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); |
| 264 SBREG->fill(SBDEFPIXEL); | 264 SBREG->fill(SBDEFPIXEL); |
| 265 if (IADT->decode(pArithDecoder, &STRIPT) == -1) { | 265 if (!IADT->decode(pArithDecoder, &STRIPT)) { |
| 266 goto failed; | 266 goto failed; |
| 267 } | 267 } |
| 268 STRIPT *= SBSTRIPS; | 268 STRIPT *= SBSTRIPS; |
| 269 STRIPT = -STRIPT; | 269 STRIPT = -STRIPT; |
| 270 FIRSTS = 0; | 270 FIRSTS = 0; |
| 271 NINSTANCES = 0; | 271 NINSTANCES = 0; |
| 272 while (NINSTANCES < SBNUMINSTANCES) { | 272 while (NINSTANCES < SBNUMINSTANCES) { |
| 273 if (IADT->decode(pArithDecoder, &DT) == -1) { | 273 if (!IADT->decode(pArithDecoder, &DT)) { |
| 274 goto failed; | 274 goto failed; |
| 275 } | 275 } |
| 276 DT *= SBSTRIPS; | 276 DT *= SBSTRIPS; |
| 277 STRIPT = STRIPT + DT; | 277 STRIPT = STRIPT + DT; |
| 278 bFirst = TRUE; | 278 bFirst = TRUE; |
| 279 for (;;) { | 279 for (;;) { |
| 280 if (bFirst) { | 280 if (bFirst) { |
| 281 if (IAFS->decode(pArithDecoder, &DFS) == -1) { | 281 if (!IAFS->decode(pArithDecoder, &DFS)) { |
| 282 goto failed; | 282 goto failed; |
| 283 } | 283 } |
| 284 FIRSTS = FIRSTS + DFS; | 284 FIRSTS = FIRSTS + DFS; |
| 285 CURS = FIRSTS; | 285 CURS = FIRSTS; |
| 286 bFirst = FALSE; | 286 bFirst = FALSE; |
| 287 } else { | 287 } else { |
| 288 nRet = IADS->decode(pArithDecoder, &IDS); | 288 nRet = IADS->decode(pArithDecoder, &IDS); |
| 289 if (nRet == JBIG2_OOB) { | 289 if (nRet == JBIG2_OOB) { |
| 290 break; | 290 break; |
| 291 } else if (nRet != 0) { | 291 } else if (nRet != 0) { |
| 292 goto failed; | 292 goto failed; |
| 293 } else { | 293 } else { |
| 294 CURS = CURS + IDS + SBDSOFFSET; | 294 CURS = CURS + IDS + SBDSOFFSET; |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 if (NINSTANCES >= SBNUMINSTANCES) { | 297 if (NINSTANCES >= SBNUMINSTANCES) { |
| 298 break; | 298 break; |
| 299 } | 299 } |
| 300 if (SBSTRIPS == 1) { | 300 if (SBSTRIPS == 1) { |
| 301 CURT = 0; | 301 CURT = 0; |
| 302 } else { | 302 } else { |
| 303 if (IAIT->decode(pArithDecoder, &nVal) == -1) { | 303 if (!IAIT->decode(pArithDecoder, &nVal)) { |
| 304 goto failed; | 304 goto failed; |
| 305 } | 305 } |
| 306 CURT = nVal; | 306 CURT = nVal; |
| 307 } | 307 } |
| 308 TI = STRIPT + CURT; | 308 TI = STRIPT + CURT; |
| 309 if (IAID->decode(pArithDecoder, &nVal) == -1) { | 309 IAID->decode(pArithDecoder, &nVal); |
| 310 goto failed; | |
| 311 } | |
| 312 IDI = nVal; | 310 IDI = nVal; |
| 313 if (IDI >= SBNUMSYMS) { | 311 if (IDI >= SBNUMSYMS) { |
| 314 goto failed; | 312 goto failed; |
| 315 } | 313 } |
| 316 if (SBREFINE == 0) { | 314 if (SBREFINE == 0) { |
| 317 RI = 0; | 315 RI = 0; |
| 318 } else { | 316 } else { |
| 319 if (IARI->decode(pArithDecoder, &RI) == -1) { | 317 if (!IARI->decode(pArithDecoder, &RI)) { |
| 320 goto failed; | 318 goto failed; |
| 321 } | 319 } |
| 322 } | 320 } |
| 323 if (!SBSYMS[IDI]) { | 321 if (!SBSYMS[IDI]) { |
| 324 goto failed; | 322 goto failed; |
| 325 } | 323 } |
| 326 if (RI == 0) { | 324 if (RI == 0) { |
| 327 IBI = SBSYMS[IDI]; | 325 IBI = SBSYMS[IDI]; |
| 328 } else { | 326 } else { |
| 329 if ((IARDW->decode(pArithDecoder, &RDWI) == -1) || | 327 if (!IARDW->decode(pArithDecoder, &RDWI) || |
| 330 (IARDH->decode(pArithDecoder, &RDHI) == -1) || | 328 !IARDH->decode(pArithDecoder, &RDHI) || |
| 331 (IARDX->decode(pArithDecoder, &RDXI) == -1) || | 329 !IARDX->decode(pArithDecoder, &RDXI) || |
| 332 (IARDY->decode(pArithDecoder, &RDYI) == -1)) { | 330 !IARDY->decode(pArithDecoder, &RDYI)) { |
| 333 goto failed; | 331 goto failed; |
| 334 } | 332 } |
| 335 IBOI = SBSYMS[IDI]; | 333 IBOI = SBSYMS[IDI]; |
| 336 WOI = IBOI->m_nWidth; | 334 WOI = IBOI->m_nWidth; |
| 337 HOI = IBOI->m_nHeight; | 335 HOI = IBOI->m_nHeight; |
| 338 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { | 336 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { |
| 339 goto failed; | 337 goto failed; |
| 340 } | 338 } |
| 341 nonstd::unique_ptr<CJBig2_GRRDProc> pGRRD(new CJBig2_GRRDProc()); | 339 nonstd::unique_ptr<CJBig2_GRRDProc> pGRRD(new CJBig2_GRRDProc()); |
| 342 pGRRD->GRW = WOI + RDWI; | 340 pGRRD->GRW = WOI + RDWI; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 delete IAIT; | 427 delete IAIT; |
| 430 delete IARI; | 428 delete IARI; |
| 431 delete IARDW; | 429 delete IARDW; |
| 432 delete IARDH; | 430 delete IARDH; |
| 433 delete IARDX; | 431 delete IARDX; |
| 434 delete IARDY; | 432 delete IARDY; |
| 435 delete IAID; | 433 delete IAID; |
| 436 } | 434 } |
| 437 return nullptr; | 435 return nullptr; |
| 438 } | 436 } |
| OLD | NEW |