Coverage Report

Created: 2026-09-14 06:44

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.1k
  : m_reducedBoundary       (nullptr)
62
19.1k
  , m_reducedBoundaryTransp (nullptr)
63
19.1k
  , m_inputOffset           ( 0 )
64
19.1k
  , m_inputOffsetTransp     ( 0 )
65
19.1k
  , m_refSamplesTop         (nullptr)
66
19.1k
  , m_refSamplesLeft        (nullptr)
67
19.1k
  , m_blockSize             ( 0, 0 )
68
19.1k
  , m_sizeId                ( 0 )
69
19.1k
  , m_reducedBdrySize       ( 0 )
70
19.1k
  , m_reducedPredSize       ( 0 )
71
19.1k
  , m_upsmpFactorHor        ( 0 )
72
19.1k
  , m_upsmpFactorVer        ( 0 )
73
19.1k
{
74
19.1k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
19.1k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
19.1k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
19.1k
{
80
19.1k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
19.1k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
19.1k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
42.8k
{
86
  // Step 1: Save block size and calculate dependent values
87
42.8k
  initPredBlockParams(block);
88
89
42.8k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
42.8k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
42.8k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
42.8k
  Pel* const topReduced = m_reducedBoundary;
96
42.8k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
42.8k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
42.8k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
42.8k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
42.8k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
214k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
171k
  {
105
171k
    topReducedTransposed[x] = topReduced[x];
106
171k
  }
107
214k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
171k
  {
109
171k
    leftReducedTransposed[y] = leftReduced[y];
110
171k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
42.8k
  m_inputOffset       = m_reducedBoundary[0];
114
42.8k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
42.8k
  const bool hasFirstCol = (m_sizeId < 2);
117
42.8k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
42.8k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
343k
  for (int i = 1; i < inputSize; i++)
120
300k
  {
121
300k
    m_reducedBoundary      [i] -= m_inputOffset;
122
300k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
300k
  }
124
42.8k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
256k
{
128
256k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
256k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
256k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
256k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
256k
  {
135
256k
    const int outputSize = m_reducedPredSize;
136
256k
    const int inputSize  = 2 * m_reducedBdrySize;
137
256k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
256k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
256k
    if( outputSize == 8)
141
250k
    {
142
250k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
250k
    }
144
5.98k
    else
145
5.98k
    {
146
5.98k
      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.98k
      else
151
5.98k
      {
152
5.98k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
5.98k
      }
154
5.98k
    }
155
256k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
256k
  if( needUpsampling )
159
256k
  {
160
256k
    const Pel* verSrc   = reducedPred;
161
256k
    SizeType verSrcStep = m_blockSize.width;
162
163
256k
    if( m_upsmpFactorHor > 1 )
164
247k
    {
165
247k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
247k
      verSrc = horDst;
167
247k
      verSrcStep *= m_upsmpFactorVer;
168
169
247k
      if( m_reducedPredSize == 4)
170
5.98k
      {
171
5.98k
        if( m_upsmpFactorHor == 2 )
172
5.98k
          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.98k
      }
178
242k
      else
179
242k
      {
180
242k
        if( m_upsmpFactorHor == 2 )
181
79.4k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
162k
        else if( m_upsmpFactorHor == 4 )
183
96.3k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
66.2k
        else
185
66.2k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
242k
      }
187
247k
    }
188
189
256k
    if( m_upsmpFactorVer > 1 )
190
245k
    {
191
245k
      if( m_reducedPredSize == 4)
192
5.98k
      {
193
5.98k
        if( m_upsmpFactorVer == 2 )
194
5.98k
          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.98k
      }
200
239k
      else
201
239k
      {
202
239k
        if( m_upsmpFactorVer == 2 )
203
72.3k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
167k
        else if( m_upsmpFactorVer == 4 )
205
101k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
66.2k
        else
207
66.2k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
239k
      }
209
245k
    }
210
256k
  }
211
256k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
42.8k
{
215
42.8k
  m_blockSize = block;
216
  // init size index
217
42.8k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
42.8k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
42.8k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
42.8k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
42.8k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
42.8k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
42.8k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
42.8k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
85.7k
{
235
85.7k
  if (dstLen < srcLen)
236
85.7k
  {
237
    // Create reduced boundary by downsampling
238
85.7k
    const SizeType downsmpFactor = srcLen / dstLen;
239
85.7k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
85.7k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
85.7k
    SizeType srcIdx = 0;
243
428k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
343k
    {
245
343k
      int sum = 0;
246
3.36M
      for( int k = 0; k < downsmpFactor; k++ )
247
3.02M
      {
248
3.02M
        sum += fullSrc[srcIdx++];
249
3.02M
      }
250
343k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
343k
    }
252
85.7k
  }
253
0
  else
254
0
  {
255
    // Copy boundary if no downsampling is needed
256
0
    for (SizeType i = 0; i < dstLen; ++i)
257
0
    {
258
0
      reducedDst[i] = fullSrc[i];
259
0
    }
260
0
  }
261
85.7k
}
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.20M
  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.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
68.9M
      {
284
68.9M
        scaledVal += valDiff;
285
68.9M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
68.9M
        currDst++;
287
68.9M
      }
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
5.98k
{
266
5.98k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
5.98k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
5.98k
        Pel* dstLine   = dst;
270
5.98k
  const Pel* srcLine   = src;
271
5.98k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
29.9k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
23.9k
  {
275
23.9k
    const Pel* before  = bndryLine;
276
23.9k
    const Pel* behind  = srcLine;
277
23.9k
          Pel* currDst = dstLine;
278
119k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
95.7k
    {
280
95.7k
      const int valDiff   = *behind - *before;
281
95.7k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
287k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
191k
      {
284
191k
        scaledVal += valDiff;
285
191k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
191k
        currDst++;
287
191k
      }
288
95.7k
      before = behind;
289
95.7k
      behind ++;
290
95.7k
    }
291
292
23.9k
    srcLine   += predPredSize;
293
23.9k
    dstLine   += dstStride;
294
23.9k
    bndryLine += bndryStep;
295
23.9k
  }
296
5.98k
}
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
79.4k
{
266
79.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
79.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
79.4k
        Pel* dstLine   = dst;
270
79.4k
  const Pel* srcLine   = src;
271
79.4k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
715k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
635k
  {
275
635k
    const Pel* before  = bndryLine;
276
635k
    const Pel* behind  = srcLine;
277
635k
          Pel* currDst = dstLine;
278
5.72M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.08M
    {
280
5.08M
      const int valDiff   = *behind - *before;
281
5.08M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
15.2M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
10.1M
      {
284
10.1M
        scaledVal += valDiff;
285
10.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
10.1M
        currDst++;
287
10.1M
      }
288
5.08M
      before = behind;
289
5.08M
      behind ++;
290
5.08M
    }
291
292
635k
    srcLine   += predPredSize;
293
635k
    dstLine   += dstStride;
294
635k
    bndryLine += bndryStep;
295
635k
  }
296
79.4k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
96.3k
{
266
96.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
96.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
96.3k
        Pel* dstLine   = dst;
270
96.3k
  const Pel* srcLine   = src;
271
96.3k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
866k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
770k
  {
275
770k
    const Pel* before  = bndryLine;
276
770k
    const Pel* behind  = srcLine;
277
770k
          Pel* currDst = dstLine;
278
6.93M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.16M
    {
280
6.16M
      const int valDiff   = *behind - *before;
281
6.16M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
30.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
24.6M
      {
284
24.6M
        scaledVal += valDiff;
285
24.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
24.6M
        currDst++;
287
24.6M
      }
288
6.16M
      before = behind;
289
6.16M
      behind ++;
290
6.16M
    }
291
292
770k
    srcLine   += predPredSize;
293
770k
    dstLine   += dstStride;
294
770k
    bndryLine += bndryStep;
295
770k
  }
296
96.3k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
66.2k
{
266
66.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
66.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
66.2k
        Pel* dstLine   = dst;
270
66.2k
  const Pel* srcLine   = src;
271
66.2k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
595k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
529k
  {
275
529k
    const Pel* before  = bndryLine;
276
529k
    const Pel* behind  = srcLine;
277
529k
          Pel* currDst = dstLine;
278
4.76M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.23M
    {
280
4.23M
      const int valDiff   = *behind - *before;
281
4.23M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
38.1M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
33.9M
      {
284
33.9M
        scaledVal += valDiff;
285
33.9M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
33.9M
        currDst++;
287
33.9M
      }
288
4.23M
      before = behind;
289
4.23M
      behind ++;
290
4.23M
    }
291
292
529k
    srcLine   += predPredSize;
293
529k
    dstLine   += dstStride;
294
529k
    bndryLine += bndryStep;
295
529k
  }
296
66.2k
}
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
245k
{
301
245k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
245k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
245k
        Pel* dstLine   = dst;
305
245k
  const Pel* srcLine   = src;
306
245k
  const Pel* bndryLine = bndry;
307
308
8.78M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.54M
  {
310
8.54M
    const Pel* before  = bndryLine;
311
8.54M
    const Pel* behind  = srcLine;
312
8.54M
          Pel* currDst = dstLine;
313
76.6M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
68.1M
    {
315
68.1M
      const int valDiff   = *behind - *before;
316
68.1M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
447M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
379M
      {
320
379M
        scaledVal += valDiff;
321
379M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
379M
        currDst += outWidth;
323
379M
      }
324
68.1M
      before = behind;
325
68.1M
      behind += srcStep;
326
68.1M
    }
327
328
8.54M
    srcLine ++;
329
8.54M
    dstLine ++;
330
8.54M
    bndryLine ++;
331
8.54M
  }
332
245k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
5.98k
{
301
5.98k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
5.98k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
5.98k
        Pel* dstLine   = dst;
305
5.98k
  const Pel* srcLine   = src;
306
5.98k
  const Pel* bndryLine = bndry;
307
308
53.8k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
47.8k
  {
310
47.8k
    const Pel* before  = bndryLine;
311
47.8k
    const Pel* behind  = srcLine;
312
47.8k
          Pel* currDst = dstLine;
313
239k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
191k
    {
315
191k
      const int valDiff   = *behind - *before;
316
191k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
574k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
382k
      {
320
382k
        scaledVal += valDiff;
321
382k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
382k
        currDst += outWidth;
323
382k
      }
324
191k
      before = behind;
325
191k
      behind += srcStep;
326
191k
    }
327
328
47.8k
    srcLine ++;
329
47.8k
    dstLine ++;
330
47.8k
    bndryLine ++;
331
47.8k
  }
332
5.98k
}
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
72.3k
{
301
72.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
72.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
72.3k
        Pel* dstLine   = dst;
305
72.3k
  const Pel* srcLine   = src;
306
72.3k
  const Pel* bndryLine = bndry;
307
308
1.83M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.76M
  {
310
1.76M
    const Pel* before  = bndryLine;
311
1.76M
    const Pel* behind  = srcLine;
312
1.76M
          Pel* currDst = dstLine;
313
15.8M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
14.1M
    {
315
14.1M
      const int valDiff   = *behind - *before;
316
14.1M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
42.3M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
28.2M
      {
320
28.2M
        scaledVal += valDiff;
321
28.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
28.2M
        currDst += outWidth;
323
28.2M
      }
324
14.1M
      before = behind;
325
14.1M
      behind += srcStep;
326
14.1M
    }
327
328
1.76M
    srcLine ++;
329
1.76M
    dstLine ++;
330
1.76M
    bndryLine ++;
331
1.76M
  }
332
72.3k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
101k
{
301
101k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
101k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
101k
        Pel* dstLine   = dst;
305
101k
  const Pel* srcLine   = src;
306
101k
  const Pel* bndryLine = bndry;
307
308
2.59M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.49M
  {
310
2.49M
    const Pel* before  = bndryLine;
311
2.49M
    const Pel* behind  = srcLine;
312
2.49M
          Pel* currDst = dstLine;
313
22.4M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
19.9M
    {
315
19.9M
      const int valDiff   = *behind - *before;
316
19.9M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
99.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
79.6M
      {
320
79.6M
        scaledVal += valDiff;
321
79.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
79.6M
        currDst += outWidth;
323
79.6M
      }
324
19.9M
      before = behind;
325
19.9M
      behind += srcStep;
326
19.9M
    }
327
328
2.49M
    srcLine ++;
329
2.49M
    dstLine ++;
330
2.49M
    bndryLine ++;
331
2.49M
  }
332
101k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
66.2k
{
301
66.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
66.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
66.2k
        Pel* dstLine   = dst;
305
66.2k
  const Pel* srcLine   = src;
306
66.2k
  const Pel* bndryLine = bndry;
307
308
4.30M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.23M
  {
310
4.23M
    const Pel* before  = bndryLine;
311
4.23M
    const Pel* behind  = srcLine;
312
4.23M
          Pel* currDst = dstLine;
313
38.1M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
33.9M
    {
315
33.9M
      const int valDiff   = *behind - *before;
316
33.9M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
305M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
271M
      {
320
271M
        scaledVal += valDiff;
321
271M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
271M
        currDst += outWidth;
323
271M
      }
324
33.9M
      before = behind;
325
33.9M
      behind += srcStep;
326
33.9M
    }
327
328
4.23M
    srcLine ++;
329
4.23M
    dstLine ++;
330
4.23M
    bndryLine ++;
331
4.23M
  }
332
66.2k
}
333
334
335
} // namespace vvenc
336
337
//! \}