Coverage Report

Created: 2026-07-25 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libheif/libheif/codecs/uncompressed/unc_dec.h
Line
Count
Source
1
/*
2
 * HEIF codec.
3
 * Copyright (c) 2024 Dirk Farin <dirk.farin@gmail.com>
4
 *
5
 * This file is part of libheif.
6
 *
7
 * libheif is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Lesser General Public License as
9
 * published by the Free Software Foundation, either version 3 of
10
 * the License, or (at your option) any later version.
11
 *
12
 * libheif is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public License
18
 * along with libheif.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#ifndef HEIF_UNC_DEC_H
22
#define HEIF_UNC_DEC_H
23
24
#include "libheif/heif.h"
25
#include "box.h"
26
#include "error.h"
27
28
#include <memory>
29
#include <vector>
30
#include "codecs/decoder.h"
31
#include <utility>
32
33
class Box_uncC;
34
class Box_cmpd;
35
class Box_cpat;
36
class Box_cmpC;
37
class Box_icef;
38
class Box_splz;
39
class Box_sbpm;
40
class Box_snuc;
41
class Box_cloc;
42
43
44
class Decoder_uncompressed : public Decoder
45
{
46
public:
47
  explicit Decoder_uncompressed(std::shared_ptr<Box_uncC> uncC,
48
                                std::shared_ptr<Box_cmpd> cmpd,
49
                                std::shared_ptr<const Box_ispe> ispe);
50
51
0
  void set_cpat(std::shared_ptr<const Box_cpat> cpat) { m_cpat = std::move(cpat); }
52
0
  void set_cmpC(std::shared_ptr<const Box_cmpC> cmpC) { m_cmpC = std::move(cmpC); }
53
0
  void set_icef(std::shared_ptr<const Box_icef> icef) { m_icef = std::move(icef); }
54
0
  void set_cloc(std::shared_ptr<const Box_cloc> cloc) { m_cloc = std::move(cloc); }
55
0
  void set_splz(std::vector<std::shared_ptr<const Box_splz>> splz) { m_splz = std::move(splz); }
56
0
  void set_sbpm(std::vector<std::shared_ptr<const Box_sbpm>> sbpm) { m_sbpm = std::move(sbpm); }
57
0
  void set_snuc(std::vector<std::shared_ptr<const Box_snuc>> snuc) { m_snuc = std::move(snuc); }
58
59
  // Overloads accepting non-const shared_ptrs (from get_child_boxes)
60
0
  void set_splz(std::vector<std::shared_ptr<Box_splz>> splz) { m_splz.assign(splz.begin(), splz.end()); }
61
0
  void set_sbpm(std::vector<std::shared_ptr<Box_sbpm>> sbpm) { m_sbpm.assign(sbpm.begin(), sbpm.end()); }
62
0
  void set_snuc(std::vector<std::shared_ptr<Box_snuc>> snuc) { m_snuc.assign(snuc.begin(), snuc.end()); }
63
64
0
  heif_compression_format get_compression_format() const override { return heif_compression_uncompressed; }
65
66
  int get_luma_bits_per_pixel() const override;
67
68
  int get_chroma_bits_per_pixel() const override;
69
70
  Error get_coded_image_colorspace(heif_colorspace*, heif_chroma*) const override;
71
72
  bool has_alpha_component() const;
73
74
  Result<std::vector<uint8_t>> read_bitstream_configuration_data() const override;
75
76
  Result<std::shared_ptr<HeifPixelImage>>
77
  decode_single_frame_from_compressed_data(const struct heif_decoding_options& options,
78
                                           const struct heif_security_limits* limits) override;
79
80
81
  // Push data for one frame into decoder.
82
  Error
83
  decode_sequence_frame_from_compressed_data(bool upload_configuration_NALs,
84
                                             const heif_decoding_options& options,
85
                                             uintptr_t user_data,
86
                                             const heif_security_limits* limits) override;
87
88
0
  Error flush_decoder() override { return {}; }
89
90
  // Get a decoded frame from the decoder.
91
  // It may return NULL when there is buffering in the codec.
92
  Result<std::shared_ptr<HeifPixelImage> > get_decoded_frame(const heif_decoding_options& options,
93
                                                             uintptr_t* out_user_data,
94
                                                             const heif_security_limits* limits) override;
95
96
private:
97
  std::shared_ptr<const Box_uncC> m_uncC;
98
  std::shared_ptr<const Box_cmpd> m_cmpd;
99
  std::shared_ptr<const Box_ispe> m_ispe;
100
  std::shared_ptr<const Box_cpat> m_cpat;
101
  std::shared_ptr<const Box_cmpC> m_cmpC;
102
  std::shared_ptr<const Box_icef> m_icef;
103
  std::vector<std::shared_ptr<const Box_splz>> m_splz;
104
  std::vector<std::shared_ptr<const Box_sbpm>> m_sbpm;
105
  std::vector<std::shared_ptr<const Box_snuc>> m_snuc;
106
  std::shared_ptr<const Box_cloc> m_cloc;
107
108
  std::shared_ptr<HeifPixelImage> m_decoded_image;
109
  uintptr_t m_decoded_image_user_data;
110
};
111
112
#endif