Coverage Report

Created: 2026-10-17 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvdec/source/Lib/DecoderLib/DecLibRecon.h
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) 2018-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC 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
/** \file     DecLibRecon.h
44
    \brief    decoder class (header)
45
*/
46
47
#pragma once
48
49
#include "CommonLib/CommonDef.h"
50
#include "CommonLib/AdaptiveLoopFilter.h"
51
#include "CommonLib/LoopFilter.h"
52
#include "CommonLib/InterPrediction.h"
53
#include "CommonLib/IntraPrediction.h"
54
#include "CommonLib/Picture.h"
55
#include "CommonLib/RdCost.h"
56
#include "CommonLib/Reshape.h"
57
#include "CommonLib/SampleAdaptiveOffset.h"
58
#include "CommonLib/TrQuant.h"
59
60
#include "DecCu.h"
61
#include "Utilities/ThreadPool.h"
62
63
64
namespace vvdec
65
{
66
67
class DecLibRecon;
68
class InterPrediction;
69
class TrQuant;
70
71
//! \ingroup DecoderLib
72
//! \{
73
// ====================================================================================================================
74
// Class definition
75
// ====================================================================================================================
76
77
78
enum TaskType
79
{
80
  /*TRAFO=-1,*/ MIDER, MIDER_cont, LF_INIT, INTER, INTRA, INTRA_cont, RSP, LF_V, LF_V_cont, LF_H, PRESAO, SAO, SAO_cont, ALF, DONE, DMVR
81
};
82
using CtuState = std::atomic<TaskType>;
83
84
struct CommonTaskParam
85
{
86
  DecLibRecon&             decLib;
87
  CodingStructure*         cs           = nullptr;
88
  std::vector<CtuState>    ctuStates;
89
  std::vector<MotionHist>  perLineMiHist;
90
91
  bool                     doALF        = true;
92
93
1.13k
  explicit CommonTaskParam( DecLibRecon* dec ) : decLib( *dec ) {}
94
  void reset( CodingStructure& cs, TaskType ctuStartState, int tasksPerLine, bool doALF );
95
};
96
97
struct LineTaskParam
98
{
99
  CommonTaskParam& common;
100
  int              line;
101
};
102
103
struct CtuTaskParam
104
{
105
  CommonTaskParam& common;
106
  int              taskLine;
107
  int              taskCol;
108
  int              ctuStart;
109
  int              ctuEnd;
110
  int              numColPerTask;
111
  int              numTasksPerLine;
112
};
113
114
struct FinishPicTaskParam
115
{
116
  DecLibRecon* decLib;
117
  Picture*     pic;
118
119
1.13k
  FinishPicTaskParam() : decLib( nullptr ), pic( nullptr ) {}
120
0
  FinishPicTaskParam( DecLibRecon* _dec, Picture* _pic ) : decLib( _dec ), pic( _pic ) {}
121
};
122
123
struct PerThreadResource
124
{
125
  IntraPrediction m_cIntraPred;
126
  InterPrediction m_cInterPred;
127
  TrQuant         m_cTrQuant;
128
  Reshape         m_cReshaper;
129
  DecCu           m_cCuDecoder;
130
131
378
  explicit PerThreadResource() : m_cTrQuant( &m_cInterPred ) {}
132
11.7k
  explicit PerThreadResource( TrQuant& trQuant0 ) : m_cTrQuant( &m_cInterPred, &trQuant0 ) {}
133
};
134
135
/// decoder class
136
class DecLibRecon
137
{
138
private:
139
  PerThreadResource  **m_pcThreadResource;
140
  RdCost               m_cRdCost;
141
  LoopFilter           m_cLoopFilter;
142
  SampleAdaptiveOffset m_cSAO;
143
  AdaptiveLoopFilter   m_cALF;
144
145
  int                  m_numDecThreads = 0;
146
  ThreadPool*          m_decodeThreadPool;
147
  bool                 m_upscaleOutputEnabled = false;
148
149
  Picture*             m_currDecompPic = nullptr;
150
#if TRACE_ENABLE_ITT
151
  __itt_domain*        m_itt_decInst = nullptr;
152
#endif
153
154
  std::unique_ptr<Pel[], AlignedDeleter<Pel>> 
155
                       m_predBuf;
156
  ptrdiff_t            m_predBufSize     = 0;
157
  Mv*                  m_dmvrMvCache     = nullptr;
158
  size_t               m_dmvrMvCacheSize = 0;
159
  ptrdiff_t            m_num4x4Elements  = 0;
160
  LoopFilterParam*     m_loopFilterParam = nullptr;
161
  MotionInfo*          m_motionInfo      = nullptr;
162
163
  PelStorage           m_fltBuf;
164
165
  CommonTaskParam            commonTaskParam{ this };
166
  std::vector<LineTaskParam> tasksFinishMotion;
167
  std::vector<CtuTaskParam>  tasksCtu;
168
  FinishPicTaskParam         taskFinishPic;
169
  CBarrierVec                picBarriers;
170
171
public:
172
  DecLibRecon();
173
1.13k
  ~DecLibRecon() = default;
174
  CLASS_COPY_MOVE_DELETE( DecLibRecon )
175
176
  void create( ThreadPool* threadPool, unsigned instanceId, bool upscaleOutputEnabled );
177
  void destroy();
178
179
  void     decompressPicture( Picture* pcPic );
180
  Picture* waitForPrevDecompressedPic();
181
  void     cleanupOnException();
182
0
  Picture* getCurrPic() const { return m_currDecompPic; }
183
  void     swapBufs( CodingStructure& cs );
184
185
186
private:
187
  void borderExtPic       ( Picture* pic, const Picture* currPic );
188
  void createSubPicRefBufs( Picture* pic, const Picture* currPic );
189
190
  template<bool checkReadyState=false>
191
  static bool ctuTask( int tid, void* task_param );
192
};
193
194
}