Coverage Report

Created: 2026-12-01 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvdec/source/Lib/CommonLib/IntraPrediction.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) 2018-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC 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     IntraPrediction.h
44
    \brief    prediction class (header)
45
*/
46
47
#pragma once
48
49
// Include files
50
#include "Unit.h"
51
#include "Buffer.h"
52
53
#include "MatrixIntraPrediction.h"
54
55
56
namespace vvdec
57
{
58
#if ENABLE_SIMD_OPT_INTRAPRED && defined( TARGET_SIMD_X86 )
59
using namespace x86_simd;
60
#endif
61
// ====================================================================================================================
62
// Class definition
63
// ====================================================================================================================
64
65
/// prediction class
66
enum PredBuf
67
{
68
  PRED_BUF_UNFILTERED = 0,
69
  PRED_BUF_FILTERED   = 1,
70
  NUM_PRED_BUF        = 2
71
};
72
73
static const uint32_t MAX_INTRA_FILTER_DEPTHS=8;
74
75
// the C version of IntraPrediction::IntraPredAngPdpc, also used by the SIMD version for the rare steep angles
76
void IntraPredAngPdpcCore( Pel* pDst, const ptrdiff_t dstStride, const Pel* refSide, const int width, const int height, const int invAngle, const int angularScale );
77
78
class IntraPrediction
79
{
80
private:
81
82
  Pel    m_piYuvExt     [NUM_PRED_BUF][( MAX_TU_SIZE_FOR_PROFILE * 2 + 1 + MAX_REF_LINE_IDX ) * ( MAX_TU_SIZE_FOR_PROFILE * 2 + 1 + MAX_REF_LINE_IDX )];
83
  PelBuf m_pelBufISPBase[NUM_PRED_BUF];
84
  PelBuf m_pelBufISP    [NUM_PRED_BUF];
85
  int    m_neighborSize [3];
86
  int    m_lastCUidx;
87
  static const uint8_t
88
       m_aucIntraFilter [MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS];
89
90
  MatrixIntraPrediction m_matrixIntraPred;
91
92
protected:
93
94
  ChromaFormat  m_currChromaFormat;
95
96
  int m_topRefLength;
97
  int m_leftRefLength;
98
  // prediction
99
  void xPredIntraDc               ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType,                                                                                          const bool enableBoundaryFilter = true, const int mrlIdx = 0 );
100
  void xPredIntraAng              ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const SPS& sps,
101
                                          int  multiRefIdx,
102
                                    const bool useFilteredPredSamples,
103
                                          bool &doPDPC,
104
                                    const bool useISP = false,
105
                                    const Size cuSize = Size( 0, 0 )
106
                                   );
107
108
  void xPredIntraBDPCM            ( const CPelBuf &pSrc, PelBuf &pDst, const uint32_t dirMode, const ClpRng& clpRng );
109
  Pel  xGetPredValDc              ( const CPelBuf &pSrc, const Size &dstSize, const int mrlIdx );
110
  
111
  void xFillReferenceSamples      ( const CPelBuf &recoBuf,      Pel* refBufUnfiltered, const CompArea &area, const TransformUnit &tu );
112
  void xFilterReferenceSamples    ( const Pel* refBufUnfiltered, Pel* refBufFiltered, const CompArea &area, const SPS &sps, int multiRefIdx, ptrdiff_t predStride = 0 ) const;
113
114
  static int getWideAngle         ( int width, int height, int predMode );
115
  void setReferenceArrayLengths   ( const CompArea &area );
116
117
  void destroy                    ();
118
119
  void xGetLMParameters           (const CodingUnit &cu, const ComponentID compID, const CompArea& chromaArea, int& a, int& b, int& iShift);
120
public:
121
  IntraPrediction();
122
  ~IntraPrediction();
123
124
  void init                       (ChromaFormat chromaFormatIDC, const unsigned bitDepthY);
125
126
  // Angular Intra
127
  void predIntraAng               (const ComponentID compId, PelBuf &piPred, const CodingUnit &cu, const bool useFilteredPredSamples);
128
0
  Pel*  getPredictorPtr           (const ComponentID compID, const bool bUseFilteredPredictions = false) { return m_piYuvExt[bUseFilteredPredictions?PRED_BUF_FILTERED:PRED_BUF_UNFILTERED]; }
129
  // Cross-component Chroma
130
  void predIntraChromaLM          (const ComponentID compID, PelBuf &piPred, const CodingUnit &cu, const CompArea& chromaArea, int intraDir);
131
  void xGetLumaRecPixels          (const CodingUnit &cu, CompArea chromaArea);
132
  /// set parameters from CU data for accessing intra data
133
  void initIntraPatternChType     (const TransformUnit &cu, const CompArea &area, const bool bFilterRefSamples = false );
134
  void initIntraPatternChTypeISP  (const CodingUnit& cu, const CompArea& area, PelBuf& piReco);
135
0
  const PelBuf& getISPBuffer      (const bool bUseFilteredPredictions = false) { return m_pelBufISP[bUseFilteredPredictions ? PRED_BUF_FILTERED : PRED_BUF_UNFILTERED]; }
136
137
  // Matrix-based intra prediction
138
  void initIntraMip               (const CodingUnit &cu, const CompArea &area);
139
  void predIntraMip               (const ComponentID compId, PelBuf &piPred, const CodingUnit &cu);
140
141
  static bool useFilteredIntraRefSamples( const ComponentID &compID, const CodingUnit &cu, const UnitArea &tuArea );
142
143
  void predBlendIntraCiip         (PelUnitBuf &predUnit, const CodingUnit &cu);
144
145
  void ( *CiipBlend )                   ( Pel* dst, const ptrdiff_t dstStride, const Pel* intraPred, const ptrdiff_t intraStride, const int width, const int height, const int wMerge, const int wIntra );
146
147
  void ( *IntraPredAngleCore4 )         ( Pel* pDstBuf,const ptrdiff_t dstStride,Pel* refMain,int width,int height,int deltaPos,int intraPredAngle,const TFilterCoeff *ff,const bool useCubicFilter,const ClpRng& clpRng);
148
  void ( *IntraPredAngleCore8 )         ( Pel* pDstBuf,const ptrdiff_t dstStride,Pel* refMain,int width,int height,int deltaPos,int intraPredAngle,const TFilterCoeff *ff,const bool useCubicFilter,const ClpRng& clpRng);
149
150
  void ( *IntraPredAngPdpc )            ( Pel* pDst, const ptrdiff_t dstStride, const Pel* refSide, const int width, const int height, const int invAngle, const int angularScale );
151
152
  void( *IntraPredAngleChroma4 )        ( int16_t* pDst, const ptrdiff_t dstStride, int16_t* pBorder, int width, int height, int deltaPos, int intraPredAngle );
153
  void( *IntraPredAngleChroma8 )        ( int16_t* pDst, const ptrdiff_t dstStride, int16_t* pBorder, int width, int height, int deltaPos, int intraPredAngle );
154
155
  MipMatrixMulFunc   MipMatrixMul;      // the matrix multiplication used by m_matrixIntraPred
156
  MipUpsampleHorFunc MipUpsampleHor;    // the horizontal upsampling used by m_matrixIntraPred
157
158
  void  ( *IntraPredSampleFilter8 )     ( Pel *ptrSrc,const ptrdiff_t  srcStride,PelBuf &piPred,const uint32_t uiDirMode,const ClpRng& clpRng );
159
  void  ( *IntraPredSampleFilter16 )    ( Pel *ptrSrc,const ptrdiff_t  srcStride,PelBuf &piPred,const uint32_t uiDirMode,const ClpRng& clpRng );
160
  void  ( *xPredIntraPlanar )           ( const CPelBuf &pSrc, PelBuf &pDst, const SPS& sps );
161
  void  ( *IntraPredHorVerPdpc )        ( Pel* pDst, const ptrdiff_t dstStride, const Pel* refMain, const Pel* refSide, const int width, const int height, const int scale, const Pel topLeft, const ClpRng& clpRng );
162
163
  void ( *GetLumaRecPixel420 )          ( const int width,const int height, const Pel* pRecSrc0,const ptrdiff_t iRecStride,Pel* pDst0,const ptrdiff_t iDstStride );
164
  void ( *GetLumaRecPixel420Collocated )( const int width, const int height, const Pel* pRecSrc0, const ptrdiff_t iRecStride, Pel* pDst0, const ptrdiff_t iDstStride );
165
  void ( *GetLumaRecPixel420Left )      ( const int height, const Pel* pRecSrc0, const ptrdiff_t iRecStride, Pel* pDst, const ptrdiff_t iDstStride, const bool collocated );
166
167
#if ENABLE_SIMD_OPT_INTRAPRED && defined( TARGET_SIMD_X86 )
168
  void initIntraPredictionX86();
169
  template <X86_VEXT vext>
170
  void _initIntraPredictionX86();
171
#endif
172
#if ENABLE_SIMD_OPT_INTRAPRED && defined( TARGET_SIMD_ARM )
173
  void initIntraPredictionARM();
174
  template <ARM_VEXT vext>
175
  void _initIntraPredictionARM();
176
#endif
177
};
178
179
}