Coverage Report

Created: 2026-05-30 06:10

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
3.89k
  : m_stageParallelProc( false )
54
3.89k
  , m_salienceBasedOpt( true )
55
3.89k
  , m_rateCap ( false )
56
3.89k
  , m_bimCtuSize( 64 )
57
3.89k
  , m_MaxQT { 128, 128, 128 }
58
3.89k
{
59
3.89k
  m_fg.m_fgcSEIEnabled = false;
60
3.89k
  m_fg.m_fgcSEICompModelPresent[0] = false;
61
3.89k
  m_fg.m_fgcSEICompModelPresent[1] = false;
62
3.89k
  m_fg.m_fgcSEICompModelPresent[2] = false;
63
3.89k
}
64
65
VVEncCfg& VVEncCfg::operator= ( const vvenc_config& extern_cfg )
66
1.29k
{
67
1.29k
  *((vvenc_config*)this) = extern_cfg;
68
1.29k
  xInitCfgMembers();
69
70
1.29k
  return *this;
71
1.29k
}
72
73
static unsigned getMaxTlVal( unsigned perTlVal )
74
2.59k
{
75
2.59k
  unsigned maxVal = 0;
76
5.19k
  while( perTlVal > 0 )
77
2.59k
  {
78
2.59k
    maxVal    = std::max( maxVal, perTlVal % 10 );
79
2.59k
    perTlVal /= 10;
80
2.59k
  }
81
2.59k
  return maxVal;
82
2.59k
}
83
84
void VVEncCfg::xInitCfgMembers()
85
1.29k
{
86
1.29k
  m_stageParallelProc   = m_numThreads > 0 && m_maxParallelFrames > 0;
87
1.29k
  m_log2GopSize         = floorLog2( m_GOPSize );
88
1.29k
  m_maxTLayer           = m_picReordering && m_GOPSize > 1 ? vvenc::ceilLog2( m_GOPSize ) : 0;
89
1.29k
  m_bimCtuSize          = m_CTUSize;
90
1.29k
  m_MaxQT[0]            =
91
1.29k
  m_MaxQT[1]            = 
92
1.29k
  m_MaxQT[2]            = m_CTUSize;
93
1.29k
  m_rateCap             = m_RCMaxBitrate > 0 && m_RCMaxBitrate < INT32_MAX && m_RCTargetBitrate == 0;
94
1.29k
  m_reuseCuResults      = ( m_IntraPeriod > 1 && getMaxTlVal( m_maxMTTDepth ) > 1 ) || m_maxMTTDepthI > ( m_IntraPeriod == 1 ? 1 : 2 );
95
1.29k
  m_splitCostThrParamId = getMaxTlVal(m_maxMTTDepth);
96
97
1.29k
  m_mergeRdCandQuotaRegular = std::min( NUM_MRG_SATD_CAND, std::max( ( int ) m_maxNumMergeCand - 2, 1 ) );
98
  //                                        0  1  2  3  4
99
1.29k
  static constexpr int mrgNumSmallBlk[] = { 0, 1, 1, 2, 2 };
100
1.29k
  m_mergeRdCandQuotaRegularSmallBlk
101
1.29k
                            = mrgNumSmallBlk[m_mergeRdCandQuotaRegular];
102
1.29k
  m_mergeRdCandQuotaSubBlk  = std::min( m_Affine ? NUM_AFF_MRG_SATD_CAND : 0, ( int ) m_maxNumAffineMergeCand );
103
1.29k
  m_mergeRdCandQuotaCiip    = m_CIIP > 0 && m_CIIP < 3 ? 1 : 0;
104
1.29k
  m_mergeRdCandQuotaGpm     = m_Geo ? ( m_Geo > 1 ? 2 : GEO_MAX_TRY_WEIGHTED_SATD ) : 0;
105
  //                                     0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
106
1.29k
  static constexpr int mrgNumTotal[] = { 0, 1, 2, 3, 3, 4, 5, 5, 6, 7,  7,  8,  9,  9, 10, 11 };
107
1.29k
  m_maxMergeRdCandNumTotal  = mrgNumTotal[m_mergeRdCandQuotaRegular + m_mergeRdCandQuotaSubBlk + m_mergeRdCandQuotaCiip + m_mergeRdCandQuotaGpm];
108
109
1.29k
  if ( this->m_fga )
110
0
  {
111
0
    memset( m_fg.m_fgcSEIIntensityIntervalLowerBound, 0, sizeof(uint8_t) * 3 * VVENC_MAX_NUM_INTENSITIES );
112
0
    memset( m_fg.m_fgcSEIIntensityIntervalUpperBound, 255, sizeof(uint8_t) * 3 * VVENC_MAX_NUM_INTENSITIES );
113
0
    memset( m_fg.m_fgcSEICompModelValue, 0, sizeof(uint32_t) * 3 * VVENC_MAX_NUM_INTENSITIES * VVENC_MAX_NUM_MODEL_VALUES );
114
0
    m_fg.m_fgcSEIEnabled = true;
115
0
    m_fg.m_fgcSEICompModelPresent[0] = true; // FGA is performed only for the luma plane
116
0
    m_fg.m_fgcSEICompModelPresent[1] = true;
117
0
    m_fg.m_fgcSEICompModelPresent[2] = true;
118
0
    m_fg.m_fgcSEICancelFlag = false;
119
0
    m_fg.m_fgcSEIPersistenceFlag = true;
120
0
    m_fg.m_fgcSEIModelID = 0;
121
0
    m_fg.m_fgcSEISepColourDescPresentFlag = false;
122
0
    m_fg.m_fgcSEIBlendingModeID = 0;
123
0
    m_fg.m_fgcSEILog2ScaleFactor = 0;
124
0
    m_fg.m_fgcSEIPerPictureSEI = false;
125
0
    m_fg.m_fgcSEINumIntensityIntervalMinus1[0] = 0;
126
0
    m_fg.m_fgcSEINumIntensityIntervalMinus1[1] = 0;
127
0
    m_fg.m_fgcSEINumIntensityIntervalMinus1[2] = 0;
128
0
    m_fg.m_fgcSEINumModelValuesMinus1[0] = 0;
129
0
    m_fg.m_fgcSEINumModelValuesMinus1[1] = 0;
130
0
    m_fg.m_fgcSEINumModelValuesMinus1[2] = 0;
131
0
  }
132
  
133
1.29k
  if( m_usePerceptQPATempFiltISlice > 2 )
134
0
  {
135
0
    m_internalUsePerceptQPATempFiltISlice = m_usePerceptQPATempFiltISlice - 2;
136
0
    m_disableForce2ndOderFilter           = true;
137
0
  }
138
1.29k
  else
139
1.29k
  {
140
1.29k
    m_internalUsePerceptQPATempFiltISlice = m_usePerceptQPATempFiltISlice;
141
1.29k
    m_disableForce2ndOderFilter           = false;
142
1.29k
  }
143
1.29k
}
144
145
}
146