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 |
11 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" | 11 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" |
12 #include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h" | 12 #include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h" |
13 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" | 13 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" |
14 #include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h" | 14 #include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h" |
| 15 #include "third_party/base/ptr_util.h" |
15 | 16 |
16 CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, | 17 CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, |
17 JBig2ArithCtx* grContext) { | 18 JBig2ArithCtx* grContext) { |
18 std::unique_ptr<CJBig2_HuffmanDecoder> pHuffmanDecoder( | 19 std::unique_ptr<CJBig2_HuffmanDecoder> pHuffmanDecoder( |
19 new CJBig2_HuffmanDecoder(pStream)); | 20 new CJBig2_HuffmanDecoder(pStream)); |
20 std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); | 21 std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); |
21 SBREG->fill(SBDEFPIXEL); | 22 SBREG->fill(SBDEFPIXEL); |
22 int32_t STRIPT; | 23 int32_t STRIPT; |
23 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) | 24 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) |
24 return nullptr; | 25 return nullptr; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 pIAFS = pIDS->IAFS; | 236 pIAFS = pIDS->IAFS; |
236 pIADS = pIDS->IADS; | 237 pIADS = pIDS->IADS; |
237 pIAIT = pIDS->IAIT; | 238 pIAIT = pIDS->IAIT; |
238 pIARI = pIDS->IARI; | 239 pIARI = pIDS->IARI; |
239 pIARDW = pIDS->IARDW; | 240 pIARDW = pIDS->IARDW; |
240 pIARDH = pIDS->IARDH; | 241 pIARDH = pIDS->IARDH; |
241 pIARDX = pIDS->IARDX; | 242 pIARDX = pIDS->IARDX; |
242 pIARDY = pIDS->IARDY; | 243 pIARDY = pIDS->IARDY; |
243 pIAID = pIDS->IAID; | 244 pIAID = pIDS->IAID; |
244 } else { | 245 } else { |
245 IADT.reset(new CJBig2_ArithIntDecoder()); | 246 IADT = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
246 IAFS.reset(new CJBig2_ArithIntDecoder()); | 247 IAFS = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
247 IADS.reset(new CJBig2_ArithIntDecoder()); | 248 IADS = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
248 IAIT.reset(new CJBig2_ArithIntDecoder()); | 249 IAIT = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
249 IARI.reset(new CJBig2_ArithIntDecoder()); | 250 IARI = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
250 IARDW.reset(new CJBig2_ArithIntDecoder()); | 251 IARDW = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
251 IARDH.reset(new CJBig2_ArithIntDecoder()); | 252 IARDH = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
252 IARDX.reset(new CJBig2_ArithIntDecoder()); | 253 IARDX = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
253 IARDY.reset(new CJBig2_ArithIntDecoder()); | 254 IARDY = pdfium::MakeUnique<CJBig2_ArithIntDecoder>(); |
254 IAID.reset(new CJBig2_ArithIaidDecoder(SBSYMCODELEN)); | 255 IAID = pdfium::MakeUnique<CJBig2_ArithIaidDecoder>(SBSYMCODELEN); |
255 pIADT = IADT.get(); | 256 pIADT = IADT.get(); |
256 pIAFS = IAFS.get(); | 257 pIAFS = IAFS.get(); |
257 pIADS = IADS.get(); | 258 pIADS = IADS.get(); |
258 pIAIT = IAIT.get(); | 259 pIAIT = IAIT.get(); |
259 pIARI = IARI.get(); | 260 pIARI = IARI.get(); |
260 pIARDW = IARDW.get(); | 261 pIARDW = IARDW.get(); |
261 pIARDH = IARDH.get(); | 262 pIARDH = IARDH.get(); |
262 pIARDX = IARDX.get(); | 263 pIARDX = IARDX.get(); |
263 pIARDY = IARDY.get(); | 264 pIARDY = IARDY.get(); |
264 pIAID = IAID.get(); | 265 pIAID = IAID.get(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 CURS += WI - 1; | 399 CURS += WI - 1; |
399 } else if (TRANSPOSED == 1 && ((REFCORNER == JBIG2_CORNER_TOPLEFT) || | 400 } else if (TRANSPOSED == 1 && ((REFCORNER == JBIG2_CORNER_TOPLEFT) || |
400 (REFCORNER == JBIG2_CORNER_TOPRIGHT))) { | 401 (REFCORNER == JBIG2_CORNER_TOPRIGHT))) { |
401 CURS += HI - 1; | 402 CURS += HI - 1; |
402 } | 403 } |
403 ++NINSTANCES; | 404 ++NINSTANCES; |
404 } | 405 } |
405 } | 406 } |
406 return SBREG.release(); | 407 return SBREG.release(); |
407 } | 408 } |
OLD | NEW |