Coverage Report

Created: 2026-07-16 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvenc/source/Lib/CommonLib/MatrixIntraPrediction.cpp
Line
Count
Source
1
/* -----------------------------------------------------------------------------
2
The copyright in this software is being made available under the Clear BSD
3
License, included below. No patent rights, trademark rights and/or 
4
other Intellectual Property Rights other than the copyrights concerning 
5
the Software are granted under this license.
6
7
The Clear BSD License
8
9
Copyright (c) 2019-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVenC Authors.
10
All rights reserved.
11
12
Redistribution and use in source and binary forms, with or without modification,
13
are permitted (subject to the limitations in the disclaimer below) provided that
14
the following conditions are met:
15
16
     * Redistributions of source code must retain the above copyright notice,
17
     this list of conditions and the following disclaimer.
18
19
     * Redistributions in binary form must reproduce the above copyright
20
     notice, this list of conditions and the following disclaimer in the
21
     documentation and/or other materials provided with the distribution.
22
23
     * Neither the name of the copyright holder nor the names of its
24
     contributors may be used to endorse or promote products derived from this
25
     software without specific prior written permission.
26
27
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
28
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
29
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
36
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
POSSIBILITY OF SUCH DAMAGE.
39
40
41
------------------------------------------------------------------------------------------- */
42
43
44
/** \file     MatrixIntraPrediction.cpp
45
\brief    matrix-based intra prediction class
46
*/
47
48
49
#include "MatrixIntraPrediction.h"
50
#include "dtrace_next.h"
51
52
#include "UnitTools.h"
53
#include "MipData.h"
54
55
namespace vvenc {
56
57
static const int MIP_MAX_INPUT_SIZE             =  8;
58
static const int MIP_MAX_REDUCED_OUTPUT_SAMPLES = 64;
59
60
MatrixIntraPrediction::MatrixIntraPrediction()
61
19.4k
  : m_reducedBoundary       (nullptr)
62
19.4k
  , m_reducedBoundaryTransp (nullptr)
63
19.4k
  , m_inputOffset           ( 0 )
64
19.4k
  , m_inputOffsetTransp     ( 0 )
65
19.4k
  , m_refSamplesTop         (nullptr)
66
19.4k
  , m_refSamplesLeft        (nullptr)
67
19.4k
  , m_blockSize             ( 0, 0 )
68
19.4k
  , m_sizeId                ( 0 )
69
19.4k
  , m_reducedBdrySize       ( 0 )
70
19.4k
  , m_reducedPredSize       ( 0 )
71
19.4k
  , m_upsmpFactorHor        ( 0 )
72
19.4k
  , m_upsmpFactorVer        ( 0 )
73
19.4k
{
74
19.4k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
19.4k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
19.4k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
19.4k
{
80
19.4k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
19.4k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
19.4k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
43.2k
{
86
  // Step 1: Save block size and calculate dependent values
87
43.2k
  initPredBlockParams(block);
88
89
43.2k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
43.2k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
43.2k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
43.2k
  Pel* const topReduced = m_reducedBoundary;
96
43.2k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
43.2k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
43.2k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
43.2k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
43.2k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
216k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
172k
  {
105
172k
    topReducedTransposed[x] = topReduced[x];
106
172k
  }
107
216k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
172k
  {
109
172k
    leftReducedTransposed[y] = leftReduced[y];
110
172k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
43.2k
  m_inputOffset       = m_reducedBoundary[0];
114
43.2k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
43.2k
  const bool hasFirstCol = (m_sizeId < 2);
117
43.2k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
43.2k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
345k
  for (int i = 1; i < inputSize; i++)
120
302k
  {
121
302k
    m_reducedBoundary      [i] -= m_inputOffset;
122
302k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
302k
  }
124
43.2k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
258k
{
128
258k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
258k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
258k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
258k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
258k
  {
135
258k
    const int outputSize = m_reducedPredSize;
136
258k
    const int inputSize  = 2 * m_reducedBdrySize;
137
258k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
258k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
258k
    if( outputSize == 8)
141
252k
    {
142
252k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
252k
    }
144
6.64k
    else
145
6.64k
    {
146
6.64k
      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.64k
      else
151
6.64k
      {
152
6.64k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.64k
      }
154
6.64k
    }
155
258k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
258k
  if( needUpsampling )
159
258k
  {
160
258k
    const Pel* verSrc   = reducedPred;
161
258k
    SizeType verSrcStep = m_blockSize.width;
162
163
258k
    if( m_upsmpFactorHor > 1 )
164
249k
    {
165
249k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
249k
      verSrc = horDst;
167
249k
      verSrcStep *= m_upsmpFactorVer;
168
169
249k
      if( m_reducedPredSize == 4)
170
6.64k
      {
171
6.64k
        if( m_upsmpFactorHor == 2 )
172
6.64k
          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.64k
      }
178
243k
      else
179
243k
      {
180
243k
        if( m_upsmpFactorHor == 2 )
181
80.3k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
162k
        else if( m_upsmpFactorHor == 4 )
183
97.6k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
65.0k
        else
185
65.0k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
243k
      }
187
249k
    }
188
189
258k
    if( m_upsmpFactorVer > 1 )
190
247k
    {
191
247k
      if( m_reducedPredSize == 4)
192
6.64k
      {
193
6.64k
        if( m_upsmpFactorVer == 2 )
194
6.64k
          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.64k
      }
200
241k
      else
201
241k
      {
202
241k
        if( m_upsmpFactorVer == 2 )
203
76.8k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
164k
        else if( m_upsmpFactorVer == 4 )
205
99.2k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
65.0k
        else
207
65.0k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
241k
      }
209
247k
    }
210
258k
  }
211
258k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
43.2k
{
215
43.2k
  m_blockSize = block;
216
  // init size index
217
43.2k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
43.2k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
43.2k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
43.2k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
43.2k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
43.2k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
43.2k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
43.2k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
86.4k
{
235
86.4k
  if (dstLen < srcLen)
236
86.4k
  {
237
    // Create reduced boundary by downsampling
238
86.4k
    const SizeType downsmpFactor = srcLen / dstLen;
239
86.4k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
86.4k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
86.4k
    SizeType srcIdx = 0;
243
432k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
345k
    {
245
345k
      int sum = 0;
246
3.35M
      for( int k = 0; k < downsmpFactor; k++ )
247
3.00M
      {
248
3.00M
        sum += fullSrc[srcIdx++];
249
3.00M
      }
250
345k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
345k
    }
252
86.4k
  }
253
0
  else
254
0
  {
255
    // Copy boundary if no downsampling is needed
256
0
    for (SizeType i = 0; i < dstLen; ++i)
257
0
    {
258
0
      reducedDst[i] = fullSrc[i];
259
0
    }
260
0
  }
261
86.4k
}
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
249k
{
266
249k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
249k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
249k
        Pel* dstLine   = dst;
270
249k
  const Pel* srcLine   = src;
271
249k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.22M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.97M
  {
275
1.97M
    const Pel* before  = bndryLine;
276
1.97M
    const Pel* behind  = srcLine;
277
1.97M
          Pel* currDst = dstLine;
278
17.6M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
15.6M
    {
280
15.6M
      const int valDiff   = *behind - *before;
281
15.6M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
84.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
68.8M
      {
284
68.8M
        scaledVal += valDiff;
285
68.8M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
68.8M
        currDst++;
287
68.8M
      }
288
15.6M
      before = behind;
289
15.6M
      behind ++;
290
15.6M
    }
291
292
1.97M
    srcLine   += predPredSize;
293
1.97M
    dstLine   += dstStride;
294
1.97M
    bndryLine += bndryStep;
295
1.97M
  }
296
249k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.64k
{
266
6.64k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.64k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.64k
        Pel* dstLine   = dst;
270
6.64k
  const Pel* srcLine   = src;
271
6.64k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
33.2k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
26.5k
  {
275
26.5k
    const Pel* before  = bndryLine;
276
26.5k
    const Pel* behind  = srcLine;
277
26.5k
          Pel* currDst = dstLine;
278
132k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
106k
    {
280
106k
      const int valDiff   = *behind - *before;
281
106k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
318k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
212k
      {
284
212k
        scaledVal += valDiff;
285
212k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
212k
        currDst++;
287
212k
      }
288
106k
      before = behind;
289
106k
      behind ++;
290
106k
    }
291
292
26.5k
    srcLine   += predPredSize;
293
26.5k
    dstLine   += dstStride;
294
26.5k
    bndryLine += bndryStep;
295
26.5k
  }
296
6.64k
}
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
80.3k
{
266
80.3k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
80.3k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
80.3k
        Pel* dstLine   = dst;
270
80.3k
  const Pel* srcLine   = src;
271
80.3k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
723k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
643k
  {
275
643k
    const Pel* before  = bndryLine;
276
643k
    const Pel* behind  = srcLine;
277
643k
          Pel* currDst = dstLine;
278
5.78M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.14M
    {
280
5.14M
      const int valDiff   = *behind - *before;
281
5.14M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
15.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
10.2M
      {
284
10.2M
        scaledVal += valDiff;
285
10.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
10.2M
        currDst++;
287
10.2M
      }
288
5.14M
      before = behind;
289
5.14M
      behind ++;
290
5.14M
    }
291
292
643k
    srcLine   += predPredSize;
293
643k
    dstLine   += dstStride;
294
643k
    bndryLine += bndryStep;
295
643k
  }
296
80.3k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
97.6k
{
266
97.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
97.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
97.6k
        Pel* dstLine   = dst;
270
97.6k
  const Pel* srcLine   = src;
271
97.6k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
879k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
781k
  {
275
781k
    const Pel* before  = bndryLine;
276
781k
    const Pel* behind  = srcLine;
277
781k
          Pel* currDst = dstLine;
278
7.03M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.25M
    {
280
6.25M
      const int valDiff   = *behind - *before;
281
6.25M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
31.2M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
25.0M
      {
284
25.0M
        scaledVal += valDiff;
285
25.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
25.0M
        currDst++;
287
25.0M
      }
288
6.25M
      before = behind;
289
6.25M
      behind ++;
290
6.25M
    }
291
292
781k
    srcLine   += predPredSize;
293
781k
    dstLine   += dstStride;
294
781k
    bndryLine += bndryStep;
295
781k
  }
296
97.6k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
65.0k
{
266
65.0k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
65.0k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
65.0k
        Pel* dstLine   = dst;
270
65.0k
  const Pel* srcLine   = src;
271
65.0k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
585k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
520k
  {
275
520k
    const Pel* before  = bndryLine;
276
520k
    const Pel* behind  = srcLine;
277
520k
          Pel* currDst = dstLine;
278
4.68M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.16M
    {
280
4.16M
      const int valDiff   = *behind - *before;
281
4.16M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
37.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
33.3M
      {
284
33.3M
        scaledVal += valDiff;
285
33.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
33.3M
        currDst++;
287
33.3M
      }
288
4.16M
      before = behind;
289
4.16M
      behind ++;
290
4.16M
    }
291
292
520k
    srcLine   += predPredSize;
293
520k
    dstLine   += dstStride;
294
520k
    bndryLine += bndryStep;
295
520k
  }
296
65.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
247k
{
301
247k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
247k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
247k
        Pel* dstLine   = dst;
305
247k
  const Pel* srcLine   = src;
306
247k
  const Pel* bndryLine = bndry;
307
308
8.77M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.52M
  {
310
8.52M
    const Pel* before  = bndryLine;
311
8.52M
    const Pel* behind  = srcLine;
312
8.52M
          Pel* currDst = dstLine;
313
76.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
67.9M
    {
315
67.9M
      const int valDiff   = *behind - *before;
316
67.9M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
442M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
374M
      {
320
374M
        scaledVal += valDiff;
321
374M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
374M
        currDst += outWidth;
323
374M
      }
324
67.9M
      before = behind;
325
67.9M
      behind += srcStep;
326
67.9M
    }
327
328
8.52M
    srcLine ++;
329
8.52M
    dstLine ++;
330
8.52M
    bndryLine ++;
331
8.52M
  }
332
247k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.64k
{
301
6.64k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.64k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.64k
        Pel* dstLine   = dst;
305
6.64k
  const Pel* srcLine   = src;
306
6.64k
  const Pel* bndryLine = bndry;
307
308
59.7k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
53.1k
  {
310
53.1k
    const Pel* before  = bndryLine;
311
53.1k
    const Pel* behind  = srcLine;
312
53.1k
          Pel* currDst = dstLine;
313
265k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
212k
    {
315
212k
      const int valDiff   = *behind - *before;
316
212k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
637k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
424k
      {
320
424k
        scaledVal += valDiff;
321
424k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
424k
        currDst += outWidth;
323
424k
      }
324
212k
      before = behind;
325
212k
      behind += srcStep;
326
212k
    }
327
328
53.1k
    srcLine ++;
329
53.1k
    dstLine ++;
330
53.1k
    bndryLine ++;
331
53.1k
  }
332
6.64k
}
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
76.8k
{
301
76.8k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
76.8k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
76.8k
        Pel* dstLine   = dst;
305
76.8k
  const Pel* srcLine   = src;
306
76.8k
  const Pel* bndryLine = bndry;
307
308
1.94M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.86M
  {
310
1.86M
    const Pel* before  = bndryLine;
311
1.86M
    const Pel* behind  = srcLine;
312
1.86M
          Pel* currDst = dstLine;
313
16.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
14.9M
    {
315
14.9M
      const int valDiff   = *behind - *before;
316
14.9M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
44.7M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
29.8M
      {
320
29.8M
        scaledVal += valDiff;
321
29.8M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
29.8M
        currDst += outWidth;
323
29.8M
      }
324
14.9M
      before = behind;
325
14.9M
      behind += srcStep;
326
14.9M
    }
327
328
1.86M
    srcLine ++;
329
1.86M
    dstLine ++;
330
1.86M
    bndryLine ++;
331
1.86M
  }
332
76.8k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
99.2k
{
301
99.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
99.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
99.2k
        Pel* dstLine   = dst;
305
99.2k
  const Pel* srcLine   = src;
306
99.2k
  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
99.2k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
65.0k
{
301
65.0k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
65.0k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
65.0k
        Pel* dstLine   = dst;
305
65.0k
  const Pel* srcLine   = src;
306
65.0k
  const Pel* bndryLine = bndry;
307
308
4.22M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.16M
  {
310
4.16M
    const Pel* before  = bndryLine;
311
4.16M
    const Pel* behind  = srcLine;
312
4.16M
          Pel* currDst = dstLine;
313
37.4M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
33.3M
    {
315
33.3M
      const int valDiff   = *behind - *before;
316
33.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
299M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
266M
      {
320
266M
        scaledVal += valDiff;
321
266M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
266M
        currDst += outWidth;
323
266M
      }
324
33.3M
      before = behind;
325
33.3M
      behind += srcStep;
326
33.3M
    }
327
328
4.16M
    srcLine ++;
329
4.16M
    dstLine ++;
330
4.16M
    bndryLine ++;
331
4.16M
  }
332
65.0k
}
333
334
335
} // namespace vvenc
336
337
//! \}