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/Unit.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     Unit.cpp
45
 *  \brief    defines unit as a set of blocks and basic unit types (coding, prediction, transform)
46
 */
47
48
#include "Unit.h"
49
#include "Picture.h"
50
#include "UnitTools.h"
51
#include "UnitPartitioner.h"
52
53
//! \ingroup CommonLib
54
//! \{
55
56
namespace vvenc {
57
58
 // ---------------------------------------------------------------------------
59
 // block method definitions
60
 // ---------------------------------------------------------------------------
61
62
void CompArea::xRecalcLumaToChroma()
63
12.5M
{
64
12.5M
  const uint32_t csx = getComponentScaleX(compID, chromaFormat);
65
12.5M
  const uint32_t csy = getComponentScaleY(compID, chromaFormat);
66
67
12.5M
  x      >>= csx;
68
12.5M
  y      >>= csy;
69
12.5M
  width  >>= csx;
70
12.5M
  height >>= csy;
71
12.5M
}
72
73
Position CompArea::chromaPos() const
74
56.6k
{
75
56.6k
  if (isLuma(compID))
76
0
  {
77
0
    uint32_t scaleX = getComponentScaleX(compID, chromaFormat);
78
0
    uint32_t scaleY = getComponentScaleY(compID, chromaFormat);
79
80
0
    return Position(x >> scaleX, y >> scaleY);
81
0
  }
82
56.6k
  else
83
56.6k
  {
84
56.6k
    return *this;
85
56.6k
  }
86
56.6k
}
87
88
Size CompArea::lumaSize() const
89
2.89M
{
90
2.89M
  if( isChroma( compID ) )
91
2.30M
  {
92
2.30M
    uint32_t scaleX = getComponentScaleX( compID, chromaFormat );
93
2.30M
    uint32_t scaleY = getComponentScaleY( compID, chromaFormat );
94
95
2.30M
    return Size( width << scaleX, height << scaleY );
96
2.30M
  }
97
587k
  else
98
587k
  {
99
587k
    return *this;
100
587k
  }
101
2.89M
}
102
103
Size CompArea::chromaSize() const
104
113k
{
105
113k
  if( isLuma( compID ) )
106
0
  {
107
0
    uint32_t scaleX = getComponentScaleX( compID, chromaFormat );
108
0
    uint32_t scaleY = getComponentScaleY( compID, chromaFormat );
109
110
0
    return Size( width >> scaleX, height >> scaleY );
111
0
  }
112
113k
  else
113
113k
  {
114
113k
    return *this;
115
113k
  }
116
113k
}
117
118
Position CompArea::lumaPos() const
119
1.34M
{
120
1.34M
  if( isChroma( compID ) )
121
1.06M
  {
122
1.06M
    uint32_t scaleX = getComponentScaleX( compID, chromaFormat );
123
1.06M
    uint32_t scaleY = getComponentScaleY( compID, chromaFormat );
124
125
1.06M
    return Position( x << scaleX, y << scaleY );
126
1.06M
  }
127
278k
  else
128
278k
  {
129
278k
    return *this;
130
278k
  }
131
1.34M
}
132
133
Position CompArea::compPos( const ComponentID compID ) const
134
0
{
135
0
  return isLuma( compID ) ? lumaPos() : chromaPos();
136
0
}
137
138
Position CompArea::chanPos( const ChannelType chType ) const
139
0
{
140
0
  return isLuma( chType ) ? lumaPos() : chromaPos();
141
0
}
142
143
// ---------------------------------------------------------------------------
144
// unit method definitions
145
// ---------------------------------------------------------------------------
146
147
860k
UnitArea::UnitArea(const ChromaFormat _chromaFormat) : chromaFormat(_chromaFormat) { }
148
149
4.71M
UnitArea::UnitArea(const ChromaFormat _chromaFormat, const Area& _area) : chromaFormat(_chromaFormat), blocks(getNumberValidComponents(_chromaFormat))
150
4.71M
{
151
4.71M
  const uint32_t numCh = getNumberValidComponents(chromaFormat);
152
153
17.2M
  for (uint32_t i = 0; i < numCh; i++)
154
12.5M
  {
155
12.5M
    new (&blocks[i]) CompArea(ComponentID(i), chromaFormat, _area, true);
156
12.5M
  }
157
4.71M
}
158
159
0
UnitArea::UnitArea(const ChromaFormat _chromaFormat, const CompArea&  blkY) : chromaFormat(_chromaFormat), blocks { blkY } {}
160
161
0
UnitArea::UnitArea(const ChromaFormat _chromaFormat,       CompArea&& blkY) : chromaFormat(_chromaFormat), blocks { std::forward<CompArea>(blkY) } {}
162
163
0
UnitArea::UnitArea(const ChromaFormat _chromaFormat, const CompArea&  blkY, const CompArea& blkCb, const CompArea& blkCr)  : chromaFormat(_chromaFormat), blocks { blkY, blkCb, blkCr } {}
164
165
0
UnitArea::UnitArea(const ChromaFormat _chromaFormat,       CompArea&& blkY,      CompArea&& blkCb,      CompArea&& blkCr) : chromaFormat(_chromaFormat), blocks { std::forward<CompArea>(blkY), std::forward<CompArea>(blkCb), std::forward<CompArea>(blkCr) } {}
166
167
bool UnitArea::contains(const UnitArea& other) const
168
543k
{
169
543k
  bool ret = true;
170
543k
  bool any = false;
171
172
543k
  for( const auto &blk : other.blocks )
173
1.63M
  {
174
1.63M
    if( blk.valid() && blocks[blk.compID].valid() )
175
1.34M
    {
176
1.34M
      ret &= blocks[blk.compID].contains( blk );
177
1.34M
      any = true;
178
1.34M
    }
179
1.63M
  }
180
181
543k
  return any && ret;
182
543k
}
183
184
bool UnitArea::contains( const UnitArea& other, const ChannelType chType ) const
185
56.6k
{
186
56.6k
  bool ret = true;
187
56.6k
  bool any = false;
188
189
56.6k
  for( const auto &blk : other.blocks )
190
169k
  {
191
169k
    if( toChannelType( blk.compID ) == chType && blk.valid() && blocks[blk.compID].valid() )
192
113k
    {
193
113k
      ret &= blocks[blk.compID].contains( blk );
194
113k
      any = true;
195
113k
    }
196
169k
  }
197
198
56.6k
  return any && ret;
199
56.6k
}
200
201
void UnitArea::repositionTo(const UnitArea& unitArea)
202
687k
{
203
2.74M
  for(uint32_t i = 0; i < blocks.size(); i++)
204
2.06M
  {
205
2.06M
    blocks[i].repositionTo(unitArea.blocks[i]);
206
2.06M
  }
207
687k
}
208
209
const UnitArea UnitArea::singleComp(const ComponentID compID) const
210
0
{
211
0
  UnitArea ret(chromaFormat);
212
213
0
  for (const auto &blk : blocks)
214
0
  {
215
0
    if (blk.compID == compID)
216
0
    {
217
0
      ret.blocks.push_back(blk);
218
0
    }
219
0
    else
220
0
    {
221
0
      ret.blocks.push_back(CompArea());
222
0
    }
223
0
  }
224
225
0
  return ret;
226
0
}
227
228
const UnitArea UnitArea::singleChan(const ChannelType chType) const
229
619k
{
230
619k
  UnitArea ret(chromaFormat);
231
232
619k
  for (const auto &blk : blocks)
233
1.85M
  {
234
1.85M
    if (toChannelType(blk.compID) == chType)
235
850k
    {
236
850k
      ret.blocks.push_back(blk);
237
850k
    }
238
1.00M
    else
239
1.00M
    {
240
1.00M
      ret.blocks.push_back(CompArea());
241
1.00M
    }
242
1.85M
  }
243
244
619k
  return ret;
245
619k
}
246
247
// ---------------------------------------------------------------------------
248
// coding unit method definitions
249
// ---------------------------------------------------------------------------
250
251
25.2k
CodingUnit::CodingUnit(const UnitArea& unit)                                : UnitArea(unit),                 cs(nullptr), slice(nullptr), chType( CH_L ), next(nullptr), firstTU(nullptr), lastTU(nullptr) { initData(); initPuData(); }
252
0
CodingUnit::CodingUnit(const ChromaFormat _chromaFormat, const Area& _area) : UnitArea(_chromaFormat, _area), cs(nullptr), slice(nullptr), chType( CH_L ), next(nullptr), firstTU(nullptr), lastTU(nullptr) { initData(); initPuData(); }
253
254
CodingUnit& CodingUnit::operator=( const CodingUnit& other )
255
155k
{
256
155k
  slice             = other.slice;
257
155k
  predMode          = other.predMode;
258
155k
  qtDepth           = other.qtDepth;
259
155k
  depth             = other.depth;
260
155k
  btDepth           = other.btDepth;
261
155k
  mtDepth           = other.mtDepth;
262
155k
  splitSeries       = other.splitSeries;
263
155k
  skip              = other.skip;
264
155k
  mmvdSkip          = other.mmvdSkip;
265
155k
  affine            = other.affine;
266
155k
  affineType        = other.affineType;
267
155k
  colorTransform    = other.colorTransform;
268
155k
  geo               = other.geo;
269
155k
  geo               = other.geo;
270
155k
  bdpcmM[CH_L]      = other.bdpcmM[CH_L];
271
155k
  bdpcmM[CH_C]      = other.bdpcmM[CH_C];
272
155k
  qp                = other.qp;
273
155k
  chromaQpAdj       = other.chromaQpAdj;
274
155k
  rootCbf           = other.rootCbf;
275
155k
  sbtInfo           = other.sbtInfo;
276
155k
  mtsFlag           = other.mtsFlag;
277
155k
  lfnstIdx          = other.lfnstIdx;
278
155k
  tileIdx           = other.tileIdx;
279
155k
  imv               = other.imv;
280
155k
  imvNumCand        = other.imvNumCand;
281
155k
  BcwIdx            = other.BcwIdx;
282
283
155k
  smvdMode          = other.smvdMode;
284
155k
  ispMode           = other.ispMode;
285
155k
  mipFlag           = other.mipFlag;
286
287
155k
  treeType          = other.treeType;
288
155k
  modeType          = other.modeType;
289
155k
  modeTypeSeries    = other.modeTypeSeries;
290
291
155k
  const IntraPredictionData& ipd = other;
292
155k
  *this = ipd;
293
294
155k
  const InterPredictionData& tpd = other;
295
155k
  *this = tpd;
296
155k
  return *this;
297
155k
}
298
299
void CodingUnit::initData()
300
313k
{
301
313k
  predMode          = NUMBER_OF_PREDICTION_MODES;
302
313k
  qtDepth           = 0;
303
313k
  depth             = 0;
304
313k
  btDepth           = 0;
305
313k
  mtDepth           = 0;
306
313k
  splitSeries       = 0;
307
313k
  skip              = false;
308
313k
  mmvdSkip          = false;
309
313k
  affine            = false;
310
313k
  affineType        = 0;
311
313k
  colorTransform    = false;
312
313k
  geo               = false;
313
313k
  bdpcmM[CH_L]      = 0;
314
313k
  bdpcmM[CH_C]      = 0;
315
313k
  qp                = 0;
316
313k
  chromaQpAdj       = 0;
317
313k
  rootCbf           = true;
318
313k
  sbtInfo           = 0;
319
313k
  mtsFlag           = 0;
320
313k
  lfnstIdx          = 0;
321
313k
  tileIdx           = 0;
322
313k
  imv               = IMV_OFF;
323
313k
  imvNumCand        = 0;
324
313k
  BcwIdx            = BCW_DEFAULT;
325
313k
  smvdMode          = 0;
326
313k
  ispMode           = 0;
327
313k
  mipFlag           = false;
328
329
313k
  treeType          = TREE_D;
330
313k
  modeType          = MODE_TYPE_ALL;
331
313k
  modeTypeSeries    = 0;
332
313k
  mcControl         = 0;
333
313k
}
334
335
336
337
338
// ---------------------------------------------------------------------------
339
// prediction unit method definitions
340
// ---------------------------------------------------------------------------
341
342
void CodingUnit::initPuData()
343
182k
{
344
  // intra data - need this default initialization for PCM
345
182k
  intraDir[0]       = DC_IDX;
346
182k
  intraDir[1]       = PLANAR_IDX;
347
182k
  multiRefIdx       = 0;
348
182k
  mipTransposedFlag = false;
349
350
  // inter data
351
182k
  mergeFlag         = false;
352
182k
  ciip              = false;
353
182k
  mvRefine          = false;
354
182k
  mmvdMergeFlag     = false;
355
182k
  mergeIdx          = MAX_UCHAR;
356
182k
  geoSplitDir       = MAX_UCHAR;
357
182k
  geoMergeIdx       = { MAX_SCHAR, MAX_SCHAR };
358
359
182k
  mcControl         = 0;
360
361
182k
  interDir          = MAX_UCHAR;
362
182k
  mmvdMergeIdx.val  = MmvdIdx::INVALID;
363
182k
  mergeType         = MRG_TYPE_DEFAULT_N;
364
365
182k
  if( mvdL0SubPu )
366
74.1k
  {
367
74.1k
    int maxDmvrMvds = std::max<int>( 1, lwidth() >> DMVR_SUBCU_SIZE_LOG2 ) * std::max<int>( 1, lheight() >> DMVR_SUBCU_SIZE_LOG2 );
368
442k
    for (uint32_t i = 0; i < maxDmvrMvds; i++)
369
368k
    {
370
368k
      mvdL0SubPu[i].setZero();
371
368k
    }
372
74.1k
  }
373
374
548k
  for (uint32_t i = 0; i < NUM_REF_PIC_LIST_01; i++)
375
365k
  {
376
365k
    mvpIdx[i] = MAX_UCHAR;
377
365k
    mvpNum[i] = MAX_UCHAR;
378
365k
    refIdx[i] = -1;
379
1.46M
    for( uint32_t j = 0; j < 3; j++ )
380
1.09M
    {
381
1.09M
      mvd[i][j].setZero();
382
1.09M
      mv [i][j].setZero();
383
1.09M
    }
384
365k
  }
385
182k
}
386
387
CodingUnit& CodingUnit::operator=( const IntraPredictionData& other )
388
155k
{
389
466k
  for( uint32_t i = 0; i < MAX_NUM_CH; i++ )
390
311k
  {
391
311k
    intraDir[ i ] = other.intraDir[ i ];
392
311k
  }
393
155k
  mipTransposedFlag = other.mipTransposedFlag;
394
155k
  multiRefIdx       = other.multiRefIdx;
395
155k
  return *this;
396
155k
}
397
398
CodingUnit& CodingUnit::operator=( const InterPredictionData& other )
399
155k
{
400
155k
  mergeFlag         = other.mergeFlag;
401
155k
  mergeIdx          = other.mergeIdx;
402
155k
  geoSplitDir       = other.geoSplitDir;
403
155k
  geoMergeIdx       = other.geoMergeIdx;
404
155k
  mmvdMergeFlag     = other.mmvdMergeFlag;
405
155k
  mmvdMergeIdx      = other.mmvdMergeIdx;
406
155k
  interDir          = other.interDir;
407
155k
  mergeType         = other.mergeType;
408
155k
  mvRefine          = other.mvRefine;
409
410
155k
  if( other.mergeFlag && mvdL0SubPu )
411
0
  {
412
0
    const int maxDmvrMvds = std::max<int>( 1, lwidth() >> DMVR_SUBCU_SIZE_LOG2 ) * std::max<int>( 1, lheight() >> DMVR_SUBCU_SIZE_LOG2 );
413
414
0
    memcpy( mvdL0SubPu, other.mvdL0SubPu, sizeof( Mv ) * maxDmvrMvds );
415
0
  }
416
417
466k
  for (uint32_t i = 0; i < NUM_REF_PIC_LIST_01; i++)
418
311k
  {
419
311k
    mvpIdx[i]   = other.mvpIdx[i];
420
311k
    mvpNum[i]   = other.mvpNum[i];
421
311k
    refIdx[i]   = other.refIdx[i];
422
1.24M
    for( uint32_t j = 0; j < 3; j++ )
423
933k
    {
424
933k
      mvd[i][j] = other.mvd[i][j];
425
933k
      mv [i][j] = other.mv [i][j];
426
933k
    }
427
311k
  }
428
155k
  ciip = other.ciip;
429
155k
  return *this;
430
155k
}
431
432
CodingUnit& CodingUnit::operator=( const MotionInfo& mi )
433
0
{
434
0
  interDir = mi.interDir();
435
436
0
  for( uint32_t i = 0; i < NUM_REF_PIC_LIST_01; i++ )
437
0
  {
438
0
    refIdx[i] = mi.miRefIdx[i];
439
0
    mv [i][0] = mi.mv[i];
440
0
  }
441
442
0
  return *this;
443
0
}
444
445
const MotionInfo& CodingUnit::getMotionInfo() const
446
0
{
447
0
  return cs->getMotionInfo( lumaPos() );
448
0
}
449
450
const MotionInfo& CodingUnit::getMotionInfo( const Position& pos ) const
451
0
{
452
0
  CHECKD( !Y().contains( pos ), "Trying to access motion info outsied of PU" );
453
0
  return cs->getMotionInfo( pos );
454
0
}
455
456
MotionBuf CodingUnit::getMotionBuf()
457
22.5k
{
458
22.5k
  return cs->getMotionBuf( *this );
459
22.5k
}
460
461
CMotionBuf CodingUnit::getMotionBuf() const
462
0
{
463
0
  return cs->getMotionBuf( *this );
464
0
}
465
466
467
// ---------------------------------------------------------------------------
468
// transform unit method definitions
469
// ---------------------------------------------------------------------------
470
471
0
TransformUnit::TransformUnit(const UnitArea& unit) : UnitArea(unit), cu(nullptr), cs(nullptr), chType( CH_L ), next( nullptr )
472
0
{
473
0
  for( unsigned i = 0; i < MAX_NUM_TBLOCKS; i++ )
474
0
  {
475
0
    m_coeffs[i] = nullptr;
476
0
  }
477
478
0
  initData();
479
0
}
480
481
0
TransformUnit::TransformUnit(const ChromaFormat _chromaFormat, const Area& _area) : UnitArea(_chromaFormat, _area), cu(nullptr), cs(nullptr), chType( CH_L ), next( nullptr )
482
0
{
483
0
  for( unsigned i = 0; i < MAX_NUM_TBLOCKS; i++ )
484
0
  {
485
0
    m_coeffs[i] = nullptr;
486
0
  }
487
488
0
  initData();
489
0
}
490
491
void TransformUnit::initData()
492
966k
{
493
3.86M
  for( unsigned i = 0; i < MAX_NUM_TBLOCKS; i++ )
494
2.89M
  {
495
2.89M
    cbf[i]      = 0;
496
2.89M
    mtsIdx[i]   = MTS_DCT2_DCT2;
497
2.89M
    lastPos[i]  = 0;
498
2.89M
  }
499
966k
  depth       = 0;
500
966k
  noResidual  = false;
501
966k
  jointCbCr   = 0;
502
966k
  chromaAdj   = 0;
503
966k
}
504
505
void TransformUnit::init(TCoeffSig** coeffs)
506
517k
{
507
517k
  uint32_t numBlocks = getNumberValidComponents( chromaFormat );
508
509
2.07M
  for (uint32_t i = 0; i < numBlocks; i++)
510
1.55M
  {
511
1.55M
    m_coeffs[i] = coeffs[i];
512
1.55M
  }
513
517k
}
514
515
TransformUnit& TransformUnit::operator=( const TransformUnit& other )
516
39.7k
{
517
39.7k
  CHECK( chromaFormat != other.chromaFormat, "Incompatible formats" );
518
519
39.7k
  unsigned numBlocks = getNumberValidTBlocks(*cs->pcv);
520
159k
  for( unsigned i = 0; i < numBlocks; i++ )
521
119k
  {
522
119k
    CHECKD( blocks[i].area() != other.blocks[i].area(), "Transformation units cover different areas" );
523
524
119k
    cbf[i]      = other.cbf[i];
525
119k
    bool cpyRsi = other.cbf[i] || ( i && other.jointCbCr && numBlocks > 1 && ( TU::getCbf( other, COMP_Cb ) || TU::getCbf( other, COMP_Cr ) ) );
526
119k
    if( m_coeffs[i] && other.m_coeffs[i] && m_coeffs[i] != other.m_coeffs[i] && cpyRsi )
527
3.81k
    {
528
3.81k
      uint32_t area = blocks[i].area();
529
3.81k
      memcpy( m_coeffs[i], other.m_coeffs[i], sizeof( TCoeffSig ) * area );
530
3.81k
    }
531
119k
    mtsIdx[i]   = other.mtsIdx[i];
532
119k
    lastPos[i]  = other.lastPos[i];
533
119k
  }
534
39.7k
  depth         = other.depth;
535
39.7k
  noResidual    = other.noResidual;
536
39.7k
  jointCbCr     = other.jointCbCr;
537
39.7k
  return *this;
538
39.7k
}
539
540
void TransformUnit::copyComponentFrom( const TransformUnit& other, const ComponentID i )
541
3.50M
{
542
3.50M
  CHECK( chromaFormat != other.chromaFormat, "Incompatible formats" );
543
3.50M
  CHECKD( blocks[i].area() != other.blocks[i].area(), "Transformation units cover different areas" );
544
545
3.50M
  bool cpyRsi = other.cbf[i] || ( i && other.jointCbCr && blocks.size() > 1 && ( TU::getCbf( other, COMP_Cb ) || TU::getCbf( other, COMP_Cr ) ) );
546
3.50M
  if( m_coeffs[i] && other.m_coeffs[i] && m_coeffs[i] != other.m_coeffs[i] && cpyRsi )
547
1.32M
  {
548
1.32M
    uint32_t area = blocks[i].area();
549
1.32M
    memcpy( m_coeffs[i], other.m_coeffs[i], sizeof( TCoeffSig ) * area );
550
1.32M
  }
551
552
3.50M
  cbf[i]      = other.cbf[i];
553
554
3.50M
  depth       = other.depth;
555
3.50M
  mtsIdx[i]   = other.mtsIdx[i];
556
3.50M
  noResidual  = other.noResidual;
557
3.50M
  jointCbCr   = isChroma( i ) ? other.jointCbCr : jointCbCr;
558
3.50M
  lastPos[i]  = other.lastPos[i];
559
3.50M
}
560
561
void TransformUnit::checkTuNoResidual( unsigned idx )
562
22.5k
{
563
22.5k
  if( CU::getSbtIdx( cu->sbtInfo ) == SBT_OFF_DCT )
564
22.5k
  {
565
22.5k
    return;
566
22.5k
  }
567
568
0
  if( ( CU::getSbtPos( cu->sbtInfo ) == SBT_POS0 && idx == 1 ) || ( CU::getSbtPos( cu->sbtInfo ) == SBT_POS1 && idx == 0 ) )
569
0
  {
570
0
    noResidual = true;
571
0
  }
572
0
}
573
574
int TransformUnit::getTbAreaAfterCoefZeroOut(ComponentID compID) const
575
875k
{
576
875k
  int tbArea = blocks[compID].width * blocks[compID].height;
577
875k
  int tbZeroOutWidth = blocks[compID].width;
578
875k
  int tbZeroOutHeight = blocks[compID].height;
579
580
875k
  if (cs->sps->MTS && cu->sbtInfo != 0 && blocks[compID].width <= 32 && blocks[compID].height <= 32 && compID == COMP_Y)
581
0
  {
582
0
    tbZeroOutWidth = (blocks[compID].width == 32) ? 16 : tbZeroOutWidth;
583
0
    tbZeroOutHeight = (blocks[compID].height == 32) ? 16 : tbZeroOutHeight;
584
0
  }
585
875k
  tbZeroOutWidth = std::min<int>(JVET_C0024_ZERO_OUT_TH, tbZeroOutWidth);
586
875k
  tbZeroOutHeight = std::min<int>(JVET_C0024_ZERO_OUT_TH, tbZeroOutHeight);
587
875k
  tbArea = tbZeroOutWidth * tbZeroOutHeight;
588
875k
  return tbArea;
589
875k
}
590
591
} // namespace vvenc
592
593
//! \}
594