Coverage Report

Created: 2026-06-10 07:00

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
17.7k
  : m_reducedBoundary       (nullptr)
62
17.7k
  , m_reducedBoundaryTransp (nullptr)
63
17.7k
  , m_inputOffset           ( 0 )
64
17.7k
  , m_inputOffsetTransp     ( 0 )
65
17.7k
  , m_refSamplesTop         (nullptr)
66
17.7k
  , m_refSamplesLeft        (nullptr)
67
17.7k
  , m_blockSize             ( 0, 0 )
68
17.7k
  , m_sizeId                ( 0 )
69
17.7k
  , m_reducedBdrySize       ( 0 )
70
17.7k
  , m_reducedPredSize       ( 0 )
71
17.7k
  , m_upsmpFactorHor        ( 0 )
72
17.7k
  , m_upsmpFactorVer        ( 0 )
73
17.7k
{
74
17.7k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
17.7k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
17.7k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
17.7k
{
80
17.7k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
17.7k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
17.7k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
39.4k
{
86
  // Step 1: Save block size and calculate dependent values
87
39.4k
  initPredBlockParams(block);
88
89
39.4k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
39.4k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
39.4k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
39.4k
  Pel* const topReduced = m_reducedBoundary;
96
39.4k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
39.4k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
39.4k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
39.4k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
39.4k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
197k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
157k
  {
105
157k
    topReducedTransposed[x] = topReduced[x];
106
157k
  }
107
197k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
157k
  {
109
157k
    leftReducedTransposed[y] = leftReduced[y];
110
157k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
39.4k
  m_inputOffset       = m_reducedBoundary[0];
114
39.4k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
39.4k
  const bool hasFirstCol = (m_sizeId < 2);
117
39.4k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
39.4k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
315k
  for (int i = 1; i < inputSize; i++)
120
276k
  {
121
276k
    m_reducedBoundary      [i] -= m_inputOffset;
122
276k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
276k
  }
124
39.4k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
235k
{
128
235k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
235k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
235k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
235k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
235k
  {
135
235k
    const int outputSize = m_reducedPredSize;
136
235k
    const int inputSize  = 2 * m_reducedBdrySize;
137
235k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
235k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
235k
    if( outputSize == 8)
141
230k
    {
142
230k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
230k
    }
144
5.61k
    else
145
5.61k
    {
146
5.61k
      if( inputSize == 4)
147
0
      {
148
0
        g_pelBufOP.mipMatrixMul_4_4( reducedPred, reducedBoundary, &mipMatrix4x4[modeIdx][0][0], maxVal, offset, transpose );
149
0
      }
150
5.61k
      else
151
5.61k
      {
152
5.61k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
5.61k
      }
154
5.61k
    }
155
235k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
235k
  if( needUpsampling )
159
235k
  {
160
235k
    const Pel* verSrc   = reducedPred;
161
235k
    SizeType verSrcStep = m_blockSize.width;
162
163
235k
    if( m_upsmpFactorHor > 1 )
164
227k
    {
165
227k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
227k
      verSrc = horDst;
167
227k
      verSrcStep *= m_upsmpFactorVer;
168
169
227k
      if( m_reducedPredSize == 4)
170
5.61k
      {
171
5.61k
        if( m_upsmpFactorHor == 2 )
172
5.61k
          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
5.61k
      }
178
222k
      else
179
222k
      {
180
222k
        if( m_upsmpFactorHor == 2 )
181
73.4k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
148k
        else if( m_upsmpFactorHor == 4 )
183
89.6k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
59.0k
        else
185
59.0k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
222k
      }
187
227k
    }
188
189
235k
    if( m_upsmpFactorVer > 1 )
190
225k
    {
191
225k
      if( m_reducedPredSize == 4)
192
5.61k
      {
193
5.61k
        if( m_upsmpFactorVer == 2 )
194
5.61k
          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
5.61k
      }
200
219k
      else
201
219k
      {
202
219k
        if( m_upsmpFactorVer == 2 )
203
70.2k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
149k
        else if( m_upsmpFactorVer == 4 )
205
90.3k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
59.0k
        else
207
59.0k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
219k
      }
209
225k
    }
210
235k
  }
211
235k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
39.4k
{
215
39.4k
  m_blockSize = block;
216
  // init size index
217
39.4k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
39.4k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
39.4k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
39.4k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
39.4k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
39.4k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
39.4k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
39.4k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
78.8k
{
235
78.8k
  if (dstLen < srcLen)
236
78.8k
  {
237
    // Create reduced boundary by downsampling
238
78.8k
    const SizeType downsmpFactor = srcLen / dstLen;
239
78.8k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
78.8k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
78.8k
    SizeType srcIdx = 0;
243
394k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
315k
    {
245
315k
      int sum = 0;
246
3.05M
      for( int k = 0; k < downsmpFactor; k++ )
247
2.73M
      {
248
2.73M
        sum += fullSrc[srcIdx++];
249
2.73M
      }
250
315k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
315k
    }
252
78.8k
  }
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
78.8k
}
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
227k
{
266
227k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
227k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
227k
        Pel* dstLine   = dst;
270
227k
  const Pel* srcLine   = src;
271
227k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.02M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.79M
  {
275
1.79M
    const Pel* before  = bndryLine;
276
1.79M
    const Pel* behind  = srcLine;
277
1.79M
          Pel* currDst = dstLine;
278
16.1M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
14.3M
    {
280
14.3M
      const int valDiff   = *behind - *before;
281
14.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
77.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
62.7M
      {
284
62.7M
        scaledVal += valDiff;
285
62.7M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
62.7M
        currDst++;
287
62.7M
      }
288
14.3M
      before = behind;
289
14.3M
      behind ++;
290
14.3M
    }
291
292
1.79M
    srcLine   += predPredSize;
293
1.79M
    dstLine   += dstStride;
294
1.79M
    bndryLine += bndryStep;
295
1.79M
  }
296
227k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
5.61k
{
266
5.61k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
5.61k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
5.61k
        Pel* dstLine   = dst;
270
5.61k
  const Pel* srcLine   = src;
271
5.61k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
28.0k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
22.4k
  {
275
22.4k
    const Pel* before  = bndryLine;
276
22.4k
    const Pel* behind  = srcLine;
277
22.4k
          Pel* currDst = dstLine;
278
112k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
89.8k
    {
280
89.8k
      const int valDiff   = *behind - *before;
281
89.8k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
269k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
179k
      {
284
179k
        scaledVal += valDiff;
285
179k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
179k
        currDst++;
287
179k
      }
288
89.8k
      before = behind;
289
89.8k
      behind ++;
290
89.8k
    }
291
292
22.4k
    srcLine   += predPredSize;
293
22.4k
    dstLine   += dstStride;
294
22.4k
    bndryLine += bndryStep;
295
22.4k
  }
296
5.61k
}
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
73.4k
{
266
73.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
73.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
73.4k
        Pel* dstLine   = dst;
270
73.4k
  const Pel* srcLine   = src;
271
73.4k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
660k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
587k
  {
275
587k
    const Pel* before  = bndryLine;
276
587k
    const Pel* behind  = srcLine;
277
587k
          Pel* currDst = dstLine;
278
5.28M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.69M
    {
280
4.69M
      const int valDiff   = *behind - *before;
281
4.69M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
14.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
9.39M
      {
284
9.39M
        scaledVal += valDiff;
285
9.39M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
9.39M
        currDst++;
287
9.39M
      }
288
4.69M
      before = behind;
289
4.69M
      behind ++;
290
4.69M
    }
291
292
587k
    srcLine   += predPredSize;
293
587k
    dstLine   += dstStride;
294
587k
    bndryLine += bndryStep;
295
587k
  }
296
73.4k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
89.6k
{
266
89.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
89.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
89.6k
        Pel* dstLine   = dst;
270
89.6k
  const Pel* srcLine   = src;
271
89.6k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
806k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
717k
  {
275
717k
    const Pel* before  = bndryLine;
276
717k
    const Pel* behind  = srcLine;
277
717k
          Pel* currDst = dstLine;
278
6.45M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.73M
    {
280
5.73M
      const int valDiff   = *behind - *before;
281
5.73M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
28.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
22.9M
      {
284
22.9M
        scaledVal += valDiff;
285
22.9M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
22.9M
        currDst++;
287
22.9M
      }
288
5.73M
      before = behind;
289
5.73M
      behind ++;
290
5.73M
    }
291
292
717k
    srcLine   += predPredSize;
293
717k
    dstLine   += dstStride;
294
717k
    bndryLine += bndryStep;
295
717k
  }
296
89.6k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
59.0k
{
266
59.0k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
59.0k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
59.0k
        Pel* dstLine   = dst;
270
59.0k
  const Pel* srcLine   = src;
271
59.0k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
531k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
472k
  {
275
472k
    const Pel* before  = bndryLine;
276
472k
    const Pel* behind  = srcLine;
277
472k
          Pel* currDst = dstLine;
278
4.25M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
3.78M
    {
280
3.78M
      const int valDiff   = *behind - *before;
281
3.78M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
34.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
30.2M
      {
284
30.2M
        scaledVal += valDiff;
285
30.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
30.2M
        currDst++;
287
30.2M
      }
288
3.78M
      before = behind;
289
3.78M
      behind ++;
290
3.78M
    }
291
292
472k
    srcLine   += predPredSize;
293
472k
    dstLine   += dstStride;
294
472k
    bndryLine += bndryStep;
295
472k
  }
296
59.0k
}
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
225k
{
301
225k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
225k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
225k
        Pel* dstLine   = dst;
305
225k
  const Pel* srcLine   = src;
306
225k
  const Pel* bndryLine = bndry;
307
308
7.99M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
7.76M
  {
310
7.76M
    const Pel* before  = bndryLine;
311
7.76M
    const Pel* behind  = srcLine;
312
7.76M
          Pel* currDst = dstLine;
313
69.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
61.9M
    {
315
61.9M
      const int valDiff   = *behind - *before;
316
61.9M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
403M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
341M
      {
320
341M
        scaledVal += valDiff;
321
341M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
341M
        currDst += outWidth;
323
341M
      }
324
61.9M
      before = behind;
325
61.9M
      behind += srcStep;
326
61.9M
    }
327
328
7.76M
    srcLine ++;
329
7.76M
    dstLine ++;
330
7.76M
    bndryLine ++;
331
7.76M
  }
332
225k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
5.61k
{
301
5.61k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
5.61k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
5.61k
        Pel* dstLine   = dst;
305
5.61k
  const Pel* srcLine   = src;
306
5.61k
  const Pel* bndryLine = bndry;
307
308
50.5k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
44.9k
  {
310
44.9k
    const Pel* before  = bndryLine;
311
44.9k
    const Pel* behind  = srcLine;
312
44.9k
          Pel* currDst = dstLine;
313
224k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
179k
    {
315
179k
      const int valDiff   = *behind - *before;
316
179k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
539k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
359k
      {
320
359k
        scaledVal += valDiff;
321
359k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
359k
        currDst += outWidth;
323
359k
      }
324
179k
      before = behind;
325
179k
      behind += srcStep;
326
179k
    }
327
328
44.9k
    srcLine ++;
329
44.9k
    dstLine ++;
330
44.9k
    bndryLine ++;
331
44.9k
  }
332
5.61k
}
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
70.2k
{
301
70.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
70.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
70.2k
        Pel* dstLine   = dst;
305
70.2k
  const Pel* srcLine   = src;
306
70.2k
  const Pel* bndryLine = bndry;
307
308
1.77M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.70M
  {
310
1.70M
    const Pel* before  = bndryLine;
311
1.70M
    const Pel* behind  = srcLine;
312
1.70M
          Pel* currDst = dstLine;
313
15.3M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
13.6M
    {
315
13.6M
      const int valDiff   = *behind - *before;
316
13.6M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
41.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
27.3M
      {
320
27.3M
        scaledVal += valDiff;
321
27.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
27.3M
        currDst += outWidth;
323
27.3M
      }
324
13.6M
      before = behind;
325
13.6M
      behind += srcStep;
326
13.6M
    }
327
328
1.70M
    srcLine ++;
329
1.70M
    dstLine ++;
330
1.70M
    bndryLine ++;
331
1.70M
  }
332
70.2k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
90.3k
{
301
90.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
90.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
90.3k
        Pel* dstLine   = dst;
305
90.3k
  const Pel* srcLine   = src;
306
90.3k
  const Pel* bndryLine = bndry;
307
308
2.32M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.23M
  {
310
2.23M
    const Pel* before  = bndryLine;
311
2.23M
    const Pel* behind  = srcLine;
312
2.23M
          Pel* currDst = dstLine;
313
20.0M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
17.8M
    {
315
17.8M
      const int valDiff   = *behind - *before;
316
17.8M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
89.2M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
71.3M
      {
320
71.3M
        scaledVal += valDiff;
321
71.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
71.3M
        currDst += outWidth;
323
71.3M
      }
324
17.8M
      before = behind;
325
17.8M
      behind += srcStep;
326
17.8M
    }
327
328
2.23M
    srcLine ++;
329
2.23M
    dstLine ++;
330
2.23M
    bndryLine ++;
331
2.23M
  }
332
90.3k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
59.0k
{
301
59.0k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
59.0k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
59.0k
        Pel* dstLine   = dst;
305
59.0k
  const Pel* srcLine   = src;
306
59.0k
  const Pel* bndryLine = bndry;
307
308
3.83M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
3.78M
  {
310
3.78M
    const Pel* before  = bndryLine;
311
3.78M
    const Pel* behind  = srcLine;
312
3.78M
          Pel* currDst = dstLine;
313
34.0M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
30.2M
    {
315
30.2M
      const int valDiff   = *behind - *before;
316
30.2M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
272M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
241M
      {
320
241M
        scaledVal += valDiff;
321
241M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
241M
        currDst += outWidth;
323
241M
      }
324
30.2M
      before = behind;
325
30.2M
      behind += srcStep;
326
30.2M
    }
327
328
3.78M
    srcLine ++;
329
3.78M
    dstLine ++;
330
3.78M
    bndryLine ++;
331
3.78M
  }
332
59.0k
}
333
334
335
} // namespace vvenc
336
337
//! \}