/src/vvenc/source/Lib/EncoderLib/EncReshape.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 | | /** \file EncReshape.h |
43 | | \brief encoder reshaping header and class (header) |
44 | | */ |
45 | | |
46 | | #pragma once |
47 | | |
48 | | #include "vvenc/vvencCfg.h" |
49 | | #include "CommonLib/Reshape.h" |
50 | | |
51 | | //! \ingroup EncoderLib |
52 | | //! \{ |
53 | | |
54 | | namespace vvenc { |
55 | | |
56 | | // ==================================================================================================================== |
57 | | // Class definition |
58 | | // ==================================================================================================================== |
59 | | struct SeqInfo |
60 | | { |
61 | | SeqInfo() |
62 | 0 | : binVar { 0.0 } |
63 | 0 | , binHist { 0.0 } |
64 | 0 | , normVar { 0.0 } |
65 | 0 | , nonZeroCnt(0) |
66 | 0 | , weightVar ( 0.0 ) |
67 | 0 | , weightNorm ( 0.0 ) |
68 | 0 | , minBinVar ( 0.0 ) |
69 | 0 | , maxBinVar ( 0.0 ) |
70 | 0 | , meanBinVar ( 0.0 ) |
71 | 0 | , ratioStdU ( 0.0 ) |
72 | 0 | , ratioStdV ( 0.0 ) |
73 | 0 | { |
74 | 0 | } |
75 | | double binVar[PIC_ANALYZE_CW_BINS]; |
76 | | double binHist[PIC_ANALYZE_CW_BINS]; |
77 | | double normVar[PIC_ANALYZE_CW_BINS]; |
78 | | int nonZeroCnt; |
79 | | double weightVar; |
80 | | double weightNorm; |
81 | | double minBinVar; |
82 | | double maxBinVar; |
83 | | double meanBinVar; |
84 | | double ratioStdU; |
85 | | double ratioStdV; |
86 | | }; |
87 | | |
88 | | class EncReshape : public Reshape |
89 | | { |
90 | | private: |
91 | | bool m_exceedSTD; |
92 | | std::vector<uint32_t> m_binImportance; |
93 | | int m_tcase; |
94 | | int m_rateAdpMode; |
95 | | bool m_useAdpCW; |
96 | | uint16_t m_initCWAnalyze; |
97 | | vvencReshapeCW m_reshapeCW; |
98 | | int m_rspBaseQP; |
99 | | Pel m_cwLumaWeight[PIC_CODE_CW_BINS]; |
100 | | double m_chromaWeight; |
101 | | int m_chromaAdj; |
102 | | int m_binNum; |
103 | | SeqInfo m_srcSeqStats; |
104 | | SeqInfo m_rspSeqStats; |
105 | | public: |
106 | | |
107 | | EncReshape(); |
108 | | ~EncReshape(); |
109 | | |
110 | | void init( const VVEncCfg& encCfg ); |
111 | | void destroy(); |
112 | | |
113 | | void calcSeqStats ( Picture& pic, SeqInfo &stats); |
114 | | void preAnalyzerLMCS ( Picture& pic, const uint32_t signalType, const SliceType sliceType, const vvencReshapeCW& reshapeCW); |
115 | | void preAnalyzerHDR ( Picture& pic, const SliceType sliceType, const vvencReshapeCW& reshapeCW ); |
116 | | void bubbleSortDsd ( double *array, int * idx, int n); |
117 | | void cwPerturbation ( int startBinIdx, int endBinIdx, uint16_t maxCW); |
118 | | void cwReduction ( int startBinIdx, int endBinIdx); |
119 | | void deriveReshapeParametersSDR ( bool *intraAdp, bool *interAdp); |
120 | | void deriveReshapeParameters ( double *array, int start, int end, vvencReshapeCW respCW, double &alpha, double &beta); |
121 | | void initLUTfromdQPModel (); |
122 | | void constructReshaperLMCS(); |
123 | | void adjustLmcsPivot (); |
124 | 0 | vvencReshapeCW * getReshapeCW () { return &m_reshapeCW; } |
125 | 0 | Pel* getWeightTable() { return m_cwLumaWeight; } |
126 | 0 | double getCWeight () { return m_chromaWeight; } |
127 | | |
128 | | };// END CLASS DEFINITION EncReshape |
129 | | |
130 | | } // namespace vvenc |
131 | | |
132 | | //! \} |