Coverage Report

Created: 2026-05-30 06:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/libde265/libde265/nal.h
Line
Count
Source
1
/*
2
 * H.265 video codec.
3
 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
4
 *
5
 * This file is part of libde265.
6
 *
7
 * libde265 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
 * libde265 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 libde265.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#ifndef DE265_NAL_H
22
#define DE265_NAL_H
23
24
#ifdef HAVE_CONFIG_H
25
#include <config.h>
26
#endif
27
28
#include <stdint.h>
29
30
#include "libde265/bitstream.h"
31
#include "libde265/cabac.h"
32
#include "libde265/de265.h"
33
34
struct nal_header {
35
1.90k
  nal_header() {
36
1.90k
    nal_unit_type = 0;
37
1.90k
    nuh_layer_id = 0;
38
1.90k
    nuh_temporal_id = 0;
39
1.90k
  }
40
41
  de265_error read(bitreader* reader);
42
  void write(CABAC_encoder& writer) const;
43
44
0
  void set(int unit_type, int layer_id=0, int temporal_id=0) {
45
0
    nal_unit_type  =unit_type;
46
0
    nuh_layer_id   =layer_id;
47
0
    nuh_temporal_id=temporal_id;
48
0
  }
49
50
  uint8_t nal_unit_type;
51
  uint8_t nuh_layer_id;
52
  uint8_t nuh_temporal_id;
53
};
54
55
0
#define NAL_UNIT_TRAIL_N  0
56
#define NAL_UNIT_TRAIL_R  1
57
0
#define NAL_UNIT_TSA_N    2
58
#define NAL_UNIT_TSA_R    3
59
0
#define NAL_UNIT_STSA_N   4
60
#define NAL_UNIT_STSA_R   5
61
0
#define NAL_UNIT_RADL_N   6
62
0
#define NAL_UNIT_RADL_R   7
63
0
#define NAL_UNIT_RASL_N   8
64
0
#define NAL_UNIT_RASL_R   9
65
0
#define NAL_UNIT_RESERVED_VCL_N10  10
66
0
#define NAL_UNIT_RESERVED_VCL_N12  12
67
0
#define NAL_UNIT_RESERVED_VCL_N14  14
68
#define NAL_UNIT_RESERVED_VCL_R11  11
69
#define NAL_UNIT_RESERVED_VCL_R13  13
70
0
#define NAL_UNIT_RESERVED_VCL_R15  15
71
0
#define NAL_UNIT_BLA_W_LP   16     // BLA = broken link access
72
0
#define NAL_UNIT_BLA_W_RADL 17
73
0
#define NAL_UNIT_BLA_N_LP   18
74
572
#define NAL_UNIT_IDR_W_RADL 19
75
281
#define NAL_UNIT_IDR_N_LP   20
76
0
#define NAL_UNIT_CRA_NUT    21     // CRA = clean random access
77
#define NAL_UNIT_RESERVED_IRAP_VCL22 22
78
0
#define NAL_UNIT_RESERVED_IRAP_VCL23 23
79
#define NAL_UNIT_RESERVED_VCL24     24
80
#define NAL_UNIT_RESERVED_VCL25     25
81
#define NAL_UNIT_RESERVED_VCL26     26
82
#define NAL_UNIT_RESERVED_VCL27     27
83
#define NAL_UNIT_RESERVED_VCL28     28
84
#define NAL_UNIT_RESERVED_VCL29     29
85
#define NAL_UNIT_RESERVED_VCL30     30
86
#define NAL_UNIT_RESERVED_VCL31     31
87
59
#define NAL_UNIT_VPS_NUT       32
88
86
#define NAL_UNIT_SPS_NUT       33
89
12
#define NAL_UNIT_PPS_NUT       34
90
#define NAL_UNIT_AUD_NUT       35
91
1
#define NAL_UNIT_EOS_NUT       36
92
#define NAL_UNIT_EOB_NUT       37
93
#define NAL_UNIT_FD_NUT        38
94
6
#define NAL_UNIT_PREFIX_SEI_NUT 39
95
22
#define NAL_UNIT_SUFFIX_SEI_NUT 40
96
#define NAL_UNIT_RESERVED_NVCL41     41
97
#define NAL_UNIT_RESERVED_NVCL42     42
98
#define NAL_UNIT_RESERVED_NVCL43     43
99
#define NAL_UNIT_RESERVED_NVCL44     44
100
#define NAL_UNIT_RESERVED_NVCL45     45
101
#define NAL_UNIT_RESERVED_NVCL46     46
102
#define NAL_UNIT_RESERVED_NVCL47     47
103
104
#define NAL_UNIT_UNDEFINED    255
105
106
bool isIDR(uint8_t unit_type);
107
bool isBLA(uint8_t unit_type);
108
bool isCRA(uint8_t unit_type);
109
bool isRAP(uint8_t unit_type);
110
bool isRASL(uint8_t unit_type);
111
bool isIRAP(uint8_t unit_type);
112
bool isRADL(uint8_t unit_type);
113
bool isReferenceNALU(uint8_t unit_type);
114
bool isSublayerNonReference(uint8_t unit_type);
115
116
const char* get_NAL_name(uint8_t unit_type);
117
118
286
inline bool isIdrPic(uint8_t nal_unit_type) {
119
286
  return (nal_unit_type == NAL_UNIT_IDR_W_RADL ||
120
281
          nal_unit_type == NAL_UNIT_IDR_N_LP);
121
286
}
122
123
286
inline bool isRapPic(uint8_t nal_unit_type) {
124
286
  return nal_unit_type >= 16 && nal_unit_type <= 23;
125
286
}
126
127
#endif