Coverage Report

Created: 2026-05-30 06:10

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
20.7k
  : m_reducedBoundary       (nullptr)
62
20.7k
  , m_reducedBoundaryTransp (nullptr)
63
20.7k
  , m_inputOffset           ( 0 )
64
20.7k
  , m_inputOffsetTransp     ( 0 )
65
20.7k
  , m_refSamplesTop         (nullptr)
66
20.7k
  , m_refSamplesLeft        (nullptr)
67
20.7k
  , m_blockSize             ( 0, 0 )
68
20.7k
  , m_sizeId                ( 0 )
69
20.7k
  , m_reducedBdrySize       ( 0 )
70
20.7k
  , m_reducedPredSize       ( 0 )
71
20.7k
  , m_upsmpFactorHor        ( 0 )
72
20.7k
  , m_upsmpFactorVer        ( 0 )
73
20.7k
{
74
20.7k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
20.7k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
20.7k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
20.7k
{
80
20.7k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
20.7k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
20.7k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
46.1k
{
86
  // Step 1: Save block size and calculate dependent values
87
46.1k
  initPredBlockParams(block);
88
89
46.1k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
46.1k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
46.1k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
46.1k
  Pel* const topReduced = m_reducedBoundary;
96
46.1k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
46.1k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
46.1k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
46.1k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
46.1k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
230k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
184k
  {
105
184k
    topReducedTransposed[x] = topReduced[x];
106
184k
  }
107
230k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
184k
  {
109
184k
    leftReducedTransposed[y] = leftReduced[y];
110
184k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
46.1k
  m_inputOffset       = m_reducedBoundary[0];
114
46.1k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
46.1k
  const bool hasFirstCol = (m_sizeId < 2);
117
46.1k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
46.1k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
368k
  for (int i = 1; i < inputSize; i++)
120
322k
  {
121
322k
    m_reducedBoundary      [i] -= m_inputOffset;
122
322k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
322k
  }
124
46.1k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
276k
{
128
276k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
276k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
276k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
276k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
276k
  {
135
276k
    const int outputSize = m_reducedPredSize;
136
276k
    const int inputSize  = 2 * m_reducedBdrySize;
137
276k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
276k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
276k
    if( outputSize == 8)
141
269k
    {
142
269k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
269k
    }
144
6.43k
    else
145
6.43k
    {
146
6.43k
      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.43k
      else
151
6.43k
      {
152
6.43k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.43k
      }
154
6.43k
    }
155
276k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
276k
  if( needUpsampling )
159
276k
  {
160
276k
    const Pel* verSrc   = reducedPred;
161
276k
    SizeType verSrcStep = m_blockSize.width;
162
163
276k
    if( m_upsmpFactorHor > 1 )
164
266k
    {
165
266k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
266k
      verSrc = horDst;
167
266k
      verSrcStep *= m_upsmpFactorVer;
168
169
266k
      if( m_reducedPredSize == 4)
170
6.43k
      {
171
6.43k
        if( m_upsmpFactorHor == 2 )
172
6.43k
          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.43k
      }
178
260k
      else
179
260k
      {
180
260k
        if( m_upsmpFactorHor == 2 )
181
83.2k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
177k
        else if( m_upsmpFactorHor == 4 )
183
106k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
70.7k
        else
185
70.7k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
260k
      }
187
266k
    }
188
189
276k
    if( m_upsmpFactorVer > 1 )
190
265k
    {
191
265k
      if( m_reducedPredSize == 4)
192
6.43k
      {
193
6.43k
        if( m_upsmpFactorVer == 2 )
194
6.43k
          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.43k
      }
200
258k
      else
201
258k
      {
202
258k
        if( m_upsmpFactorVer == 2 )
203
79.5k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
179k
        else if( m_upsmpFactorVer == 4 )
205
108k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
70.7k
        else
207
70.7k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
258k
      }
209
265k
    }
210
276k
  }
211
276k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
46.1k
{
215
46.1k
  m_blockSize = block;
216
  // init size index
217
46.1k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
46.1k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
46.1k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
46.1k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
46.1k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
46.1k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
46.1k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
46.1k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
92.2k
{
235
92.2k
  if (dstLen < srcLen)
236
92.2k
  {
237
    // Create reduced boundary by downsampling
238
92.2k
    const SizeType downsmpFactor = srcLen / dstLen;
239
92.2k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
92.2k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
92.2k
    SizeType srcIdx = 0;
243
461k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
368k
    {
245
368k
      int sum = 0;
246
3.61M
      for( int k = 0; k < downsmpFactor; k++ )
247
3.24M
      {
248
3.24M
        sum += fullSrc[srcIdx++];
249
3.24M
      }
250
368k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
368k
    }
252
92.2k
  }
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
92.2k
}
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
266k
{
266
266k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
266k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
266k
        Pel* dstLine   = dst;
270
266k
  const Pel* srcLine   = src;
271
266k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.37M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
2.10M
  {
275
2.10M
    const Pel* before  = bndryLine;
276
2.10M
    const Pel* behind  = srcLine;
277
2.10M
          Pel* currDst = dstLine;
278
18.8M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
16.7M
    {
280
16.7M
      const int valDiff   = *behind - *before;
281
16.7M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
91.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
74.3M
      {
284
74.3M
        scaledVal += valDiff;
285
74.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
74.3M
        currDst++;
287
74.3M
      }
288
16.7M
      before = behind;
289
16.7M
      behind ++;
290
16.7M
    }
291
292
2.10M
    srcLine   += predPredSize;
293
2.10M
    dstLine   += dstStride;
294
2.10M
    bndryLine += bndryStep;
295
2.10M
  }
296
266k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.43k
{
266
6.43k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.43k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.43k
        Pel* dstLine   = dst;
270
6.43k
  const Pel* srcLine   = src;
271
6.43k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
32.1k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
25.7k
  {
275
25.7k
    const Pel* before  = bndryLine;
276
25.7k
    const Pel* behind  = srcLine;
277
25.7k
          Pel* currDst = dstLine;
278
128k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
102k
    {
280
102k
      const int valDiff   = *behind - *before;
281
102k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
308k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
205k
      {
284
205k
        scaledVal += valDiff;
285
205k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
205k
        currDst++;
287
205k
      }
288
102k
      before = behind;
289
102k
      behind ++;
290
102k
    }
291
292
25.7k
    srcLine   += predPredSize;
293
25.7k
    dstLine   += dstStride;
294
25.7k
    bndryLine += bndryStep;
295
25.7k
  }
296
6.43k
}
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
83.2k
{
266
83.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
83.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
83.2k
        Pel* dstLine   = dst;
270
83.2k
  const Pel* srcLine   = src;
271
83.2k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
749k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
665k
  {
275
665k
    const Pel* before  = bndryLine;
276
665k
    const Pel* behind  = srcLine;
277
665k
          Pel* currDst = dstLine;
278
5.99M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.32M
    {
280
5.32M
      const int valDiff   = *behind - *before;
281
5.32M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
15.9M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
10.6M
      {
284
10.6M
        scaledVal += valDiff;
285
10.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
10.6M
        currDst++;
287
10.6M
      }
288
5.32M
      before = behind;
289
5.32M
      behind ++;
290
5.32M
    }
291
292
665k
    srcLine   += predPredSize;
293
665k
    dstLine   += dstStride;
294
665k
    bndryLine += bndryStep;
295
665k
  }
296
83.2k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
106k
{
266
106k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
106k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
106k
        Pel* dstLine   = dst;
270
106k
  const Pel* srcLine   = src;
271
106k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
957k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
850k
  {
275
850k
    const Pel* before  = bndryLine;
276
850k
    const Pel* behind  = srcLine;
277
850k
          Pel* currDst = dstLine;
278
7.65M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.80M
    {
280
6.80M
      const int valDiff   = *behind - *before;
281
6.80M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
34.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
27.2M
      {
284
27.2M
        scaledVal += valDiff;
285
27.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
27.2M
        currDst++;
287
27.2M
      }
288
6.80M
      before = behind;
289
6.80M
      behind ++;
290
6.80M
    }
291
292
850k
    srcLine   += predPredSize;
293
850k
    dstLine   += dstStride;
294
850k
    bndryLine += bndryStep;
295
850k
  }
296
106k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
70.7k
{
266
70.7k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
70.7k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
70.7k
        Pel* dstLine   = dst;
270
70.7k
  const Pel* srcLine   = src;
271
70.7k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
636k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
565k
  {
275
565k
    const Pel* before  = bndryLine;
276
565k
    const Pel* behind  = srcLine;
277
565k
          Pel* currDst = dstLine;
278
5.09M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.52M
    {
280
4.52M
      const int valDiff   = *behind - *before;
281
4.52M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
40.7M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
36.2M
      {
284
36.2M
        scaledVal += valDiff;
285
36.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
36.2M
        currDst++;
287
36.2M
      }
288
4.52M
      before = behind;
289
4.52M
      behind ++;
290
4.52M
    }
291
292
565k
    srcLine   += predPredSize;
293
565k
    dstLine   += dstStride;
294
565k
    bndryLine += bndryStep;
295
565k
  }
296
70.7k
}
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
265k
{
301
265k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
265k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
265k
        Pel* dstLine   = dst;
305
265k
  const Pel* srcLine   = src;
306
265k
  const Pel* bndryLine = bndry;
307
308
9.47M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
9.21M
  {
310
9.21M
    const Pel* before  = bndryLine;
311
9.21M
    const Pel* behind  = srcLine;
312
9.21M
          Pel* currDst = dstLine;
313
82.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
73.5M
    {
315
73.5M
      const int valDiff   = *behind - *before;
316
73.5M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
480M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
407M
      {
320
407M
        scaledVal += valDiff;
321
407M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
407M
        currDst += outWidth;
323
407M
      }
324
73.5M
      before = behind;
325
73.5M
      behind += srcStep;
326
73.5M
    }
327
328
9.21M
    srcLine ++;
329
9.21M
    dstLine ++;
330
9.21M
    bndryLine ++;
331
9.21M
  }
332
265k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.43k
{
301
6.43k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.43k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.43k
        Pel* dstLine   = dst;
305
6.43k
  const Pel* srcLine   = src;
306
6.43k
  const Pel* bndryLine = bndry;
307
308
57.8k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
51.4k
  {
310
51.4k
    const Pel* before  = bndryLine;
311
51.4k
    const Pel* behind  = srcLine;
312
51.4k
          Pel* currDst = dstLine;
313
257k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
205k
    {
315
205k
      const int valDiff   = *behind - *before;
316
205k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
617k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
411k
      {
320
411k
        scaledVal += valDiff;
321
411k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
411k
        currDst += outWidth;
323
411k
      }
324
205k
      before = behind;
325
205k
      behind += srcStep;
326
205k
    }
327
328
51.4k
    srcLine ++;
329
51.4k
    dstLine ++;
330
51.4k
    bndryLine ++;
331
51.4k
  }
332
6.43k
}
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
79.5k
{
301
79.5k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
79.5k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
79.5k
        Pel* dstLine   = dst;
305
79.5k
  const Pel* srcLine   = src;
306
79.5k
  const Pel* bndryLine = bndry;
307
308
2.02M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.94M
  {
310
1.94M
    const Pel* before  = bndryLine;
311
1.94M
    const Pel* behind  = srcLine;
312
1.94M
          Pel* currDst = dstLine;
313
17.4M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
15.5M
    {
315
15.5M
      const int valDiff   = *behind - *before;
316
15.5M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
46.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
31.0M
      {
320
31.0M
        scaledVal += valDiff;
321
31.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
31.0M
        currDst += outWidth;
323
31.0M
      }
324
15.5M
      before = behind;
325
15.5M
      behind += srcStep;
326
15.5M
    }
327
328
1.94M
    srcLine ++;
329
1.94M
    dstLine ++;
330
1.94M
    bndryLine ++;
331
1.94M
  }
332
79.5k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
108k
{
301
108k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
108k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
108k
        Pel* dstLine   = dst;
305
108k
  const Pel* srcLine   = src;
306
108k
  const Pel* bndryLine = bndry;
307
308
2.80M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.69M
  {
310
2.69M
    const Pel* before  = bndryLine;
311
2.69M
    const Pel* behind  = srcLine;
312
2.69M
          Pel* currDst = dstLine;
313
24.2M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
21.5M
    {
315
21.5M
      const int valDiff   = *behind - *before;
316
21.5M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
107M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
86.2M
      {
320
86.2M
        scaledVal += valDiff;
321
86.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
86.2M
        currDst += outWidth;
323
86.2M
      }
324
21.5M
      before = behind;
325
21.5M
      behind += srcStep;
326
21.5M
    }
327
328
2.69M
    srcLine ++;
329
2.69M
    dstLine ++;
330
2.69M
    bndryLine ++;
331
2.69M
  }
332
108k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
70.7k
{
301
70.7k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
70.7k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
70.7k
        Pel* dstLine   = dst;
305
70.7k
  const Pel* srcLine   = src;
306
70.7k
  const Pel* bndryLine = bndry;
307
308
4.59M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.52M
  {
310
4.52M
    const Pel* before  = bndryLine;
311
4.52M
    const Pel* behind  = srcLine;
312
4.52M
          Pel* currDst = dstLine;
313
40.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
36.2M
    {
315
36.2M
      const int valDiff   = *behind - *before;
316
36.2M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
326M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
289M
      {
320
289M
        scaledVal += valDiff;
321
289M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
289M
        currDst += outWidth;
323
289M
      }
324
36.2M
      before = behind;
325
36.2M
      behind += srcStep;
326
36.2M
    }
327
328
4.52M
    srcLine ++;
329
4.52M
    dstLine ++;
330
4.52M
    bndryLine ++;
331
4.52M
  }
332
70.7k
}
333
334
335
} // namespace vvenc
336
337
//! \}