Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vvenc/source/Lib/CommonLib/Reshape.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     Reshape.h
43
     \brief    reshaping header and class (header)
44
 */
45
46
#pragma once
47
48
#include "CommonDef.h"
49
#include "Rom.h"
50
#include "Slice.h"
51
#include "Unit.h"
52
53
//! \ingroup CommonLib
54
//! \{
55
56
namespace vvenc {
57
58
// ====================================================================================================================
59
// Class definition
60
// ====================================================================================================================
61
62
class ReshapeData
63
{
64
protected:
65
  LmcsParam               m_sliceReshapeInfo;
66
  bool                    m_CTUFlag;
67
  int                     m_chromaScale;
68
  int                     m_lumaBD;
69
  int                     m_vpduX;
70
  int                     m_vpduY;
71
  double                  m_chromaWeightRS;
72
  std::vector<Pel>        m_invLUT;
73
  std::vector<Pel>        m_fwdLUT;
74
  std::vector<Pel>        m_reshapePivot;
75
  std::vector<int>        m_chromaAdjHelpLUT;
76
  std::vector<uint32_t>   m_reshapeLumaLevelToWeightPLUT;
77
78
public:
79
  ReshapeData()
80
0
    : m_CTUFlag         ( false )
81
0
    , m_chromaScale     ( 1 << CSCALE_FP_PREC )
82
0
    , m_lumaBD          ( 0 )
83
0
    , m_vpduX           ( -1 )
84
0
    , m_vpduY           ( -1 )
85
0
    , m_chromaWeightRS  ( 0.0 )
86
0
  {}
87
88
0
  virtual ~ReshapeData() {}
89
90
0
  void   copyReshapeData( const ReshapeData& d )          { *this = d; }
91
92
0
  const Pel* getFwdLUT()                            const { return m_fwdLUT.data(); }
93
0
  const Pel* getInvLUT()                            const { return m_invLUT.data(); }
94
0
  double getChromaWeight()                          const { return m_chromaWeightRS; }
95
0
  const uint32_t* getReshapeLumaLevelToWeightPLUT() const { return m_reshapeLumaLevelToWeightPLUT.data(); }
96
97
0
  bool   getCTUFlag()                               const { return m_CTUFlag; }
98
0
  void   setCTUFlag( bool b )                             { m_CTUFlag = b; }
99
100
0
  bool   isVPDUprocessed( int x, int y )            const { return ( ( x == m_vpduX ) && ( y == m_vpduY ) ); }
101
0
  void   setVPDULoc     ( int x, int y )                  { m_vpduX = x; m_vpduY = y; }
102
103
0
  LmcsParam& getSliceReshaperInfo()                       { return m_sliceReshapeInfo; }
104
105
  int    calculateChromaAdjVpduNei( const TransformUnit& tu, const CompArea& , const TreeType _treeType );
106
107
protected:
108
  int    getPWLIdxInv( int lumaVal )       const;
109
  int    calculateChromaAdj( Pel avgLuma ) const;
110
};
111
112
class Reshape : public ReshapeData
113
{
114
protected:
115
  std::vector<uint16_t>   m_binCW;
116
  uint16_t                m_initCW;
117
  bool                    m_reshape;
118
  std::vector<Pel>        m_inputPivot;
119
  std::vector<int32_t>    m_fwdScaleCoef;
120
  std::vector<int32_t>    m_invScaleCoef;
121
  int                     m_reshapeLUTSize;
122
123
  uint32_t                m_signalType;
124
  std::vector<double>     m_lumaLevelToWeightPLUT; //ALF
125
126
public:
127
  Reshape()
128
0
    : m_reshape (true)
129
0
  {}
130
131
0
  virtual ~Reshape() {}
132
133
  void createDec(int bitDepth);
134
135
  void constructReshaper();
136
137
0
  bool getReshapeFlag()                           const { return m_reshape; }
138
0
  void setReshapeFlag(bool b)                           { m_reshape = b; }
139
0
  const double* getlumaLevelToWeightPLUT()        const { return m_lumaLevelToWeightPLUT.data(); }
140
141
  void initLumaLevelToWeightTableReshape();
142
  void updateReshapeLumaLevelToWeightTableChromaMD (const Pel* ILUT);
143
  void restoreReshapeLumaLevelToWeightTable        ();
144
  void updateReshapeLumaLevelToWeightTable         (LmcsParam &sliceReshape, Pel* wtTable, double cwt);
145
};// END CLASS DEFINITION Reshape
146
147
} // namespace vvenc
148
149
//! \}
150
151