#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
#include <algorithm>
#include <array>
#include <utility>
#include "build/build_config.h"
#include "constants/stream_dict_common.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcodec/data_and_bytes_consumed.h"
#include "core/fxcodec/fax/faxmodule.h"
#include "core/fxcodec/flate/flatemodule.h"
#include "core/fxcodec/scanlinedecoder.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/containers/contains.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/numerics/safe_conversions.h"
#include "core/fxcrt/span.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxcrt/utf16.h"
namespace {
const uint32_t kMaxStreamSize = …;
bool CheckFlateDecodeParams(int Colors, int BitsPerComponent, int Columns) { … }
uint8_t GetA85Result(uint32_t res, size_t i) { … }
}
const std::array<uint16_t, 256> kPDFDocEncoding = …;
bool ValidateDecoderPipeline(const CPDF_Array* pDecoders) { … }
DataAndBytesConsumed A85Decode(pdfium::span<const uint8_t> src_span) { … }
DataAndBytesConsumed HexDecode(pdfium::span<const uint8_t> src_span) { … }
DataAndBytesConsumed RunLengthDecode(pdfium::span<const uint8_t> src_span) { … }
std::unique_ptr<ScanlineDecoder> CreateFaxDecoder(
pdfium::span<const uint8_t> src_span,
int width,
int height,
const CPDF_Dictionary* pParams) { … }
std::unique_ptr<ScanlineDecoder> CreateFlateDecoder(
pdfium::span<const uint8_t> src_span,
int width,
int height,
int nComps,
int bpc,
const CPDF_Dictionary* pParams) { … }
DataAndBytesConsumed FlateOrLZWDecode(bool use_lzw,
pdfium::span<const uint8_t> src_span,
const CPDF_Dictionary* pParams,
uint32_t estimated_size) { … }
std::optional<DecoderArray> GetDecoderArray(
RetainPtr<const CPDF_Dictionary> pDict) { … }
PDFDataDecodeResult::PDFDataDecodeResult() = default;
PDFDataDecodeResult::PDFDataDecodeResult(
DataVector<uint8_t> data,
ByteString image_encoding,
RetainPtr<const CPDF_Dictionary> image_params)
: … { … }
PDFDataDecodeResult::PDFDataDecodeResult(PDFDataDecodeResult&& that) noexcept =
default;
PDFDataDecodeResult& PDFDataDecodeResult::operator=(
PDFDataDecodeResult&& that) noexcept = default;
PDFDataDecodeResult::~PDFDataDecodeResult() = default;
std::optional<PDFDataDecodeResult> PDF_DataDecode(
pdfium::span<const uint8_t> src_span,
uint32_t last_estimated_size,
bool bImageAcc,
const DecoderArray& decoder_array) { … }
static size_t StripLanguageCodes(pdfium::span<wchar_t> s, size_t n) { … }
WideString PDF_DecodeText(pdfium::span<const uint8_t> span) { … }
ByteString PDF_EncodeText(WideStringView str) { … }
ByteString PDF_EncodeString(ByteStringView src) { … }
ByteString PDF_HexEncodeString(ByteStringView src) { … }