/src/libheif/libheif/codecs/hevc_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_HEVC_H |
22 | | #define HEIF_ENCODER_HEVC_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_HEVC : public Encoder { |
37 | | public: |
38 | | Result<CodedImageData> encode(const std::shared_ptr<HeifPixelImage>& image, |
39 | | heif_encoder* encoder, |
40 | | const heif_encoding_options& options, |
41 | | heif_image_input_class input_class) override; |
42 | | |
43 | 0 | bool encode_sequence_started() const override { return m_encoder_active; } |
44 | | |
45 | | Error encode_sequence_frame(const std::shared_ptr<HeifPixelImage>& image, |
46 | | heif_encoder* encoder, |
47 | | const heif_sequence_encoding_options& options, |
48 | | heif_image_input_class input_class, |
49 | | uint32_t framerate_num, uint32_t framerate_denom, |
50 | | uintptr_t frame_number) override; |
51 | | |
52 | | Error encode_sequence_flush(heif_encoder* encoder) override; |
53 | | |
54 | | std::optional<CodedImageData> encode_sequence_get_data() override; |
55 | | |
56 | | std::shared_ptr<Box_VisualSampleEntry> get_sample_description_box(const CodedImageData&) const override; |
57 | | |
58 | | private: |
59 | | bool m_encoder_active = false; |
60 | | bool m_end_of_sequence_reached = false; |
61 | | |
62 | | // Whether the hvcC is complete and was returned in an encode_sequence_get_data() call. |
63 | | bool m_hvcC_has_VPS = false; |
64 | | bool m_hvcC_has_SPS = false; |
65 | | bool m_hvcC_has_PPS = false; |
66 | | std::shared_ptr<class Box_hvcC> m_hvcC; |
67 | | bool m_hvcC_sent = false; |
68 | | |
69 | | int m_encoded_image_width = 0; |
70 | | int m_encoded_image_height = 0; |
71 | | |
72 | | std::optional<CodedImageData> m_current_output_data; |
73 | | |
74 | | Error get_data(heif_encoder*); |
75 | | }; |
76 | | |
77 | | |
78 | | #endif |