Coverage Report

Created: 2026-09-13 06:34

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.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
342k
  for (int i = 1; i < inputSize; i++)
120
299k
  {
121
299k
    m_reducedBoundary      [i] -= m_inputOffset;
122
299k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
299k
  }
124
42.8k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
255k
{
128
255k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
255k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
255k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
255k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
255k
  {
135
255k
    const int outputSize = m_reducedPredSize;
136
255k
    const int inputSize  = 2 * m_reducedBdrySize;
137
255k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
255k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
255k
    if( outputSize == 8)
141
249k
    {
142
249k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
249k
    }
144
6.20k
    else
145
6.20k
    {
146
6.20k
      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.20k
      else
151
6.20k
      {
152
6.20k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.20k
      }
154
6.20k
    }
155
255k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
255k
  if( needUpsampling )
159
255k
  {
160
255k
    const Pel* verSrc   = reducedPred;
161
255k
    SizeType verSrcStep = m_blockSize.width;
162
163
255k
    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
6.20k
      {
171
6.20k
        if( m_upsmpFactorHor == 2 )
172
6.20k
          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.20k
      }
178
241k
      else
179
241k
      {
180
241k
        if( m_upsmpFactorHor == 2 )
181
79.7k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
161k
        else if( m_upsmpFactorHor == 4 )
183
95.8k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
65.4k
        else
185
65.4k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
241k
      }
187
247k
    }
188
189
255k
    if( m_upsmpFactorVer > 1 )
190
245k
    {
191
245k
      if( m_reducedPredSize == 4)
192
6.20k
      {
193
6.20k
        if( m_upsmpFactorVer == 2 )
194
6.20k
          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.20k
      }
200
239k
      else
201
239k
      {
202
239k
        if( m_upsmpFactorVer == 2 )
203
73.1k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
165k
        else if( m_upsmpFactorVer == 4 )
205
100k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
65.4k
        else
207
65.4k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
239k
      }
209
245k
    }
210
255k
  }
211
255k
}
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.6k
{
235
85.6k
  if (dstLen < srcLen)
236
85.6k
  {
237
    // Create reduced boundary by downsampling
238
85.6k
    const SizeType downsmpFactor = srcLen / dstLen;
239
85.6k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
85.6k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
85.6k
    SizeType srcIdx = 0;
243
428k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
342k
    {
245
342k
      int sum = 0;
246
3.34M
      for( int k = 0; k < downsmpFactor; k++ )
247
2.99M
      {
248
2.99M
        sum += fullSrc[srcIdx++];
249
2.99M
      }
250
342k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
342k
    }
252
85.6k
  }
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.6k
}
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
247k
{
266
247k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
247k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
247k
        Pel* dstLine   = dst;
270
247k
  const Pel* srcLine   = src;
271
247k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.20M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.95M
  {
275
1.95M
    const Pel* before  = bndryLine;
276
1.95M
    const Pel* behind  = srcLine;
277
1.95M
          Pel* currDst = dstLine;
278
17.4M
    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
83.9M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
68.4M
      {
284
68.4M
        scaledVal += valDiff;
285
68.4M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
68.4M
        currDst++;
287
68.4M
      }
288
15.5M
      before = behind;
289
15.5M
      behind ++;
290
15.5M
    }
291
292
1.95M
    srcLine   += predPredSize;
293
1.95M
    dstLine   += dstStride;
294
1.95M
    bndryLine += bndryStep;
295
1.95M
  }
296
247k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.20k
{
266
6.20k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.20k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.20k
        Pel* dstLine   = dst;
270
6.20k
  const Pel* srcLine   = src;
271
6.20k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
31.0k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
24.8k
  {
275
24.8k
    const Pel* before  = bndryLine;
276
24.8k
    const Pel* behind  = srcLine;
277
24.8k
          Pel* currDst = dstLine;
278
124k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
99.3k
    {
280
99.3k
      const int valDiff   = *behind - *before;
281
99.3k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
297k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
198k
      {
284
198k
        scaledVal += valDiff;
285
198k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
198k
        currDst++;
287
198k
      }
288
99.3k
      before = behind;
289
99.3k
      behind ++;
290
99.3k
    }
291
292
24.8k
    srcLine   += predPredSize;
293
24.8k
    dstLine   += dstStride;
294
24.8k
    bndryLine += bndryStep;
295
24.8k
  }
296
6.20k
}
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.7k
{
266
79.7k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
79.7k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
79.7k
        Pel* dstLine   = dst;
270
79.7k
  const Pel* srcLine   = src;
271
79.7k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
717k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
637k
  {
275
637k
    const Pel* before  = bndryLine;
276
637k
    const Pel* behind  = srcLine;
277
637k
          Pel* currDst = dstLine;
278
5.73M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.10M
    {
280
5.10M
      const int valDiff   = *behind - *before;
281
5.10M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
15.3M
      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.10M
      before = behind;
289
5.10M
      behind ++;
290
5.10M
    }
291
292
637k
    srcLine   += predPredSize;
293
637k
    dstLine   += dstStride;
294
637k
    bndryLine += bndryStep;
295
637k
  }
296
79.7k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
95.8k
{
266
95.8k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
95.8k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
95.8k
        Pel* dstLine   = dst;
270
95.8k
  const Pel* srcLine   = src;
271
95.8k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
862k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
767k
  {
275
767k
    const Pel* before  = bndryLine;
276
767k
    const Pel* behind  = srcLine;
277
767k
          Pel* currDst = dstLine;
278
6.90M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
6.13M
    {
280
6.13M
      const int valDiff   = *behind - *before;
281
6.13M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
30.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
24.5M
      {
284
24.5M
        scaledVal += valDiff;
285
24.5M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
24.5M
        currDst++;
287
24.5M
      }
288
6.13M
      before = behind;
289
6.13M
      behind ++;
290
6.13M
    }
291
292
767k
    srcLine   += predPredSize;
293
767k
    dstLine   += dstStride;
294
767k
    bndryLine += bndryStep;
295
767k
  }
296
95.8k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
65.4k
{
266
65.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
65.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
65.4k
        Pel* dstLine   = dst;
270
65.4k
  const Pel* srcLine   = src;
271
65.4k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
588k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
523k
  {
275
523k
    const Pel* before  = bndryLine;
276
523k
    const Pel* behind  = srcLine;
277
523k
          Pel* currDst = dstLine;
278
4.71M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.18M
    {
280
4.18M
      const int valDiff   = *behind - *before;
281
4.18M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
37.6M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
33.4M
      {
284
33.4M
        scaledVal += valDiff;
285
33.4M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
33.4M
        currDst++;
287
33.4M
      }
288
4.18M
      before = behind;
289
4.18M
      behind ++;
290
4.18M
    }
291
292
523k
    srcLine   += predPredSize;
293
523k
    dstLine   += dstStride;
294
523k
    bndryLine += bndryStep;
295
523k
  }
296
65.4k
}
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.72M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
8.47M
  {
310
8.47M
    const Pel* before  = bndryLine;
311
8.47M
    const Pel* behind  = srcLine;
312
8.47M
          Pel* currDst = dstLine;
313
76.1M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
67.6M
    {
315
67.6M
      const int valDiff   = *behind - *before;
316
67.6M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
443M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
375M
      {
320
375M
        scaledVal += valDiff;
321
375M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
375M
        currDst += outWidth;
323
375M
      }
324
67.6M
      before = behind;
325
67.6M
      behind += srcStep;
326
67.6M
    }
327
328
8.47M
    srcLine ++;
329
8.47M
    dstLine ++;
330
8.47M
    bndryLine ++;
331
8.47M
  }
332
245k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.20k
{
301
6.20k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.20k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.20k
        Pel* dstLine   = dst;
305
6.20k
  const Pel* srcLine   = src;
306
6.20k
  const Pel* bndryLine = bndry;
307
308
55.8k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
49.6k
  {
310
49.6k
    const Pel* before  = bndryLine;
311
49.6k
    const Pel* behind  = srcLine;
312
49.6k
          Pel* currDst = dstLine;
313
248k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
198k
    {
315
198k
      const int valDiff   = *behind - *before;
316
198k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
595k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
397k
      {
320
397k
        scaledVal += valDiff;
321
397k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
397k
        currDst += outWidth;
323
397k
      }
324
198k
      before = behind;
325
198k
      behind += srcStep;
326
198k
    }
327
328
49.6k
    srcLine ++;
329
49.6k
    dstLine ++;
330
49.6k
    bndryLine ++;
331
49.6k
  }
332
6.20k
}
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.1k
{
301
73.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
73.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
73.1k
        Pel* dstLine   = dst;
305
73.1k
  const Pel* srcLine   = src;
306
73.1k
  const Pel* bndryLine = bndry;
307
308
1.84M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.77M
  {
310
1.77M
    const Pel* before  = bndryLine;
311
1.77M
    const Pel* behind  = srcLine;
312
1.77M
          Pel* currDst = dstLine;
313
15.9M
    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.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
28.3M
      {
320
28.3M
        scaledVal += valDiff;
321
28.3M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
28.3M
        currDst += outWidth;
323
28.3M
      }
324
14.1M
      before = behind;
325
14.1M
      behind += srcStep;
326
14.1M
    }
327
328
1.77M
    srcLine ++;
329
1.77M
    dstLine ++;
330
1.77M
    bndryLine ++;
331
1.77M
  }
332
73.1k
}
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.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
79.0M
      {
320
79.0M
        scaledVal += valDiff;
321
79.0M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
79.0M
        currDst += outWidth;
323
79.0M
      }
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
65.4k
{
301
65.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
65.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
65.4k
        Pel* dstLine   = dst;
305
65.4k
  const Pel* srcLine   = src;
306
65.4k
  const Pel* bndryLine = bndry;
307
308
4.25M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
4.18M
  {
310
4.18M
    const Pel* before  = bndryLine;
311
4.18M
    const Pel* behind  = srcLine;
312
4.18M
          Pel* currDst = dstLine;
313
37.6M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
33.4M
    {
315
33.4M
      const int valDiff   = *behind - *before;
316
33.4M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
301M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
267M
      {
320
267M
        scaledVal += valDiff;
321
267M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
267M
        currDst += outWidth;
323
267M
      }
324
33.4M
      before = behind;
325
33.4M
      behind += srcStep;
326
33.4M
    }
327
328
4.18M
    srcLine ++;
329
4.18M
    dstLine ++;
330
4.18M
    bndryLine ++;
331
4.18M
  }
332
65.4k
}
333
334
335
} // namespace vvenc
336
337
//! \}