blob: 30cc19878df68d70de1ba4a816c19e32fe8b3a9f [file] [log] [blame]
// Copyright 2020 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_
#define CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_
#include <stdint.h>
#include <memory>
#include "core/fxcodec/cfx_codec_memory.h"
#include "core/fxcrt/fx_types.h"
namespace fxcodec {
class CFX_DIBAttribute;
class ProgressiveDecoderContext;
class JpegProgressiveDecoder {
public:
static std::unique_ptr<ProgressiveDecoderContext> Start();
// Result codes for ReadHeader()/ReadScanline():
static constexpr int kFatal = -1;
static constexpr int kOk = 0;
static constexpr int kError = 1;
static constexpr int kNeedsMoreInput = 2;
static int ReadHeader(ProgressiveDecoderContext* pContext,
int* width,
int* height,
int* nComps,
CFX_DIBAttribute* pAttribute);
static bool StartScanline(ProgressiveDecoderContext* pContext);
static int ReadScanline(ProgressiveDecoderContext* pContext,
uint8_t* dest_buf);
static FX_FILESIZE GetAvailInput(ProgressiveDecoderContext* pContext);
static bool Input(ProgressiveDecoderContext* pContext,
RetainPtr<CFX_CodecMemory> codec_memory);
// Only `static` methods.
JpegProgressiveDecoder() = delete;
JpegProgressiveDecoder(const JpegProgressiveDecoder&) = delete;
JpegProgressiveDecoder& operator=(const JpegProgressiveDecoder&) = delete;
};
} // namespace fxcodec
using JpegProgressiveDecoder = fxcodec::JpegProgressiveDecoder;
#endif // CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_