K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2020 The PDFium Authors |
Lei Zhang | 01b618f | 2020-05-15 03:35:54 +0000 | [diff] [blame] | 2 | // 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 Zhang | b0e6fbc | 2021-08-05 22:06:49 +0000 | [diff] [blame] | 10 | #include <setjmp.h> |
| 11 | |
Lei Zhang | 01b618f | 2020-05-15 03:35:54 +0000 | [diff] [blame] | 12 | #include <memory> |
| 13 | |
| 14 | #include "core/fxcodec/progressive_decoder_iface.h" |
Lei Zhang | 01b618f | 2020-05-15 03:35:54 +0000 | [diff] [blame] | 15 | |
| 16 | namespace fxcodec { |
| 17 | |
| 18 | class CFX_DIBAttribute; |
| 19 | |
| 20 | class JpegProgressiveDecoder final : public ProgressiveDecoderIface { |
| 21 | public: |
Lei Zhang | 6b79c51 | 2023-10-25 18:58:12 +0000 | [diff] [blame^] | 22 | static void InitializeGlobals(); |
| 23 | static void DestroyGlobals(); |
| 24 | |
Lei Zhang | 01b618f | 2020-05-15 03:35:54 +0000 | [diff] [blame] | 25 | 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 Sepez | f61618b | 2021-10-27 22:13:36 +0000 | [diff] [blame] | 43 | RetainPtr<CFX_CodecMemory> codec_memory) override; |
Lei Zhang | 01b618f | 2020-05-15 03:35:54 +0000 | [diff] [blame] | 44 | |
| 45 | private: |
Lei Zhang | 01b618f | 2020-05-15 03:35:54 +0000 | [diff] [blame] | 46 | JpegProgressiveDecoder(); |
| 47 | ~JpegProgressiveDecoder() override; |
| 48 | }; |
| 49 | |
| 50 | } // namespace fxcodec |
| 51 | |
| 52 | using JpegProgressiveDecoder = fxcodec::JpegProgressiveDecoder; |
| 53 | |
| 54 | #endif // CORE_FXCODEC_JPEG_JPEG_PROGRESSIVE_DECODER_H_ |