Chromium Code Reviews| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 } | 214 } |
| 215 | 215 |
| 216 CJBig2_Image* CJBig2_TRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, | 216 CJBig2_Image* CJBig2_TRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, |
| 217 JBig2ArithCtx* grContext, | 217 JBig2ArithCtx* grContext, |
| 218 JBig2IntDecoderState* pIDS) { | 218 JBig2IntDecoderState* pIDS) { |
| 219 int32_t STRIPT, FIRSTS; | 219 int32_t STRIPT, FIRSTS; |
| 220 FX_DWORD NINSTANCES; | 220 FX_DWORD NINSTANCES; |
| 221 int32_t DT, DFS, CURS; | 221 int32_t DT, DFS, CURS; |
| 222 int32_t CURT; | 222 int32_t CURT; |
| 223 int32_t SI, TI; | 223 int32_t SI, TI; |
| 224 FX_DWORD IDI; | |
| 225 CJBig2_Image* IBI; | 224 CJBig2_Image* IBI; |
| 226 FX_DWORD WI, HI; | 225 FX_DWORD WI, HI; |
| 227 int32_t IDS; | 226 int32_t IDS; |
| 228 int RI; | 227 int RI; |
| 229 int32_t RDWI, RDHI, RDXI, RDYI; | 228 int32_t RDWI, RDHI, RDXI, RDYI; |
| 230 CJBig2_Image* IBOI; | 229 CJBig2_Image* IBOI; |
| 231 FX_DWORD WOI, HOI; | 230 FX_DWORD WOI, HOI; |
| 232 FX_BOOL bFirst; | 231 FX_BOOL bFirst; |
| 233 int32_t nRet, nVal; | 232 int32_t nRet, nVal; |
| 234 int32_t bRetained; | 233 int32_t bRetained; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 255 IARI = new CJBig2_ArithIntDecoder(); | 254 IARI = new CJBig2_ArithIntDecoder(); |
| 256 IARDW = new CJBig2_ArithIntDecoder(); | 255 IARDW = new CJBig2_ArithIntDecoder(); |
| 257 IARDH = new CJBig2_ArithIntDecoder(); | 256 IARDH = new CJBig2_ArithIntDecoder(); |
| 258 IARDX = new CJBig2_ArithIntDecoder(); | 257 IARDX = new CJBig2_ArithIntDecoder(); |
| 259 IARDY = new CJBig2_ArithIntDecoder(); | 258 IARDY = new CJBig2_ArithIntDecoder(); |
| 260 IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); | 259 IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); |
| 261 bRetained = FALSE; | 260 bRetained = FALSE; |
| 262 } | 261 } |
| 263 nonstd::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); | 262 nonstd::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); |
| 264 SBREG->fill(SBDEFPIXEL); | 263 SBREG->fill(SBDEFPIXEL); |
| 265 if (IADT->decode(pArithDecoder, &STRIPT) == -1) { | 264 if (!IADT->decode(pArithDecoder, &STRIPT)) { |
| 266 goto failed; | 265 goto failed; |
| 267 } | 266 } |
| 268 STRIPT *= SBSTRIPS; | 267 STRIPT *= SBSTRIPS; |
| 269 STRIPT = -STRIPT; | 268 STRIPT = -STRIPT; |
| 270 FIRSTS = 0; | 269 FIRSTS = 0; |
| 271 NINSTANCES = 0; | 270 NINSTANCES = 0; |
| 272 while (NINSTANCES < SBNUMINSTANCES) { | 271 while (NINSTANCES < SBNUMINSTANCES) { |
| 273 if (IADT->decode(pArithDecoder, &DT) == -1) { | 272 if (!IADT->decode(pArithDecoder, &DT)) { |
| 274 goto failed; | 273 goto failed; |
| 275 } | 274 } |
| 276 DT *= SBSTRIPS; | 275 DT *= SBSTRIPS; |
| 277 STRIPT = STRIPT + DT; | 276 STRIPT = STRIPT + DT; |
| 278 bFirst = TRUE; | 277 bFirst = TRUE; |
| 279 for (;;) { | 278 for (;;) { |
| 280 if (bFirst) { | 279 if (bFirst) { |
| 281 if (IAFS->decode(pArithDecoder, &DFS) == -1) { | 280 if (!IAFS->decode(pArithDecoder, &DFS)) { |
| 282 goto failed; | 281 goto failed; |
| 283 } | 282 } |
| 284 FIRSTS = FIRSTS + DFS; | 283 FIRSTS = FIRSTS + DFS; |
| 285 CURS = FIRSTS; | 284 CURS = FIRSTS; |
| 286 bFirst = FALSE; | 285 bFirst = FALSE; |
| 287 } else { | 286 } else { |
| 288 nRet = IADS->decode(pArithDecoder, &IDS); | 287 nRet = IADS->decode(pArithDecoder, &IDS); |
| 289 if (nRet == JBIG2_OOB) { | 288 if (nRet == JBIG2_OOB) { |
| 290 break; | 289 break; |
| 291 } else if (nRet != 0) { | 290 } else if (nRet != 0) { |
| 292 goto failed; | 291 goto failed; |
| 293 } else { | 292 } else { |
| 294 CURS = CURS + IDS + SBDSOFFSET; | 293 CURS = CURS + IDS + SBDSOFFSET; |
| 295 } | 294 } |
| 296 } | 295 } |
| 297 if (NINSTANCES >= SBNUMINSTANCES) { | 296 if (NINSTANCES >= SBNUMINSTANCES) { |
| 298 break; | 297 break; |
| 299 } | 298 } |
| 300 if (SBSTRIPS == 1) { | 299 if (SBSTRIPS == 1) { |
| 301 CURT = 0; | 300 CURT = 0; |
| 302 } else { | 301 } else { |
| 303 if (IAIT->decode(pArithDecoder, &nVal) == -1) { | 302 if (!IAIT->decode(pArithDecoder, &nVal)) { |
|
Tom Sepez
2015/09/30 20:09:50
Same thing here. Can we get rid of the nVal tempo
Lei Zhang
2015/10/01 06:01:59
Done.
| |
| 304 goto failed; | 303 goto failed; |
| 305 } | 304 } |
| 306 CURT = nVal; | 305 CURT = nVal; |
| 307 } | 306 } |
| 308 TI = STRIPT + CURT; | 307 TI = STRIPT + CURT; |
| 309 if (IAID->decode(pArithDecoder, &nVal) == -1) { | 308 FX_DWORD IDI; |
| 310 goto failed; | 309 IAID->decode(pArithDecoder, &IDI); |
| 311 } | |
| 312 IDI = nVal; | |
| 313 if (IDI >= SBNUMSYMS) { | 310 if (IDI >= SBNUMSYMS) { |
| 314 goto failed; | 311 goto failed; |
| 315 } | 312 } |
| 316 if (SBREFINE == 0) { | 313 if (SBREFINE == 0) { |
| 317 RI = 0; | 314 RI = 0; |
| 318 } else { | 315 } else { |
| 319 if (IARI->decode(pArithDecoder, &RI) == -1) { | 316 if (!IARI->decode(pArithDecoder, &RI)) { |
| 320 goto failed; | 317 goto failed; |
| 321 } | 318 } |
| 322 } | 319 } |
| 323 if (!SBSYMS[IDI]) { | 320 if (!SBSYMS[IDI]) { |
| 324 goto failed; | 321 goto failed; |
| 325 } | 322 } |
| 326 if (RI == 0) { | 323 if (RI == 0) { |
| 327 IBI = SBSYMS[IDI]; | 324 IBI = SBSYMS[IDI]; |
| 328 } else { | 325 } else { |
| 329 if ((IARDW->decode(pArithDecoder, &RDWI) == -1) || | 326 if (!IARDW->decode(pArithDecoder, &RDWI) || |
| 330 (IARDH->decode(pArithDecoder, &RDHI) == -1) || | 327 !IARDH->decode(pArithDecoder, &RDHI) || |
| 331 (IARDX->decode(pArithDecoder, &RDXI) == -1) || | 328 !IARDX->decode(pArithDecoder, &RDXI) || |
| 332 (IARDY->decode(pArithDecoder, &RDYI) == -1)) { | 329 !IARDY->decode(pArithDecoder, &RDYI)) { |
| 333 goto failed; | 330 goto failed; |
| 334 } | 331 } |
| 335 IBOI = SBSYMS[IDI]; | 332 IBOI = SBSYMS[IDI]; |
| 336 WOI = IBOI->m_nWidth; | 333 WOI = IBOI->m_nWidth; |
| 337 HOI = IBOI->m_nHeight; | 334 HOI = IBOI->m_nHeight; |
| 338 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { | 335 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { |
| 339 goto failed; | 336 goto failed; |
| 340 } | 337 } |
| 341 nonstd::unique_ptr<CJBig2_GRRDProc> pGRRD(new CJBig2_GRRDProc()); | 338 nonstd::unique_ptr<CJBig2_GRRDProc> pGRRD(new CJBig2_GRRDProc()); |
| 342 pGRRD->GRW = WOI + RDWI; | 339 pGRRD->GRW = WOI + RDWI; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 delete IAIT; | 426 delete IAIT; |
| 430 delete IARI; | 427 delete IARI; |
| 431 delete IARDW; | 428 delete IARDW; |
| 432 delete IARDH; | 429 delete IARDH; |
| 433 delete IARDX; | 430 delete IARDX; |
| 434 delete IARDY; | 431 delete IARDY; |
| 435 delete IAID; | 432 delete IAID; |
| 436 } | 433 } |
| 437 return nullptr; | 434 return nullptr; |
| 438 } | 435 } |
| OLD | NEW |