Coverage Report

Created: 2026-08-13 07:23

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.2k
  : m_reducedBoundary       (nullptr)
62
19.2k
  , m_reducedBoundaryTransp (nullptr)
63
19.2k
  , m_inputOffset           ( 0 )
64
19.2k
  , m_inputOffsetTransp     ( 0 )
65
19.2k
  , m_refSamplesTop         (nullptr)
66
19.2k
  , m_refSamplesLeft        (nullptr)
67
19.2k
  , m_blockSize             ( 0, 0 )
68
19.2k
  , m_sizeId                ( 0 )
69
19.2k
  , m_reducedBdrySize       ( 0 )
70
19.2k
  , m_reducedPredSize       ( 0 )
71
19.2k
  , m_upsmpFactorHor        ( 0 )
72
19.2k
  , m_upsmpFactorVer        ( 0 )
73
19.2k
{
74
19.2k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
19.2k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
19.2k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
19.2k
{
80
19.2k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
19.2k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
19.2k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
42.9k
{
86
  // Step 1: Save block size and calculate dependent values
87
42.9k
  initPredBlockParams(block);
88
89
42.9k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
42.9k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
42.9k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
42.9k
  Pel* const topReduced = m_reducedBoundary;
96
42.9k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
42.9k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
42.9k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
42.9k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
42.9k
  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.9k
  m_inputOffset       = m_reducedBoundary[0];
114
42.9k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
42.9k
  const bool hasFirstCol = (m_sizeId < 2);
117
42.9k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
42.9k
  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.9k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
257k
{
128
257k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
257k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
257k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
257k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
257k
  {
135
257k
    const int outputSize = m_reducedPredSize;
136
257k
    const int inputSize  = 2 * m_reducedBdrySize;
137
257k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
257k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
257k
    if( outputSize == 8)
141
251k
    {
142
251k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
251k
    }
144
6.73k
    else
145
6.73k
    {
146
6.73k
      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.73k
      else
151
6.73k
      {
152
6.73k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.73k
      }
154
6.73k
    }
155
257k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
257k
  if( needUpsampling )
159
257k
  {
160
257k
    const Pel* verSrc   = reducedPred;
161
257k
    SizeType verSrcStep = m_blockSize.width;
162
163
257k
    if( m_upsmpFactorHor > 1 )
164
248k
    {
165
248k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
248k
      verSrc = horDst;
167
248k
      verSrcStep *= m_upsmpFactorVer;
168
169
248k
      if( m_reducedPredSize == 4)
170
6.73k
      {
171
6.73k
        if( m_upsmpFactorHor == 2 )
172
6.73k
          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.73k
      }
178
241k
      else
179
241k
      {
180
241k
        if( m_upsmpFactorHor == 2 )
181
78.6k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
163k
        else if( m_upsmpFactorHor == 4 )
183
96.6k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
66.5k
        else
185
66.5k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
241k
      }
187
248k
    }
188
189
257k
    if( m_upsmpFactorVer > 1 )
190
247k
    {
191
247k
      if( m_reducedPredSize == 4)
192
6.73k
      {
193
6.73k
        if( m_upsmpFactorVer == 2 )
194
6.73k
          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.73k
      }
200
240k
      else
201
240k
      {
202
240k
        if( m_upsmpFactorVer == 2 )
203
73.7k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
166k
        else if( m_upsmpFactorVer == 4 )
205
100k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
66.5k
        else
207
66.5k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
240k
      }
209
247k
    }
210
257k
  }
211
257k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
42.9k
{
215
42.9k
  m_blockSize = block;
216
  // init size index
217
42.9k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
42.9k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
42.9k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
42.9k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
42.9k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
42.9k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
42.9k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
42.9k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
85.9k
{
235
85.9k
  if (dstLen < srcLen)
236
85.9k
  {
237
    // Create reduced boundary by downsampling
238
85.9k
    const SizeType downsmpFactor = srcLen / dstLen;
239
85.9k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
85.9k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
85.9k
    SizeType srcIdx = 0;
243
429k
    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.9k
  }
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.9k
}
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.21M
  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.7M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
69.1M
      {
284
69.1M
        scaledVal += valDiff;
285
69.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
69.1M
        currDst++;
287
69.1M
      }
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
6.73k
{
266
6.73k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.73k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.73k
        Pel* dstLine   = dst;
270
6.73k
  const Pel* srcLine   = src;
271
6.73k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
33.6k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
26.9k
  {
275
26.9k
    const Pel* before  = bndryLine;
276
26.9k
    const Pel* behind  = srcLine;
277
26.9k
          Pel* currDst = dstLine;
278
134k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
107k
    {
280
107k
      const int valDiff   = *behind - *before;
281
107k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
323k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
215k
      {
284
215k
        scaledVal += valDiff;
285
215k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
215k
        currDst++;
287
215k
      }
288
107k
      before = behind;
289
107k
      behind ++;
290
107k
    }
291
292
26.9k
    srcLine   += predPredSize;
293
26.9k
    dstLine   += dstStride;
294
26.9k
    bndryLine += bndryStep;
295
26.9k
  }
296
6.73k
}
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
78.6k
{
266
78.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
78.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
78.6k
        Pel* dstLine   = dst;
270
78.6k
  const Pel* srcLine   = src;
271
78.6k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
708k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
629k
  {
275
629k
    const Pel* before  = bndryLine;
276
629k
    const Pel* behind  = srcLine;
277
629k
          Pel* currDst = dstLine;
278
5.66M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.03M
    {
280
5.03M
      const int valDiff   = *behind - *before;
281
5.03M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
15.1M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
10.0M
      {
284
10.0M
        scaledVal += valDiff;
285
10.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
10.0M
        currDst++;
287
10.0M
      }
288
5.03M
      before = behind;
289
5.03M
      behind ++;
290
5.03M
    }
291
292
629k
    srcLine   += predPredSize;
293
629k
    dstLine   += dstStride;
294
629k
    bndryLine += bndryStep;
295
629k
  }
296
78.6k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
96.6k
{
266
96.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
96.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
96.6k
        Pel* dstLine   = dst;
270
96.6k
  const Pel* srcLine   = src;
271
96.6k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
870k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
773k
  {
275
773k
    const Pel* before  = bndryLine;
276
773k
    const Pel* behind  = srcLine;
277
773k
          Pel* currDst = dstLine;
278
6.96M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.18M
    {
280
6.18M
      const int valDiff   = *behind - *before;
281
6.18M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
30.9M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
24.7M
      {
284
24.7M
        scaledVal += valDiff;
285
24.7M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
24.7M
        currDst++;
287
24.7M
      }
288
6.18M
      before = behind;
289
6.18M
      behind ++;
290
6.18M
    }
291
292
773k
    srcLine   += predPredSize;
293
773k
    dstLine   += dstStride;
294
773k
    bndryLine += bndryStep;
295
773k
  }
296
96.6k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
66.5k
{
266
66.5k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
66.5k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
66.5k
        Pel* dstLine   = dst;
270
66.5k
  const Pel* srcLine   = src;
271
66.5k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
599k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
532k
  {
275
532k
    const Pel* before  = bndryLine;
276
532k
    const Pel* behind  = srcLine;
277
532k
          Pel* currDst = dstLine;
278
4.79M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.26M
    {
280
4.26M
      const int valDiff   = *behind - *before;
281
4.26M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
38.3M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
34.0M
      {
284
34.0M
        scaledVal += valDiff;
285
34.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
34.0M
        currDst++;
287
34.0M
      }
288
4.26M
      before = behind;
289
4.26M
      behind ++;
290
4.26M
    }
291
292
532k
    srcLine   += predPredSize;
293
532k
    dstLine   += dstStride;
294
532k
    bndryLine += bndryStep;
295
532k
  }
296
66.5k
}
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.82M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.57M
  {
310
8.57M
    const Pel* before  = bndryLine;
311
8.57M
    const Pel* behind  = srcLine;
312
8.57M
          Pel* currDst = dstLine;
313
76.9M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
68.3M
    {
315
68.3M
      const int valDiff   = *behind - *before;
316
68.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
449M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
380M
      {
320
380M
        scaledVal += valDiff;
321
380M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
380M
        currDst += outWidth;
323
380M
      }
324
68.3M
      before = behind;
325
68.3M
      behind += srcStep;
326
68.3M
    }
327
328
8.57M
    srcLine ++;
329
8.57M
    dstLine ++;
330
8.57M
    bndryLine ++;
331
8.57M
  }
332
247k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.73k
{
301
6.73k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.73k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.73k
        Pel* dstLine   = dst;
305
6.73k
  const Pel* srcLine   = src;
306
6.73k
  const Pel* bndryLine = bndry;
307
308
60.6k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
53.8k
  {
310
53.8k
    const Pel* before  = bndryLine;
311
53.8k
    const Pel* behind  = srcLine;
312
53.8k
          Pel* currDst = dstLine;
313
269k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
215k
    {
315
215k
      const int valDiff   = *behind - *before;
316
215k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
646k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
431k
      {
320
431k
        scaledVal += valDiff;
321
431k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
431k
        currDst += outWidth;
323
431k
      }
324
215k
      before = behind;
325
215k
      behind += srcStep;
326
215k
    }
327
328
53.8k
    srcLine ++;
329
53.8k
    dstLine ++;
330
53.8k
    bndryLine ++;
331
53.8k
  }
332
6.73k
}
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
73.7k
{
301
73.7k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
73.7k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
73.7k
        Pel* dstLine   = dst;
305
73.7k
  const Pel* srcLine   = src;
306
73.7k
  const Pel* bndryLine = bndry;
307
308
1.85M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.78M
  {
310
1.78M
    const Pel* before  = bndryLine;
311
1.78M
    const Pel* behind  = srcLine;
312
1.78M
          Pel* currDst = dstLine;
313
16.0M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
14.2M
    {
315
14.2M
      const int valDiff   = *behind - *before;
316
14.2M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
42.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
28.5M
      {
320
28.5M
        scaledVal += valDiff;
321
28.5M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
28.5M
        currDst += outWidth;
323
28.5M
      }
324
14.2M
      before = behind;
325
14.2M
      behind += srcStep;
326
14.2M
    }
327
328
1.78M
    srcLine ++;
329
1.78M
    dstLine ++;
330
1.78M
    bndryLine ++;
331
1.78M
  }
332
73.7k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
100k
{
301
100k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
100k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
100k
        Pel* dstLine   = dst;
305
100k
  const Pel* srcLine   = src;
306
100k
  const Pel* bndryLine = bndry;
307
308
2.57M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.47M
  {
310
2.47M
    const Pel* before  = bndryLine;
311
2.47M
    const Pel* behind  = srcLine;
312
2.47M
          Pel* currDst = dstLine;
313
22.2M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
19.7M
    {
315
19.7M
      const int valDiff   = *behind - *before;
316
19.7M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
98.9M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
79.1M
      {
320
79.1M
        scaledVal += valDiff;
321
79.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
79.1M
        currDst += outWidth;
323
79.1M
      }
324
19.7M
      before = behind;
325
19.7M
      behind += srcStep;
326
19.7M
    }
327
328
2.47M
    srcLine ++;
329
2.47M
    dstLine ++;
330
2.47M
    bndryLine ++;
331
2.47M
  }
332
100k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
66.5k
{
301
66.5k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
66.5k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
66.5k
        Pel* dstLine   = dst;
305
66.5k
  const Pel* srcLine   = src;
306
66.5k
  const Pel* bndryLine = bndry;
307
308
4.32M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.26M
  {
310
4.26M
    const Pel* before  = bndryLine;
311
4.26M
    const Pel* behind  = srcLine;
312
4.26M
          Pel* currDst = dstLine;
313
38.3M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
34.0M
    {
315
34.0M
      const int valDiff   = *behind - *before;
316
34.0M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
306M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
272M
      {
320
272M
        scaledVal += valDiff;
321
272M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
272M
        currDst += outWidth;
323
272M
      }
324
34.0M
      before = behind;
325
34.0M
      behind += srcStep;
326
34.0M
    }
327
328
4.26M
    srcLine ++;
329
4.26M
    dstLine ++;
330
4.26M
    bndryLine ++;
331
4.26M
  }
332
66.5k
}
333
334
335
} // namespace vvenc
336
337
//! \}