/src/vvenc/source/Lib/EncoderLib/GOPCfg.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 | | /** \file GOPCfg.h |
44 | | \brief |
45 | | */ |
46 | | |
47 | | #pragma once |
48 | | |
49 | | #include "CommonLib/CommonDef.h" |
50 | | #include "CommonLib/Slice.h" |
51 | | #include "Utilities/MsgLog.h" |
52 | | |
53 | | |
54 | | //! \ingroup EncoderLib |
55 | | //! \{ |
56 | | |
57 | | namespace vvenc { |
58 | | |
59 | | class PicShared; |
60 | | |
61 | | class GOPCfg |
62 | | { |
63 | | typedef std::vector<GOPEntry> GOPEntryList; |
64 | | |
65 | | private: |
66 | | MsgLog& msg; |
67 | | |
68 | | std::vector<GOPEntryList> m_defaultGopLists; |
69 | | GOPEntryList m_remainGopList; |
70 | | |
71 | | GOPEntryList* m_gopList; |
72 | | std::vector<int> m_pocToGopIdx; |
73 | | |
74 | | std::vector<const GOPEntry*> m_defaultRPLList; |
75 | | std::vector<int> m_maxDecPicBuffering; |
76 | | std::vector<int> m_numReorderPics; |
77 | | |
78 | | const vvencMCTF* m_mctfCfg; |
79 | | |
80 | | bool m_picReordering; |
81 | | int m_refreshType; |
82 | | int m_fixIntraPeriod; |
83 | | bool m_poc0idr; |
84 | | int m_maxGopSize; |
85 | | int m_defGopSize; |
86 | | int m_nextListIdx; |
87 | | int m_gopNum; |
88 | | int m_nextPoc; |
89 | | int m_pocOffset; |
90 | | int m_cnOffset; |
91 | | int m_numTillGop; |
92 | | int m_numTillIntra; |
93 | | int m_maxTid; |
94 | | int m_firstPassMode; |
95 | | int m_defaultNumActive[ 2 ]; |
96 | | int m_minIntraDist; |
97 | | int m_lastIntraPOC; |
98 | | bool m_adjustNoLPcodingOrder; |
99 | | |
100 | | public: |
101 | | GOPCfg( MsgLog& _m ) |
102 | 0 | : msg ( _m ) |
103 | 0 | , m_gopList ( nullptr ) |
104 | 0 | , m_mctfCfg ( nullptr ) |
105 | 0 | , m_picReordering ( false ) |
106 | 0 | , m_refreshType ( 0 ) |
107 | 0 | , m_fixIntraPeriod ( 0 ) |
108 | 0 | , m_poc0idr ( false ) |
109 | 0 | , m_maxGopSize ( 0 ) |
110 | 0 | , m_defGopSize ( 0 ) |
111 | 0 | , m_nextListIdx ( 0 ) |
112 | 0 | , m_gopNum ( 0 ) |
113 | 0 | , m_nextPoc ( 0 ) |
114 | 0 | , m_pocOffset ( 0 ) |
115 | 0 | , m_cnOffset ( 0 ) |
116 | 0 | , m_numTillGop ( 0 ) |
117 | 0 | , m_numTillIntra ( 0 ) |
118 | 0 | , m_maxTid ( 0 ) |
119 | 0 | , m_firstPassMode ( 0 ) |
120 | 0 | , m_defaultNumActive{ 0, 0 } |
121 | 0 | , m_minIntraDist ( -1 ) |
122 | 0 | , m_lastIntraPOC ( -1 ) |
123 | 0 | , m_adjustNoLPcodingOrder( false ) |
124 | 0 | { |
125 | 0 | }; |
126 | | |
127 | | ~GOPCfg() |
128 | 0 | { |
129 | 0 | }; |
130 | | |
131 | | void initGopList( int refreshType, bool poc0idr, int intraPeriod, int gopSize, int leadFrames, bool bPicReordering, const vvencGOPEntry cfgGopList[ VVENC_MAX_GOP ], const vvencMCTF& mctfCfg, int firstPassMode, int m_minIntraDist ); |
132 | | void getNextGopEntry( GOPEntry& gopEntry ); |
133 | | void startIntraPeriod( GOPEntry& gopEntry ); |
134 | | void fixStartOfLastGop( GOPEntry& gopEntry ); |
135 | | void getDefaultRPLLists( RPLList& rpl0, RPLList& rpl1 ) const; |
136 | 0 | void setLastIntraSTA( int poc ) { m_lastIntraPOC = poc; } |
137 | | |
138 | 0 | int getMaxTLayer() const { return m_maxTid; } |
139 | 0 | const std::vector<int>& getMaxDecPicBuffering() const { return m_maxDecPicBuffering; } |
140 | 0 | const std::vector<int>& getNumReorderPics() const { return m_numReorderPics; } |
141 | 0 | int getDefaultNumActive( int l ) const { return m_defaultNumActive[ l ]; } |
142 | | |
143 | | bool isSTAallowed( int poc ) const; |
144 | | bool hasNonZeroTemporalId() const; |
145 | | bool hasLeadingPictures() const; |
146 | | bool isChromaDeltaQPEnabled() const; |
147 | | |
148 | | private: |
149 | | int xGetMinPoc ( int maxGopSize, const vvencGOPEntry cfgGopList[ VVENC_MAX_GOP ] ) const; |
150 | | void xCreateGopList ( int maxGopSize, int gopSize, int pocOffset, const vvencGOPEntry cfgGopList[ VVENC_MAX_GOP ], const GOPEntryList* prevGopList, GOPEntryList& gopList ) const; |
151 | | void xGetPrevGopRefs ( const GOPEntryList* prevGopList, std::vector< std::pair<int, int> >& prevGopRefs ) const; |
152 | | void xPruneGopList ( int gopSize, GOPEntryList& gopList ) const; |
153 | | void xGetRefsOfNextGop ( int gopSize, const vvencGOPEntry cfgGopList[ VVENC_MAX_GOP ], int pocOffset, std::vector<int>& pocList ) const; |
154 | | void xSetMctfIndex ( int maxGopSize, GOPEntryList& gopList ) const; |
155 | | void xSetSkipFirstPass ( GOPEntryList& gopList ) const; |
156 | | void xCreatePocToGopIdx ( const GOPEntryList& gopList, bool bShift, std::vector<int>& pocToGopIdx ) const; |
157 | | void xSetSTSA ( GOPEntryList& gopList, const std::vector<int>& pocToGopIdx ) const; |
158 | | void xSetBckwdOnly ( GOPEntryList& gopList ) const; |
159 | | void xSetVTL ( GOPEntryList& gopList ) const; |
160 | | void xSetDefaultRPL ( std::vector<GOPEntryList>& defaultLists ); |
161 | | void xSetDBPConstraints ( std::vector<GOPEntryList>& defaultLists ); |
162 | | bool xCheckDBPConstraints( const GOPEntryList& gopList ) const; |
163 | | void xAddRefPicsBckwd ( std::vector<int>& deltaList, const GOPEntry* gopEntry, const std::vector<GOPEntry*>& availList ) const; |
164 | | void xAddRefPicsFwd ( std::vector<int>& deltaList, const GOPEntry* gopEntry, const std::vector<GOPEntry*>& availList ) const; |
165 | | void xAddRefPicsPrevGOP ( std::vector<int>& deltaList, const GOPEntry* gopEntry, const std::vector< std::pair<int, int> >& prevGopRefs ) const; |
166 | | int xGetMaxTid ( const GOPEntryList& gopList ) const; |
167 | | int xGetMaxRefPics ( const GOPEntry& gopEntry ) const; |
168 | | int xGetMaxNumReorder ( const GOPEntry& gopEntry, const GOPEntryList& gopList ) const; |
169 | | void xAdjustNoLPcodingOrder( GOPEntry& gopEntry, const int orgGopId ) const; |
170 | | }; |
171 | | |
172 | | } // namespace vvenc |
173 | | |
174 | | //! \} |
175 | | |