Coverage Report

Created: 2025-10-12 06:18

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
0
{
31
0
  return std::vector<uint8_t>{};
32
0
}
33
34
35
int Decoder_JPEG2000::get_luma_bits_per_pixel() const
36
0
{
37
0
  Result<std::vector<uint8_t>> imageDataResult = get_compressed_data();
38
0
  if (!imageDataResult) {
39
0
    return -1;
40
0
  }
41
42
0
  JPEG2000MainHeader header;
43
0
  Error err = header.parseHeader(*imageDataResult);
44
0
  if (err) {
45
0
    return -1;
46
0
  }
47
0
  return header.get_precision(0);
48
0
}
49
50
51
int Decoder_JPEG2000::get_chroma_bits_per_pixel() const
52
0
{
53
0
  Result<std::vector<uint8_t>> imageDataResult = get_compressed_data();
54
0
  if (!imageDataResult) {
55
0
    return -1;
56
0
  }
57
58
0
  JPEG2000MainHeader header;
59
0
  Error err = header.parseHeader(*imageDataResult);
60
0
  if (err) {
61
0
    return -1;
62
0
  }
63
0
  return header.get_precision(1);
64
0
}
65
66
67
Error Decoder_JPEG2000::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const
68
0
{
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
0
  *out_colorspace = heif_colorspace_YCbCr;
81
0
  *out_chroma = heif_chroma_444;
82
83
0
  return Error::Ok;
84
0
}