Coverage Report

Created: 2026-09-02 06:43

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
18.3k
  : m_reducedBoundary       (nullptr)
62
18.3k
  , m_reducedBoundaryTransp (nullptr)
63
18.3k
  , m_inputOffset           ( 0 )
64
18.3k
  , m_inputOffsetTransp     ( 0 )
65
18.3k
  , m_refSamplesTop         (nullptr)
66
18.3k
  , m_refSamplesLeft        (nullptr)
67
18.3k
  , m_blockSize             ( 0, 0 )
68
18.3k
  , m_sizeId                ( 0 )
69
18.3k
  , m_reducedBdrySize       ( 0 )
70
18.3k
  , m_reducedPredSize       ( 0 )
71
18.3k
  , m_upsmpFactorHor        ( 0 )
72
18.3k
  , m_upsmpFactorVer        ( 0 )
73
18.3k
{
74
18.3k
  m_reducedBoundary       = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE ); 
75
18.3k
  m_reducedBoundaryTransp = (Pel*)xMalloc( Pel, MIP_MAX_INPUT_SIZE );
76
18.3k
}
77
78
MatrixIntraPrediction::~MatrixIntraPrediction()
79
18.3k
{
80
18.3k
  xFree( m_reducedBoundary );       m_reducedBoundary = nullptr;
81
18.3k
  xFree( m_reducedBoundaryTransp ); m_reducedBoundaryTransp = nullptr;
82
18.3k
}
83
84
void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth)
85
40.6k
{
86
  // Step 1: Save block size and calculate dependent values
87
40.6k
  initPredBlockParams(block);
88
89
40.6k
  m_refSamplesTop  = pSrc.bufAt(1, 0);
90
40.6k
  m_refSamplesLeft = pSrc.bufAt(1, 1);
91
92
  // Step 3: Compute the reduced boundary via Haar-downsampling (input for the prediction)
93
40.6k
  const int inputSize = 2 * m_reducedBdrySize;
94
95
40.6k
  Pel* const topReduced = m_reducedBoundary;
96
40.6k
  boundaryDownsampling1D( topReduced, m_refSamplesTop, block.width, m_reducedBdrySize );
97
98
40.6k
  Pel* const leftReduced = m_reducedBoundary + m_reducedBdrySize;
99
40.6k
  boundaryDownsampling1D( leftReduced, m_refSamplesLeft, block.height, m_reducedBdrySize );
100
101
40.6k
  Pel* const leftReducedTransposed = m_reducedBoundaryTransp;
102
40.6k
  Pel* const topReducedTransposed  = m_reducedBoundaryTransp + m_reducedBdrySize;
103
203k
  for( int x = 0; x < m_reducedBdrySize; x++ )
104
162k
  {
105
162k
    topReducedTransposed[x] = topReduced[x];
106
162k
  }
107
203k
  for( int y = 0; y < m_reducedBdrySize; y++ )
108
162k
  {
109
162k
    leftReducedTransposed[y] = leftReduced[y];
110
162k
  }
111
112
  // Step 4: Rebase the reduced boundary
113
40.6k
  m_inputOffset       = m_reducedBoundary[0];
114
40.6k
  m_inputOffsetTransp = m_reducedBoundaryTransp[0];
115
116
40.6k
  const bool hasFirstCol = (m_sizeId < 2);
117
40.6k
  m_reducedBoundary      [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset      ) : 0; // first column of matrix not needed for large blocks
118
40.6k
  m_reducedBoundaryTransp[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0;
119
325k
  for (int i = 1; i < inputSize; i++)
120
284k
  {
121
284k
    m_reducedBoundary      [i] -= m_inputOffset;
122
284k
    m_reducedBoundaryTransp[i] -= m_inputOffsetTransp;
123
284k
  }
124
40.6k
}
125
126
void MatrixIntraPrediction::predBlock(Pel* const result, const int modeIdx, const bool transpose, const int bitDepth)
127
243k
{
128
243k
  ALIGN_DATA( MEMORY_ALIGN_DEF_SIZE, Pel bufReducedPred[MIP_MAX_REDUCED_OUTPUT_SAMPLES] );
129
130
243k
  const bool       needUpsampling  = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 );
131
243k
  Pel* const       reducedPred     = needUpsampling ? bufReducedPred : result;
132
243k
  const Pel* const reducedBoundary = transpose ? m_reducedBoundaryTransp : m_reducedBoundary;
133
134
243k
  {
135
243k
    const int outputSize = m_reducedPredSize;
136
243k
    const int inputSize  = 2 * m_reducedBdrySize;
137
243k
    const int offset     = transpose ? m_inputOffsetTransp : m_inputOffset;
138
243k
    const int maxVal     = ( 1 << bitDepth ) - 1;
139
140
243k
    if( outputSize == 8)
141
237k
    {
142
237k
      g_pelBufOP.mipMatrixMul_8_8( reducedPred, reducedBoundary, &mipMatrix16x16[modeIdx][0][0], maxVal, offset, transpose );
143
237k
    }
144
5.98k
    else
145
5.98k
    {
146
5.98k
      if( inputSize == 4)
147
0
      {
148
0
        g_pelBufOP.mipMatrixMul_4_4( reducedPred, reducedBoundary, &mipMatrix4x4[modeIdx][0][0], maxVal, offset, transpose );
149
0
      }
150
5.98k
      else
151
5.98k
      {
152
5.98k
        g_pelBufOP.mipMatrixMul_8_4( reducedPred, reducedBoundary, &mipMatrix8x8[modeIdx][0][0], maxVal, offset, transpose );
153
5.98k
      }
154
5.98k
    }
155
243k
  }
156
157
  // Reduced prediction is transposed if ( transpose && needUpsampling ).
158
243k
  if( needUpsampling )
159
243k
  {
160
243k
    const Pel* verSrc   = reducedPred;
161
243k
    SizeType verSrcStep = m_blockSize.width;
162
163
243k
    if( m_upsmpFactorHor > 1 )
164
234k
    {
165
234k
      Pel* const horDst = result + (m_upsmpFactorVer - 1) * m_blockSize.width;
166
234k
      verSrc = horDst;
167
234k
      verSrcStep *= m_upsmpFactorVer;
168
169
234k
      if( m_reducedPredSize == 4)
170
5.98k
      {
171
5.98k
        if( m_upsmpFactorHor == 2 )
172
5.98k
          predictionUpsampling1DHor<4,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
173
0
        else if( m_upsmpFactorHor == 4 )
174
0
          predictionUpsampling1DHor<4,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
175
0
        else
176
0
          predictionUpsampling1DHor<4,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
177
5.98k
      }
178
228k
      else
179
228k
      {
180
228k
        if( m_upsmpFactorHor == 2 )
181
75.2k
          predictionUpsampling1DHor<8,1>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
182
153k
        else if( m_upsmpFactorHor == 4 )
183
93.4k
          predictionUpsampling1DHor<8,2>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
184
59.9k
        else
185
59.9k
          predictionUpsampling1DHor<8,3>( horDst, reducedPred, &m_refSamplesLeft[0], verSrcStep, m_upsmpFactorVer );
186
228k
      }
187
234k
    }
188
189
243k
    if( m_upsmpFactorVer > 1 )
190
233k
    {
191
233k
      if( m_reducedPredSize == 4)
192
5.98k
      {
193
5.98k
        if( m_upsmpFactorVer == 2 )
194
5.98k
          predictionUpsampling1DVer<4,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
195
0
        else if( m_upsmpFactorVer == 4 )
196
0
          predictionUpsampling1DVer<4,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
197
0
        else
198
0
          predictionUpsampling1DVer<4,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
199
5.98k
      }
200
227k
      else
201
227k
      {
202
227k
        if( m_upsmpFactorVer == 2 )
203
70.0k
          predictionUpsampling1DVer<8,1>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
204
157k
        else if( m_upsmpFactorVer == 4 )
205
97.6k
          predictionUpsampling1DVer<8,2>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
206
59.9k
        else
207
59.9k
          predictionUpsampling1DVer<8,3>( result, verSrc, &m_refSamplesTop[0], m_blockSize.width, verSrcStep );
208
227k
      }
209
233k
    }
210
243k
  }
211
243k
}
212
213
void MatrixIntraPrediction::initPredBlockParams(const Size& block)
214
40.6k
{
215
40.6k
  m_blockSize = block;
216
  // init size index
217
40.6k
  m_sizeId = getMipSizeId( m_blockSize );
218
219
  // init reduced boundary size
220
40.6k
  m_reducedBdrySize = (m_sizeId == 0) ? 2 : 4;
221
222
  // init reduced prediction size
223
40.6k
  m_reducedPredSize = ( m_sizeId < 2 ) ? 4 : 8;
224
225
  // init upsampling factors
226
40.6k
  m_upsmpFactorHor = m_blockSize.width  / m_reducedPredSize;
227
40.6k
  m_upsmpFactorVer = m_blockSize.height / m_reducedPredSize;
228
229
40.6k
  CHECKD( (m_upsmpFactorHor < 1) || ((m_upsmpFactorHor & (m_upsmpFactorHor - 1)) != 0), "Need power of two horizontal upsampling factor." );
230
40.6k
  CHECKD( (m_upsmpFactorVer < 1) || ((m_upsmpFactorVer & (m_upsmpFactorVer - 1)) != 0), "Need power of two vertical upsampling factor." );
231
40.6k
}
232
233
void MatrixIntraPrediction::boundaryDownsampling1D(Pel* reducedDst, const Pel* const fullSrc, const SizeType srcLen, const SizeType dstLen)
234
81.3k
{
235
81.3k
  if (dstLen < srcLen)
236
81.3k
  {
237
    // Create reduced boundary by downsampling
238
81.3k
    const SizeType downsmpFactor = srcLen / dstLen;
239
81.3k
    const int log2DownsmpFactor = floorLog2(downsmpFactor);
240
81.3k
    const int roundingOffset = (1 << (log2DownsmpFactor - 1));
241
242
81.3k
    SizeType srcIdx = 0;
243
406k
    for( SizeType dstIdx = 0; dstIdx < dstLen; dstIdx++ )
244
325k
    {
245
325k
      int sum = 0;
246
3.15M
      for( int k = 0; k < downsmpFactor; k++ )
247
2.82M
      {
248
2.82M
        sum += fullSrc[srcIdx++];
249
2.82M
      }
250
325k
      reducedDst[dstIdx] = (sum + roundingOffset) >> log2DownsmpFactor;
251
325k
    }
252
81.3k
  }
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
81.3k
}
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
234k
{
266
234k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
234k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
234k
        Pel* dstLine   = dst;
270
234k
  const Pel* srcLine   = src;
271
234k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
2.08M
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
1.85M
  {
275
1.85M
    const Pel* before  = bndryLine;
276
1.85M
    const Pel* behind  = srcLine;
277
1.85M
          Pel* currDst = dstLine;
278
16.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
14.7M
    {
280
14.7M
      const int valDiff   = *behind - *before;
281
14.7M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
79.1M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
64.4M
      {
284
64.4M
        scaledVal += valDiff;
285
64.4M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
64.4M
        currDst++;
287
64.4M
      }
288
14.7M
      before = behind;
289
14.7M
      behind ++;
290
14.7M
    }
291
292
1.85M
    srcLine   += predPredSize;
293
1.85M
    dstLine   += dstStride;
294
1.85M
    bndryLine += bndryStep;
295
1.85M
  }
296
234k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
5.98k
{
266
5.98k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
5.98k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
5.98k
        Pel* dstLine   = dst;
270
5.98k
  const Pel* srcLine   = src;
271
5.98k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
29.9k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
23.9k
  {
275
23.9k
    const Pel* before  = bndryLine;
276
23.9k
    const Pel* behind  = srcLine;
277
23.9k
          Pel* currDst = dstLine;
278
119k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
95.7k
    {
280
95.7k
      const int valDiff   = *behind - *before;
281
95.7k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
287k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
191k
      {
284
191k
        scaledVal += valDiff;
285
191k
        *currDst   = scaledVal >> log2UpsmpFactor;
286
191k
        currDst++;
287
191k
      }
288
95.7k
      before = behind;
289
95.7k
      behind ++;
290
95.7k
    }
291
292
23.9k
    srcLine   += predPredSize;
293
23.9k
    dstLine   += dstStride;
294
23.9k
    bndryLine += bndryStep;
295
23.9k
  }
296
5.98k
}
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<4u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
75.2k
{
266
75.2k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
75.2k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
75.2k
        Pel* dstLine   = dst;
270
75.2k
  const Pel* srcLine   = src;
271
75.2k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
677k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
602k
  {
275
602k
    const Pel* before  = bndryLine;
276
602k
    const Pel* behind  = srcLine;
277
602k
          Pel* currDst = dstLine;
278
5.41M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
4.81M
    {
280
4.81M
      const int valDiff   = *behind - *before;
281
4.81M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
14.4M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
9.63M
      {
284
9.63M
        scaledVal += valDiff;
285
9.63M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
9.63M
        currDst++;
287
9.63M
      }
288
4.81M
      before = behind;
289
4.81M
      behind ++;
290
4.81M
    }
291
292
602k
    srcLine   += predPredSize;
293
602k
    dstLine   += dstStride;
294
602k
    bndryLine += bndryStep;
295
602k
  }
296
75.2k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
93.4k
{
266
93.4k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
93.4k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
93.4k
        Pel* dstLine   = dst;
270
93.4k
  const Pel* srcLine   = src;
271
93.4k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
841k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
747k
  {
275
747k
    const Pel* before  = bndryLine;
276
747k
    const Pel* behind  = srcLine;
277
747k
          Pel* currDst = dstLine;
278
6.73M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
5.98M
    {
280
5.98M
      const int valDiff   = *behind - *before;
281
5.98M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
29.9M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
23.9M
      {
284
23.9M
        scaledVal += valDiff;
285
23.9M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
23.9M
        currDst++;
287
23.9M
      }
288
5.98M
      before = behind;
289
5.98M
      behind ++;
290
5.98M
    }
291
292
747k
    srcLine   += predPredSize;
293
747k
    dstLine   += dstStride;
294
747k
    bndryLine += bndryStep;
295
747k
  }
296
93.4k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DHor<8u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
265
59.9k
{
266
59.9k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
267
59.9k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
268
269
59.9k
        Pel* dstLine   = dst;
270
59.9k
  const Pel* srcLine   = src;
271
59.9k
  const Pel* bndryLine = bndry + bndryStep - 1;
272
273
539k
  for( SizeType idxOrthDim = 0; idxOrthDim < predPredSize; idxOrthDim++ )
274
479k
  {
275
479k
    const Pel* before  = bndryLine;
276
479k
    const Pel* behind  = srcLine;
277
479k
          Pel* currDst = dstLine;
278
4.31M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < predPredSize; idxUpsmpDim++ )
279
3.83M
    {
280
3.83M
      const int valDiff   = *behind - *before;
281
3.83M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
282
34.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
283
30.7M
      {
284
30.7M
        scaledVal += valDiff;
285
30.7M
        *currDst   = scaledVal >> log2UpsmpFactor;
286
30.7M
        currDst++;
287
30.7M
      }
288
3.83M
      before = behind;
289
3.83M
      behind ++;
290
3.83M
    }
291
292
479k
    srcLine   += predPredSize;
293
479k
    dstLine   += dstStride;
294
479k
    bndryLine += bndryStep;
295
479k
  }
296
59.9k
}
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
233k
{
301
233k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
233k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
233k
        Pel* dstLine   = dst;
305
233k
  const Pel* srcLine   = src;
306
233k
  const Pel* bndryLine = bndry;
307
308
8.22M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
7.99M
  {
310
7.99M
    const Pel* before  = bndryLine;
311
7.99M
    const Pel* behind  = srcLine;
312
7.99M
          Pel* currDst = dstLine;
313
71.7M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
63.7M
    {
315
63.7M
      const int valDiff   = *behind - *before;
316
63.7M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
414M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
350M
      {
320
350M
        scaledVal += valDiff;
321
350M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
350M
        currDst += outWidth;
323
350M
      }
324
63.7M
      before = behind;
325
63.7M
      behind += srcStep;
326
63.7M
    }
327
328
7.99M
    srcLine ++;
329
7.99M
    dstLine ++;
330
7.99M
    bndryLine ++;
331
7.99M
  }
332
233k
}
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
5.98k
{
301
5.98k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
5.98k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
5.98k
        Pel* dstLine   = dst;
305
5.98k
  const Pel* srcLine   = src;
306
5.98k
  const Pel* bndryLine = bndry;
307
308
53.8k
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
47.8k
  {
310
47.8k
    const Pel* before  = bndryLine;
311
47.8k
    const Pel* behind  = srcLine;
312
47.8k
          Pel* currDst = dstLine;
313
239k
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
191k
    {
315
191k
      const int valDiff   = *behind - *before;
316
191k
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
574k
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
382k
      {
320
382k
        scaledVal += valDiff;
321
382k
        *currDst   = scaledVal >> log2UpsmpFactor;
322
382k
        currDst += outWidth;
323
382k
      }
324
191k
      before = behind;
325
191k
      behind += srcStep;
326
191k
    }
327
328
47.8k
    srcLine ++;
329
47.8k
    dstLine ++;
330
47.8k
    bndryLine ++;
331
47.8k
  }
332
5.98k
}
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 2u>(short*, short const*, short const*, unsigned int, unsigned int)
Unexecuted instantiation: void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<4u, 3u>(short*, short const*, short const*, unsigned int, unsigned int)
void vvenc::MatrixIntraPrediction::predictionUpsampling1DVer<8u, 1u>(short*, short const*, short const*, unsigned int, unsigned int)
Line
Count
Source
300
70.0k
{
301
70.0k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
70.0k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
70.0k
        Pel* dstLine   = dst;
305
70.0k
  const Pel* srcLine   = src;
306
70.0k
  const Pel* bndryLine = bndry;
307
308
1.76M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
1.69M
  {
310
1.69M
    const Pel* before  = bndryLine;
311
1.69M
    const Pel* behind  = srcLine;
312
1.69M
          Pel* currDst = dstLine;
313
15.2M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
13.5M
    {
315
13.5M
      const int valDiff   = *behind - *before;
316
13.5M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
40.7M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
27.1M
      {
320
27.1M
        scaledVal += valDiff;
321
27.1M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
27.1M
        currDst += outWidth;
323
27.1M
      }
324
13.5M
      before = behind;
325
13.5M
      behind += srcStep;
326
13.5M
    }
327
328
1.69M
    srcLine ++;
329
1.69M
    dstLine ++;
330
1.69M
    bndryLine ++;
331
1.69M
  }
332
70.0k
}
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.5M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
77.2M
      {
320
77.2M
        scaledVal += valDiff;
321
77.2M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
77.2M
        currDst += outWidth;
323
77.2M
      }
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
59.9k
{
301
59.9k
  const int roundingOffset   = 1 << (log2UpsmpFactor - 1);
302
59.9k
  const SizeType upsmpFactor = 1 << log2UpsmpFactor;
303
304
59.9k
        Pel* dstLine   = dst;
305
59.9k
  const Pel* srcLine   = src;
306
59.9k
  const Pel* bndryLine = bndry;
307
308
3.89M
  for( SizeType idxOrthDim = 0; idxOrthDim < outWidth; idxOrthDim++ )
309
3.83M
  {
310
3.83M
    const Pel* before  = bndryLine;
311
3.83M
    const Pel* behind  = srcLine;
312
3.83M
          Pel* currDst = dstLine;
313
34.5M
    for( SizeType idxUpsmpDim = 0; idxUpsmpDim < inHeight; idxUpsmpDim++ )
314
30.7M
    {
315
30.7M
      const int valDiff   = *behind - *before;
316
30.7M
            int scaledVal = ( ( *before ) << log2UpsmpFactor ) + roundingOffset;
317
318
276M
      for( SizeType pos = 0; pos < upsmpFactor; pos++)
319
245M
      {
320
245M
        scaledVal += valDiff;
321
245M
        *currDst   = scaledVal >> log2UpsmpFactor;
322
245M
        currDst += outWidth;
323
245M
      }
324
30.7M
      before = behind;
325
30.7M
      behind += srcStep;
326
30.7M
    }
327
328
3.83M
    srcLine ++;
329
3.83M
    dstLine ++;
330
3.83M
    bndryLine ++;
331
3.83M
  }
332
59.9k
}
333
334
335
} // namespace vvenc
336
337
//! \}