summaryrefslogtreecommitdiff
path: root/core/fxcodec
AgeCommit message (Collapse)Author
2018-10-12Split core/fxcrt build rules into core/fxcrt/BUILD.gn.Lei Zhang
Change-Id: I9b3608bd76ec4911a4bb820fcda62c5d9533fb4f Reviewed-on: https://pdfium-review.googlesource.com/c/43947 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-12Remove more unnecessary includes and do IWYU as needed.Lei Zhang
Also move some implementations out of headers. Change-Id: I321fc26970c440d874b135bd28e8bc8156b9afee Reviewed-on: https://pdfium-review.googlesource.com/c/43890 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-12Split most core build rules into various BUILD.gn files in core.Lei Zhang
Change-Id: I773eec2bbf104f073eba7a64ed19f6fba0131d21 Reviewed-on: https://pdfium-review.googlesource.com/c/43946 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-10-12Forward declare more in codec code.Lei Zhang
Change-Id: I8060ada299f845a9198a6e83d31d128bd4bf09bc Reviewed-on: https://pdfium-review.googlesource.com/c/43870 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-11Use pdfium::Vector2D in CCodec_FaxEncoder ctor.Lei Zhang
Instead of manual CHECKs. Change-Id: I387008bea88cba9b9b3e813631d9fc02ac7eb3a9 Reviewed-on: https://pdfium-review.googlesource.com/c/43932 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-10Fix dangling reference in CFX_CodecMemory.Tom Sepez
Do this by making CFX_CodecMemory actually own the memory that it is ref-counting. Remove some test cases that are now prohibited, and relax one lifetime restriction in the test because we are now doing one additional copy (in the test, but not in real life). Bug:879512 Change-Id: If030dfcf97fe40155c46a42288fc73192437ce9c Reviewed-on: https://pdfium-review.googlesource.com/c/43670 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-10Use std::vector in ccodec_faxmodule.cppTom Sepez
Rework a memset while we're at it. Change-Id: Id62ae3a8c1f64a93417915e23fcd93935ae95c73 Reviewed-on: https://pdfium-review.googlesource.com/c/43651 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-09Do IWYU for retain_ptr.h and unowned_ptr.hLei Zhang
Change-Id: I2897feee27f80c85f0328f0b220ae5be93686170 Reviewed-on: https://pdfium-review.googlesource.com/c/43610 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Do IWYU for ptr_util.h.Lei Zhang
Change-Id: Ib96a66eb47bea791f061e1d6da8aadad8037a99d Reviewed-on: https://pdfium-review.googlesource.com/c/43609 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Do IWYU for cpdf_dictionary.h.Lei Zhang
Move some method implementations out of headers in the process. Change-Id: I8701e360d4addd9aec39fe887d932209985d2443 Reviewed-on: https://pdfium-review.googlesource.com/c/43608 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-09Pass CFX_CodecMemory in place of spans to codecs.Tom Sepez
Next step towards making CFX_CodecMemory own the memory it is ref-counting. Change-Id: I5922d80d13032c3ea028447c47d34a10234109a3 Reviewed-on: https://pdfium-review.googlesource.com/c/43630 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-09Switch to std::vector in ccodec_flatemodule.cpp.Tom Sepez
We may choose to clean up the memcpy's in a subsequent cl. Change-Id: I038ae67504b6b3b9c3dbd36e9ddf2600392c2d94 Reviewed-on: https://pdfium-review.googlesource.com/c/43650 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-09Kill off some memset()s following FX_Alloc()Tom Sepez
Change-Id: I92aa74c86aef890fcb991f039b9707d680fdb83c Reviewed-on: https://pdfium-review.googlesource.com/c/43652 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-04Change |virtual ~Foo(){}| to |virtual ~Foo()=default;|chromium/3571Tom Sepez
Otherwise code coverage flags the empty body as unreachable. Change-Id: Iee1d9a876d68276529c70d9b8c7a28276f271767 Reviewed-on: https://pdfium-review.googlesource.com/c/43514 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-03Make CCodec_ProgressiveDecoder::ReadMoreData() slightly sanerchromium/3570Tom Sepez
- Fix buffer leak if TryRealloc fails. - Make m_SrcSize always represent the usable bytes in the buffer, even when read the last partial block from the file. - Remove redundant comparisons and use std::min(). - Better naming. Change-Id: Ie7dd79bac21b2f2422f299563a2dd28ed358e3e2 Reviewed-on: https://pdfium-review.googlesource.com/42130 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-02Consolidate ReadMoreData() calls.Tom Sepez
Extract some dividends from having landed the previous CL. Change-Id: I9ade77c801b51762cab801716b9fd2bc4c634036 Reviewed-on: https://pdfium-review.googlesource.com/c/41990 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-25Revert "Remove unreachable code in CPDF_DIBBase."Lei Zhang
This reverts commit 214982c4d02a720c3b1b3de121cddc62189b8848. Reason for revert: Turns out it is reachable. Original change's description: > Remove unreachable code in CPDF_DIBBase. > > The colorspace is always available when creating image decoders that use > colorspaces. > > Change-Id: I20ac75edcd614ccc1e83de262c128776e9d03eed > Reviewed-on: https://pdfium-review.googlesource.com/42872 > Commit-Queue: Ryan Harrison <rharrison@chromium.org> > Reviewed-by: Ryan Harrison <rharrison@chromium.org> TBR=thestig@chromium.org,rharrison@chromium.org BUG=chromium:888743 # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I45903543f0e4bf2785660fb8c1e45c34febb6ecf Reviewed-on: https://pdfium-review.googlesource.com/43050 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-25Add FxAlignToBoundary<>() template helper function.Tom Sepez
Because I nearly botched this trivial calculation in the previous CL. Change-Id: I7438f9d3476d93b7899c2d7d761234769f53f9e3 Reviewed-on: https://pdfium-review.googlesource.com/43010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-25Introduce CodecModuleIface for progressive decoder modules.Tom Sepez
Another step before trying to fix the memory issue. Forces common APIs on the bunch of decoders, though some methods are unused. Requires adding some arguments/return values to get to a common API which are not used in all cases (yet?). Required converting some args to spans. Required proxying a GetJumpMark() call through the public module API to the private context. Bug: pdfium:1082 Change-Id: I0c0b7415141ff2a6f4f44777ca3d05521f08130d Reviewed-on: https://pdfium-review.googlesource.com/41950 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-21Cleanup in CCodec_FaxModuleNicolas Pena
This CL moves FaxG4Decode to the class where it's implemented. It should remain there because it calls FaxG4GetRow, declared and used in the cpp file. Do some ++ cleanup while at it. This CL also makes CCodec_FaxModule own some methods that were namespaced since doing so allows removing a bunch of parameters. Change-Id: I24787f5668c7273b9bdb4009c3d0b29590c5552f Reviewed-on: https://pdfium-review.googlesource.com/42950 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-09-21Remove unreachable code in CPDF_DIBBase.Lei Zhang
The colorspace is always available when creating image decoders that use colorspaces. Change-Id: I20ac75edcd614ccc1e83de262c128776e9d03eed Reviewed-on: https://pdfium-review.googlesource.com/42872 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-20Remove extraneous 'extern "C"' entries.Lei Zhang
Also remove dead code found along the way, and fix lint errors. BUG=pdfium:410 Change-Id: I4cd0ede516483209cf49a6686d909953ab196106 Reviewed-on: https://pdfium-review.googlesource.com/42771 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-20Fix misc lint errors and other cleanups.Lei Zhang
Change-Id: I00ce0109251d1231858e87ffc3889abe6937fa26 Reviewed-on: https://pdfium-review.googlesource.com/42811 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-09-20Remove many unneeded STL #includes from headers.Lei Zhang
Change-Id: I7010cedee8d17d05b2c37a94d767e6f3a9c48f7d Reviewed-on: https://pdfium-review.googlesource.com/42790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-17Remove a check that is never true in CJBig2_ArithDecoder::Decode().chromium/3555Lei Zhang
Change-Id: I538fd8bf9905be61d2297181bd02a243a01b30db Reviewed-on: https://pdfium-review.googlesource.com/42607 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-17Use more booleans within JBig2ArithCtx.Lei Zhang
Change-Id: I41535238715926795f5c588dcae0834bf3a789d0 Reviewed-on: https://pdfium-review.googlesource.com/42606 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-17Make JBig2ArithCtx a class.Lei Zhang
For better encapsulation. Change-Id: Ia6fd8056112d97d672b91a9a521a2978c807060f Reviewed-on: https://pdfium-review.googlesource.com/42605 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-17Fix final/protected conflicts.Tom Sepez
Classes marked |final| should not have |protected| members. In turn, "private field m_dwEncryptObjNum is not used" warning is produced. Change-Id: I51a96aca5a5f499381a6764d892962f7f2dc0327 Reviewed-on: https://pdfium-review.googlesource.com/42611 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-11Fix a regression in CJBig2_Context::HuffmanAssignCode().Lei Zhang
An assignment statement accidentally got removed in https://pdfium-review.googlesource.com/c/pdfium/+/31538. BUG=chromium:880920 Change-Id: Iaff20bd2484cd8bf6dc6a13cbf444cefbd605b25 Reviewed-on: https://pdfium-review.googlesource.com/42250 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-11Make flate decode functions' buffer out parameter unique_ptrs.Lei Zhang
Change-Id: Idb14846e87a8287dd911b0a2f7a32146e86c2af7 Reviewed-on: https://pdfium-review.googlesource.com/41853 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-09-11Make RunLengthDecode()'s buffer out parameter a unique_ptr.Lei Zhang
Change-Id: I1dc99831a564e88035c317455411f1eba9aa41c4 Reviewed-on: https://pdfium-review.googlesource.com/41852 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-09-06Rename CFX_GifContext::ReadData() to ReadAllOrNone()Tom Sepez
The whole point of this wrapper method is to disallow partial reads, so name it accordingly. No functional change. Change-Id: Ia2e7ee756192615f399369d5b077b836438befb2 Reviewed-on: https://pdfium-review.googlesource.com/42150 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-04Consolidate some common code in ccoded_progressivedecoder.Tom Sepez
Small consolidation before trying to fix a memory issue. Unfortunately, this involves converting a switch -> ifs, since we no longer dispatch exactly the same. Change-Id: I7ef61db98cdfbbc983adf21e7b3fe4ef1d2ce869 Reviewed-on: https://pdfium-review.googlesource.com/41830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-04Fix some more span/memcpy interactions.Tom Sepez
Use the preferred idiom of creating a subspan, which makes the proper checks prior to the copy. Change-Id: Ia7f25b5760dea5707df66cf421195b23a1ce0ad0 Reviewed-on: https://pdfium-review.googlesource.com/41911 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-31Remove avail_buf out argument from GetAvailInput() methods.chromium/3542chromium/3541chromium/3540chromium/3539Tom Sepez
It's always passed as nullptr. It's a good thing, too, since it looks like some of the implementations are returning a wrong pointer. Add some missing |const|s. Change-Id: I768048fdfe4cdd1dc838fee26fec18e024e39920 Reviewed-on: https://pdfium-review.googlesource.com/41810 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-30Use pdfium::span<> arg in A85 and RLE encoder methodsTom Sepez
Change-Id: Iff900bc3e1cd9c9dd6b023230c1feba78759581c Reviewed-on: https://pdfium-review.googlesource.com/41710 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-30Fix lifetime issue in CCodec_ProgressiveDecoder.Tom Sepez
The associated bug is caused by failure to clean up context before returing at line 740 or so. But cleanups are fragile, so instead do not move context out of a local until success. This in turn means passing the local to one helper rather that using the stored value and confirming this is the only helper method invoked during the time in which the context is not yet stored. Bug: 879025 Change-Id: I1acb438edc28f7f4dd8acccc2461fe3a5ea7f5c8 Reviewed-on: https://pdfium-review.googlesource.com/41670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-29Use pdfium::span<> in fpdf_parser_decode.h helper functions.Tom Sepez
Change-Id: Ib0a2bd21fe4304163cf9c080e07475e7c033c299 Reviewed-on: https://pdfium-review.googlesource.com/41570 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Use pdfium::span<> in more image modulesTom Sepez
Change-Id: Ie344bb37abf7dde158d03cc2897dca3588f1a5e3 Reviewed-on: https://pdfium-review.googlesource.com/41550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-28Rename remaining fx_codec*.cpp to match class and .h file nameTom Sepez
Then include headers in the proper order per standards, since it will no longer trigger a presubmit warning. Change-Id: I6bb86ac90e8fd9aed30b66dac61726f0dea8222c Reviewed-on: https://pdfium-review.googlesource.com/41535 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Use std::span<> in CCodec_JPEGModuleTom Sepez
Also rename .cpp file to match class name and .h file. Modify some helper functions to operate on spans. Move some initializations to member declarations. Change-Id: Ie0889bda91daaef80fae6f5681f8ce068e92453b Reviewed-on: https://pdfium-review.googlesource.com/41534 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Let CCodec_ProgressiveDecoder::m_pSrcBuf outlive contextsTom Sepez
This requires making some members unique_ptr<> to preserve the destruction order. Bug: 877766 Change-Id: I69e0173fdde7e9cd0d24017d6c829b9b9cf600c0 Reviewed-on: https://pdfium-review.googlesource.com/41490 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-27Rework CCODEC_ProgressiveDecoder.Tom Sepez
Rename .cpp file to match class and .h file (!!!) Put initialziations into header. Change-Id: I2cbc7608287f8df887ce186d122dcd3db2aef19b Reviewed-on: https://pdfium-review.googlesource.com/41511 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-27Use pdfium::span<> in CCodec_RLScanlineDecoderTom Sepez
Change-Id: I3dc2dd54d89858722c2aea4b9e694308796b8274 Reviewed-on: https://pdfium-review.googlesource.com/41510 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27The final game: mark everything final.Tom Sepez
Then revert the ones that break compilation. Fix one IWYU noticed during presubmit. Change-Id: I881a8a72818e55dbc4816247e35ff5e3015194e7 Reviewed-on: https://pdfium-review.googlesource.com/41470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-24Rename CFX_DIBSource to CFX_DIBBase.Tom Sepez
It is not a source from which you can get CFX_DIBs, but rather a base class from which all DIBs inherit. Do the same thing for the CPDF_DIBSource wrapper class. Mechanical change apart from adding a one-line comment in cfx_dibbase.h Change-Id: Id2bde87813ca301d9fafc55ce08d703dfc6a7184 Reviewed-on: https://pdfium-review.googlesource.com/41352 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-24Use span<uint8_t> in more fxcodec code.Tom Sepez
There are also small tweaks in tests to ensure strict order of stack variable lifetimes. Change-Id: Ic9d5c6a2bdd378b517be627f8e29f725bafdc2ad Reviewed-on: https://pdfium-review.googlesource.com/41310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Fix shadowed variablesRyan Harrison
This CL fixes instances of variable shadowing that are discovered by turning on -Wshadow. BUG=pdfium:1137 Change-Id: I418d50de89ecbeb12e85b23a358bc61e8f16e888 Reviewed-on: https://pdfium-review.googlesource.com/41150 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-22Use UnownedPtr<> in JBig2_TrdProc, part 2.Tom Sepez
Re-order some locals to obey strict lifetime constraint. Pack a little tighter. Change-Id: Iae011d21b934fac865cf10ac20c046c8917d3a98 Reviewed-on: https://pdfium-review.googlesource.com/40915 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-21Use UnownedPtr<> in JBIG2_SDDProc.Tom Sepez
Pack a little tighter while at it. Change-Id: If7cbb324ebf828a4bb60eb364fc3e0f31625e57f Reviewed-on: https://pdfium-review.googlesource.com/40913 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>