Coverage Report

Created: 2025-08-11 08:01

/src/libheif/libheif/image-items/vvc.cc
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * HEIF VVC codec.
3
 * Copyright (c) 2023 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 "vvc.h"
22
#include "codecs/vvc_dec.h"
23
#include "codecs/vvc_enc.h"
24
#include "codecs/vvc_boxes.h"
25
#include <cstring>
26
#include <string>
27
#include <cassert>
28
#include "api_structs.h"
29
#include <utility>
30
31
32
17
ImageItem_VVC::ImageItem_VVC(HeifContext* ctx, heif_item_id id) : ImageItem(ctx, id)
33
17
{
34
17
  m_encoder = std::make_shared<Encoder_VVC>();
35
17
}
36
37
0
ImageItem_VVC::ImageItem_VVC(HeifContext* ctx) : ImageItem(ctx)
38
0
{
39
0
  m_encoder = std::make_shared<Encoder_VVC>();
40
0
}
41
42
43
Result<std::vector<uint8_t>> ImageItem_VVC::read_bitstream_configuration_data() const
44
0
{
45
  // --- get codec configuration
46
47
0
  std::shared_ptr<Box_vvcC> vvcC_box = get_property<Box_vvcC>();
48
0
  if (!vvcC_box)
49
0
  {
50
0
    assert(false);
51
0
    return Error(heif_error_Invalid_input,
52
0
                 heif_suberror_No_vvcC_box);
53
0
  }
54
55
0
  std::vector<uint8_t> data;
56
0
  if (!vvcC_box->get_headers(&data))
57
0
  {
58
0
    return Error(heif_error_Invalid_input,
59
0
                 heif_suberror_No_item_data);
60
0
  }
61
62
0
  return data;
63
0
}
64
65
66
Result<std::shared_ptr<Decoder>> ImageItem_VVC::get_decoder() const
67
0
{
68
0
  return {m_decoder};
69
0
}
70
71
72
std::shared_ptr<class Encoder> ImageItem_VVC::get_encoder() const
73
0
{
74
0
  return m_encoder;
75
0
}
76
77
78
Error ImageItem_VVC::initialize_decoder()
79
16
{
80
16
  auto vvcC_box = get_property<Box_vvcC>();
81
16
  if (!vvcC_box) {
82
16
    return Error{heif_error_Invalid_input,
83
16
                 heif_suberror_No_av1C_box};
84
16
  }
85
86
0
  m_decoder = std::make_shared<Decoder_VVC>(vvcC_box);
87
88
0
  return Error::Ok;
89
16
}
90
91
void ImageItem_VVC::set_decoder_input_data()
92
0
{
93
0
  DataExtent extent;
94
0
  extent.set_from_image_item(get_context()->get_heif_file(), get_id());
95
96
0
  m_decoder->set_data_extent(std::move(extent));
97
0
}
98
99
heif_brand2 ImageItem_VVC::get_compatible_brand() const
100
0
{
101
0
  return heif_brand2_vvic;
102
0
}