Coverage Report

Created: 2026-05-24 07:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libheif/libheif/codecs/jpeg2000_dec.cc
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
#include "jpeg2000_dec.h"
22
#include "jpeg2000_boxes.h"
23
#include "error.h"
24
#include "context.h"
25
26
#include <string>
27
28
29
Result<std::vector<uint8_t>> Decoder_JPEG2000::read_bitstream_configuration_data() const
30
4.14k
{
31
4.14k
  return std::vector<uint8_t>{};
32
4.14k
}
33
34
35
int Decoder_JPEG2000::get_luma_bits_per_pixel() const
36
2.07k
{
37
2.07k
  Result<std::vector<uint8_t>> imageDataResult = get_compressed_data(true);
38
2.07k
  if (!imageDataResult) {
39
7
    return -1;
40
7
  }
41
42
2.06k
  JPEG2000MainHeader header;
43
2.06k
  Error err = header.parseHeader(*imageDataResult);
44
2.06k
  if (err) {
45
26
    return -1;
46
26
  }
47
2.03k
  return header.get_precision(0);
48
2.06k
}
49
50
51
int Decoder_JPEG2000::get_chroma_bits_per_pixel() const
52
1.03k
{
53
1.03k
  Result<std::vector<uint8_t>> imageDataResult = get_compressed_data(true);
54
1.03k
  if (!imageDataResult) {
55
4
    return -1;
56
4
  }
57
58
1.03k
  JPEG2000MainHeader header;
59
1.03k
  Error err = header.parseHeader(*imageDataResult);
60
1.03k
  if (err) {
61
14
    return -1;
62
14
  }
63
1.02k
  return header.get_precision(1);
64
1.03k
}
65
66
67
Error Decoder_JPEG2000::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const
68
3.10k
{
69
#if 0
70
  *out_chroma = (heif_chroma) (m_hvcC->get_configuration().chroma_format);
71
72
  if (*out_chroma == heif_chroma_monochrome) {
73
    *out_colorspace = heif_colorspace_monochrome;
74
  }
75
  else {
76
    *out_colorspace = heif_colorspace_YCbCr;
77
  }
78
#endif
79
80
3.10k
  *out_colorspace = heif_colorspace_YCbCr;
81
3.10k
  *out_chroma = heif_chroma_444;
82
83
3.10k
  return Error::Ok;
84
3.10k
}