Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vvenc/source/Lib/CommonLib/HRD.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) 2019-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVenC 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
44
#pragma once
45
46
#include "Common.h"
47
#include "SEI.h"
48
49
namespace vvenc {
50
51
struct OlsHrdParams
52
{
53
  bool     fixedPicRateGeneralFlag;
54
  bool     fixedPicRateWithinCvsFlag;
55
  bool     lowDelayHrdFlag;
56
57
  uint32_t elementDurationInTcMinus1;
58
  uint32_t bitRateValueMinus1[MAX_CPB_CNT][2];
59
  uint32_t cpbSizeValueMinus1[MAX_CPB_CNT][2];
60
  uint32_t duCpbSizeValueMinus1[MAX_CPB_CNT][2];
61
  uint32_t duBitRateValueMinus1[MAX_CPB_CNT][2];
62
  bool     cbrFlag[MAX_CPB_CNT][2];
63
64
  OlsHrdParams()
65
0
    : fixedPicRateGeneralFlag   (false)
66
0
    , fixedPicRateWithinCvsFlag (false)
67
0
    , lowDelayHrdFlag           (false)
68
0
    , elementDurationInTcMinus1 (0)
69
0
  {
70
0
    memset( bitRateValueMinus1,   0, sizeof(bitRateValueMinus1));
71
0
    memset( cpbSizeValueMinus1,   0, sizeof(cpbSizeValueMinus1));
72
0
    memset( duCpbSizeValueMinus1, 0, sizeof(duCpbSizeValueMinus1));
73
0
    memset( duBitRateValueMinus1, 0, sizeof(duBitRateValueMinus1));
74
0
    memset( cbrFlag,              0, sizeof(cbrFlag));
75
0
  }
76
};
77
78
struct GeneralHrdParams
79
{
80
  uint32_t numUnitsInTick;
81
  uint32_t timeScale;
82
  bool     generalNalHrdParamsPresent;
83
  bool     generalVclHrdParamsPresent;
84
  bool     generalSamePicTimingInAllOlsFlag;
85
  uint32_t tickDivisorMinus2;
86
  bool     generalDecodingUnitHrdParamsPresent;
87
  uint32_t bitRateScale;
88
  uint32_t cpbSizeScale;
89
  uint32_t cpbSizeDuScale;
90
  uint32_t hrdCpbCntMinus1;
91
92
  GeneralHrdParams()
93
0
    : generalNalHrdParamsPresent              (false)
94
0
    , generalVclHrdParamsPresent              (false)
95
0
    , generalSamePicTimingInAllOlsFlag        (true)
96
0
    , tickDivisorMinus2                       (0)
97
0
    , generalDecodingUnitHrdParamsPresent     (false)
98
0
    , bitRateScale                            (0)
99
0
    , cpbSizeScale                            (0)
100
0
    , cpbSizeDuScale                          (0)
101
0
    , hrdCpbCntMinus1                         (0)
102
0
  {}
103
104
  bool operator==(const GeneralHrdParams& other) const
105
0
  {
106
0
    return (numUnitsInTick == other.numUnitsInTick
107
0
      && timeScale == other.timeScale
108
0
      && generalNalHrdParamsPresent == other.generalNalHrdParamsPresent
109
0
      && generalVclHrdParamsPresent == other.generalVclHrdParamsPresent
110
0
      && generalSamePicTimingInAllOlsFlag == other.generalSamePicTimingInAllOlsFlag
111
0
      && generalDecodingUnitHrdParamsPresent == other.generalDecodingUnitHrdParamsPresent
112
0
      && (generalDecodingUnitHrdParamsPresent ? (tickDivisorMinus2 == other.tickDivisorMinus2): 1)
113
0
      && bitRateScale == other.bitRateScale
114
0
      && cpbSizeScale == other.cpbSizeScale
115
0
      && (generalDecodingUnitHrdParamsPresent ? (cpbSizeDuScale == other.cpbSizeDuScale) : 1)
116
0
      && hrdCpbCntMinus1 == other.hrdCpbCntMinus1
117
0
      );
118
0
  }
119
120
  GeneralHrdParams& operator=(const GeneralHrdParams& input)
121
0
  {
122
0
    numUnitsInTick = input.numUnitsInTick;
123
0
    timeScale = input.timeScale;
124
0
    generalNalHrdParamsPresent = input.generalNalHrdParamsPresent;
125
0
    generalVclHrdParamsPresent = input.generalVclHrdParamsPresent;
126
0
    generalSamePicTimingInAllOlsFlag = input.generalSamePicTimingInAllOlsFlag;
127
0
    generalDecodingUnitHrdParamsPresent = input.generalDecodingUnitHrdParamsPresent;
128
0
    if (input.generalDecodingUnitHrdParamsPresent)
129
0
    {
130
0
      tickDivisorMinus2 = input.tickDivisorMinus2;
131
0
    }
132
0
    bitRateScale = input.bitRateScale;
133
0
    cpbSizeScale = input.cpbSizeScale;
134
0
    if (input.generalDecodingUnitHrdParamsPresent)
135
0
    {
136
0
      cpbSizeDuScale = input.cpbSizeDuScale;
137
0
    }
138
0
    hrdCpbCntMinus1 = input.hrdCpbCntMinus1;
139
0
    return *this;
140
0
  }
141
};
142
143
struct HRD
144
{
145
  HRD()
146
0
  : bufferingPeriodInitialized  (false)
147
0
  , pictureTimingAvailable      (false) 
148
0
  {};
149
150
  GeneralHrdParams      generalHrdParams;
151
  OlsHrdParams          olsHrdParams[VVENC_MAX_TLAYER];
152
  bool                  bufferingPeriodInitialized;
153
  bool                  pictureTimingAvailable;
154
  SEIBufferingPeriod    bufferingPeriodSEI;
155
  SEIPictureTiming      pictureTimingSEI;
156
};
157
158
} // namespace vvenc