blob: 5be4b874d247667843382f0816c6419fc640d1e8 [file] [log] [blame]
Dan Sinclair0bb13332017-03-30 16:12:02 -04001// Copyright 2017 PDFium Authors. All rights reserved.
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_CODEC_CJPX_DECODER_H_
8#define CORE_FXCODEC_CODEC_CJPX_DECODER_H_
9
Ryan Harrison808b52a2017-09-08 10:10:26 -040010#include <memory>
Dan Sinclair0bb13332017-03-30 16:12:02 -040011#include <vector>
12
Ryan Harrison808b52a2017-09-08 10:10:26 -040013#include "core/fxcodec/codec/codec_int.h"
Dan Sinclairaee0db02017-09-21 16:53:58 -040014#include "core/fxcrt/unowned_ptr.h"
Tom Sepez00ba8bb2018-06-27 18:02:30 +000015#include "third_party/base/span.h"
Dan Sinclair0bb13332017-03-30 16:12:02 -040016#include "third_party/libopenjpeg20/openjpeg.h"
17
18class CPDF_ColorSpace;
19
20class CJPX_Decoder {
21 public:
22 explicit CJPX_Decoder(CPDF_ColorSpace* cs);
23 ~CJPX_Decoder();
24
Tom Sepez00ba8bb2018-06-27 18:02:30 +000025 bool Init(pdfium::span<const uint8_t> src_data);
Dan Sinclair0bb13332017-03-30 16:12:02 -040026 void GetInfo(uint32_t* width, uint32_t* height, uint32_t* components);
27 bool Decode(uint8_t* dest_buf,
Ryan Harrisonb6e01172018-06-20 13:43:04 +000028 uint32_t pitch,
Dan Sinclair0bb13332017-03-30 16:12:02 -040029 const std::vector<uint8_t>& offsets);
30
31 private:
Tom Sepez00ba8bb2018-06-27 18:02:30 +000032 pdfium::span<const uint8_t> m_SrcData;
33 UnownedPtr<opj_image_t> m_Image;
34 UnownedPtr<opj_codec_t> m_Codec;
Ryan Harrison808b52a2017-09-08 10:10:26 -040035 std::unique_ptr<DecodeData> m_DecodeData;
Tom Sepez00ba8bb2018-06-27 18:02:30 +000036 UnownedPtr<opj_stream_t> m_Stream;
Ryan Harrison808b52a2017-09-08 10:10:26 -040037 opj_dparameters_t m_Parameters;
Dan Sinclairaee0db02017-09-21 16:53:58 -040038 UnownedPtr<const CPDF_ColorSpace> const m_ColorSpace;
Dan Sinclair0bb13332017-03-30 16:12:02 -040039};
40
41#endif // CORE_FXCODEC_CODEC_CJPX_DECODER_H_