Coverage Report

Created: 2025-12-21 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libheif/libheif/codecs/jpeg_enc.h
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
#ifndef HEIF_ENCODER_JPEG_H
22
#define HEIF_ENCODER_JPEG_H
23
24
#include "libheif/heif.h"
25
#include "box.h"
26
#include "error.h"
27
#include "file.h"
28
29
#include <memory>
30
#include <string>
31
#include <utility>
32
#include <vector>
33
#include "codecs/encoder.h"
34
35
36
class Encoder_JPEG : public Encoder {
37
public:
38
  const heif_color_profile_nclx* get_forced_output_nclx() const override;
39
40
  Result<CodedImageData> encode(const std::shared_ptr<HeifPixelImage>& image,
41
                                heif_encoder* encoder,
42
                                const heif_encoding_options& options,
43
                                enum heif_image_input_class input_class) override;
44
45
  std::shared_ptr<Box_VisualSampleEntry> get_sample_description_box(const CodedImageData&) const override;
46
47
48
0
  bool encode_sequence_started() const override { return m_codedImageData.has_value(); }
49
50
  Error encode_sequence_frame(const std::shared_ptr<HeifPixelImage>& image,
51
                                      heif_encoder* encoder,
52
                                      const heif_sequence_encoding_options& options,
53
                                      heif_image_input_class input_class,
54
                                      uint32_t framerate_num, uint32_t framerate_denom,
55
                                      uintptr_t frame_number) override
56
0
  {
57
0
    heif_encoding_options dummy_options{};
58
59
0
    auto encodeResult = encode(image, encoder, dummy_options, input_class);
60
0
    if (encodeResult.error()) {
61
0
      return encodeResult.error();
62
0
    }
63
64
0
    m_codedImageData = std::move(*encodeResult);
65
66
0
    m_codedImageData->frame_nr = frame_number;
67
0
    m_codedImageData->is_sync_frame = true;
68
69
0
    return {};
70
0
  }
71
72
  Error encode_sequence_flush(heif_encoder* encoder) override
73
0
  {
74
0
    return {};
75
0
  }
76
77
  std::optional<CodedImageData> encode_sequence_get_data() override
78
0
  {
79
0
    return std::move(m_codedImageData);
80
0
  }
81
82
private:
83
  std::optional<CodedImageData> m_codedImageData;
84
};
85
86
87
#endif