Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/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
class IntraPrediction
76
{
77
private:
78
79
  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 )];
80
  PelBuf m_pelBufISPBase[NUM_PRED_BUF];
81
  PelBuf m_pelBufISP    [NUM_PRED_BUF];
82
  int    m_neighborSize [3];
83
  int    m_lastCUidx;
84
  static const uint8_t
85
       m_aucIntraFilter [MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS];
86
87
  MatrixIntraPrediction m_matrixIntraPred;
88
89
protected:
90
91
  ChromaFormat  m_currChromaFormat;
92
93
  int m_topRefLength;
94
  int m_leftRefLength;
95
  // prediction
96
  void xPredIntraDc               ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType,                                                                                          const bool enableBoundaryFilter = true, const int mrlIdx = 0 );
97
  void xPredIntraAng              ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const SPS& sps,
98
                                          int  multiRefIdx,
99
                                    const bool useFilteredPredSamples,
100
                                          bool &doPDPC,
101
                                    const bool useISP = false,
102
                                    const Size cuSize = Size( 0, 0 )
103
                                   );
104
105
  void xPredIntraBDPCM            ( const CPelBuf &pSrc, PelBuf &pDst, const uint32_t dirMode, const ClpRng& clpRng );
106
  Pel  xGetPredValDc              ( const CPelBuf &pSrc, const Size &dstSize, const int mrlIdx );
107
  
108
  void xFillReferenceSamples      ( const CPelBuf &recoBuf,      Pel* refBufUnfiltered, const CompArea &area, const TransformUnit &tu );
109
  void xFilterReferenceSamples    ( const Pel* refBufUnfiltered, Pel* refBufFiltered, const CompArea &area, const SPS &sps, int multiRefIdx, ptrdiff_t predStride = 0 ) const;
110
111
  static int getWideAngle         ( int width, int height, int predMode );
112
  void setReferenceArrayLengths   ( const CompArea &area );
113
114
  void destroy                    ();
115
116
  void xGetLMParameters           (const CodingUnit &cu, const ComponentID compID, const CompArea& chromaArea, int& a, int& b, int& iShift);
117
public:
118
  IntraPrediction();
119
  ~IntraPrediction();
120
121
  void init                       (ChromaFormat chromaFormatIDC, const unsigned bitDepthY);
122
123
  // Angular Intra
124
  void predIntraAng               (const ComponentID compId, PelBuf &piPred, const CodingUnit &cu, const bool useFilteredPredSamples);
125
0
  Pel*  getPredictorPtr           (const ComponentID compID, const bool bUseFilteredPredictions = false) { return m_piYuvExt[bUseFilteredPredictions?PRED_BUF_FILTERED:PRED_BUF_UNFILTERED]; }
126
  // Cross-component Chroma
127
  void predIntraChromaLM          (const ComponentID compID, PelBuf &piPred, const CodingUnit &cu, const CompArea& chromaArea, int intraDir);
128
  void xGetLumaRecPixels          (const CodingUnit &cu, CompArea chromaArea);
129
  /// set parameters from CU data for accessing intra data
130
  void initIntraPatternChType     (const TransformUnit &cu, const CompArea &area, const bool bFilterRefSamples = false );
131
  void initIntraPatternChTypeISP  (const CodingUnit& cu, const CompArea& area, PelBuf& piReco);
132
0
  const PelBuf& getISPBuffer      (const bool bUseFilteredPredictions = false) { return m_pelBufISP[bUseFilteredPredictions ? PRED_BUF_FILTERED : PRED_BUF_UNFILTERED]; }
133
134
  // Matrix-based intra prediction
135
  void initIntraMip               (const CodingUnit &cu, const CompArea &area);
136
  void predIntraMip               (const ComponentID compId, PelBuf &piPred, const CodingUnit &cu);
137
138
  static bool useFilteredIntraRefSamples( const ComponentID &compID, const CodingUnit &cu, const UnitArea &tuArea );
139
140
  void predBlendIntraCiip         (PelUnitBuf &predUnit, const CodingUnit &cu);
141
142
  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);
143
  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);
144
145
  void( *IntraPredAngleChroma4 )        ( int16_t* pDst, const ptrdiff_t dstStride, int16_t* pBorder, int width, int height, int deltaPos, int intraPredAngle );
146
  void( *IntraPredAngleChroma8 )        ( int16_t* pDst, const ptrdiff_t dstStride, int16_t* pBorder, int width, int height, int deltaPos, int intraPredAngle );
147
148
  void  ( *IntraPredSampleFilter8 )     ( Pel *ptrSrc,const ptrdiff_t  srcStride,PelBuf &piPred,const uint32_t uiDirMode,const ClpRng& clpRng );
149
  void  ( *IntraPredSampleFilter16 )    ( Pel *ptrSrc,const ptrdiff_t  srcStride,PelBuf &piPred,const uint32_t uiDirMode,const ClpRng& clpRng );
150
  void  ( *xPredIntraPlanar )           ( const CPelBuf &pSrc, PelBuf &pDst, const SPS& sps );
151
152
  void ( *GetLumaRecPixel420 )          ( const int width,const int height, const Pel* pRecSrc0,const ptrdiff_t iRecStride,Pel* pDst0,const ptrdiff_t iDstStride );
153
154
#if ENABLE_SIMD_OPT_INTRAPRED && defined( TARGET_SIMD_X86 )
155
  void initIntraPredictionX86();
156
  template <X86_VEXT vext>
157
  void _initIntraPredictionX86();
158
#endif
159
};
160
161
}