Coverage Report

Created: 2026-09-01 06:57

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
18.6k
  : m_reducedBoundary       (nullptr)
62
18.6k
  , m_reducedBoundaryTransp (nullptr)
63
18.6k
  , m_inputOffset           ( 0 )
64
18.6k
  , m_inputOffsetTransp     ( 0 )
65
18.6k
  , m_refSamplesTop         (nullptr)
66
18.6k
  , m_refSamplesLeft        (nullptr)
67
18.6k
  , m_blockSize             ( 0, 0 )
68
18.6k
  , m_sizeId                ( 0 )
69
18.6k
  , m_reducedBdrySize       ( 0 )
70
18.6k
  , m_reducedPredSize       ( 0 )
71
18.6k
  , m_upsmpFactorHor        ( 0 )
72
18.6k
  , m_upsmpFactorVer        ( 0 )
73
18.6k
{
74
18.6k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
18.6k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
18.6k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
18.6k
{
80
18.6k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
18.6k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
18.6k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
41.0k
{
86
  // Step 1: Save block size and calculate dependent values
87
41.0k
  initPredBlockParams(block);
88
89
41.0k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
41.0k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
41.0k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
41.0k
  Pel* const topReduced = m_reducedBoundary;
96
41.0k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
41.0k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
41.0k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
41.0k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
41.0k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
205k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
164k
  {
105
164k
    topReducedTransposed[x] = topReduced[x];
106
164k
  }
107
205k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
164k
  {
109
164k
    leftReducedTransposed[y] = leftReduced[y];
110
164k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
41.0k
  m_inputOffset       = m_reducedBoundary[0];
114
41.0k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
41.0k
  const bool hasFirstCol = (m_sizeId < 2);
117
41.0k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
41.0k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
328k
  for (int i = 1; i < inputSize; i++)
120
287k
  {
121
287k
    m_reducedBoundary      [i] -= m_inputOffset;
122
287k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
287k
  }
124
41.0k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
245k
{
128
245k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
245k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
245k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
245k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
245k
  {
135
245k
    const int outputSize = m_reducedPredSize;
136
245k
    const int inputSize  = 2 * m_reducedBdrySize;
137
245k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
245k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
245k
    if( outputSize == 8)
141
239k
    {
142
239k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
239k
    }
144
6.01k
    else
145
6.01k
    {
146
6.01k
      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.01k
      else
151
6.01k
      {
152
6.01k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.01k
      }
154
6.01k
    }
155
245k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
245k
  if( needUpsampling )
159
245k
  {
160
245k
    const Pel* verSrc   = reducedPred;
161
245k
    SizeType verSrcStep = m_blockSize.width;
162
163
245k
    if( m_upsmpFactorHor > 1 )
164
237k
    {
165
237k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
237k
      verSrc = horDst;
167
237k
      verSrcStep *= m_upsmpFactorVer;
168
169
237k
      if( m_reducedPredSize == 4)
170
6.01k
      {
171
6.01k
        if( m_upsmpFactorHor == 2 )
172
6.01k
          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.01k
      }
178
231k
      else
179
231k
      {
180
231k
        if( m_upsmpFactorHor == 2 )
181
75.8k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
155k
        else if( m_upsmpFactorHor == 4 )
183
95.2k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
60.1k
        else
185
60.1k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
231k
      }
187
237k
    }
188
189
245k
    if( m_upsmpFactorVer > 1 )
190
236k
    {
191
236k
      if( m_reducedPredSize == 4)
192
6.01k
      {
193
6.01k
        if( m_upsmpFactorVer == 2 )
194
6.01k
          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.01k
      }
200
230k
      else
201
230k
      {
202
230k
        if( m_upsmpFactorVer == 2 )
203
71.1k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
158k
        else if( m_upsmpFactorVer == 4 )
205
98.7k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
60.1k
        else
207
60.1k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
230k
      }
209
236k
    }
210
245k
  }
211
245k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
41.0k
{
215
41.0k
  m_blockSize = block;
216
  // init size index
217
41.0k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
41.0k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
41.0k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
41.0k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
41.0k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
41.0k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
41.0k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
41.0k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
82.1k
{
235
82.1k
  if (dstLen < srcLen)
236
82.1k
  {
237
    // Create reduced boundary by downsampling
238
82.1k
    const SizeType downsmpFactor = srcLen / dstLen;
239
82.1k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
82.1k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
82.1k
    SizeType srcIdx = 0;
243
410k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
328k
    {
245
328k
      int sum = 0;
246
3.18M
      for( int k = 0; k < downsmpFactor; k++ )
247
2.85M
      {
248
2.85M
        sum += fullSrc[srcIdx++];
249
2.85M
      }
250
328k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
328k
    }
252
82.1k
  }
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
82.1k
}
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
237k
{
266
237k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
237k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
237k
        Pel* dstLine   = dst;
270
237k
  const Pel* srcLine   = src;
271
237k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.11M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.87M
  {
275
1.87M
    const Pel* before  = bndryLine;
276
1.87M
    const Pel* behind  = srcLine;
277
1.87M
          Pel* currDst = dstLine;
278
16.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
14.8M
    {
280
14.8M
      const int valDiff   = *behind - *before;
281
14.8M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
79.9M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
65.0M
      {
284
65.0M
        scaledVal += valDiff;
285
65.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
65.0M
        currDst++;
287
65.0M
      }
288
14.8M
      before = behind;
289
14.8M
      behind ++;
290
14.8M
    }
291
292
1.87M
    srcLine   += predPredSize;
293
1.87M
    dstLine   += dstStride;
294
1.87M
    bndryLine += bndryStep;
295
1.87M
  }
296
237k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.01k
{
266
6.01k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.01k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.01k
        Pel* dstLine   = dst;
270
6.01k
  const Pel* srcLine   = src;
271
6.01k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
30.0k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
24.0k
  {
275
24.0k
    const Pel* before  = bndryLine;
276
24.0k
    const Pel* behind  = srcLine;
277
24.0k
          Pel* currDst = dstLine;
278
120k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
96.2k
    {
280
96.2k
      const int valDiff   = *behind - *before;
281
96.2k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
288k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
192k
      {
284
192k
        scaledVal += valDiff;
285
192k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
192k
        currDst++;
287
192k
      }
288
96.2k
      before = behind;
289
96.2k
      behind ++;
290
96.2k
    }
291
292
24.0k
    srcLine   += predPredSize;
293
24.0k
    dstLine   += dstStride;
294
24.0k
    bndryLine += bndryStep;
295
24.0k
  }
296
6.01k
}
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
75.8k
{
266
75.8k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
75.8k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
75.8k
        Pel* dstLine   = dst;
270
75.8k
  const Pel* srcLine   = src;
271
75.8k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
682k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
606k
  {
275
606k
    const Pel* before  = bndryLine;
276
606k
    const Pel* behind  = srcLine;
277
606k
          Pel* currDst = dstLine;
278
5.45M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.85M
    {
280
4.85M
      const int valDiff   = *behind - *before;
281
4.85M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
14.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
9.70M
      {
284
9.70M
        scaledVal += valDiff;
285
9.70M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
9.70M
        currDst++;
287
9.70M
      }
288
4.85M
      before = behind;
289
4.85M
      behind ++;
290
4.85M
    }
291
292
606k
    srcLine   += predPredSize;
293
606k
    dstLine   += dstStride;
294
606k
    bndryLine += bndryStep;
295
606k
  }
296
75.8k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
95.2k
{
266
95.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
95.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
95.2k
        Pel* dstLine   = dst;
270
95.2k
  const Pel* srcLine   = src;
271
95.2k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
857k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
761k
  {
275
761k
    const Pel* before  = bndryLine;
276
761k
    const Pel* behind  = srcLine;
277
761k
          Pel* currDst = dstLine;
278
6.85M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.09M
    {
280
6.09M
      const int valDiff   = *behind - *before;
281
6.09M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
30.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
24.3M
      {
284
24.3M
        scaledVal += valDiff;
285
24.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
24.3M
        currDst++;
287
24.3M
      }
288
6.09M
      before = behind;
289
6.09M
      behind ++;
290
6.09M
    }
291
292
761k
    srcLine   += predPredSize;
293
761k
    dstLine   += dstStride;
294
761k
    bndryLine += bndryStep;
295
761k
  }
296
95.2k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
60.1k
{
266
60.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
60.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
60.1k
        Pel* dstLine   = dst;
270
60.1k
  const Pel* srcLine   = src;
271
60.1k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
541k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
481k
  {
275
481k
    const Pel* before  = bndryLine;
276
481k
    const Pel* behind  = srcLine;
277
481k
          Pel* currDst = dstLine;
278
4.33M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
3.85M
    {
280
3.85M
      const int valDiff   = *behind - *before;
281
3.85M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
34.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
30.8M
      {
284
30.8M
        scaledVal += valDiff;
285
30.8M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
30.8M
        currDst++;
287
30.8M
      }
288
3.85M
      before = behind;
289
3.85M
      behind ++;
290
3.85M
    }
291
292
481k
    srcLine   += predPredSize;
293
481k
    dstLine   += dstStride;
294
481k
    bndryLine += bndryStep;
295
481k
  }
296
60.1k
}
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
236k
{
301
236k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
236k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
236k
        Pel* dstLine   = dst;
305
236k
  const Pel* srcLine   = src;
306
236k
  const Pel* bndryLine = bndry;
307
308
8.30M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.07M
  {
310
8.07M
    const Pel* before  = bndryLine;
311
8.07M
    const Pel* behind  = srcLine;
312
8.07M
          Pel* currDst = dstLine;
313
72.4M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
64.3M
    {
315
64.3M
      const int valDiff   = *behind - *before;
316
64.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
417M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
352M
      {
320
352M
        scaledVal += valDiff;
321
352M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
352M
        currDst += outWidth;
323
352M
      }
324
64.3M
      before = behind;
325
64.3M
      behind += srcStep;
326
64.3M
    }
327
328
8.07M
    srcLine ++;
329
8.07M
    dstLine ++;
330
8.07M
    bndryLine ++;
331
8.07M
  }
332
236k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.01k
{
301
6.01k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.01k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.01k
        Pel* dstLine   = dst;
305
6.01k
  const Pel* srcLine   = src;
306
6.01k
  const Pel* bndryLine = bndry;
307
308
54.1k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
48.1k
  {
310
48.1k
    const Pel* before  = bndryLine;
311
48.1k
    const Pel* behind  = srcLine;
312
48.1k
          Pel* currDst = dstLine;
313
240k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
192k
    {
315
192k
      const int valDiff   = *behind - *before;
316
192k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
577k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
385k
      {
320
385k
        scaledVal += valDiff;
321
385k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
385k
        currDst += outWidth;
323
385k
      }
324
192k
      before = behind;
325
192k
      behind += srcStep;
326
192k
    }
327
328
48.1k
    srcLine ++;
329
48.1k
    dstLine ++;
330
48.1k
    bndryLine ++;
331
48.1k
  }
332
6.01k
}
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
71.1k
{
301
71.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
71.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
71.1k
        Pel* dstLine   = dst;
305
71.1k
  const Pel* srcLine   = src;
306
71.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.5M
    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.5M
      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
71.1k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
98.7k
{
301
98.7k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
98.7k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
98.7k
        Pel* dstLine   = dst;
305
98.7k
  const Pel* srcLine   = src;
306
98.7k
  const Pel* bndryLine = bndry;
307
308
2.54M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.44M
  {
310
2.44M
    const Pel* before  = bndryLine;
311
2.44M
    const Pel* behind  = srcLine;
312
2.44M
          Pel* currDst = dstLine;
313
21.9M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
19.5M
    {
315
19.5M
      const int valDiff   = *behind - *before;
316
19.5M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
97.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
78.1M
      {
320
78.1M
        scaledVal += valDiff;
321
78.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
78.1M
        currDst += outWidth;
323
78.1M
      }
324
19.5M
      before = behind;
325
19.5M
      behind += srcStep;
326
19.5M
    }
327
328
2.44M
    srcLine ++;
329
2.44M
    dstLine ++;
330
2.44M
    bndryLine ++;
331
2.44M
  }
332
98.7k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
60.1k
{
301
60.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
60.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
60.1k
        Pel* dstLine   = dst;
305
60.1k
  const Pel* srcLine   = src;
306
60.1k
  const Pel* bndryLine = bndry;
307
308
3.91M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
3.85M
  {
310
3.85M
    const Pel* before  = bndryLine;
311
3.85M
    const Pel* behind  = srcLine;
312
3.85M
          Pel* currDst = dstLine;
313
34.6M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
30.8M
    {
315
30.8M
      const int valDiff   = *behind - *before;
316
30.8M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
277M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
246M
      {
320
246M
        scaledVal += valDiff;
321
246M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
246M
        currDst += outWidth;
323
246M
      }
324
30.8M
      before = behind;
325
30.8M
      behind += srcStep;
326
30.8M
    }
327
328
3.85M
    srcLine ++;
329
3.85M
    dstLine ++;
330
3.85M
    bndryLine ++;
331
3.85M
  }
332
60.1k
}
333
334
335
} // namespace vvenc
336
337
//! \}