diff options
Diffstat (limited to 'core/fxcodec/codec/ccodec_jpegmodule.cpp')
-rw-r--r-- | core/fxcodec/codec/ccodec_jpegmodule.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/core/fxcodec/codec/ccodec_jpegmodule.cpp b/core/fxcodec/codec/ccodec_jpegmodule.cpp index aaf16ae762..7c15aa35a0 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.cpp +++ b/core/fxcodec/codec/ccodec_jpegmodule.cpp @@ -31,12 +31,12 @@ extern "C" { #endif } // extern "C" -class CJpegContext final : public CCodec_JpegModule::Context { +class CJpegContext final : public CodecModuleIface::Context { public: CJpegContext(); ~CJpegContext() override; - jmp_buf* GetJumpMark() override { return &m_JumpMark; } + jmp_buf* GetJumpMark() { return &m_JumpMark; } jmp_buf m_JumpMark; jpeg_decompress_struct m_Info; @@ -398,7 +398,7 @@ CJpegContext::~CJpegContext() { jpeg_destroy_decompress(&m_Info); } -std::unique_ptr<CCodec_JpegModule::Context> CCodec_JpegModule::Start() { +std::unique_ptr<CodecModuleIface::Context> CCodec_JpegModule::Start() { // Use ordinary pointer until past the possibility of a longjump. auto* pContext = new CJpegContext(); if (setjmp(pContext->m_JumpMark) == -1) { @@ -412,22 +412,22 @@ std::unique_ptr<CCodec_JpegModule::Context> CCodec_JpegModule::Start() { return pdfium::WrapUnique(pContext); } -void CCodec_JpegModule::Input(Context* pContext, - const unsigned char* src_buf, - uint32_t src_size) { +bool CCodec_JpegModule::Input(Context* pContext, + pdfium::span<uint8_t> src_buf, + CFX_DIBAttribute*) { auto* ctx = static_cast<CJpegContext*>(pContext); if (ctx->m_SkipSize) { - if (ctx->m_SkipSize > src_size) { + if (ctx->m_SkipSize > src_buf.size()) { ctx->m_SrcMgr.bytes_in_buffer = 0; - ctx->m_SkipSize -= src_size; - return; + ctx->m_SkipSize -= src_buf.size(); + return true; } - src_size -= ctx->m_SkipSize; - src_buf += ctx->m_SkipSize; + src_buf = src_buf.subspan(ctx->m_SkipSize); ctx->m_SkipSize = 0; } - ctx->m_SrcMgr.next_input_byte = src_buf; - ctx->m_SrcMgr.bytes_in_buffer = src_size; + ctx->m_SrcMgr.next_input_byte = src_buf.data(); + ctx->m_SrcMgr.bytes_in_buffer = src_buf.size(); + return true; } #ifdef PDF_ENABLE_XFA @@ -464,9 +464,13 @@ bool CCodec_JpegModule::ReadScanline(Context* pContext, return nlines == 1; } -uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext) const { +FX_FILESIZE CCodec_JpegModule::GetAvailInput(Context* pContext) const { auto* ctx = static_cast<CJpegContext*>(pContext); - return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer; + return static_cast<FX_FILESIZE>(ctx->m_SrcMgr.bytes_in_buffer); +} + +jmp_buf* CCodec_JpegModule::GetJumpMark(Context* pContext) { + return static_cast<CJpegContext*>(pContext)->GetJumpMark(); } #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ |