summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
AgeCommit message (Collapse)Author
2017-04-07Remove the ICC transform where it is never initialized.Nicolas Pena
- All callers of CFX_DIBitmap methods use nullptr as the ICC Transform. - The CFX_ScanlineCompositor is always initialized with a null ICC transform. Many of its methods call TranslateScanline from the ICC module. This method casts just uses ((CLcmsCmm*)pTransform)->m_hTransform, and this should not be done when pTransform is nullptr. Change-Id: I1b846d1f20699fa017cb9a276be3214eb8fabd4b Reviewed-on: https://pdfium-review.googlesource.com/3931 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-07Remove the "old way" of performing FlateUncompress.Tom Sepez
Repeated looping over Realloc() with a linearly increasing buffer size is going to be O(N^2) which is why it was limited to small cases. But it's wrong to do it anyways, and it kicks out a lurking issue in PartitionAlloc as it turns out. See https://crbug.com/709271, but this doesn't actually fix that issue, it just avoids it. Change-Id: I39d8f8df0d5fc358b7b9caa15c507a8f57e45004 Reviewed-on: https://pdfium-review.googlesource.com/3910 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-04-04Remove a couple checks for MakeUnique failures.Lei Zhang
Combine some common CCodec_Jbig2Module code. Change-Id: I9a046314bc0e9dddc9a8c1a06b37764e9f3cc4b6 Reviewed-on: https://pdfium-review.googlesource.com/3713 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-04-04RefCount CPDF_StreamAcc all the time.Tom Sepez
Pass stream argument to constructor; it feels like a stream accessor should always be made from a stream rather than passing one in after the fact. Change-Id: Iaa46cb37677b81f0170f5d39bab76ad38ea4af44 Reviewed-on: https://pdfium-review.googlesource.com/3620 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-04-04Finish splitting up fx_dib.hNicolas Pena
After this CL, fx_dib.h only has some definitions used in multiple places. Definitions that were of restricted usage were moved out to the corresponding place. Includes in fx_dib were reduced, thus revealing other needed includes. Change-Id: I3607da0af81c491256d64c0aa085225631efbdcc Reviewed-on: https://pdfium-review.googlesource.com/3594 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-04Remove unneeded void* casts.Lei Zhang
Change-Id: Icf6b0ec88dfc8dc707b18ca4ad25dd77610b4c91 Reviewed-on: https://pdfium-review.googlesource.com/3622 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-03Drop FXSYS_ from mem methodsDan Sinclair
This Cl drops the FXSYS_ from mem methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I9d5ae905997dbaaec5aa0b2ae4c07358ed9c6236 Reviewed-on: https://pdfium-review.googlesource.com/3613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-03Drop FXSYS_ from math methodsDan Sinclair
This Cl drops the FXSYS_ from math methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I85c9ff841fd9095b1434f67319847ba0cd9df7ac Reviewed-on: https://pdfium-review.googlesource.com/3598 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-03Drop FXSYS_ from string methodsDan Sinclair
This Cl drops the FXSYS_ from string methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I1698aafd84f40474997549ae91ce35603377e303 Reviewed-on: https://pdfium-review.googlesource.com/3597 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-31Move zlib to a DEPS-based checkout.Lei Zhang
BUG=chromium:541704 Change-Id: I313d8853450ff5940b3baa4054ff441b342c46b7 Reviewed-on: https://pdfium-review.googlesource.com/3350 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-30Add some calls to MakeUniqueDan Sinclair
This CL replaces some new's with pdfium::MakeUnique. Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb Reviewed-on: https://pdfium-review.googlesource.com/3430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-28Revert "Revert "Refcount all CFX_DIBSources (and subclasses) all the time.""Tom Sepez
This reverts commit 31b08d4cdaa17d7a03f35e087096a77036af98ec. Re-landing the patch after fixing skia build issue. Change-Id: Ie7039890088b803a6ec5ce365d70f57277459b48 Reviewed-on: https://pdfium-review.googlesource.com/3245 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-28Revert "Refcount all CFX_DIBSources (and subclasses) all the time."dsinclair
This reverts commit 0004f29bf6ee3c6060a272c79f14993e92e053c7. Reason for revert: Breaks build with skia_paths enabled (which will break the chrome roll). ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1858:38: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1861:42: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2987:15: error: no viable overloaded '=' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2991:18: error: no viable overloaded '=' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2999:17: error: no viable overloaded '=' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:3001:43: error: no member named 'GetObject' in 'CFX_RetainPtr<CFX_DIBitmap>' Original change's description: > Refcount all CFX_DIBSources (and subclasses) all the time. > > There are currently several ownership models for these objects, > including ad-hoc logic for sharing and deletion, and the > now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs. > > Replace them all with the internal refcount scheme. > > Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872 > Reviewed-on: https://pdfium-review.googlesource.com/3166 > Reviewed-by: dsinclair <dsinclair@chromium.org> > Commit-Queue: dsinclair <dsinclair@chromium.org> > TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I678b1fbc5e666cf7a19372ebaff3270fb115ba5e Reviewed-on: https://pdfium-review.googlesource.com/3243 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-28Refcount all CFX_DIBSources (and subclasses) all the time.Tom Sepez
There are currently several ownership models for these objects, including ad-hoc logic for sharing and deletion, and the now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs. Replace them all with the internal refcount scheme. Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872 Reviewed-on: https://pdfium-review.googlesource.com/3166 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-27Update to zlib 1.2.11Adenilson Cavalcanti
This is the same version used by Chromium (as also the latest release of zlib). BUG=687631 Change-Id: Ia4bcdee3c36443ba01914d157ea795d7fb881a45 Reviewed-on: https://pdfium-review.googlesource.com/3096 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-23Revert "Remove CFX_FixedBufGrow"Nicolás Peña
This reverts commit 55d1d0191ea8316df32858d8cc62fb7c620e8613. Reason for revert: Slowing down corpus tests by a lot on Mac/Win Original change's description: > Remove CFX_FixedBufGrow > > This Cl replaces the CFX_FixedBufGrow class with std::vector. > > Change-Id: I85c85b7a8de4794840b561e09841bb464cfa9dfe > Reviewed-on: https://pdfium-review.googlesource.com/3138 > Reviewed-by: Tom Sepez <tsepez@chromium.org> > Commit-Queue: dsinclair <dsinclair@chromium.org> > TBR=tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Iaee27570f140b2033b5d8fb8f3077fc839558d64 Reviewed-on: https://pdfium-review.googlesource.com/3158 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-22Remove CFX_FixedBufGrowDan Sinclair
This Cl replaces the CFX_FixedBufGrow class with std::vector. Change-Id: I85c85b7a8de4794840b561e09841bb464cfa9dfe Reviewed-on: https://pdfium-review.googlesource.com/3138 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-17Add pdfium::clamp() as a placeholder for std::clamp().chromium/3046Lei Zhang
Ue it to fix a typo as well. BUG=pdfium:634 Change-Id: I2d686242ffb841aedc2fae6a3cf7a00bea667404 Reviewed-on: https://pdfium-review.googlesource.com/3113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-15Refactor some CPDF_ColorSpace code.Lei Zhang
Change-Id: I1e30d68dae3bf70cf3c426f6126d593b7f1c3ba4 Reviewed-on: https://pdfium-review.googlesource.com/2991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-14Replace FX_FLOAT with underlying float type.Dan Sinclair
Change-Id: I158b7d80b0ec28b742a9f2d5a96f3dde7fb3ab56 Reviewed-on: https://pdfium-review.googlesource.com/3031 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-14Replace FX_CHAR and FX_WCHAR with underlying types.Dan Sinclair
Change-Id: I96e0a20d66b9184d22f64d8e4ce0dadd5a78c1e8 Reviewed-on: https://pdfium-review.googlesource.com/2967 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-13Remove openjpeg write support.thestig
Review-Url: https://codereview.chromium.org/2071693002
2017-03-13Fix some nits in fx_codec_faxNicolas Pena
Change-Id: I16acba7b3eda26b4edfbfe0cb356267bd536fee8 Reviewed-on: https://pdfium-review.googlesource.com/2964 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-13Check run lengths in FaxG4GetRowNicolas Pena
The spec says a1 is to the right of a0, a2 to the right of a1. I think that means that the run lengths have to be positive, but that certainly means that they cannot be negative. BUG=chromium:699340 Change-Id: Ic07a272e63610f7a66c5073179cdb2768f80e2b8 Reviewed-on: https://pdfium-review.googlesource.com/2963 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-07fx_codec_flate code cleanup.chromium/3035Dan Sinclair
This CL cleans up the namespacing along with some type confusion in the flate codec class. Change-Id: I4772ee571bcd78f1c839b5cefc370860aca06bb3 Reviewed-on: https://pdfium-review.googlesource.com/2917 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-06Check size before writtingchromium/3033dan sinclair
Before writting to the stream buffer make sure that we won't walk off the end of the allocated size. In this specific case the dest_size of the buffer is 0, so we're basically just looping over to free the temp results. BUG=chromium:697847 Change-Id: I229eea96179692216cb2685facbb7d5379c501c7 Reviewed-on: https://pdfium-review.googlesource.com/2903 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-01Create virtual codec APIs so chrome/fuzzers can link separatelyTom Sepez
The one step to make an actual concrete class is conditionalized in fpdfview and is unconditional in the fuzzer. Also replace the clumsy C-style callbacks with a delegate interface as long as we are making new interfaces. Change-Id: I733a437483ce5e0c34211cfbbda05105336f55b5 Reviewed-on: https://pdfium-review.googlesource.com/2887 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-02-27Fix nits from commit db764708.Lei Zhang
- Constify test data - ASSERT_EQ() buffer size - EXPECT_EQ() arguments are reversed - Fix typos in comments Change-Id: I846bfcc29bbf43d0a8b333250d1cce1aae5a8d59 Reviewed-on: https://pdfium-review.googlesource.com/2841 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-02-27Allow building XFA without additional codecs.Tom Sepez
This is something we'd like to try for initial XFA launches adding in codecs as justified by results in the wild. Adding statistics for the unsupported cases is a follow-up exercise once this builds correctly. We always build all the additional libraries, to allow fuzzers to link against them even if we are not shipping them. The linker will sort it out for the actual code. Rename some files to match the classes contained within. That the existing tests seem to pass with the codecs disabled warrants further investigation. Change-Id: Iad269db91289f12dc9f5dda8f48121d27a0c4367 Reviewed-on: https://pdfium-review.googlesource.com/2836 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-02-14Prevent heap-buffer-overflow in CCodec_ProgressiveDecoderNicolas Pena
In CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback, m_pSrcPalette can be allocated size pal_num. So if pal_index >= pal_num, then bail out. BUG=691278 Change-Id: Ib0157cf51cbf52ecd5d60b027e5fc32898a906ed Reviewed-on: https://pdfium-review.googlesource.com/2699 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-01-23Fix bug found by fuzzer in A85 encoder (bad shift).rbpotter
A85 encoder is not called yet; fix before adding calls to this code in Chromium. BUG=682550 Review-Url: https://codereview.chromium.org/2649263002
2017-01-16Use FX_Alloc() properly in fxcodec.tsepez
It already has a sizeof() and a cast built into the macro, so we don't need to do sizeof() and cast on each usage. Review-Url: https://codereview.chromium.org/2625133009
2017-01-12Add postscript pathrbpotter
This patch adds the additional functions required to make postscript printing functional. The most significant additions are are two added compression functions and a new API for setting the postscript level. Not currently called from Chromium, Chromium patch to come. BUG= Review-Url: https://codereview.chromium.org/2612243005
2017-01-11Make tiff_read return actual length readNicolas Pena
The return value is used to determine whether TIFFReadFile fails. If we return just the length, libtiff will try reading uninitilized values afterwards, on corrupted files. BUG=679230, 670928 Change-Id: I579adc9d8a00e8cafab45dbdb728f1cb702da051 Reviewed-on: https://pdfium-review.googlesource.com/2172 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-01-09Check validity of width and height in CCodec_TiffContext::LoadFrameInfoNicolas Pena
We are using pdfium::base::checked_cast to get the width and height, but we may overflow and abort. Therefore, we should instead early return if the obtained width and height are not valid int32_t's. BUG=655056 Change-Id: Ic0c6b88a16dc3d547fe82736bb14ed3122cd356a Reviewed-on: https://pdfium-review.googlesource.com/2160 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-01-09Remove CFX_ArrayTemplate from fpdftext and fxcodec.tsepez
Remove unused m_Segments. Review-Url: https://codereview.chromium.org/2618863004
2017-01-06Revert postscript code removal.rbpotter
Revert CL http://crrev.com/2608663003 in preparation for adding postscript generation to Pdfium. Note postscript generation code will not be called until additional patches land. These patches will also include modifications needed to make this code functional (currently missing a few compression functions). BUG= Review-Url: https://codereview.chromium.org/2615703002
2016-12-14Avoid the ptr.reset(new XXX()) anti-patterntsepez
Be suspicious of |new|. This removes some of the easy cases. Review-Url: https://codereview.chromium.org/2571913002
2016-12-13Return unique_ptr<>s from fxcodec/chromium/2951tsepez
Review-Url: https://codereview.chromium.org/2572843002
2016-12-07Refcount all the IFX_ stream classes all the time.tsepez
We can remove a lot of "bOwnsStream" logic in the process. Always pass these by const reference, in case the called method wants to hang on to the stream (one exception is where we stick a raw pointer into a void* slot in a context from another layer). Review-Url: https://codereview.chromium.org/2451493002
2016-12-06Return unique_ptrs from CFX_DIBitmap::Clone().tsepez
Because that's what clone does. Perform immediate release in some spots to avoid disrupting too much at once. Review-Url: https://codereview.chromium.org/2534953004
2016-11-22Multiply safely in CCodec_TiffContext::Decodenpm
BUG=667074 Review-Url: https://codereview.chromium.org/2520253003
2016-11-22pdfium: Fix inconsistent number of color components of ICC profilekcwu
fx_codec_icc.cpp specify default number of color components as 3 for unknown profiles. However, lcms may know such profile with different number of components. The inconsistency may lead to array access violation. This CL uses cmsChannelsOf() from lcms to ensure consistency. And rejects unexpected number according to PDF spec. BUG=chromium:667694 Review-Url: https://codereview.chromium.org/2522933002
2016-11-21Check dimensions and content of bitmaps in EmbedderTests.chromium/2927thestig
Review-Url: https://codereview.chromium.org/2514173002
2016-11-21Fixup lint flags.Dan Sinclair
The -build/include setting was masking out build/include_what_you_use. This CL restores them, fixes any build errors, and adds NOLINT as needed. As well, the runtime/explicit and runtime/printf flags are aslo enabled and NOLINT'd. lint cleanups Change-Id: Ib013b3eb29c8d0e48cad74c5df9028684130719f Reviewed-on: https://pdfium-review.googlesource.com/2030 Reviewed-by: Tom Sepez <tsepez@chromium.org>
2016-11-09Revert of Clean up fx_codec_icc.cpp (patchset #1 id:1 of ↵kcwu
https://codereview.chromium.org/2482663002/ ) Reason for revert: Max cmsChannelsOf() is 15, which is larger than expectation of existing code and cause crashes (at least the fuzzer). BUG=chromium:663240 Original issue's description: > Clean up fx_codec_icc.cpp > > Committed: https://pdfium.googlesource.com/pdfium/+/a94fc11866adb1b9ca4a4e1afb4fb574ed472e07 TBR=dsinclair@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. Review-Url: https://codereview.chromium.org/2485363002
2016-11-07Clean up fx_codec_icc.cppkcwu
Review-Url: https://codereview.chromium.org/2482663002
2016-11-02Remove FX_BOOL from coretsepez
Review-Url: https://codereview.chromium.org/2477443002
2016-11-01Fix founding difference in pdfium_test on AdobeCMYK_to_sRGBbrucedawson
An optimization to speed up float-to-int rounding caused a different result for one input value. This tweaks the conversion constant so that the results are identical across the entire valid range, and adds a test that checks the part of the range that is most sensitive to errors. BUG=pdfium:624 Review-Url: https://codereview.chromium.org/2466203002
2016-10-28Fix more FX_BOOL / int noise in core/fpdfsdktsepez
Review-Url: https://codereview.chromium.org/2454263002