Coverage Report

Created: 2026-03-08 06:41

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
33
struct nal_header {
34
0
  nal_header() {
35
0
    nal_unit_type = 0;
36
0
    nuh_layer_id = 0;
37
0
    nuh_temporal_id = 0;
38
0
  }
39
40
  void read(bitreader* reader);
41
  void write(CABAC_encoder& writer) const;
42
43
0
  void set(int unit_type, int layer_id=0, int temporal_id=0) {
44
0
    nal_unit_type  =unit_type;
45
0
    nuh_layer_id   =layer_id;
46
0
    nuh_temporal_id=temporal_id;
47
0
  }
48
49
  uint8_t nal_unit_type;
50
  uint8_t nuh_layer_id;
51
  uint8_t nuh_temporal_id;
52
};
53
54
0
#define NAL_UNIT_TRAIL_N  0
55
#define NAL_UNIT_TRAIL_R  1
56
0
#define NAL_UNIT_TSA_N    2
57
#define NAL_UNIT_TSA_R    3
58
0
#define NAL_UNIT_STSA_N   4
59
#define NAL_UNIT_STSA_R   5
60
0
#define NAL_UNIT_RADL_N   6
61
0
#define NAL_UNIT_RADL_R   7
62
0
#define NAL_UNIT_RASL_N   8
63
0
#define NAL_UNIT_RASL_R   9
64
0
#define NAL_UNIT_RESERVED_VCL_N10  10
65
0
#define NAL_UNIT_RESERVED_VCL_N12  12
66
0
#define NAL_UNIT_RESERVED_VCL_N14  14
67
#define NAL_UNIT_RESERVED_VCL_R11  11
68
#define NAL_UNIT_RESERVED_VCL_R13  13
69
0
#define NAL_UNIT_RESERVED_VCL_R15  15
70
0
#define NAL_UNIT_BLA_W_LP   16     // BLA = broken link access
71
0
#define NAL_UNIT_BLA_W_RADL 17
72
0
#define NAL_UNIT_BLA_N_LP   18
73
0
#define NAL_UNIT_IDR_W_RADL 19
74
0
#define NAL_UNIT_IDR_N_LP   20
75
0
#define NAL_UNIT_CRA_NUT    21     // CRA = clean random access
76
#define NAL_UNIT_RESERVED_IRAP_VCL22 22
77
0
#define NAL_UNIT_RESERVED_IRAP_VCL23 23
78
#define NAL_UNIT_RESERVED_VCL24     24
79
#define NAL_UNIT_RESERVED_VCL25     25
80
#define NAL_UNIT_RESERVED_VCL26     26
81
#define NAL_UNIT_RESERVED_VCL27     27
82
#define NAL_UNIT_RESERVED_VCL28     28
83
#define NAL_UNIT_RESERVED_VCL29     29
84
#define NAL_UNIT_RESERVED_VCL30     30
85
#define NAL_UNIT_RESERVED_VCL31     31
86
0
#define NAL_UNIT_VPS_NUT       32
87
0
#define NAL_UNIT_SPS_NUT       33
88
0
#define NAL_UNIT_PPS_NUT       34
89
#define NAL_UNIT_AUD_NUT       35
90
0
#define NAL_UNIT_EOS_NUT       36
91
#define NAL_UNIT_EOB_NUT       37
92
#define NAL_UNIT_FD_NUT        38
93
0
#define NAL_UNIT_PREFIX_SEI_NUT 39
94
0
#define NAL_UNIT_SUFFIX_SEI_NUT 40
95
#define NAL_UNIT_RESERVED_NVCL41     41
96
#define NAL_UNIT_RESERVED_NVCL42     42
97
#define NAL_UNIT_RESERVED_NVCL43     43
98
#define NAL_UNIT_RESERVED_NVCL44     44
99
#define NAL_UNIT_RESERVED_NVCL45     45
100
#define NAL_UNIT_RESERVED_NVCL46     46
101
#define NAL_UNIT_RESERVED_NVCL47     47
102
103
#define NAL_UNIT_UNDEFINED    255
104
105
bool isIDR(uint8_t unit_type);
106
bool isBLA(uint8_t unit_type);
107
bool isCRA(uint8_t unit_type);
108
bool isRAP(uint8_t unit_type);
109
bool isRASL(uint8_t unit_type);
110
bool isIRAP(uint8_t unit_type);
111
bool isRADL(uint8_t unit_type);
112
bool isReferenceNALU(uint8_t unit_type);
113
bool isSublayerNonReference(uint8_t unit_type);
114
115
const char* get_NAL_name(uint8_t unit_type);
116
117
0
inline bool isIdrPic(uint8_t nal_unit_type) {
118
0
  return (nal_unit_type == NAL_UNIT_IDR_W_RADL ||
119
0
          nal_unit_type == NAL_UNIT_IDR_N_LP);
120
0
}
121
122
0
inline bool isRapPic(uint8_t nal_unit_type) {
123
0
  return nal_unit_type >= 16 && nal_unit_type <= 23;
124
0
}
125
126
#endif