Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vvdec/source/Lib/CommonLib/NAL.h
Line
Count
Source
1
/* -----------------------------------------------------------------------------
2
The copyright in this software is being made available under the Clear BSD
3
License, included below. No patent rights, trademark rights and/or 
4
other Intellectual Property Rights other than the copyrights concerning 
5
the Software are granted under this license.
6
7
The Clear BSD License
8
9
Copyright (c) 2018-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC Authors.
10
All rights reserved.
11
12
Redistribution and use in source and binary forms, with or without modification,
13
are permitted (subject to the limitations in the disclaimer below) provided that
14
the following conditions are met:
15
16
     * Redistributions of source code must retain the above copyright notice,
17
     this list of conditions and the following disclaimer.
18
19
     * Redistributions in binary form must reproduce the above copyright
20
     notice, this list of conditions and the following disclaimer in the
21
     documentation and/or other materials provided with the distribution.
22
23
     * Neither the name of the copyright holder nor the names of its
24
     contributors may be used to endorse or promote products derived from this
25
     software without specific prior written permission.
26
27
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
28
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
29
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
36
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
POSSIBILITY OF SUCH DAMAGE.
39
40
41
------------------------------------------------------------------------------------------- */
42
43
#pragma once
44
45
#include "CommonDef.h"
46
47
namespace vvdec
48
{
49
50
/**
51
 * Represents a single NALunit header and the associated RBSPayload
52
 */
53
struct NALUnit
54
{
55
  NalUnitType m_nalUnitType = NAL_UNIT_INVALID;   ///< nal_unit_type
56
  uint32_t    m_temporalId  = 0;                  ///< temporal_id
57
  uint32_t    m_nuhLayerId  = 0;                  ///< nuh_layer_id
58
  uint32_t    m_forbiddenZeroBit   = 0;
59
  uint32_t    m_nuhReservedZeroBit = 0;
60
61
  uint64_t    m_bits     = 0;            ///< original nal unit bits
62
  uint64_t    m_cts      = 0;            ///< composition time stamp in TicksPerSecond
63
  uint64_t    m_dts      = 0;            ///< decoding time stamp in TicksPerSecond
64
  bool        m_rap      = false;        ///< random access point flag
65
  void       *m_userData = nullptr;      ///< opaque user data
66
  NALUnit(const NALUnit &src)
67
0
    : m_nalUnitType (src.m_nalUnitType)
68
0
    , m_temporalId  (src.m_temporalId)
69
0
    , m_nuhLayerId  (src.m_nuhLayerId)
70
0
    , m_forbiddenZeroBit  (src.m_forbiddenZeroBit)
71
0
    , m_nuhReservedZeroBit(src.m_nuhReservedZeroBit)
72
0
  {}
73
74
  /** construct an NALunit structure with given header values. */
75
  NALUnit( NalUnitType nalUnitType,
76
           int         temporalId = 0 ,
77
           int         nuhLayerId = 0 )
78
    : m_nalUnitType (nalUnitType)
79
    , m_temporalId  (temporalId)
80
    , m_nuhLayerId  (nuhLayerId)
81
0
  {}
82
83
  /** default constructor - no initialization; must be performed by user */
84
0
  NALUnit() {}
85
86
0
  virtual ~NALUnit() { }
87
88
  /** returns true if the NALunit is a slice NALunit */
89
  bool isSlice()
90
0
  {
91
0
    return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL
92
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA
93
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL
94
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL
95
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
96
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
97
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
98
0
        || m_nalUnitType == NAL_UNIT_CODED_SLICE_GDR
99
0
        ;
100
0
  }
101
  bool isSei()
102
0
  {
103
0
    return m_nalUnitType == NAL_UNIT_PREFIX_SEI
104
0
        || m_nalUnitType == NAL_UNIT_SUFFIX_SEI;
105
0
  }
106
107
  bool isVcl()
108
0
  {
109
0
    return isVclNalUnitType(m_nalUnitType);
110
0
  }
111
112
  static bool isVclNalUnitType(NalUnitType t)
113
0
  {
114
0
    return t <= NAL_UNIT_RESERVED_IRAP_VCL_11;
115
0
  }
116
};
117
118
}