Coverage Report

Created: 2025-07-23 08:18

/src/libheif/libheif/codecs/encoder.h
Line
Count
Source (jump to first uncovered line)
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_ENCODER_H
22
#define HEIF_ENCODER_H
23
24
#include "libheif/heif.h"
25
#include "error.h"
26
#include "libheif/heif_plugin.h"
27
28
#include <memory>
29
#include <string>
30
#include <utility>
31
#include <vector>
32
#include "sequences/seq_boxes.h"
33
34
class HeifPixelImage;
35
36
class Box;
37
38
39
class Encoder {
40
public:
41
43.7k
  virtual ~Encoder() = default;
42
43
  struct CodedImageData {
44
    std::vector<std::shared_ptr<Box>> properties;
45
    std::vector<uint8_t> bitstream;
46
    CodingConstraints codingConstraints;
47
48
    // If 0, the encoded size is equal to the input size.
49
    uint32_t encoded_image_width = 0;
50
    uint32_t encoded_image_height = 0;
51
52
    bool is_sync_frame = true; // TODO: set in encoder
53
54
    void append(const uint8_t* data, size_t size);
55
56
    void append_with_4bytes_size(const uint8_t* data, size_t size);
57
  };
58
59
  // If the output format requires a specific nclx (like JPEG), return this. Otherwise, return NULL.
60
0
  virtual const heif_color_profile_nclx* get_forced_output_nclx() const { return nullptr; }
61
62
  Result<std::shared_ptr<HeifPixelImage>> convert_colorspace_for_encoding(const std::shared_ptr<HeifPixelImage>& image,
63
                                                                          struct heif_encoder* encoder,
64
                                                                          const struct heif_encoding_options& options,
65
                                                                          const heif_security_limits* security_limits);
66
67
  virtual Result<CodedImageData> encode(const std::shared_ptr<HeifPixelImage>& image,
68
                                        struct heif_encoder* encoder,
69
                                        const struct heif_encoding_options& options,
70
0
                                        enum heif_image_input_class input_class) { return {}; }
71
72
0
  virtual std::shared_ptr<class Box_VisualSampleEntry> get_sample_description_box(const CodedImageData&) const { return {}; }
73
};
74
75
76
#endif