/src/libheif/libheif/plugins/nalu_utils.h
Line | Count | Source |
1 | | /* |
2 | | * HEIF 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 | | #include <map> |
22 | | #include <memory> |
23 | | #include "libheif/heif.h" |
24 | | |
25 | | static const int AVC_NAL_UNIT_MAX_VCL = 5; |
26 | | static const int AVC_NAL_UNIT_SPS_NUT = 7; |
27 | | static const int AVC_NAL_UNIT_PPS_NUT = 8; |
28 | | static const int AVC_NAL_UNIT_SPS_EXT_NUT = 13; |
29 | | |
30 | | static const int HEVC_NAL_UNIT_MAX_VCL = 31; |
31 | | static const int HEVC_NAL_UNIT_VPS_NUT = 32; |
32 | | static const int HEVC_NAL_UNIT_SPS_NUT = 33; |
33 | | static const int HEVC_NAL_UNIT_PPS_NUT = 34; |
34 | | static const int HEVC_NAL_UNIT_IDR_W_RADL = 19; |
35 | | static const int HEVC_NAL_UNIT_IDR_N_LP = 20; |
36 | | |
37 | | static const int VVC_NAL_UNIT_MAX_VCL = 11; |
38 | | static const int VVC_NAL_UNIT_VPS_NUT = 14; |
39 | | static const int VVC_NAL_UNIT_SPS_NUT = 15; |
40 | | static const int VVC_NAL_UNIT_PPS_NUT = 16; |
41 | | static const int VVC_NAL_UNIT_SUFFIX_SEI_NUT = 24; |
42 | | |
43 | | |
44 | | class NalUnit |
45 | | { |
46 | | public: |
47 | | NalUnit(); |
48 | | ~NalUnit() = default; |
49 | | bool set_data(const unsigned char* in_data, int n); |
50 | 0 | int size() const { return nal_data_size; } |
51 | 0 | int unit_type() const { return nal_unit_type; } |
52 | 0 | const unsigned char* data() const { return nal_data_ptr; } |
53 | | int bitExtracted(int number, int bits_count, int position_nr); |
54 | | private: |
55 | | const unsigned char* nal_data_ptr; |
56 | | int nal_unit_type; |
57 | | int nal_data_size; |
58 | | }; |
59 | | |
60 | | class NalMap |
61 | | { |
62 | | public: |
63 | | size_t count(int nal_type); |
64 | | |
65 | | const unsigned char* data(int nal_type); |
66 | | |
67 | | int size(int nal_type); |
68 | | |
69 | | const heif_error parseHevcNalu(const uint8_t *cdata, size_t size); |
70 | | |
71 | | void clear(); |
72 | | private: |
73 | | std::map<int, std::unique_ptr<NalUnit>> map; |
74 | | }; |