Coverage Report

Created: 2026-10-28 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvenc/source/Lib/EncoderLib/EncCfg.cpp
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
/** \file     EncCfg.cpp
43
    \brief    encoder internal configuration class
44
*/
45
46
47
#include "EncCfg.h"
48
#include "CommonLib/CommonDef.h"
49
50
namespace vvenc {
51
52
VVEncCfg::VVEncCfg()
53
4.47k
  : m_stageParallelProc( false )
54
4.47k
  , m_salienceBasedOpt( true )
55
4.47k
  , m_rateCap ( false )
56
4.47k
  , m_bimCtuSize( 64 )
57
4.47k
  , m_MaxQT { 128, 128, 128 }
58
4.47k
  , m_cuTreeScale( 0.0 )
59
4.47k
  , m_QPFraction( 0.0 )
60
4.47k
  , m_fgaStrength( 0.0 )
61
4.47k
{
62
4.47k
  m_fg.m_fgcSEIEnabled = false;
63
4.47k
  m_fg.m_fgcSEICompModelPresent[0] = false;
64
4.47k
  m_fg.m_fgcSEICompModelPresent[1] = false;
65
4.47k
  m_fg.m_fgcSEICompModelPresent[2] = false;
66
4.47k
}
67
68
VVEncCfg& VVEncCfg::operator= ( const vvenc_config& extern_cfg )
69
1.49k
{
70
1.49k
  *((vvenc_config*)this) = extern_cfg;
71
1.49k
  xInitCfgMembers();
72
73
1.49k
  return *this;
74
1.49k
}
75
76
static unsigned getMaxTlVal( unsigned perTlVal )
77
2.98k
{
78
2.98k
  unsigned maxVal = 0;
79
5.97k
  while( perTlVal > 0 )
80
2.98k
  {
81
2.98k
    maxVal    = std::max( maxVal, perTlVal % 10 );
82
2.98k
    perTlVal /= 10;
83
2.98k
  }
84
2.98k
  return maxVal;
85
2.98k
}
86
87
void VVEncCfg::xInitCfgMembers()
88
1.49k
{
89
1.49k
  m_stageParallelProc   = m_numThreads > 0 && m_maxParallelFrames > 0;
90
1.49k
  m_log2GopSize         = floorLog2( m_GOPSize );
91
1.49k
  m_maxTLayer           = m_picReordering && m_GOPSize > 1 ? vvenc::ceilLog2( m_GOPSize ) : 0;
92
1.49k
  m_bimCtuSize          = m_CTUSize;
93
1.49k
  m_QPFraction          = m_QPFractionVal / 256.0;
94
1.49k
  m_fgaStrength         = m_fgaStrengthVal / 64.0;
95
1.49k
  m_MaxQT[0]            =
96
1.49k
  m_MaxQT[1]            = 
97
1.49k
  m_MaxQT[2]            = m_CTUSize;
98
1.49k
  m_rateCap             = m_RCMaxBitrate > 0 && m_RCMaxBitrate < INT32_MAX && m_RCTargetBitrate == 0;
99
1.49k
  m_reuseCuResults      = ( m_IntraPeriod > 1 && getMaxTlVal( m_maxMTTDepth ) > 1 ) || m_maxMTTDepthI > ( m_IntraPeriod == 1 ? 1 : 2 );
100
1.49k
  m_splitCostThrParamId = getMaxTlVal(m_maxMTTDepth);
101
1.49k
  m_cuTreeScale         = m_cuTreeStrength / 32.0;
102
103
1.49k
  m_mergeRdCandQuotaRegular = std::min( NUM_MRG_SATD_CAND, std::max( ( int ) m_maxNumMergeCand - 2, 1 ) );
104
  //                                        0  1  2  3  4
105
1.49k
  static constexpr int mrgNumSmallBlk[] = { 0, 1, 1, 2, 2 };
106
1.49k
  m_mergeRdCandQuotaRegularSmallBlk
107
1.49k
                            = mrgNumSmallBlk[m_mergeRdCandQuotaRegular];
108
1.49k
  m_mergeRdCandQuotaSubBlk  = std::min( m_Affine ? NUM_AFF_MRG_SATD_CAND : 0, ( int ) m_maxNumAffineMergeCand );
109
1.49k
  m_mergeRdCandQuotaCiip    = m_CIIP > 0 && m_CIIP < 3 ? 1 : 0;
110
1.49k
  m_mergeRdCandQuotaGpm     = m_Geo ? ( m_Geo > 1 ? 2 : GEO_MAX_TRY_WEIGHTED_SATD ) : 0;
111
  //                                     0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
112
1.49k
  static constexpr int mrgNumTotal[] = { 0, 1, 2, 3, 3, 4, 5, 5, 6, 7,  7,  8,  9,  9, 10, 11 };
113
1.49k
  m_maxMergeRdCandNumTotal  = mrgNumTotal[m_mergeRdCandQuotaRegular + m_mergeRdCandQuotaSubBlk + m_mergeRdCandQuotaCiip + m_mergeRdCandQuotaGpm];
114
115
1.49k
  if ( this->m_fga )
116
0
  {
117
0
    memset( m_fg.m_fgcSEIIntensityIntervalLowerBound, 0, sizeof(uint8_t) * 3 * VVENC_MAX_NUM_INTENSITIES );
118
0
    memset( m_fg.m_fgcSEIIntensityIntervalUpperBound, 255, sizeof(uint8_t) * 3 * VVENC_MAX_NUM_INTENSITIES );
119
0
    memset( m_fg.m_fgcSEICompModelValue, 0, sizeof(uint32_t) * 3 * VVENC_MAX_NUM_INTENSITIES * VVENC_MAX_NUM_MODEL_VALUES );
120
0
    m_fg.m_fgcSEIEnabled = true;
121
0
    m_fg.m_fgcSEICompModelPresent[0] = true; // FGA is performed only for the luma plane
122
0
    m_fg.m_fgcSEICompModelPresent[1] = true;
123
0
    m_fg.m_fgcSEICompModelPresent[2] = true;
124
0
    m_fg.m_fgcSEICancelFlag = false;
125
0
    m_fg.m_fgcSEIPersistenceFlag = true;
126
0
    m_fg.m_fgcSEIModelID = this->m_fga == 3 ? 1 : 0;   // --fga 3: the auto-regressive model
127
0
    m_fg.m_fgcSEISepColourDescPresentFlag = false;
128
0
    m_fg.m_fgcSEIBlendingModeID = 0;
129
0
    m_fg.m_fgcSEILog2ScaleFactor = 0;
130
0
    m_fg.m_fgcSEIPerPictureSEI = false;
131
0
    m_fg.m_fgcSEINumIntensityIntervalMinus1[0] = 0;
132
0
    m_fg.m_fgcSEINumIntensityIntervalMinus1[1] = 0;
133
0
    m_fg.m_fgcSEINumIntensityIntervalMinus1[2] = 0;
134
0
    m_fg.m_fgcSEINumModelValuesMinus1[0] = 0;
135
0
    m_fg.m_fgcSEINumModelValuesMinus1[1] = 0;
136
0
    m_fg.m_fgcSEINumModelValuesMinus1[2] = 0;
137
0
  }
138
  
139
1.49k
  if( m_usePerceptQPATempFiltISlice > 2 )
140
0
  {
141
0
    m_internalUsePerceptQPATempFiltISlice = m_usePerceptQPATempFiltISlice - 2;
142
0
    m_disableForce2ndOderFilter           = true;
143
0
  }
144
1.49k
  else
145
1.49k
  {
146
1.49k
    m_internalUsePerceptQPATempFiltISlice = m_usePerceptQPATempFiltISlice;
147
1.49k
    m_disableForce2ndOderFilter           = false;
148
1.49k
  }
149
1.49k
}
150
151
}
152