Coverage Report

Created: 2026-12-01 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvdec/source/Lib/CommonLib/Buffer.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     Buffer.h
44
 *  \brief    Low-overhead class describing 2D memory layout
45
 */
46
47
#pragma once
48
49
#include "Common.h"
50
#include "CommonDef.h"
51
#include "ChromaFormat.h"
52
#include "MotionInfo.h"
53
54
#include <string.h>
55
#include <type_traits>
56
#include <utility>
57
58
namespace vvdec
59
{
60
61
struct CodingUnit;
62
63
#if ENABLE_SIMD_OPT_BUFFER && defined(TARGET_SIMD_X86)
64
using namespace x86_simd;
65
#endif
66
#if ENABLE_SIMD_OPT_BUFFER && defined(TARGET_SIMD_ARM)
67
using namespace arm_simd;
68
#endif
69
70
struct PelBufferOps
71
{
72
  PelBufferOps();
73
74
#if defined( TARGET_SIMD_X86 ) && ENABLE_SIMD_OPT_BUFFER
75
  void initPelBufOpsX86();
76
  template<X86_VEXT vext>
77
  void _initPelBufOpsX86();
78
#endif
79
80
#if defined( TARGET_SIMD_ARM ) && ENABLE_SIMD_OPT_BUFFER
81
  void initPelBufOpsARM();
82
  template<ARM_VEXT vext>
83
  void _initPelBufOpsARM();
84
#endif
85
86
  void ( *addAvg4 )       ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height,            int shift, int offset,      const ClpRng& clpRng );
87
  void ( *addAvg8 )       ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height,            int shift, int offset,      const ClpRng& clpRng );
88
  void ( *addAvg16 )      ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height,            int shift, int offset,      const ClpRng& clpRng );
89
  void ( *reco4 )         ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height,                                        const ClpRng& clpRng );
90
  void ( *reco8 )         ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height,                                        const ClpRng& clpRng );
91
  void ( *linTf4 )        ( const Pel* src0, ptrdiff_t src0Stride,                                        Pel *dst, ptrdiff_t dstStride, int width, int height, int scale, int shift, int offset,      const ClpRng& clpRng, bool bClip );
92
  void ( *linTf8 )        ( const Pel* src0, ptrdiff_t src0Stride,                                        Pel *dst, ptrdiff_t dstStride, int width, int height, int scale, int shift, int offset,      const ClpRng& clpRng, bool bClip );
93
  void ( *wghtAvg4 )      ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height, int shift, int offset, int w0, int w1, const ClpRng& clpRng );
94
  void ( *wghtAvg8 )      ( const Pel* src0, ptrdiff_t src0Stride, const Pel* src1, ptrdiff_t src1Stride, Pel *dst, ptrdiff_t dstStride, int width, int height, int shift, int offset, int w0, int w1, const ClpRng& clpRng );
95
  void ( *copyBuffer  )    ( const char*src,  ptrdiff_t srcStride,        char* dst, ptrdiff_t  dstStride,                                int width, int height );
96
  void ( *transpose4x4 )  ( const Pel* src,  ptrdiff_t srcStride, Pel* dst, ptrdiff_t dstStride );
97
  void ( *transpose8x8 )  ( const Pel* src,  ptrdiff_t srcStride, Pel* dst, ptrdiff_t dstStride );
98
  void ( *applyLut )      (       Pel* ptr,  ptrdiff_t ptrStride, int width, int height, const Pel* lut );
99
  void ( *rspFwd )        (       Pel* ptr,  ptrdiff_t ptrStride, int width, int height, const int bd,                   const Pel OrgCW,  const Pel* LmcsPivot, const Pel* ScaleCoeff, const Pel* InputPivot );
100
  void ( *rspBcw )        (       Pel* ptr,  ptrdiff_t ptrStride, int width, int height, const int bd, const int minBin, const int maxBin, const Pel* LmcsPivot, const Pel* InvScCoeff, const Pel* InputPivot );
101
  void ( *scaleSignal )   (       Pel* ptr,  ptrdiff_t ptrStride, int width, int height, const int scale, const int bd );
102
  void ( *fillN_CU )      (       CodingUnit** ptr, ptrdiff_t ptrStride, int width, int height, CodingUnit* cuPtr );
103
  void ( *fillN_MotionInfo )(     MotionInfo*  ptr, ptrdiff_t ptrStride, int width, int height, const MotionInfo& val );
104
105
  void (*sampleRateConv)  ( const std::pair<int, int> scalingRatio, const std::pair<int, int> compScale,
106
                            const Pel* orgSrc, const ptrdiff_t orgStride, const int orgWidth, const int orgHeight,
107
                            const int beforeScaleLeftOffset, const int beforeScaleTopOffset,
108
                            Pel* scaledSrc, const ptrdiff_t scaledStride, const int scaledWidth, const int scaledHeight,
109
                            const int afterScaleLeftOffset, const int afterScaleTopOffset,
110
                            const int bitDepth, const bool useLumaFilter, const bool horCollocatedPositionFlag, const bool verCollocatedPositionFlag );
111
};
112
113
extern PelBufferOps g_pelBufOP;
114
115
void sampleRateConvCore( const std::pair<int, int> scalingRatio, const std::pair<int, int> compScale,
116
                         const Pel* orgSrc, const ptrdiff_t orgStride, const int orgWidth, const int orgHeight,
117
                         const int beforeScaleLeftOffset, const int beforeScaleTopOffset,
118
                         Pel* scaledSrc, const ptrdiff_t scaledStride, const int scaledWidth, const int scaledHeight,
119
                         const int afterScaleLeftOffset, const int afterScaleTopOffset,
120
                         const int bitDepth, const bool useLumaFilter,
121
                         const bool horCollocatedPositionFlag, const bool verCollocatedPositionFlag );
122
123
0
#define INCX( ptr, stride ) { ptr++; }
124
0
#define INCY( ptr, stride ) { ptr += ( stride ); }
125
0
#define OFFSETX( ptr, stride, x ) { ptr += ( x ); }
126
0
#define OFFSETY( ptr, stride, y ) { ptr += ( y ) * ( stride ); }
127
0
#define OFFSET( ptr, stride, x, y ) { ptr += ( x ) + ( y ) * ( stride ); }
128
0
#define GET_OFFSETX( ptr, stride, x ) ( ( ptr ) + ( x ) )
129
0
#define GET_OFFSETY( ptr, stride, y ) ( ( ptr ) + ( y ) * ( stride ) )
130
0
#define GET_OFFSET( ptr, stride, x, y ) ( ( ptr ) + ( x ) + ( y ) * ( stride ) )
131
132
class Window;
133
struct BitDepths;
134
135
template<typename T>
136
struct AreaBuf : public Size
137
{
138
  T*        buf;
139
  ptrdiff_t stride;
140
141
183k
  AreaBuf()                                                                                     : Size(),                  buf( NULL ), stride( 0 )          { }
Unexecuted instantiation: vvdec::AreaBuf<short const>::AreaBuf()
vvdec::AreaBuf<short>::AreaBuf()
Line
Count
Source
141
183k
  AreaBuf()                                                                                     : Size(),                  buf( NULL ), stride( 0 )          { }
Unexecuted instantiation: vvdec::AreaBuf<vvdec::MotionInfo>::AreaBuf()
142
0
  AreaBuf( T *_buf, const Size &size )                                                          : Size( size ),            buf( _buf ), stride( size.width ) { }
143
0
  AreaBuf( T *_buf, const ptrdiff_t &_stride, const Size &size )                                : Size( size ),            buf( _buf ), stride( _stride )    { }
Unexecuted instantiation: vvdec::AreaBuf<short const>::AreaBuf(short const*, long const&, vvdec::Size const&)
Unexecuted instantiation: vvdec::AreaBuf<short>::AreaBuf(short*, long const&, vvdec::Size const&)
144
0
  AreaBuf( T *_buf, const SizeType &_width, const SizeType &_height )                           : Size( _width, _height ), buf( _buf ), stride( _width )     { }
Unexecuted instantiation: vvdec::AreaBuf<short>::AreaBuf(short*, unsigned int const&, unsigned int const&)
Unexecuted instantiation: vvdec::AreaBuf<short const>::AreaBuf(short const*, unsigned int const&, unsigned int const&)
Unexecuted instantiation: vvdec::AreaBuf<int>::AreaBuf(int*, unsigned int const&, unsigned int const&)
145
0
  AreaBuf( T *_buf, const ptrdiff_t &_stride, const SizeType &_width, const SizeType &_height ) : Size( _width, _height ), buf( _buf ), stride( _stride )    { }
Unexecuted instantiation: vvdec::AreaBuf<short>::AreaBuf(short*, long const&, unsigned int const&, unsigned int const&)
Unexecuted instantiation: vvdec::AreaBuf<vvdec::MotionInfo>::AreaBuf(vvdec::MotionInfo*, long const&, unsigned int const&, unsigned int const&)
Unexecuted instantiation: vvdec::AreaBuf<vvdec::MotionInfo const>::AreaBuf(vvdec::MotionInfo const*, long const&, unsigned int const&, unsigned int const&)
Unexecuted instantiation: vvdec::AreaBuf<short const>::AreaBuf(short const*, long const&, unsigned int const&, unsigned int const&)
146
147
  AreaBuf( const AreaBuf& )  = default;
148
  AreaBuf(       AreaBuf&& ) = default;
149
  AreaBuf& operator=( const AreaBuf& )  = default;
150
  AreaBuf& operator=(       AreaBuf&& ) = default;
151
152
  // conversion from AreaBuf<const T> to AreaBuf<T>
153
  template<bool T_IS_CONST = std::is_const<T>::value>
154
0
  AreaBuf( const AreaBuf<typename std::remove_const_t<T>>& other, std::enable_if_t<T_IS_CONST>* = 0) : Size( other ), buf( other.buf ), stride( other.stride ) { }
Unexecuted instantiation: vvdec::AreaBuf<short const>::AreaBuf<true>(vvdec::AreaBuf<short> const&, std::__1::enable_if<true, void>::type*)
Unexecuted instantiation: vvdec::AreaBuf<int const>::AreaBuf<true>(vvdec::AreaBuf<int> const&, std::__1::enable_if<true, void>::type*)
155
156
  void fill                 ( const T &val );
157
  void memset               ( const int val );
158
159
  void copyFrom             ( const AreaBuf<const T> &other );
160
  
161
  void reconstruct          ( const AreaBuf<const T> &pred, const AreaBuf<const T> &resi, const ClpRng& clpRng);
162
  
163
  void subtract             ( const AreaBuf<const T> &other );
164
  void extendBorderPel      ( unsigned margin );
165
  void extendBorderPel      ( unsigned margin, bool left, bool right, bool top, bool bottom );
166
  void addWeightedAvg       ( const AreaBuf<const T> &other1, const AreaBuf<const T> &other2, const ClpRng& clpRng, const int8_t bcwIdx);
167
  void addAvg               ( const AreaBuf<const T> &other1, const AreaBuf<const T> &other2, const ClpRng& clpRng );
168
  void padBorderPel         ( unsigned marginX, unsigned marginY, int dir );
169
  
170
  void linearTransform      ( const int scale, const int shift, const int offset, bool bClip, const ClpRng& clpRng );
171
172
  void transposedFrom       ( const AreaBuf<const T> &other );
173
174
  void scaleSignal          ( const int scale, const ClpRng& clpRng );
175
176
0
        T& at( const int &x, const int &y )          { return buf[y * stride + x]; }
Unexecuted instantiation: vvdec::AreaBuf<vvdec::MotionInfo>::at(int const&, int const&)
Unexecuted instantiation: vvdec::AreaBuf<short>::at(int const&, int const&)
177
0
  const T& at( const int &x, const int &y ) const    { return buf[y * stride + x]; }
Unexecuted instantiation: vvdec::AreaBuf<short const>::at(int const&, int const&) const
Unexecuted instantiation: vvdec::AreaBuf<int const>::at(int const&, int const&) const
178
179
        T& at( const Position &pos )                 { return buf[pos.y * stride + pos.x]; }
180
  const T& at( const Position &pos ) const           { return buf[pos.y * stride + pos.x]; }
181
182
183
0
        T* bufAt( const int &x, const int &y )       { return GET_OFFSET( buf, stride,     x,     y ); }
Unexecuted instantiation: vvdec::AreaBuf<short>::bufAt(int const&, int const&)
Unexecuted instantiation: vvdec::AreaBuf<short const>::bufAt(int const&, int const&)
184
0
  const T* bufAt( const int &x, const int &y ) const { return GET_OFFSET( buf, stride,     x,     y ); }
Unexecuted instantiation: vvdec::AreaBuf<short>::bufAt(int const&, int const&) const
Unexecuted instantiation: vvdec::AreaBuf<short const>::bufAt(int const&, int const&) const
185
0
        T* bufAt( const Position& pos )              { return GET_OFFSET( buf, stride, pos.x, pos.y ); }
Unexecuted instantiation: vvdec::AreaBuf<short>::bufAt(vvdec::Position const&)
Unexecuted instantiation: vvdec::AreaBuf<short const>::bufAt(vvdec::Position const&)
186
0
  const T* bufAt( const Position& pos ) const        { return GET_OFFSET( buf, stride, pos.x, pos.y ); }
Unexecuted instantiation: vvdec::AreaBuf<short>::bufAt(vvdec::Position const&) const
Unexecuted instantiation: vvdec::AreaBuf<short const>::bufAt(vvdec::Position const&) const
187
188
0
  AreaBuf<      T> subBuf( const Area &area )                                                         { return subBuf( area.pos(), area.size() ); }
189
0
  AreaBuf<const T> subBuf( const Area &area )                                                   const { return subBuf( area.pos(), area.size() ); }
Unexecuted instantiation: vvdec::AreaBuf<short>::subBuf(vvdec::Area const&) const
Unexecuted instantiation: vvdec::AreaBuf<short const>::subBuf(vvdec::Area const&) const
190
0
  AreaBuf<      T> subBuf( const Position &pos, const Size &size )                                    { return AreaBuf<      T>( bufAt( pos  ), stride, size   ); }
191
0
  AreaBuf<const T> subBuf( const Position &pos, const Size &size )                              const { return AreaBuf<const T>( bufAt( pos  ), stride, size   ); }
Unexecuted instantiation: vvdec::AreaBuf<short>::subBuf(vvdec::Position const&, vvdec::Size const&) const
Unexecuted instantiation: vvdec::AreaBuf<short const>::subBuf(vvdec::Position const&, vvdec::Size const&) const
192
0
  AreaBuf<      T> subBuf( const int &x, const int &y, const unsigned &_w, const unsigned &_h )       { return AreaBuf<      T>( bufAt( x, y ), stride, _w, _h ); }
193
  AreaBuf<const T> subBuf( const int &x, const int &y, const unsigned &_w, const unsigned &_h ) const { return AreaBuf<const T>( bufAt( x, y ), stride, _w, _h ); }
194
};
195
196
typedef AreaBuf<      Pel>  PelBuf;
197
typedef AreaBuf<const Pel> CPelBuf;
198
199
typedef AreaBuf<      TCoeff>  CoeffBuf;
200
typedef AreaBuf<const TCoeff> CCoeffBuf;
201
202
typedef AreaBuf<TCoeffSig>        CoeffSigBuf;
203
typedef AreaBuf<const TCoeffSig> CCoeffSigBuf;
204
205
typedef AreaBuf<      MotionInfo>  MotionBuf;
206
typedef AreaBuf<const MotionInfo> CMotionBuf;
207
208
typedef AreaBuf<      LoopFilterParam>  LFPBuf;
209
typedef AreaBuf<const LoopFilterParam> CLFPBuf;
210
211
0
#define SIZE_AWARE_PER_EL_OP( OP, INC )                     \
212
0
if( ( width & 7 ) == 0 )                                    \
213
0
{                                                           \
214
0
  for( int y = 0; y < height; y++ )                         \
215
0
  {                                                         \
216
0
    for( int x = 0; x < width; x += 8 )                     \
217
0
    {                                                       \
218
0
      OP( x + 0 );                                          \
219
0
      OP( x + 1 );                                          \
220
0
      OP( x + 2 );                                          \
221
0
      OP( x + 3 );                                          \
222
0
      OP( x + 4 );                                          \
223
0
      OP( x + 5 );                                          \
224
0
      OP( x + 6 );                                          \
225
0
      OP( x + 7 );                                          \
226
0
    }                                                       \
227
0
                                                            \
228
0
    INC;                                                    \
229
0
  }                                                         \
230
0
}                                                           \
231
0
else if( ( width & 3 ) == 0 )                               \
232
0
{                                                           \
233
0
  for( int y = 0; y < height; y++ )                         \
234
0
  {                                                         \
235
0
    for( int x = 0; x < width; x += 4 )                     \
236
0
    {                                                       \
237
0
      OP( x + 0 );                                          \
238
0
      OP( x + 1 );                                          \
239
0
      OP( x + 2 );                                          \
240
0
      OP( x + 3 );                                          \
241
0
    }                                                       \
242
0
                                                            \
243
0
    INC;                                                    \
244
0
  }                                                         \
245
0
}                                                           \
246
0
else if( ( width & 1 ) == 0 )                               \
247
0
{                                                           \
248
0
  for( int y = 0; y < height; y++ )                         \
249
0
  {                                                         \
250
0
    for( int x = 0; x < width; x += 2 )                     \
251
0
    {                                                       \
252
0
      OP( x + 0 );                                          \
253
0
      OP( x + 1 );                                          \
254
0
    }                                                       \
255
0
                                                            \
256
0
    INC;                                                    \
257
0
  }                                                         \
258
0
}                                                           \
259
0
else                                                        \
260
0
{                                                           \
261
0
  for( int y = 0; y < height; y++ )                         \
262
0
  {                                                         \
263
0
    for( int x = 0; x < width; x++ )                        \
264
0
    {                                                       \
265
0
      OP( x );                                              \
266
0
    }                                                       \
267
0
                                                            \
268
0
    INC;                                                    \
269
0
  }                                                         \
270
0
}
271
272
273
template<typename TOP, typename TINC>
274
static inline void size_aware_pel_op( TOP op, TINC inc, int width, int height )
275
{
276
  if( ( width & 7 ) == 0 )
277
  {
278
    for( int y = 0; y < height; y++ )
279
    {
280
      for( int x = 0; x < width; x += 8 )
281
      {
282
        op( x + 0 );
283
        op( x + 1 );
284
        op( x + 2 );
285
        op( x + 3 );
286
        op( x + 4 );
287
        op( x + 5 );
288
        op( x + 6 );
289
        op( x + 7 );
290
      }
291
292
      inc();
293
    }
294
  }
295
  else if( ( width & 3 ) == 0 )
296
  {
297
    for( int y = 0; y < height; y++ )
298
    {
299
      for( int x = 0; x < width; x += 4 )
300
      {
301
        op( x + 0 );
302
        op( x + 1 );
303
        op( x + 2 );
304
        op( x + 3 );
305
      }
306
307
      inc();
308
    }
309
  }
310
  else if( ( width & 1 ) == 0 )
311
  {
312
    for( int y = 0; y < height; y++ )
313
    {
314
      for( int x = 0; x < width; x += 2 )
315
      {
316
        op( x + 0 );
317
        op( x + 1 );
318
      }
319
320
      inc();
321
    }
322
  }
323
  else
324
  {
325
    for( int y = 0; y < height; y++ )
326
    {
327
      for( int x = 0; x < width; x++ )
328
      {
329
        op( x );
330
      }
331
332
      inc();
333
    }
334
  }
335
}
336
337
template<>
338
void AreaBuf<MotionInfo>::fill( const MotionInfo& val );
339
340
template<typename T>
341
void AreaBuf<T>::fill(const T &val)
342
0
{
343
0
  if( T( 0 ) == val )
344
0
  {
345
0
    if( width == stride )
346
0
    {
347
0
      ::memset( buf, 0, width * height * sizeof( T ) );
348
0
    }
349
0
    else
350
0
    {
351
0
      T* dest = buf;
352
0
      size_t line = width * sizeof( T );
353
354
0
      for( unsigned y = 0; y < height; y++ )
355
0
      {
356
0
        ::memset( dest, 0, line );
357
358
0
        dest += stride;
359
0
      }
360
0
    }
361
0
  }
362
0
  else
363
0
  {
364
0
    if( width == stride )
365
0
    {
366
0
      std::fill_n( buf, width * height, val );
367
0
    }
368
0
    else
369
0
    {
370
0
      T* dest = buf;
371
372
0
      for( int y = 0; y < height; y++, dest += stride )
373
0
      {
374
0
        std::fill_n( dest, width, val );
375
0
      }
376
0
    }
377
0
  }
378
0
}
379
380
template<typename T>
381
void AreaBuf<T>::memset( const int val )
382
0
{
383
0
  if( width == stride )
384
0
  {
385
0
    ::memset( NO_WARNING_class_memaccess( buf ), val, width * height * sizeof( T ) );
386
0
  }
387
0
  else
388
0
  {
389
0
    T* dest = buf;
390
0
    size_t line = width * sizeof( T );
391
392
0
    for( int y = 0; y < height; y++ )
393
0
    {
394
0
      ::memset( NO_WARNING_class_memaccess( dest ), val, line );
395
396
0
      dest += stride;
397
0
    }
398
0
  }
399
0
}
Unexecuted instantiation: vvdec::AreaBuf<int>::memset(int)
Unexecuted instantiation: vvdec::AreaBuf<short>::memset(int)
Unexecuted instantiation: vvdec::AreaBuf<vvdec::MotionInfo>::memset(int)
400
401
#if ENABLE_SIMD_OPT_BUFFER
402
template<typename T>
403
void AreaBuf<T>::copyFrom( const AreaBuf<const T> &other )
404
0
{
405
#if !defined(__GNUC__) || __GNUC__ > 5
406
  static_assert( std::is_trivially_copyable<T>::value, "Type T is not trivially_copyable" );
407
#endif
408
409
0
  g_pelBufOP.copyBuffer( (const char *) other.buf, sizeof( T ) * other.stride, (char *) buf, sizeof( T ) * stride, sizeof( T ) * width, height );
410
0
}
411
#else
412
template<typename T>
413
void AreaBuf<T>::copyFrom( const AreaBuf<const T> &other )
414
{
415
#if !defined(__GNUC__) || __GNUC__ > 5
416
  static_assert( std::is_trivially_copyable<T>::value, "Type T is not trivially_copyable" );
417
#endif
418
419
  CHECK_FATAL( width  != other.width,  "Incompatible size" );
420
  CHECK_FATAL( height != other.height, "Incompatible size" );
421
422
  if( buf == other.buf )
423
  {
424
    return;
425
  }
426
427
  if( ptrdiff_t( width ) == stride && stride == other.stride )
428
  {
429
    memcpy( buf, other.buf, width * height * sizeof( T ) );
430
  }
431
  else
432
  {
433
          T* dst              =       buf;
434
    const T* src              = other.buf;
435
    const ptrdiff_t srcStride = other.stride;
436
437
    for( unsigned y = 0; y < height; y++ )
438
    {
439
      memcpy( dst, src, width * sizeof( T ) );
440
441
      dst += stride;
442
      src += srcStride;
443
    }
444
  }
445
}
446
#endif
447
448
449
template<typename T>
450
void AreaBuf<T>::subtract( const AreaBuf<const T> &other )
451
{
452
  CHECK( width  != other.width,  "Incompatible size" );
453
  CHECK( height != other.height, "Incompatible size" );
454
455
        T* dest =       buf;
456
  const T* subs = other.buf;
457
458
#define SUBS_INC        \
459
  dest +=       stride; \
460
  subs += other.stride; \
461
462
#define SUBS_OP( ADDR ) dest[ADDR] -= subs[ADDR]
463
464
  SIZE_AWARE_PER_EL_OP( SUBS_OP, SUBS_INC );
465
466
#undef SUBS_OP
467
#undef SUBS_INC
468
}
469
470
template<typename T>
471
void AreaBuf<T>::reconstruct( const AreaBuf<const T> &pred, const AreaBuf<const T> &resi, const ClpRng& clpRng )
472
{
473
  THROW_FATAL( "Type not supported" );
474
}
475
476
template<>
477
void AreaBuf<Pel>::reconstruct( const AreaBuf<const Pel> &pred, const AreaBuf<const Pel> &resi, const ClpRng& clpRng );
478
479
480
template<typename T>
481
void AreaBuf<T>::addAvg( const AreaBuf<const T> &other1, const AreaBuf<const T> &other2, const ClpRng& clpRng )
482
{
483
  THROW_FATAL( "Type not supported" );
484
}
485
486
template<>
487
void AreaBuf<Pel>::addAvg( const AreaBuf<const Pel> &other1, const AreaBuf<const Pel> &other2, const ClpRng& clpRng );
488
489
template<typename T>
490
void AreaBuf<T>::linearTransform( const int scale, const int shift, const int offset, bool bClip, const ClpRng& clpRng )
491
{
492
  THROW_FATAL( "Type not supported" );
493
}
494
495
template<>
496
void AreaBuf<Pel>::linearTransform( const int scale, const int shift, const int offset, bool bClip, const ClpRng& clpRng );
497
498
template<typename T>
499
void AreaBuf<T>::extendBorderPel( unsigned margin )
500
0
{
501
0
  T*        p = buf;
502
0
  int       h = height;
503
0
  int       w = width;
504
0
  ptrdiff_t s = stride;
505
506
0
  CHECK( ( w + 2 * margin ) > s, "Size of buffer too small to extend" );
507
  // do left and right margins
508
0
  for( int y = 0; y < h; y++ )
509
0
  {
510
0
    for( int x = 0; x < margin; x++ )
511
0
    {
512
0
      *( p - margin + x ) = p[0];
513
0
      p[w + x]            = p[w - 1];
514
0
    }
515
0
    p += s;
516
0
  }
517
518
  // p is now the (0,height) (bottom left of image within bigger picture
519
0
  p -= ( s + margin );
520
  // p is now the (-margin, height-1)
521
0
  for( int y = 0; y < margin; y++ )
522
0
  {
523
0
    ::memcpy( p + ( y + 1 ) * s, p, sizeof( T ) * ( w + ( margin << 1 ) ) );
524
0
  }
525
526
  // pi is still (-marginX, height-1)
527
0
  p -= ( ( h - 1 ) * s );
528
  // pi is now (-marginX, 0)
529
0
  for( int y = 0; y < margin; y++ )
530
0
  {
531
0
    ::memcpy( p - ( y + 1 ) * s, p, sizeof( T ) * ( w + ( margin << 1 ) ) );
532
0
  }
533
0
}
534
535
template<typename T>
536
void AreaBuf<T>::extendBorderPel(unsigned margin, bool left, bool right, bool top, bool bottom)
537
0
{
538
0
  CHECK( ( width + left*margin + right*margin) > stride, "Size of buffer too small to extend" );
539
  // do left and right margins
540
541
0
  if( left && right )
542
0
  {
543
0
    T* p = buf;
544
0
    for( int y = 0; y < height; y++ )
545
0
    {
546
0
      for( int x = 0; x < margin; x++ )
547
0
      {
548
0
        p[-(int)margin + x] = p[0];
549
0
        p[width + x]   = p[width - 1];
550
0
      }
551
0
      p += stride;
552
0
    }
553
0
  }
554
555
0
  else if( left )
556
0
  {
557
0
    T* p = buf;
558
0
    for( int y = 0; y < height; y++ )
559
0
    {
560
0
      for( int x = 0; x < margin; x++ )
561
0
      {
562
0
        p[-(int)margin + x] = p[0];
563
0
      }
564
0
      p += stride;
565
0
    }
566
0
  }
567
568
0
  else if( right )
569
0
  {
570
0
    T* p = buf;
571
0
    for( int y = 0; y < height; y++ )
572
0
    {
573
0
      for( int x = 0; x < margin; x++ )
574
0
      {
575
0
        p[width + x] = p[width - 1];
576
0
      }
577
0
      p += stride;
578
0
    }
579
0
  }
580
581
0
  const int copylen = width + ( left ? margin : 0 ) + ( right ? margin : 0 );
582
0
  if( bottom )
583
0
  {
584
0
    T* p = buf + stride * height;
585
0
    if( left )
586
0
      p -= margin;
587
588
    // p is now the (-margin, height)
589
0
    for( int y = 0; y < margin; y++ )
590
0
    {
591
0
      ::memcpy( p + y * stride, p - stride, sizeof( T ) * copylen );
592
0
    }
593
0
  }
594
595
0
  if( top )
596
0
  {
597
0
    T* p = buf;
598
0
    if( left )
599
0
      p -= margin;
600
601
    // pi is now (-marginX, 0)
602
0
    for( int y = -(int)margin; y < 0; y++ )
603
0
    {
604
0
      ::memcpy( p + y * stride, p, sizeof( T ) * copylen );
605
0
    }
606
0
  }
607
0
}
608
609
template<typename T>
610
void AreaBuf<T>::padBorderPel( unsigned marginX, unsigned marginY, int dir )
611
0
{
612
0
  T*   p = buf;
613
0
  auto s = stride;
614
0
  int  h = height;
615
0
  int  w = width;
616
617
0
  CHECK( w  > s, "Size of buffer too small to extend" );
618
619
  // top-left margin
620
0
  if ( dir == 1 )
621
0
  {
622
0
    for( int y = 0; y < marginY; y++ )
623
0
    {
624
0
      for( int x = 0; x < marginX; x++ )
625
0
      {
626
0
        p[x] = p[marginX];
627
0
      }
628
0
      p += s;
629
0
    }
630
0
  }
631
632
  // bottom-right margin
633
0
  if ( dir == 2 )
634
0
  {
635
0
    p = buf + s * ( h - marginY ) + w - marginX;
636
637
0
    for( int y = 0; y < marginY; y++ )
638
0
    {
639
0
      for( int x = 0; x < marginX; x++ )
640
0
      {
641
0
        p[x] = p[-1];
642
0
      }
643
0
      p += s;
644
0
    }
645
0
  }
646
0
}
647
648
#if ENABLE_SIMD_OPT_BUFFER && defined(TARGET_SIMD_X86)
649
template<> void AreaBuf<Pel>::transposedFrom( const AreaBuf<const Pel> &other );
650
#endif
651
652
template<typename T>
653
void AreaBuf<T>::transposedFrom( const AreaBuf<const T> &other )
654
0
{
655
0
  CHECK( width * height != other.width * other.height, "Incompatible size" );
656
657
0
        T* dst  =       buf;
658
0
  const T* src  = other.buf;
659
0
  width         = other.height;
660
0
  height        = other.width;
661
0
  stride        = stride < width ? width : stride;
662
663
0
  for( unsigned y = 0; y < other.height; y++ )
664
0
  {
665
0
    for( unsigned x = 0; x < other.width; x++ )
666
0
    {
667
0
      dst[y + x*stride] = src[x + y * other.stride];
668
0
    }
669
0
  }
670
0
}
671
672
#ifndef DONT_UNDEF_SIZE_AWARE_PER_EL_OP
673
#undef SIZE_AWARE_PER_EL_OP
674
#endif // !DONT_UNDEF_SIZE_AWARE_PER_EL_OP
675
676
// ---------------------------------------------------------------------------
677
// UnitBuf struct
678
// ---------------------------------------------------------------------------
679
680
struct UnitArea;
681
682
template<typename T>
683
struct UnitBuf
684
{
685
  typedef static_vector<AreaBuf<T>,       MAX_NUM_COMPONENT> UnitBufBuffers;
686
687
  ChromaFormat chromaFormat;
688
  UnitBufBuffers bufs;
689
690
10.6k
  UnitBuf() : chromaFormat( NUM_CHROMA_FORMAT ) { }
vvdec::UnitBuf<short>::UnitBuf()
Line
Count
Source
690
10.6k
  UnitBuf() : chromaFormat( NUM_CHROMA_FORMAT ) { }
Unexecuted instantiation: vvdec::UnitBuf<short const>::UnitBuf()
691
  UnitBuf( const ChromaFormat &_chromaFormat, const UnitBufBuffers&  _bufs ) : chromaFormat( _chromaFormat ), bufs( _bufs ) { }
692
  UnitBuf( const ChromaFormat &_chromaFormat,       UnitBufBuffers&& _bufs ) : chromaFormat( _chromaFormat ), bufs( std::forward<UnitBufBuffers>( _bufs ) ) { }
693
0
  UnitBuf( const ChromaFormat &_chromaFormat, const AreaBuf<T>  &blkY ) : chromaFormat( _chromaFormat ), bufs{ blkY } { }
694
0
  UnitBuf( const ChromaFormat &_chromaFormat,       AreaBuf<T> &&blkY ) : chromaFormat( _chromaFormat ), bufs{ std::forward<AreaBuf<T> >(blkY) } { }
695
0
  UnitBuf( const ChromaFormat &_chromaFormat, const AreaBuf<T>  &blkY, const AreaBuf<T>  &blkCb, const AreaBuf<T>  &blkCr ) : chromaFormat( _chromaFormat ), bufs{ blkY, blkCb, blkCr } { if( chromaFormat == CHROMA_400 ) bufs.resize( 1 ); }
696
0
  UnitBuf( const ChromaFormat &_chromaFormat,       AreaBuf<T> &&blkY,       AreaBuf<T> &&blkCb,       AreaBuf<T> &&blkCr ) : chromaFormat( _chromaFormat ), bufs{ std::forward<AreaBuf<T> >(blkY), std::forward<AreaBuf<T> >(blkCb), std::forward<AreaBuf<T> >(blkCr) } { if( chromaFormat == CHROMA_400 ) bufs.resize( 1 ); }
697
698
  UnitBuf( const UnitBuf& other )  = default;
699
  UnitBuf(       UnitBuf&& other ) = default;
700
  UnitBuf& operator=( const UnitBuf& other )  = default;
701
  UnitBuf& operator=(       UnitBuf&& other ) = default;
702
703
  // conversion from UnitBuf<const T> to UnitBuf<T>
704
  template<bool T_IS_COST = std::is_const<T>::value>
705
0
  UnitBuf( const UnitBuf<typename std::remove_const_t<T>>& other, std::enable_if_t<T_IS_COST>* = 0 ) : chromaFormat( other.chromaFormat ), bufs( other.bufs ) { }
706
707
0
        AreaBuf<T>& get( const ComponentID comp )        { return bufs[comp]; }
708
0
  const AreaBuf<T>& get( const ComponentID comp )  const { return bufs[comp]; }
Unexecuted instantiation: vvdec::UnitBuf<short>::get(vvdec::ComponentID) const
Unexecuted instantiation: vvdec::UnitBuf<short const>::get(vvdec::ComponentID) const
709
710
0
        AreaBuf<T>& Y()        { return bufs[0]; }
711
0
  const AreaBuf<T>& Y()  const { return bufs[0]; }
712
0
        AreaBuf<T>& Cb()       { return bufs[1]; }
713
  const AreaBuf<T>& Cb() const { return bufs[1]; }
714
0
        AreaBuf<T>& Cr()       { return bufs[2]; }
715
  const AreaBuf<T>& Cr() const { return bufs[2]; }
716
717
  void fill                 ( const T &val );
718
  void copyFrom             ( const UnitBuf<const T> &other );
719
  void reconstruct          ( const UnitBuf<const T> &pred, const UnitBuf<const T> &resi, const ClpRngs& clpRngs );
720
  void subtract             ( const UnitBuf<const T> &other );
721
  void addWeightedAvg       ( const UnitBuf<      T> &other1, const UnitBuf<      T> &other2, const ClpRngs& clpRngs, const uint8_t bcwIdx = BCW_DEFAULT, const bool chromaOnly = false, const bool lumaOnly = false);
722
  void addAvg               ( const UnitBuf<      T> &other1, const UnitBuf<      T> &other2, const ClpRngs& clpRngs, const bool chromaOnly = false, const bool lumaOnly = false);
723
  void extendBorderPel      ( unsigned margin );
724
  void extendBorderPel      ( unsigned margin, bool left, bool right, bool top, bool bottom );
725
  void padBorderPel         ( unsigned margin, int dir );
726
727
        UnitBuf<      T> subBuf (const Area& subArea);
728
  const UnitBuf<const T> subBuf (const Area& subArea) const;
729
        UnitBuf<      T> subBuf (const UnitArea& subArea);
730
  const UnitBuf<const T> subBuf (const UnitArea& subArea) const;
731
  void colorSpaceConvert    ( const UnitBuf<T> &other, const ClpRng& clpRng );
732
733
  void writeToFile( std::string filename ) const;   // for debug purposes
734
};
735
736
typedef UnitBuf<      Pel>  PelUnitBuf;
737
typedef UnitBuf<const Pel> CPelUnitBuf;
738
739
typedef UnitBuf<      TCoeff>  CoeffUnitBuf;
740
typedef UnitBuf<const TCoeff> CCoeffUnitBuf;
741
742
}   // namespace vvdec
743
744
#include <Unit.h>
745
746
namespace vvdec
747
{
748
template<typename T>
749
void UnitBuf<T>::fill( const T &val )
750
0
{
751
0
  for( unsigned i = 0; i < bufs.size(); i++ )
752
0
  {
753
0
    bufs[i].fill( val );
754
0
  }
755
0
}
756
757
template<typename T>
758
void UnitBuf<T>::copyFrom( const UnitBuf<const T> &other )
759
0
{
760
0
  CHECK( chromaFormat != other.chromaFormat, "Incompatible formats" );
761
762
0
  for( unsigned i = 0; i < bufs.size(); i++ )
763
0
  {
764
0
    bufs[i].copyFrom( other.bufs[i] );
765
0
  }
766
0
}
767
768
769
770
template<typename T>
771
void UnitBuf<T>::subtract( const UnitBuf<const T> &other )
772
{
773
  CHECK( chromaFormat != other.chromaFormat, "Incompatible formats" );
774
775
  for( unsigned i = 0; i < bufs.size(); i++ )
776
  {
777
    bufs[i].subtract( other.bufs[i] );
778
  }
779
}
780
781
template<typename T>
782
void UnitBuf<T>::reconstruct(const UnitBuf<const T> &pred, const UnitBuf<const T> &resi, const ClpRngs& clpRngs)
783
{
784
  CHECK( chromaFormat != pred.chromaFormat, "Incompatible formats" );
785
  CHECK( chromaFormat != resi.chromaFormat, "Incompatible formats" );
786
787
  for( unsigned i = 0; i < bufs.size(); i++ )
788
  {
789
    bufs[i].reconstruct( pred.bufs[i], resi.bufs[i], clpRngs );
790
  }
791
}
792
793
template<typename T>
794
void UnitBuf<T>::addWeightedAvg(const UnitBuf<T> &other1, const UnitBuf<T> &other2, const ClpRngs& clpRngs, const uint8_t bcwIdx /* = BCW_DEFAULT */, const bool chromaOnly /* = false */, const bool lumaOnly /* = false */)
795
0
{
796
0
  const size_t istart = chromaOnly ? 1 : 0;
797
0
  const size_t iend   = lumaOnly   ? 1 : bufs.size();
798
799
0
  CHECK(lumaOnly && chromaOnly, "should not happen");
800
801
0
  for(size_t i = istart; i < iend; i++)
802
0
  {
803
0
    bufs[i].addWeightedAvg(other1.bufs[i], other2.bufs[i], clpRngs, bcwIdx);
804
0
  }
805
0
}
806
807
template<typename T>
808
void UnitBuf<T>::addAvg(const UnitBuf<T> &other1, const UnitBuf<T> &other2, const ClpRngs& clpRngs, const bool chromaOnly /* = false */, const bool lumaOnly /* = false */)
809
0
{
810
0
  const size_t istart = chromaOnly ? 1 : 0;
811
0
  const size_t iend   = lumaOnly   ? 1 : bufs.size();
812
813
0
  CHECK( lumaOnly && chromaOnly, "should not happen" );
814
815
0
  for( size_t i = istart; i < iend; i++)
816
0
  {
817
0
    bufs[i].addAvg( other1.bufs[i], other2.bufs[i], clpRngs );
818
0
  }
819
0
}
820
821
template<typename T>
822
void UnitBuf<T>::colorSpaceConvert( const UnitBuf<T> &other, const ClpRng& clpRng )
823
{
824
  THROW_FATAL( "Type not supported" );
825
}
826
827
template<>
828
void UnitBuf<Pel>::colorSpaceConvert( const UnitBuf<Pel> &other, const ClpRng& clpRng );
829
830
template<typename T>
831
void UnitBuf<T>::extendBorderPel( unsigned margin )
832
0
{
833
0
  for( unsigned i = 0; i < bufs.size(); i++ )
834
0
  {
835
0
    bufs[i].extendBorderPel( margin );
836
0
  }
837
0
}
838
839
template<typename T>
840
void UnitBuf<T>::extendBorderPel(unsigned margin, bool left, bool right, bool top, bool bottom)
841
0
{
842
0
  for( unsigned i = 0; i < bufs.size(); i++ )
843
0
  {
844
0
    bufs[i].extendBorderPel( margin, left, right, top, bottom );
845
0
  }
846
0
}
847
848
template<typename T>
849
void UnitBuf<T>::padBorderPel( unsigned margin, int dir )
850
0
{
851
0
  for( unsigned i = 0; i < bufs.size(); i++ )
852
0
  {
853
0
    bufs[i].padBorderPel( margin >> getComponentScaleX( ComponentID( i ), chromaFormat ), margin >> getComponentScaleY( ComponentID( i ), chromaFormat ), dir );
854
0
  }
855
0
}
856
857
template<typename T>
858
UnitBuf<T> UnitBuf<T>::subBuf( const UnitArea& subArea )
859
0
{
860
0
  UnitBuf<T> subBuf;
861
0
  subBuf.chromaFormat = chromaFormat;
862
0
  unsigned blockIdx = 0;
863
864
0
  for( auto &subAreaBuf : bufs )
865
0
  {
866
0
    subBuf.bufs.push_back( subAreaBuf.subBuf( subArea.blocks[blockIdx].pos(), subArea.blocks[blockIdx].size() ) );
867
0
    blockIdx++;
868
0
  }
869
870
0
  return subBuf;
871
0
}
872
873
874
template<typename T>
875
const UnitBuf<const T> UnitBuf<T>::subBuf( const UnitArea& subArea ) const
876
0
{
877
0
  UnitBuf<const T> subBuf;
878
0
  subBuf.chromaFormat = chromaFormat;
879
0
  unsigned blockIdx = 0;
880
0
881
0
  for( const auto &subAreaBuf : bufs )
882
0
  {
883
0
    subBuf.bufs.push_back( subAreaBuf.subBuf( subArea.blocks[blockIdx].pos(), subArea.blocks[blockIdx].size() ) );
884
0
    blockIdx++;
885
0
  }
886
0
887
0
  return subBuf;
888
0
}
889
890
template<typename T>
891
UnitBuf<T> UnitBuf<T>::subBuf( const Area & subArea )
892
0
{
893
0
  UnitBuf<T> subBuf;
894
0
  subBuf.chromaFormat = chromaFormat;
895
0
  unsigned blockIdx = 0;
896
897
0
  for( auto &subAreaBuf : bufs )
898
0
  {
899
0
    const int scaleX = getComponentScaleX( ComponentID(blockIdx), chromaFormat);
900
0
    const int scaleY = getComponentScaleY( ComponentID(blockIdx), chromaFormat);
901
0
    const Area scaledArea( subArea.pos().x >> scaleX, subArea.pos().y >> scaleY, subArea.size().width >> scaleX, subArea.size().height >> scaleY );
902
0
    subBuf.bufs.push_back( subAreaBuf.subBuf( scaledArea.pos(), scaledArea.size() ) );
903
0
    blockIdx++;
904
0
  }
905
906
0
  return subBuf;
907
0
}
908
909
template<typename T>
910
const UnitBuf<const T> UnitBuf<T>::subBuf( const Area & subArea ) const
911
0
{
912
0
  UnitBuf<T> subBuf;
913
0
  subBuf.chromaFormat = chromaFormat;
914
0
  unsigned blockIdx = 0;
915
916
0
  for( auto &subAreaBuf : bufs )
917
0
  {
918
0
    const int scaleX = getComponentScaleX( ComponentID(blockIdx), chromaFormat);
919
0
    const int scaleY = getComponentScaleY( ComponentID(blockIdx), chromaFormat);
920
0
    const Area scaledArea( subArea.pos().x >> scaleX, subArea.pos().y >> scaleY, subArea.size().width >> scaleX, subArea.size().height >> scaleY );
921
0
    subBuf.bufs.push_back( subAreaBuf.subBuf( scaledArea.pos(), scaledArea.size() ) );
922
0
    blockIdx++;
923
0
  }
924
925
0
  return subBuf;
926
0
}
927
928
// ---------------------------------------------------------------------------
929
// PelStorage struct (PelUnitBuf which allocates its own memory)
930
// ---------------------------------------------------------------------------
931
932
struct UnitArea;
933
struct CompArea;
934
935
struct PelStorage : public PelUnitBuf
936
{
937
  PelStorage();
938
  ~PelStorage();
939
940
  void swap( PelStorage& other );
941
  void createFromBuf( PelUnitBuf buf );
942
  void create( const UnitArea &_unit );
943
  void create( const ChromaFormat _chromaFormat, const Size& _size, const unsigned _maxCUSize = 0, const unsigned _margin = 0, const unsigned _alignment = 0, const bool _scaleChromaMargin = true, const UserAllocator* userAlloc = nullptr );
944
  void destroy();
945
946
  struct CompBufSize
947
  {
948
    Size     total;   // incl. margins and alignment
949
    unsigned xmargin;
950
    unsigned ymargin;
951
    size_t   area;
952
  };
953
  // padded size of one component's buffer, as allocated by create(); throws if too large
954
  static CompBufSize calcCompBufSize( const Size& _size, const unsigned _maxCUSize, const unsigned _margin, const unsigned _alignmentByte, const bool _scaleChromaMargin, const unsigned scaleX, const unsigned scaleY );
955
956
         PelBuf getBuf( const CompArea &blk );
957
  const CPelBuf getBuf( const CompArea &blk ) const;
958
959
         PelBuf getBuf( const ComponentID CompID );
960
  const CPelBuf getBuf( const ComponentID CompID ) const;
961
962
         PelUnitBuf getBuf( const UnitArea &unit );
963
  const CPelUnitBuf getBuf( const UnitArea &unit ) const;
964
0
  Pel *getOrigin( const int id ) const { return m_origin[id]; }
965
0
  PelBuf getOriginBuf( const int id ) { return PelBuf( m_origin[id], m_origSi[id] ); }
966
967
0
  Size  getBufSize( const int id )      const { return  m_origSi[id];     }
968
0
  void *getBufAllocator( const int id ) const { return m_allocator[id];   }
969
0
  bool  isExternAllocator()             const { return m_externAllocator; }
970
971
0
  const UserAllocator* getUserAllocator() const { return m_userAlloc; }
972
973
private:
974
975
  Size    m_origSi[MAX_NUM_COMPONENT];
976
  Pel    *m_origin[MAX_NUM_COMPONENT];
977
  void   *m_allocator[MAX_NUM_COMPONENT];
978
  bool    m_externAllocator = false;
979
  const UserAllocator* m_userAlloc  = nullptr;
980
};
981
982
}   // namespace vvdec