Coverage Report

Created: 2025-11-16 07:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libheif/libheif/plugin_registry.h
Line
Count
Source
1
/*
2
 * HEIF codec.
3
 * Copyright (c) 2017 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 LIBHEIF_PLUGIN_REGISTRY_H
22
#define LIBHEIF_PLUGIN_REGISTRY_H
23
24
#include <map>
25
#include <memory>
26
#include <set>
27
#include <string>
28
#include <vector>
29
30
#include "error.h"
31
32
#include "libheif/heif.h"
33
#include "libheif/heif_plugin.h"
34
35
36
struct heif_encoder_descriptor
37
{
38
  const heif_encoder_plugin* plugin;
39
40
0
  const char* get_name() const { return plugin->get_plugin_name(); }
41
42
0
  heif_compression_format get_compression_format() const { return plugin->compression_format; }
43
};
44
45
46
struct encoder_descriptor_priority_order
47
{
48
  bool operator()(const std::unique_ptr<heif_encoder_descriptor>& a,
49
                  const std::unique_ptr<heif_encoder_descriptor>& b) const
50
2.52k
  {
51
2.52k
    return a->plugin->priority > b->plugin->priority;  // highest priority first
52
2.52k
  }
53
};
54
55
56
extern std::set<const heif_decoder_plugin*>& get_decoder_plugins();
57
58
extern std::multiset<std::unique_ptr<heif_encoder_descriptor>,
59
                     encoder_descriptor_priority_order>& get_encoder_descriptors();
60
61
void register_default_plugins();
62
63
void register_decoder(const heif_decoder_plugin* decoder_plugin);
64
65
void register_encoder(const heif_encoder_plugin* encoder_plugin);
66
67
void heif_unregister_decoder_plugins();
68
69
void heif_unregister_encoder_plugins();
70
71
#if ENABLE_PLUGIN_LOADING
72
void heif_unregister_encoder_plugin(const heif_encoder_plugin* plugin);
73
#endif
74
75
const heif_decoder_plugin* get_decoder(heif_compression_format type, const char* name_id);
76
77
const heif_encoder_plugin* get_encoder(heif_compression_format type);
78
79
std::vector<const heif_encoder_descriptor*>
80
get_filtered_encoder_descriptors(heif_compression_format,
81
                                 const char* name);
82
83
#endif