/src/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 | 0 | : m_stageParallelProc( false ) |
54 | 0 | , m_salienceBasedOpt( true ) |
55 | 0 | , m_rateCap ( false ) |
56 | 0 | , m_bimCtuSize( 64 ) |
57 | 0 | , m_MaxQT { 128, 128, 128 } |
58 | 0 | { |
59 | 0 | m_fg.m_fgcSEIEnabled = false; |
60 | 0 | m_fg.m_fgcSEICompModelPresent[0] = false; |
61 | 0 | m_fg.m_fgcSEICompModelPresent[1] = false; |
62 | 0 | m_fg.m_fgcSEICompModelPresent[2] = false; |
63 | 0 | } |
64 | | |
65 | | VVEncCfg& VVEncCfg::operator= ( const vvenc_config& extern_cfg ) |
66 | 0 | { |
67 | 0 | *((vvenc_config*)this) = extern_cfg; |
68 | 0 | xInitCfgMembers(); |
69 | |
|
70 | 0 | return *this; |
71 | 0 | } |
72 | | |
73 | | static unsigned getMaxTlVal( unsigned perTlVal ) |
74 | 0 | { |
75 | 0 | unsigned maxVal = 0; |
76 | 0 | while( perTlVal > 0 ) |
77 | 0 | { |
78 | 0 | maxVal = std::max( maxVal, perTlVal % 10 ); |
79 | 0 | perTlVal /= 10; |
80 | 0 | } |
81 | 0 | return maxVal; |
82 | 0 | } |
83 | | |
84 | | void VVEncCfg::xInitCfgMembers() |
85 | 0 | { |
86 | 0 | m_stageParallelProc = m_numThreads > 0 && m_maxParallelFrames > 0; |
87 | 0 | m_log2GopSize = floorLog2( m_GOPSize ); |
88 | 0 | m_maxTLayer = m_picReordering && m_GOPSize > 1 ? vvenc::ceilLog2( m_GOPSize ) : 0; |
89 | 0 | m_bimCtuSize = m_CTUSize; |
90 | 0 | m_MaxQT[0] = |
91 | 0 | m_MaxQT[1] = |
92 | 0 | m_MaxQT[2] = m_CTUSize; |
93 | 0 | m_rateCap = m_RCMaxBitrate > 0 && m_RCMaxBitrate < INT32_MAX && m_RCTargetBitrate == 0; |
94 | 0 | m_reuseCuResults = ( m_IntraPeriod > 1 && getMaxTlVal( m_maxMTTDepth ) > 1 ) || m_maxMTTDepthI > ( m_IntraPeriod == 1 ? 1 : 2 ); |
95 | 0 | m_splitCostThrParamId = getMaxTlVal(m_maxMTTDepth); |
96 | |
|
97 | 0 | m_mergeRdCandQuotaRegular = std::min( NUM_MRG_SATD_CAND, std::max( ( int ) m_maxNumMergeCand - 2, 1 ) ); |
98 | | // 0 1 2 3 4 |
99 | 0 | static constexpr int mrgNumSmallBlk[] = { 0, 1, 1, 2, 2 }; |
100 | 0 | m_mergeRdCandQuotaRegularSmallBlk |
101 | 0 | = mrgNumSmallBlk[m_mergeRdCandQuotaRegular]; |
102 | 0 | m_mergeRdCandQuotaSubBlk = std::min( m_Affine ? NUM_AFF_MRG_SATD_CAND : 0, ( int ) m_maxNumAffineMergeCand ); |
103 | 0 | m_mergeRdCandQuotaCiip = m_CIIP > 0 && m_CIIP < 3 ? 1 : 0; |
104 | 0 | 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 | 0 | static constexpr int mrgNumTotal[] = { 0, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11 }; |
107 | 0 | m_maxMergeRdCandNumTotal = mrgNumTotal[m_mergeRdCandQuotaRegular + m_mergeRdCandQuotaSubBlk + m_mergeRdCandQuotaCiip + m_mergeRdCandQuotaGpm]; |
108 | |
|
109 | 0 | 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 | 0 | if( m_usePerceptQPATempFiltISlice > 2 ) |
134 | 0 | { |
135 | 0 | m_internalUsePerceptQPATempFiltISlice = m_usePerceptQPATempFiltISlice - 2; |
136 | 0 | m_disableForce2ndOderFilter = true; |
137 | 0 | } |
138 | 0 | else |
139 | 0 | { |
140 | 0 | m_internalUsePerceptQPATempFiltISlice = m_usePerceptQPATempFiltISlice; |
141 | 0 | m_disableForce2ndOderFilter = false; |
142 | 0 | } |
143 | 0 | } |
144 | | |
145 | | } |
146 | | |