1 // Copyright 2020 The PDFium Authors 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 10 #include <setjmp.h> 11 12 #include <memory> 13 14 #include "core/fxcodec/progressive_decoder_iface.h" 15 16 namespace fxcodec { 17 18 class CFX_DIBAttribute; 19 20 class JpegProgressiveDecoder final : public ProgressiveDecoderIface { 21 public: 22 static void InitializeGlobals(); 23 static void DestroyGlobals(); 24 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); 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, 43 RetainPtr<CFX_CodecMemory> codec_memory) override; 44 45 private: 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_ 55