Coverage Report

Created: 2026-10-17 06:56

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
4.62k
  : m_reducedBoundary       (nullptr)
62
4.62k
  , m_reducedBoundaryTransp (nullptr)
63
4.62k
  , m_inputOffset           ( 0 )
64
4.62k
  , m_inputOffsetTransp     ( 0 )
65
4.62k
  , m_refSamplesTop         (nullptr)
66
4.62k
  , m_refSamplesLeft        (nullptr)
67
4.62k
  , m_blockSize             ( 0, 0 )
68
4.62k
  , m_sizeId                ( 0 )
69
4.62k
  , m_reducedBdrySize       ( 0 )
70
4.62k
  , m_reducedPredSize       ( 0 )
71
4.62k
  , m_upsmpFactorHor        ( 0 )
72
4.62k
  , m_upsmpFactorVer        ( 0 )
73
4.62k
{
74
4.62k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
4.62k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
4.62k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
4.62k
{
80
4.62k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
4.62k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
4.62k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
40.4k
{
86
  // Step 1: Save block size and calculate dependent values
87
40.4k
  initPredBlockParams(block);
88
89
40.4k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
40.4k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
40.4k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
40.4k
  Pel* const topReduced = m_reducedBoundary;
96
40.4k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
40.4k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
40.4k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
40.4k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
40.4k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
202k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
161k
  {
105
161k
    topReducedTransposed[x] = topReduced[x];
106
161k
  }
107
202k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
161k
  {
109
161k
    leftReducedTransposed[y] = leftReduced[y];
110
161k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
40.4k
  m_inputOffset       = m_reducedBoundary[0];
114
40.4k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
40.4k
  const bool hasFirstCol = (m_sizeId < 2);
117
40.4k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
40.4k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
323k
  for (int i = 1; i < inputSize; i++)
120
283k
  {
121
283k
    m_reducedBoundary      [i] -= m_inputOffset;
122
283k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
283k
  }
124
40.4k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
242k
{
128
242k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
242k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
242k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
242k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
242k
  {
135
242k
    const int outputSize = m_reducedPredSize;
136
242k
    const int inputSize  = 2 * m_reducedBdrySize;
137
242k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
242k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
242k
    if( outputSize == 8)
141
235k
    {
142
235k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
235k
    }
144
6.17k
    else
145
6.17k
    {
146
6.17k
      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.17k
      else
151
6.17k
      {
152
6.17k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
6.17k
      }
154
6.17k
    }
155
242k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
242k
  if( needUpsampling )
159
242k
  {
160
242k
    const Pel* verSrc   = reducedPred;
161
242k
    SizeType verSrcStep = m_blockSize.width;
162
163
242k
    if( m_upsmpFactorHor > 1 )
164
233k
    {
165
233k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
233k
      verSrc = horDst;
167
233k
      verSrcStep *= m_upsmpFactorVer;
168
169
233k
      if( m_reducedPredSize == 4)
170
6.17k
      {
171
6.17k
        if( m_upsmpFactorHor == 2 )
172
6.17k
          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.17k
      }
178
227k
      else
179
227k
      {
180
227k
        if( m_upsmpFactorHor == 2 )
181
77.1k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
149k
        else if( m_upsmpFactorHor == 4 )
183
92.4k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
57.4k
        else
185
57.4k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
227k
      }
187
233k
    }
188
189
242k
    if( m_upsmpFactorVer > 1 )
190
231k
    {
191
231k
      if( m_reducedPredSize == 4)
192
6.17k
      {
193
6.17k
        if( m_upsmpFactorVer == 2 )
194
6.17k
          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.17k
      }
200
225k
      else
201
225k
      {
202
225k
        if( m_upsmpFactorVer == 2 )
203
70.4k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
155k
        else if( m_upsmpFactorVer == 4 )
205
97.6k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
57.4k
        else
207
57.4k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
225k
      }
209
231k
    }
210
242k
  }
211
242k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
40.4k
{
215
40.4k
  m_blockSize = block;
216
  // init size index
217
40.4k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
40.4k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
40.4k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
40.4k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
40.4k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
40.4k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
40.4k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
40.4k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
80.9k
{
235
80.9k
  if (dstLen < srcLen)
236
80.9k
  {
237
    // Create reduced boundary by downsampling
238
80.9k
    const SizeType downsmpFactor = srcLen / dstLen;
239
80.9k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
80.9k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
80.9k
    SizeType srcIdx = 0;
243
404k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
323k
    {
245
323k
      int sum = 0;
246
3.10M
      for( int k = 0; k < downsmpFactor; k++ )
247
2.77M
      {
248
2.77M
        sum += fullSrc[srcIdx++];
249
2.77M
      }
250
323k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
323k
    }
252
80.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
80.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
233k
{
266
233k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
233k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
233k
        Pel* dstLine   = dst;
270
233k
  const Pel* srcLine   = src;
271
233k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.07M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.84M
  {
275
1.84M
    const Pel* before  = bndryLine;
276
1.84M
    const Pel* behind  = srcLine;
277
1.84M
          Pel* currDst = dstLine;
278
16.4M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
14.6M
    {
280
14.6M
      const int valDiff   = *behind - *before;
281
14.6M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
77.7M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
63.1M
      {
284
63.1M
        scaledVal += valDiff;
285
63.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
63.1M
        currDst++;
287
63.1M
      }
288
14.6M
      before = behind;
289
14.6M
      behind ++;
290
14.6M
    }
291
292
1.84M
    srcLine   += predPredSize;
293
1.84M
    dstLine   += dstStride;
294
1.84M
    bndryLine += bndryStep;
295
1.84M
  }
296
233k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
6.17k
{
266
6.17k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
6.17k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
6.17k
        Pel* dstLine   = dst;
270
6.17k
  const Pel* srcLine   = src;
271
6.17k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
30.8k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
24.7k
  {
275
24.7k
    const Pel* before  = bndryLine;
276
24.7k
    const Pel* behind  = srcLine;
277
24.7k
          Pel* currDst = dstLine;
278
123k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
98.8k
    {
280
98.8k
      const int valDiff   = *behind - *before;
281
98.8k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
296k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
197k
      {
284
197k
        scaledVal += valDiff;
285
197k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
197k
        currDst++;
287
197k
      }
288
98.8k
      before = behind;
289
98.8k
      behind ++;
290
98.8k
    }
291
292
24.7k
    srcLine   += predPredSize;
293
24.7k
    dstLine   += dstStride;
294
24.7k
    bndryLine += bndryStep;
295
24.7k
  }
296
6.17k
}
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
77.1k
{
266
77.1k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
77.1k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
77.1k
        Pel* dstLine   = dst;
270
77.1k
  const Pel* srcLine   = src;
271
77.1k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
694k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
617k
  {
275
617k
    const Pel* before  = bndryLine;
276
617k
    const Pel* behind  = srcLine;
277
617k
          Pel* currDst = dstLine;
278
5.55M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.93M
    {
280
4.93M
      const int valDiff   = *behind - *before;
281
4.93M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
14.8M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
9.87M
      {
284
9.87M
        scaledVal += valDiff;
285
9.87M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
9.87M
        currDst++;
287
9.87M
      }
288
4.93M
      before = behind;
289
4.93M
      behind ++;
290
4.93M
    }
291
292
617k
    srcLine   += predPredSize;
293
617k
    dstLine   += dstStride;
294
617k
    bndryLine += bndryStep;
295
617k
  }
296
77.1k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
92.4k
{
266
92.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
92.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
92.4k
        Pel* dstLine   = dst;
270
92.4k
  const Pel* srcLine   = src;
271
92.4k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
832k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
739k
  {
275
739k
    const Pel* before  = bndryLine;
276
739k
    const Pel* behind  = srcLine;
277
739k
          Pel* currDst = dstLine;
278
6.65M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.91M
    {
280
5.91M
      const int valDiff   = *behind - *before;
281
5.91M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
29.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
23.6M
      {
284
23.6M
        scaledVal += valDiff;
285
23.6M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
23.6M
        currDst++;
287
23.6M
      }
288
5.91M
      before = behind;
289
5.91M
      behind ++;
290
5.91M
    }
291
292
739k
    srcLine   += predPredSize;
293
739k
    dstLine   += dstStride;
294
739k
    bndryLine += bndryStep;
295
739k
  }
296
92.4k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
57.4k
{
266
57.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
57.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
57.4k
        Pel* dstLine   = dst;
270
57.4k
  const Pel* srcLine   = src;
271
57.4k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
517k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
459k
  {
275
459k
    const Pel* before  = bndryLine;
276
459k
    const Pel* behind  = srcLine;
277
459k
          Pel* currDst = dstLine;
278
4.13M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
3.67M
    {
280
3.67M
      const int valDiff   = *behind - *before;
281
3.67M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
33.0M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
29.4M
      {
284
29.4M
        scaledVal += valDiff;
285
29.4M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
29.4M
        currDst++;
287
29.4M
      }
288
3.67M
      before = behind;
289
3.67M
      behind ++;
290
3.67M
    }
291
292
459k
    srcLine   += predPredSize;
293
459k
    dstLine   += dstStride;
294
459k
    bndryLine += bndryStep;
295
459k
  }
296
57.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
231k
{
301
231k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
231k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
231k
        Pel* dstLine   = dst;
305
231k
  const Pel* srcLine   = src;
306
231k
  const Pel* bndryLine = bndry;
307
308
8.05M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
7.82M
  {
310
7.82M
    const Pel* before  = bndryLine;
311
7.82M
    const Pel* behind  = srcLine;
312
7.82M
          Pel* currDst = dstLine;
313
70.2M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
62.3M
    {
315
62.3M
      const int valDiff   = *behind - *before;
316
62.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
402M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
339M
      {
320
339M
        scaledVal += valDiff;
321
339M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
339M
        currDst += outWidth;
323
339M
      }
324
62.3M
      before = behind;
325
62.3M
      behind += srcStep;
326
62.3M
    }
327
328
7.82M
    srcLine ++;
329
7.82M
    dstLine ++;
330
7.82M
    bndryLine ++;
331
7.82M
  }
332
231k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
6.17k
{
301
6.17k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
6.17k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
6.17k
        Pel* dstLine   = dst;
305
6.17k
  const Pel* srcLine   = src;
306
6.17k
  const Pel* bndryLine = bndry;
307
308
55.5k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
49.4k
  {
310
49.4k
    const Pel* before  = bndryLine;
311
49.4k
    const Pel* behind  = srcLine;
312
49.4k
          Pel* currDst = dstLine;
313
247k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
197k
    {
315
197k
      const int valDiff   = *behind - *before;
316
197k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
592k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
395k
      {
320
395k
        scaledVal += valDiff;
321
395k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
395k
        currDst += outWidth;
323
395k
      }
324
197k
      before = behind;
325
197k
      behind += srcStep;
326
197k
    }
327
328
49.4k
    srcLine ++;
329
49.4k
    dstLine ++;
330
49.4k
    bndryLine ++;
331
49.4k
  }
332
6.17k
}
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
70.4k
{
301
70.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
70.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
70.4k
        Pel* dstLine   = dst;
305
70.4k
  const Pel* srcLine   = src;
306
70.4k
  const Pel* bndryLine = bndry;
307
308
1.75M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.68M
  {
310
1.68M
    const Pel* before  = bndryLine;
311
1.68M
    const Pel* behind  = srcLine;
312
1.68M
          Pel* currDst = dstLine;
313
15.1M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
13.4M
    {
315
13.4M
      const int valDiff   = *behind - *before;
316
13.4M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
40.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
26.9M
      {
320
26.9M
        scaledVal += valDiff;
321
26.9M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
26.9M
        currDst += outWidth;
323
26.9M
      }
324
13.4M
      before = behind;
325
13.4M
      behind += srcStep;
326
13.4M
    }
327
328
1.68M
    srcLine ++;
329
1.68M
    dstLine ++;
330
1.68M
    bndryLine ++;
331
1.68M
  }
332
70.4k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
97.6k
{
301
97.6k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
97.6k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
97.6k
        Pel* dstLine   = dst;
305
97.6k
  const Pel* srcLine   = src;
306
97.6k
  const Pel* bndryLine = bndry;
307
308
2.51M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
2.41M
  {
310
2.41M
    const Pel* before  = bndryLine;
311
2.41M
    const Pel* behind  = srcLine;
312
2.41M
          Pel* currDst = dstLine;
313
21.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
19.3M
    {
315
19.3M
      const int valDiff   = *behind - *before;
316
19.3M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
96.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
77.1M
      {
320
77.1M
        scaledVal += valDiff;
321
77.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
77.1M
        currDst += outWidth;
323
77.1M
      }
324
19.3M
      before = behind;
325
19.3M
      behind += srcStep;
326
19.3M
    }
327
328
2.41M
    srcLine ++;
329
2.41M
    dstLine ++;
330
2.41M
    bndryLine ++;
331
2.41M
  }
332
97.6k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
57.4k
{
301
57.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
57.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
57.4k
        Pel* dstLine   = dst;
305
57.4k
  const Pel* srcLine   = src;
306
57.4k
  const Pel* bndryLine = bndry;
307
308
3.73M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
3.67M
  {
310
3.67M
    const Pel* before  = bndryLine;
311
3.67M
    const Pel* behind  = srcLine;
312
3.67M
          Pel* currDst = dstLine;
313
33.0M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
29.4M
    {
315
29.4M
      const int valDiff   = *behind - *before;
316
29.4M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
264M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
235M
      {
320
235M
        scaledVal += valDiff;
321
235M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
235M
        currDst += outWidth;
323
235M
      }
324
29.4M
      before = behind;
325
29.4M
      behind += srcStep;
326
29.4M
    }
327
328
3.67M
    srcLine ++;
329
3.67M
    dstLine ++;
330
3.67M
    bndryLine ++;
331
3.67M
  }
332
57.4k
}
333
334
335
} // namespace vvenc
336
337
//! \}