Coverage Report

Created: 2026-07-30 06:27

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.4k
  : m_reducedBoundary       (nullptr)
62
19.4k
  , m_reducedBoundaryTransp (nullptr)
63
19.4k
  , m_inputOffset           ( 0 )
64
19.4k
  , m_inputOffsetTransp     ( 0 )
65
19.4k
  , m_refSamplesTop         (nullptr)
66
19.4k
  , m_refSamplesLeft        (nullptr)
67
19.4k
  , m_blockSize             ( 0, 0 )
68
19.4k
  , m_sizeId                ( 0 )
69
19.4k
  , m_reducedBdrySize       ( 0 )
70
19.4k
  , m_reducedPredSize       ( 0 )
71
19.4k
  , m_upsmpFactorHor        ( 0 )
72
19.4k
  , m_upsmpFactorVer        ( 0 )
73
19.4k
{
74
19.4k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
19.4k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
19.4k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
19.4k
{
80
19.4k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
19.4k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
19.4k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
43.0k
{
86
  // Step 1: Save block size and calculate dependent values
87
43.0k
  initPredBlockParams(block);
88
89
43.0k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
43.0k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
43.0k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
43.0k
  Pel* const topReduced = m_reducedBoundary;
96
43.0k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
43.0k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
43.0k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
43.0k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
43.0k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
215k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
172k
  {
105
172k
    topReducedTransposed[x] = topReduced[x];
106
172k
  }
107
215k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
172k
  {
109
172k
    leftReducedTransposed[y] = leftReduced[y];
110
172k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
43.0k
  m_inputOffset       = m_reducedBoundary[0];
114
43.0k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
43.0k
  const bool hasFirstCol = (m_sizeId < 2);
117
43.0k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
43.0k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
344k
  for (int i = 1; i < inputSize; i++)
120
301k
  {
121
301k
    m_reducedBoundary      [i] -= m_inputOffset;
122
301k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
301k
  }
124
43.0k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
257k
{
128
257k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
257k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
257k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
257k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
257k
  {
135
257k
    const int outputSize = m_reducedPredSize;
136
257k
    const int inputSize  = 2 * m_reducedBdrySize;
137
257k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
257k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
257k
    if( outputSize == 8)
141
251k
    {
142
251k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
251k
    }
144
6.72k
    else
145
6.72k
    {
146
6.72k
      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.72k
      else
151
6.72k
      {
152
6.72k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.72k
      }
154
6.72k
    }
155
257k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
257k
  if( needUpsampling )
159
257k
  {
160
257k
    const Pel* verSrc   = reducedPred;
161
257k
    SizeType verSrcStep = m_blockSize.width;
162
163
257k
    if( m_upsmpFactorHor > 1 )
164
248k
    {
165
248k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
248k
      verSrc = horDst;
167
248k
      verSrcStep *= m_upsmpFactorVer;
168
169
248k
      if( m_reducedPredSize == 4)
170
6.72k
      {
171
6.72k
        if( m_upsmpFactorHor == 2 )
172
6.72k
          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.72k
      }
178
241k
      else
179
241k
      {
180
241k
        if( m_upsmpFactorHor == 2 )
181
77.1k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
164k
        else if( m_upsmpFactorHor == 4 )
183
100k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
64.6k
        else
185
64.6k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
241k
      }
187
248k
    }
188
189
257k
    if( m_upsmpFactorVer > 1 )
190
247k
    {
191
247k
      if( m_reducedPredSize == 4)
192
6.72k
      {
193
6.72k
        if( m_upsmpFactorVer == 2 )
194
6.72k
          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.72k
      }
200
240k
      else
201
240k
      {
202
240k
        if( m_upsmpFactorVer == 2 )
203
75.5k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
165k
        else if( m_upsmpFactorVer == 4 )
205
100k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
64.6k
        else
207
64.6k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
240k
      }
209
247k
    }
210
257k
  }
211
257k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
43.0k
{
215
43.0k
  m_blockSize = block;
216
  // init size index
217
43.0k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
43.0k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
43.0k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
43.0k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
43.0k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
43.0k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
43.0k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
43.0k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
86.0k
{
235
86.0k
  if (dstLen < srcLen)
236
86.0k
  {
237
    // Create reduced boundary by downsampling
238
86.0k
    const SizeType downsmpFactor = srcLen / dstLen;
239
86.0k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
86.0k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
86.0k
    SizeType srcIdx = 0;
243
430k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
344k
    {
245
344k
      int sum = 0;
246
3.34M
      for( int k = 0; k < downsmpFactor; k++ )
247
3.00M
      {
248
3.00M
        sum += fullSrc[srcIdx++];
249
3.00M
      }
250
344k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
344k
    }
252
86.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
86.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
248k
{
266
248k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
248k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
248k
        Pel* dstLine   = dst;
270
248k
  const Pel* srcLine   = src;
271
248k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.21M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.96M
  {
275
1.96M
    const Pel* before  = bndryLine;
276
1.96M
    const Pel* behind  = srcLine;
277
1.96M
          Pel* currDst = dstLine;
278
17.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
15.5M
    {
280
15.5M
      const int valDiff   = *behind - *before;
281
15.5M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
84.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
68.8M
      {
284
68.8M
        scaledVal += valDiff;
285
68.8M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
68.8M
        currDst++;
287
68.8M
      }
288
15.5M
      before = behind;
289
15.5M
      behind ++;
290
15.5M
    }
291
292
1.96M
    srcLine   += predPredSize;
293
1.96M
    dstLine   += dstStride;
294
1.96M
    bndryLine += bndryStep;
295
1.96M
  }
296
248k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.72k
{
266
6.72k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.72k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.72k
        Pel* dstLine   = dst;
270
6.72k
  const Pel* srcLine   = src;
271
6.72k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
33.6k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
26.8k
  {
275
26.8k
    const Pel* before  = bndryLine;
276
26.8k
    const Pel* behind  = srcLine;
277
26.8k
          Pel* currDst = dstLine;
278
134k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
107k
    {
280
107k
      const int valDiff   = *behind - *before;
281
107k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
322k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
215k
      {
284
215k
        scaledVal += valDiff;
285
215k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
215k
        currDst++;
287
215k
      }
288
107k
      before = behind;
289
107k
      behind ++;
290
107k
    }
291
292
26.8k
    srcLine   += predPredSize;
293
26.8k
    dstLine   += dstStride;
294
26.8k
    bndryLine += bndryStep;
295
26.8k
  }
296
6.72k
}
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
77.1k
{
266
77.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
77.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
77.1k
        Pel* dstLine   = dst;
270
77.1k
  const Pel* srcLine   = src;
271
77.1k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
694k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
617k
  {
275
617k
    const Pel* before  = bndryLine;
276
617k
    const Pel* behind  = srcLine;
277
617k
          Pel* currDst = dstLine;
278
5.55M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.93M
    {
280
4.93M
      const int valDiff   = *behind - *before;
281
4.93M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
14.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
9.87M
      {
284
9.87M
        scaledVal += valDiff;
285
9.87M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
9.87M
        currDst++;
287
9.87M
      }
288
4.93M
      before = behind;
289
4.93M
      behind ++;
290
4.93M
    }
291
292
617k
    srcLine   += predPredSize;
293
617k
    dstLine   += dstStride;
294
617k
    bndryLine += bndryStep;
295
617k
  }
296
77.1k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
100k
{
266
100k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
100k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
100k
        Pel* dstLine   = dst;
270
100k
  const Pel* srcLine   = src;
271
100k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
901k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
801k
  {
275
801k
    const Pel* before  = bndryLine;
276
801k
    const Pel* behind  = srcLine;
277
801k
          Pel* currDst = dstLine;
278
7.20M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.40M
    {
280
6.40M
      const int valDiff   = *behind - *before;
281
6.40M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
32.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
25.6M
      {
284
25.6M
        scaledVal += valDiff;
285
25.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
25.6M
        currDst++;
287
25.6M
      }
288
6.40M
      before = behind;
289
6.40M
      behind ++;
290
6.40M
    }
291
292
801k
    srcLine   += predPredSize;
293
801k
    dstLine   += dstStride;
294
801k
    bndryLine += bndryStep;
295
801k
  }
296
100k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
64.6k
{
266
64.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
64.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
64.6k
        Pel* dstLine   = dst;
270
64.6k
  const Pel* srcLine   = src;
271
64.6k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
581k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
517k
  {
275
517k
    const Pel* before  = bndryLine;
276
517k
    const Pel* behind  = srcLine;
277
517k
          Pel* currDst = dstLine;
278
4.65M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.13M
    {
280
4.13M
      const int valDiff   = *behind - *before;
281
4.13M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
37.2M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
33.0M
      {
284
33.0M
        scaledVal += valDiff;
285
33.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
33.0M
        currDst++;
287
33.0M
      }
288
4.13M
      before = behind;
289
4.13M
      behind ++;
290
4.13M
    }
291
292
517k
    srcLine   += predPredSize;
293
517k
    dstLine   += dstStride;
294
517k
    bndryLine += bndryStep;
295
517k
  }
296
64.6k
}
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
247k
{
301
247k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
247k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
247k
        Pel* dstLine   = dst;
305
247k
  const Pel* srcLine   = src;
306
247k
  const Pel* bndryLine = bndry;
307
308
8.78M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.53M
  {
310
8.53M
    const Pel* before  = bndryLine;
311
8.53M
    const Pel* behind  = srcLine;
312
8.53M
          Pel* currDst = dstLine;
313
76.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
68.0M
    {
315
68.0M
      const int valDiff   = *behind - *before;
316
68.0M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
442M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
374M
      {
320
374M
        scaledVal += valDiff;
321
374M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
374M
        currDst += outWidth;
323
374M
      }
324
68.0M
      before = behind;
325
68.0M
      behind += srcStep;
326
68.0M
    }
327
328
8.53M
    srcLine ++;
329
8.53M
    dstLine ++;
330
8.53M
    bndryLine ++;
331
8.53M
  }
332
247k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.72k
{
301
6.72k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.72k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.72k
        Pel* dstLine   = dst;
305
6.72k
  const Pel* srcLine   = src;
306
6.72k
  const Pel* bndryLine = bndry;
307
308
60.4k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
53.7k
  {
310
53.7k
    const Pel* before  = bndryLine;
311
53.7k
    const Pel* behind  = srcLine;
312
53.7k
          Pel* currDst = dstLine;
313
268k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
215k
    {
315
215k
      const int valDiff   = *behind - *before;
316
215k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
645k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
430k
      {
320
430k
        scaledVal += valDiff;
321
430k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
430k
        currDst += outWidth;
323
430k
      }
324
215k
      before = behind;
325
215k
      behind += srcStep;
326
215k
    }
327
328
53.7k
    srcLine ++;
329
53.7k
    dstLine ++;
330
53.7k
    bndryLine ++;
331
53.7k
  }
332
6.72k
}
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
75.5k
{
301
75.5k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
75.5k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
75.5k
        Pel* dstLine   = dst;
305
75.5k
  const Pel* srcLine   = src;
306
75.5k
  const Pel* bndryLine = bndry;
307
308
1.91M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.83M
  {
310
1.83M
    const Pel* before  = bndryLine;
311
1.83M
    const Pel* behind  = srcLine;
312
1.83M
          Pel* currDst = dstLine;
313
16.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
14.6M
    {
315
14.6M
      const int valDiff   = *behind - *before;
316
14.6M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
44.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
29.3M
      {
320
29.3M
        scaledVal += valDiff;
321
29.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
29.3M
        currDst += outWidth;
323
29.3M
      }
324
14.6M
      before = behind;
325
14.6M
      behind += srcStep;
326
14.6M
    }
327
328
1.83M
    srcLine ++;
329
1.83M
    dstLine ++;
330
1.83M
    bndryLine ++;
331
1.83M
  }
332
75.5k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
100k
{
301
100k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
100k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
100k
        Pel* dstLine   = dst;
305
100k
  const Pel* srcLine   = src;
306
100k
  const Pel* bndryLine = bndry;
307
308
2.60M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.50M
  {
310
2.50M
    const Pel* before  = bndryLine;
311
2.50M
    const Pel* behind  = srcLine;
312
2.50M
          Pel* currDst = dstLine;
313
22.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
20.0M
    {
315
20.0M
      const int valDiff   = *behind - *before;
316
20.0M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
100M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
80.2M
      {
320
80.2M
        scaledVal += valDiff;
321
80.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
80.2M
        currDst += outWidth;
323
80.2M
      }
324
20.0M
      before = behind;
325
20.0M
      behind += srcStep;
326
20.0M
    }
327
328
2.50M
    srcLine ++;
329
2.50M
    dstLine ++;
330
2.50M
    bndryLine ++;
331
2.50M
  }
332
100k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
64.6k
{
301
64.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
64.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
64.6k
        Pel* dstLine   = dst;
305
64.6k
  const Pel* srcLine   = src;
306
64.6k
  const Pel* bndryLine = bndry;
307
308
4.20M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.13M
  {
310
4.13M
    const Pel* before  = bndryLine;
311
4.13M
    const Pel* behind  = srcLine;
312
4.13M
          Pel* currDst = dstLine;
313
37.2M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
33.0M
    {
315
33.0M
      const int valDiff   = *behind - *before;
316
33.0M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
297M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
264M
      {
320
264M
        scaledVal += valDiff;
321
264M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
264M
        currDst += outWidth;
323
264M
      }
324
33.0M
      before = behind;
325
33.0M
      behind += srcStep;
326
33.0M
    }
327
328
4.13M
    srcLine ++;
329
4.13M
    dstLine ++;
330
4.13M
    bndryLine ++;
331
4.13M
  }
332
64.6k
}
333
334
335
} // namespace vvenc
336
337
//! \}