blob: a94e33a6cafc99b1cd6c4af5cb92d0f2d01c06c0 [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2020 The PDFium Authors
Lei Zhang01b618f2020-05-15 03:35:54 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_
8#define CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_
9
Lei Zhangb0e6fbc2021-08-05 22:06:49 +000010#include <setjmp.h>
11
Lei Zhang01b618f2020-05-15 03:35:54 +000012#include <memory>
13
14#include "core/fxcodec/progressive_decoder_iface.h"
Lei Zhang01b618f2020-05-15 03:35:54 +000015
16namespace fxcodec {
17
18class CFX_DIBAttribute;
19
20class JpegProgressiveDecoder final : public ProgressiveDecoderIface {
21 public:
Lei Zhang6b79c512023-10-25 18:58:12 +000022 static void InitializeGlobals();
23 static void DestroyGlobals();
24
Lei Zhang01b618f2020-05-15 03:35:54 +000025 static JpegProgressiveDecoder* GetInstance();
26
27 static std::unique_ptr<Context> Start();
28
29 static jmp_buf& GetJumpMark(Context* pContext);
30
31 static int ReadHeader(Context* pContext,
32 int* width,
33 int* height,
34 int* nComps,
35 CFX_DIBAttribute* pAttribute);
36
37 static bool StartScanline(Context* pContext, int down_scale);
38 static bool ReadScanline(Context* pContext, uint8_t* dest_buf);
39
40 // ProgressiveDecoderIface:
41 FX_FILESIZE GetAvailInput(Context* pContext) const override;
42 bool Input(Context* pContext,
Tom Sepezf61618b2021-10-27 22:13:36 +000043 RetainPtr<CFX_CodecMemory> codec_memory) override;
Lei Zhang01b618f2020-05-15 03:35:54 +000044
45 private:
Lei Zhang01b618f2020-05-15 03:35:54 +000046 JpegProgressiveDecoder();
47 ~JpegProgressiveDecoder() override;
48};
49
50} // namespace fxcodec
51
52using JpegProgressiveDecoder = fxcodec::JpegProgressiveDecoder;
53
54#endif // CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_