Coverage Report

Created: 2026-08-31 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvenc/source/Lib/CommonLib/MatrixIntraPrediction.cpp
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
44
/** \file     MatrixIntraPrediction.cpp
45
\brief    matrix-based intra prediction class
46
*/
47
48
49
#include "MatrixIntraPrediction.h"
50
#include "dtrace_next.h"
51
52
#include "UnitTools.h"
53
#include "MipData.h"
54
55
namespace vvenc {
56
57
static const int MIP_MAX_INPUT_SIZE             =  8;
58
static const int MIP_MAX_REDUCED_OUTPUT_SAMPLES = 64;
59
60
MatrixIntraPrediction::MatrixIntraPrediction()
61
19.2k
  : m_reducedBoundary       (nullptr)
62
19.2k
  , m_reducedBoundaryTransp (nullptr)
63
19.2k
  , m_inputOffset           ( 0 )
64
19.2k
  , m_inputOffsetTransp     ( 0 )
65
19.2k
  , m_refSamplesTop         (nullptr)
66
19.2k
  , m_refSamplesLeft        (nullptr)
67
19.2k
  , m_blockSize             ( 0, 0 )
68
19.2k
  , m_sizeId                ( 0 )
69
19.2k
  , m_reducedBdrySize       ( 0 )
70
19.2k
  , m_reducedPredSize       ( 0 )
71
19.2k
  , m_upsmpFactorHor        ( 0 )
72
19.2k
  , m_upsmpFactorVer        ( 0 )
73
19.2k
{
74
19.2k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
19.2k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
19.2k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
19.2k
{
80
19.2k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
19.2k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
19.2k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
42.5k
{
86
  // Step 1: Save block size and calculate dependent values
87
42.5k
  initPredBlockParams(block);
88
89
42.5k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
42.5k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
42.5k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
42.5k
  Pel* const topReduced = m_reducedBoundary;
96
42.5k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
42.5k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
42.5k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
42.5k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
42.5k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
212k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
170k
  {
105
170k
    topReducedTransposed[x] = topReduced[x];
106
170k
  }
107
212k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
170k
  {
109
170k
    leftReducedTransposed[y] = leftReduced[y];
110
170k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
42.5k
  m_inputOffset       = m_reducedBoundary[0];
114
42.5k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
42.5k
  const bool hasFirstCol = (m_sizeId < 2);
117
42.5k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
42.5k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
340k
  for (int i = 1; i < inputSize; i++)
120
297k
  {
121
297k
    m_reducedBoundary      [i] -= m_inputOffset;
122
297k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
297k
  }
124
42.5k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
254k
{
128
254k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
254k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
254k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
254k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
254k
  {
135
254k
    const int outputSize = m_reducedPredSize;
136
254k
    const int inputSize  = 2 * m_reducedBdrySize;
137
254k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
254k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
254k
    if( outputSize == 8)
141
247k
    {
142
247k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
247k
    }
144
6.60k
    else
145
6.60k
    {
146
6.60k
      if( inputSize == 4)
147
0
      {
148
0
        g_pelBufOP.mipMatrixMul_4_4( reducedPred, reducedBoundary, &mipMatrix4x4[modeIdx][0][0], maxVal, offset, transpose );
149
0
      }
150
6.60k
      else
151
6.60k
      {
152
6.60k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.60k
      }
154
6.60k
    }
155
254k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
254k
  if( needUpsampling )
159
254k
  {
160
254k
    const Pel* verSrc   = reducedPred;
161
254k
    SizeType verSrcStep = m_blockSize.width;
162
163
254k
    if( m_upsmpFactorHor > 1 )
164
245k
    {
165
245k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
245k
      verSrc = horDst;
167
245k
      verSrcStep *= m_upsmpFactorVer;
168
169
245k
      if( m_reducedPredSize == 4)
170
6.60k
      {
171
6.60k
        if( m_upsmpFactorHor == 2 )
172
6.60k
          predictionUpsampling1DHor<4,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
173
0
        else if( m_upsmpFactorHor == 4 )
174
0
          predictionUpsampling1DHor<4,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
175
0
        else
176
0
          predictionUpsampling1DHor<4,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
177
6.60k
      }
178
238k
      else
179
238k
      {
180
238k
        if( m_upsmpFactorHor == 2 )
181
79.1k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
159k
        else if( m_upsmpFactorHor == 4 )
183
96.3k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
63.3k
        else
185
63.3k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
238k
      }
187
245k
    }
188
189
254k
    if( m_upsmpFactorVer > 1 )
190
244k
    {
191
244k
      if( m_reducedPredSize == 4)
192
6.60k
      {
193
6.60k
        if( m_upsmpFactorVer == 2 )
194
6.60k
          predictionUpsampling1DVer<4,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
195
0
        else if( m_upsmpFactorVer == 4 )
196
0
          predictionUpsampling1DVer<4,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
197
0
        else
198
0
          predictionUpsampling1DVer<4,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
199
6.60k
      }
200
237k
      else
201
237k
      {
202
237k
        if( m_upsmpFactorVer == 2 )
203
72.1k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
165k
        else if( m_upsmpFactorVer == 4 )
205
101k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
63.3k
        else
207
63.3k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
237k
      }
209
244k
    }
210
254k
  }
211
254k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
42.5k
{
215
42.5k
  m_blockSize = block;
216
  // init size index
217
42.5k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
42.5k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
42.5k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
42.5k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
42.5k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
42.5k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
42.5k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
42.5k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
85.0k
{
235
85.0k
  if (dstLen < srcLen)
236
85.0k
  {
237
    // Create reduced boundary by downsampling
238
85.0k
    const SizeType downsmpFactor = srcLen / dstLen;
239
85.0k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
85.0k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
85.0k
    SizeType srcIdx = 0;
243
425k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
340k
    {
245
340k
      int sum = 0;
246
3.30M
      for( int k = 0; k < downsmpFactor; k++ )
247
2.96M
      {
248
2.96M
        sum += fullSrc[srcIdx++];
249
2.96M
      }
250
340k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
340k
    }
252
85.0k
  }
253
0
  else
254
0
  {
255
    // Copy boundary if no downsampling is needed
256
0
    for (SizeType i = 0; i < dstLen; ++i)
257
0
    {
258
0
      reducedDst[i] = fullSrc[i];
259
0
    }
260
0
  }
261
85.0k
}
262
263
template< SizeType predPredSize, unsigned log2UpsmpFactor>
264
void MatrixIntraPrediction::predictionUpsampling1DHor(Pel* const dst, const Pel* const src, const Pel* const bndry, const SizeType dstStride, const SizeType bndryStep )
265
245k
{
266
245k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
245k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
245k
        Pel* dstLine   = dst;
270
245k
  const Pel* srcLine   = src;
271
245k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.18M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.93M
  {
275
1.93M
    const Pel* before  = bndryLine;
276
1.93M
    const Pel* behind  = srcLine;
277
1.93M
          Pel* currDst = dstLine;
278
17.3M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
15.3M
    {
280
15.3M
      const int valDiff   = *behind - *before;
281
15.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
82.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
67.4M
      {
284
67.4M
        scaledVal += valDiff;
285
67.4M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
67.4M
        currDst++;
287
67.4M
      }
288
15.3M
      before = behind;
289
15.3M
      behind ++;
290
15.3M
    }
291
292
1.93M
    srcLine   += predPredSize;
293
1.93M
    dstLine   += dstStride;
294
1.93M
    bndryLine += bndryStep;
295
1.93M
  }
296
245k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.60k
{
266
6.60k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.60k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.60k
        Pel* dstLine   = dst;
270
6.60k
  const Pel* srcLine   = src;
271
6.60k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
33.0k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
26.4k
  {
275
26.4k
    const Pel* before  = bndryLine;
276
26.4k
    const Pel* behind  = srcLine;
277
26.4k
          Pel* currDst = dstLine;
278
132k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
105k
    {
280
105k
      const int valDiff   = *behind - *before;
281
105k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
317k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
211k
      {
284
211k
        scaledVal += valDiff;
285
211k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
211k
        currDst++;
287
211k
      }
288
105k
      before = behind;
289
105k
      behind ++;
290
105k
    }
291
292
26.4k
    srcLine   += predPredSize;
293
26.4k
    dstLine   += dstStride;
294
26.4k
    bndryLine += bndryStep;
295
26.4k
  }
296
6.60k
}
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
79.1k
{
266
79.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
79.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
79.1k
        Pel* dstLine   = dst;
270
79.1k
  const Pel* srcLine   = src;
271
79.1k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
712k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
633k
  {
275
633k
    const Pel* before  = bndryLine;
276
633k
    const Pel* behind  = srcLine;
277
633k
          Pel* currDst = dstLine;
278
5.69M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.06M
    {
280
5.06M
      const int valDiff   = *behind - *before;
281
5.06M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
15.1M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
10.1M
      {
284
10.1M
        scaledVal += valDiff;
285
10.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
10.1M
        currDst++;
287
10.1M
      }
288
5.06M
      before = behind;
289
5.06M
      behind ++;
290
5.06M
    }
291
292
633k
    srcLine   += predPredSize;
293
633k
    dstLine   += dstStride;
294
633k
    bndryLine += bndryStep;
295
633k
  }
296
79.1k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
96.3k
{
266
96.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
96.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
96.3k
        Pel* dstLine   = dst;
270
96.3k
  const Pel* srcLine   = src;
271
96.3k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
867k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
771k
  {
275
771k
    const Pel* before  = bndryLine;
276
771k
    const Pel* behind  = srcLine;
277
771k
          Pel* currDst = dstLine;
278
6.94M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.16M
    {
280
6.16M
      const int valDiff   = *behind - *before;
281
6.16M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
30.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
24.6M
      {
284
24.6M
        scaledVal += valDiff;
285
24.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
24.6M
        currDst++;
287
24.6M
      }
288
6.16M
      before = behind;
289
6.16M
      behind ++;
290
6.16M
    }
291
292
771k
    srcLine   += predPredSize;
293
771k
    dstLine   += dstStride;
294
771k
    bndryLine += bndryStep;
295
771k
  }
296
96.3k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
63.3k
{
266
63.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
63.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
63.3k
        Pel* dstLine   = dst;
270
63.3k
  const Pel* srcLine   = src;
271
63.3k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
570k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
506k
  {
275
506k
    const Pel* before  = bndryLine;
276
506k
    const Pel* behind  = srcLine;
277
506k
          Pel* currDst = dstLine;
278
4.56M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.05M
    {
280
4.05M
      const int valDiff   = *behind - *before;
281
4.05M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
36.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
32.4M
      {
284
32.4M
        scaledVal += valDiff;
285
32.4M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
32.4M
        currDst++;
287
32.4M
      }
288
4.05M
      before = behind;
289
4.05M
      behind ++;
290
4.05M
    }
291
292
506k
    srcLine   += predPredSize;
293
506k
    dstLine   += dstStride;
294
506k
    bndryLine += bndryStep;
295
506k
  }
296
63.3k
}
297
298
template< SizeType inHeight, unsigned log2UpsmpFactor>
299
void MatrixIntraPrediction::predictionUpsampling1DVer(Pel* const dst, const Pel* const src, const Pel* const bndry, const SizeType outWidth, const SizeType srcStep  )
300
244k
{
301
244k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
244k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
244k
        Pel* dstLine   = dst;
305
244k
  const Pel* srcLine   = src;
306
244k
  const Pel* bndryLine = bndry;
307
308
8.60M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.36M
  {
310
8.36M
    const Pel* before  = bndryLine;
311
8.36M
    const Pel* behind  = srcLine;
312
8.36M
          Pel* currDst = dstLine;
313
75.0M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
66.7M
    {
315
66.7M
      const int valDiff   = *behind - *before;
316
66.7M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
435M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
368M
      {
320
368M
        scaledVal += valDiff;
321
368M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
368M
        currDst += outWidth;
323
368M
      }
324
66.7M
      before = behind;
325
66.7M
      behind += srcStep;
326
66.7M
    }
327
328
8.36M
    srcLine ++;
329
8.36M
    dstLine ++;
330
8.36M
    bndryLine ++;
331
8.36M
  }
332
244k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.60k
{
301
6.60k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.60k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.60k
        Pel* dstLine   = dst;
305
6.60k
  const Pel* srcLine   = src;
306
6.60k
  const Pel* bndryLine = bndry;
307
308
59.4k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
52.8k
  {
310
52.8k
    const Pel* before  = bndryLine;
311
52.8k
    const Pel* behind  = srcLine;
312
52.8k
          Pel* currDst = dstLine;
313
264k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
211k
    {
315
211k
      const int valDiff   = *behind - *before;
316
211k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
634k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
422k
      {
320
422k
        scaledVal += valDiff;
321
422k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
422k
        currDst += outWidth;
323
422k
      }
324
211k
      before = behind;
325
211k
      behind += srcStep;
326
211k
    }
327
328
52.8k
    srcLine ++;
329
52.8k
    dstLine ++;
330
52.8k
    bndryLine ++;
331
52.8k
  }
332
6.60k
}
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
72.1k
{
301
72.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
72.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
72.1k
        Pel* dstLine   = dst;
305
72.1k
  const Pel* srcLine   = src;
306
72.1k
  const Pel* bndryLine = bndry;
307
308
1.80M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.73M
  {
310
1.73M
    const Pel* before  = bndryLine;
311
1.73M
    const Pel* behind  = srcLine;
312
1.73M
          Pel* currDst = dstLine;
313
15.6M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
13.8M
    {
315
13.8M
      const int valDiff   = *behind - *before;
316
13.8M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
41.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
27.7M
      {
320
27.7M
        scaledVal += valDiff;
321
27.7M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
27.7M
        currDst += outWidth;
323
27.7M
      }
324
13.8M
      before = behind;
325
13.8M
      behind += srcStep;
326
13.8M
    }
327
328
1.73M
    srcLine ++;
329
1.73M
    dstLine ++;
330
1.73M
    bndryLine ++;
331
1.73M
  }
332
72.1k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
101k
{
301
101k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
101k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
101k
        Pel* dstLine   = dst;
305
101k
  const Pel* srcLine   = src;
306
101k
  const Pel* bndryLine = bndry;
307
308
2.62M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.51M
  {
310
2.51M
    const Pel* before  = bndryLine;
311
2.51M
    const Pel* behind  = srcLine;
312
2.51M
          Pel* currDst = dstLine;
313
22.6M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
20.1M
    {
315
20.1M
      const int valDiff   = *behind - *before;
316
20.1M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
100M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
80.6M
      {
320
80.6M
        scaledVal += valDiff;
321
80.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
80.6M
        currDst += outWidth;
323
80.6M
      }
324
20.1M
      before = behind;
325
20.1M
      behind += srcStep;
326
20.1M
    }
327
328
2.51M
    srcLine ++;
329
2.51M
    dstLine ++;
330
2.51M
    bndryLine ++;
331
2.51M
  }
332
101k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
63.3k
{
301
63.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
63.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
63.3k
        Pel* dstLine   = dst;
305
63.3k
  const Pel* srcLine   = src;
306
63.3k
  const Pel* bndryLine = bndry;
307
308
4.11M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.05M
  {
310
4.05M
    const Pel* before  = bndryLine;
311
4.05M
    const Pel* behind  = srcLine;
312
4.05M
          Pel* currDst = dstLine;
313
36.4M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
32.4M
    {
315
32.4M
      const int valDiff   = *behind - *before;
316
32.4M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
291M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
259M
      {
320
259M
        scaledVal += valDiff;
321
259M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
259M
        currDst += outWidth;
323
259M
      }
324
32.4M
      before = behind;
325
32.4M
      behind += srcStep;
326
32.4M
    }
327
328
4.05M
    srcLine ++;
329
4.05M
    dstLine ++;
330
4.05M
    bndryLine ++;
331
4.05M
  }
332
63.3k
}
333
334
335
} // namespace vvenc
336
337
//! \}