/src/libheif/libheif/codecs/vvc_boxes.h
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 | | #ifndef LIBHEIF_VVC_BOXES_H |
22 | | #define LIBHEIF_VVC_BOXES_H |
23 | | |
24 | | #include "box.h" |
25 | | #include <string> |
26 | | #include <vector> |
27 | | #include "image-items/image_item.h" |
28 | | #include <memory> |
29 | | #include "sequences/seq_boxes.h" |
30 | | |
31 | | |
32 | | class Box_vvcC : public FullBox |
33 | | { |
34 | | public: |
35 | | Box_vvcC() |
36 | 157 | { |
37 | 157 | set_short_type(fourcc("vvcC")); |
38 | 157 | } |
39 | | |
40 | 0 | bool is_essential() const override { return true; } |
41 | | |
42 | | struct VvcPTLRecord { |
43 | | uint8_t num_bytes_constraint_info; // 6 bits |
44 | | uint8_t general_profile_idc; // 7 bits |
45 | | uint8_t general_tier_flag; // 1 bit |
46 | | uint8_t general_level_idc; // 8 bits |
47 | | uint8_t ptl_frame_only_constraint_flag; // 1 bit |
48 | | uint8_t ptl_multi_layer_enabled_flag; // 1 bit |
49 | | std::vector<uint8_t> general_constraint_info; |
50 | | |
51 | | std::vector<bool> ptl_sublayer_level_present_flag; // TODO: should we save this here or can we simply derive it on the fly? |
52 | | |
53 | | std::vector<uint8_t> sublayer_level_idc; |
54 | | std::vector<uint32_t> general_sub_profile_idc; |
55 | | }; |
56 | | |
57 | | struct configuration |
58 | | { |
59 | | uint8_t LengthSizeMinusOne = 3; // 0,1,3 default: 4 bytes for NAL unit lengths |
60 | | bool ptl_present_flag = true; |
61 | | |
62 | | // only of PTL present |
63 | | uint16_t ols_idx; // 9 bits |
64 | | uint8_t num_sublayers; // 3 bits |
65 | | uint8_t constant_frame_rate; // 2 bits |
66 | | uint8_t chroma_format_idc; // 2 bits |
67 | | uint8_t bit_depth_minus8; // 3 bits |
68 | | struct VvcPTLRecord native_ptl; |
69 | | uint16_t max_picture_width; |
70 | | uint16_t max_picture_height; |
71 | | uint16_t avg_frame_rate; |
72 | | }; |
73 | | |
74 | | |
75 | | std::string dump(Indent&) const override; |
76 | | |
77 | | bool get_headers(std::vector<uint8_t>* dest) const; |
78 | | |
79 | 0 | void set_configuration(const configuration& config) { m_configuration = config; } |
80 | | |
81 | 0 | const configuration& get_configuration() const { return m_configuration; } |
82 | | |
83 | | void append_nal_data(const std::vector<uint8_t>& nal); |
84 | | void append_nal_data(const uint8_t* data, size_t size); |
85 | | |
86 | | Error write(StreamWriter& writer) const override; |
87 | | |
88 | | protected: |
89 | | Error parse(BitstreamRange& range, const heif_security_limits* limits) override; |
90 | | |
91 | | private: |
92 | | struct NalArray |
93 | | { |
94 | | bool m_array_completeness; |
95 | | uint8_t m_NAL_unit_type; |
96 | | |
97 | | std::vector<std::vector<uint8_t> > m_nal_units; // only one NAL item for DCI and OPI |
98 | | }; |
99 | | |
100 | | configuration m_configuration; |
101 | | std::vector<NalArray> m_nal_array; |
102 | | }; |
103 | | |
104 | | |
105 | | class Box_vvc1 : public Box_VisualSampleEntry |
106 | | { |
107 | | public: |
108 | | Box_vvc1() |
109 | 21 | { |
110 | 21 | set_short_type(fourcc("vvc1")); |
111 | 21 | } |
112 | | }; |
113 | | |
114 | | |
115 | | Error parse_sps_for_vvcC_configuration(const uint8_t* sps, size_t size, |
116 | | Box_vvcC::configuration* inout_config, |
117 | | int* width, int* height); |
118 | | |
119 | | #endif // LIBHEIF_VVC_BOXES_H |