Coverage Report

Created: 2026-10-28 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvenc/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) 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
/** \file     Buffer.h
43
 *  \brief    Low-overhead class describing 2D memory layout
44
 */
45
46
#pragma once
47
48
#ifndef __IN_UNIT_H__
49
#error "Include Unit.h not Buffer.h"
50
#endif
51
52
#include "Common.h"
53
#include "CommonDef.h"
54
#include "MotionInfo.h"
55
56
#include <string.h>
57
#include <type_traits>
58
#include <typeinfo>
59
60
#include "vvenc/vvenc.h"
61
62
//! \ingroup CommonLib
63
//! \{
64
65
struct vvencYUVBuffer;
66
67
namespace vvenc {
68
69
#if ENABLE_SIMD_OPT_BUFFER && defined(TARGET_SIMD_X86)
70
using namespace x86_simd;
71
#endif
72
73
#if ENABLE_SIMD_OPT_BUFFER && defined(TARGET_SIMD_ARM)
74
using namespace arm_simd;
75
#endif
76
77
// ---------------------------------------------------------------------------
78
// AreaBuf struct
79
// ---------------------------------------------------------------------------
80
81
struct PelBufferOps
82
{
83
  PelBufferOps();
84
  void initPelBufOps( bool enableOpt = true );
85
86
0
#define INCX( ptr, stride ) { ptr++; }
87
2.55M
#define INCY( ptr, stride ) { ptr += ( stride ); }
88
16.1M
#define OFFSETX( ptr, stride, x ) { ptr += ( x ); }
89
1.45M
#define OFFSETY( ptr, stride, y ) { ptr += ( y ) * ( stride ); }
90
2.75M
#define OFFSET( ptr, stride, x, y ) { ptr += ( x ) + ( y ) * ( stride ); }
91
#define GET_OFFSETX( ptr, stride, x ) ( ( ptr ) + ( x ) )
92
#define GET_OFFSETY( ptr, stride, y ) ( ( ptr ) + ( y ) * ( stride ) )
93
0
#define GET_OFFSET( ptr, stride, x, y ) ( ( ptr ) + ( x ) + ( y ) * ( stride ) ) // need in loopFilter.cpp + some ARM files
94
95
  void ( *roundGeo )      ( const Pel* src, Pel* dest, const int numSamples, unsigned rshift, int offset, const ClpRng &clpRng);
96
  void ( *addAvg )        ( const Pel* src0, const Pel* src1, Pel* dst, int numsamples, unsigned shift, int offset, const ClpRng& clpRng );
97
  void ( *reco  )         ( const Pel* src0, const Pel* src1, Pel* dst, int numSamples, const ClpRng& clpRng );
98
  void ( *copyClip )      ( const Pel* src0,                  Pel* dst, int numSamples, const ClpRng& clpRng );
99
  void ( *addAvg4 )       ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height,       unsigned shift, int offset, const ClpRng& clpRng );
100
  void ( *addAvg8 )       ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height,       unsigned shift, int offset, const ClpRng& clpRng );
101
  void ( *addAvg16 )      ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height,       unsigned shift, int offset, const ClpRng& clpRng );
102
  void ( *sub2 )          ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height );
103
  void ( *sub4 )          ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height );
104
  void ( *sub8 )          ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height );
105
  void ( *wghtAvg4 )      ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel *dst, int dstStride, int width, int height,       unsigned shift, int offset, int w0, int w1, const ClpRng& clpRng );
106
  void ( *wghtAvg8 )      ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel *dst, int dstStride, int width, int height,       unsigned shift, int offset, int w0, int w1, const ClpRng& clpRng );
107
  void ( *copyClip2 )     ( const Pel* src0, int src0Stride,                                  Pel* dst, int dstStride, int width, int height,                                   const ClpRng& clpRng );
108
  void ( *copyClip4 )     ( const Pel* src0, int src0Stride,                                  Pel* dst, int dstStride, int width, int height,                                   const ClpRng& clpRng );
109
  void ( *copyClip8 )     ( const Pel* src0, int src0Stride,                                  Pel* dst, int dstStride, int width, int height,                                   const ClpRng& clpRng );
110
  void ( *reco2 )         ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height,                                   const ClpRng& clpRng );
111
  void ( *reco4 )         ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height,                                   const ClpRng& clpRng );
112
  void ( *reco8 )         ( const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel* dst, int dstStride, int width, int height,                                   const ClpRng& clpRng );
113
  void ( *linTf4 )        ( const Pel* src0, int src0Stride,                                  Pel* dst, int dstStride, int width, int height, int scale, unsigned shift, int offset, const ClpRng& clpRng, bool bClip );
114
  void ( *linTf8 )        ( const Pel* src0, int src0Stride,                                  Pel* dst, int dstStride, int width, int height, int scale, unsigned shift, int offset, const ClpRng& clpRng, bool bClip );
115
  void ( *copyBuffer )    ( const char* src, int srcStride, char* dst, int dstStride, int width, int height );
116
  // the checksum of the decoded picture hash SEI for one plane: the sum, modulo 2^32, of ( p & 0xff ) ^ m and, with
117
  // twoBytes, ( p >> 8 ) ^ m, where m = ( x & 0xff ) ^ ( y & 0xff ) ^ ( x >> 8 ) ^ ( y >> 8 )
118
  uint32_t ( *pictureChecksum ) ( const Pel* plane, const ptrdiff_t stride, const int width, const int height, const bool twoBytes );
119
  void ( *removeHighFreq8)( Pel* src0, int src0Stride, const Pel* src1, int src1Stride, int width, int height);
120
  void ( *removeHighFreq4)( Pel* src0, int src0Stride, const Pel* src1, int src1Stride, int width, int height);
121
  void ( *transpose4x4 )  ( const Pel* src,  int srcStride, Pel* dst, int dstStride );
122
  void ( *transpose8x8 )  ( const Pel* src,  int srcStride, Pel* dst, int dstStride );
123
  void ( *roundIntVector) ( int* v, int size, unsigned int nShift, const int dmvLimit);
124
  void ( *mipMatrixMul_4_4)( Pel* res, const Pel* input, const uint8_t* weight, const int maxVal, const int offset, bool transpose );
125
  void ( *mipMatrixMul_8_4)( Pel* res, const Pel* input, const uint8_t* weight, const int maxVal, const int offset, bool transpose );
126
  void ( *mipMatrixMul_8_8)( Pel* res, const Pel* input, const uint8_t* weight, const int maxVal, const int offset, bool transpose );
127
  // MIP upsampling of the predSize x predSize reduced prediction by 1 << log2Factor (MatrixIntraPrediction::predBlock)
128
  void ( *mipUpsampleHor )( Pel* dst, const Pel* src, const Pel* bndry, const SizeType dstStride, const SizeType bndryStep, const SizeType predSize, const unsigned log2Factor );
129
  void ( *mipUpsampleVer )( Pel* dst, const Pel* src, const Pel* bndry, const SizeType outWidth, const SizeType srcStep, const SizeType inHeight, const unsigned log2Factor );
130
  void ( *weightCiip)     ( Pel* res, const Pel* intra, const int numSamples, int numIntra );
131
  void ( *fillPtrMap )    ( void** ptrMap, const ptrdiff_t mapStride, int width, int height, void* val );
132
  uint64_t ( *AvgHighPassWithDownsampling )    ( const int width, const int height, const Pel* pSrc, const int iSrcStride);
133
  uint64_t ( *AvgHighPass )    ( const int width, const int height, const Pel* pSrc, const int iSrcStride);
134
  uint64_t ( *AvgHighPassWithDownsamplingDiff1st ) (const int width, const int height, const Pel* pSrc,const Pel* pSrcM1, const int iSrcStride, const int iSrcM1Stride);
135
  uint64_t ( *AvgHighPassWithDownsamplingDiff2nd) (const int width,const int height,const Pel* pSrc,const Pel* pSM1,const Pel* pS21,const int iSrcStride,const int iSM1Stride,const int iSM2Stride);
136
  uint64_t ( *HDHighPass) (const int width, const int height,const Pel*  pSrc,const Pel* pSM1,const int iSrcStride,const int iSM1Stride);
137
  uint64_t ( *HDHighPass2)  (const int width, const int height,const Pel*  pSrc,const Pel* pSM1,const Pel* pSM2,const int iSrcStride,const int iSM1Stride,const int iSM2Stride);
138
  // block statistics; the sums of squares are exact for samples in 0 ... 2^15 - 1
139
  uint64_t ( *sumSquaredError )  ( const Pel* src0, const ptrdiff_t stride0, const Pel* src1, const ptrdiff_t stride1, const int width, const int height );
140
  int64_t  ( *sum )              ( const Pel* src, const ptrdiff_t stride, const int width, const int height );
141
  void     ( *sumAndSumSquares ) ( const Pel* src, const ptrdiff_t stride, const int width, const int height, int64_t& sum, int64_t& sumSquares );
142
  // replicates the first / last sample of each row into the marginLeft / marginRight samples before / after the row
143
  void     ( *padHorizontal )    ( Pel* src, const ptrdiff_t stride, const int width, const int height, const int marginLeft, const int marginRight );
144
  // dst = ( sum of the 2x2 source samples + 2 ) >> 2
145
  void     ( *downsample2x2 )    ( const Pel* src, const ptrdiff_t srcStride, Pel* dst, const ptrdiff_t dstStride, const int dstWidth, const int dstHeight );
146
  // sum of the products of the 3x3 high-pass filtered samples of two planes (the joint Cb-Cr sign decision)
147
  int64_t  ( *highPassCorrelation )( const Pel* cb, const ptrdiff_t cbStride, const Pel* cr, const ptrdiff_t crStride, const int width, const int height, const int bitDepth );
148
  // per 4x4 block of a row of numBlocks blocks: the sample sum s and the absolute deviation sum( | s - 16 * p | )
149
  void     ( *blockStats4x4 )    ( const Pel* src, const ptrdiff_t stride, const int numBlocks, const int bitDepth, int* sum, int* absDev );
150
  // sums of the absolute differences to the right, lower, lower-left and lower-right neighbours over the
151
  // ( width - 1 ) x ( height - 1 ) top-left samples: sums[0] horizontal, [1] vertical, [2] and [3] the diagonals
152
  void     ( *absGradientSums )  ( const Pel* src, const ptrdiff_t stride, const int width, const int height, int* sums );
153
  // sum( | p - value | ) over the block
154
  uint32_t ( *sumAbsDeviation )  ( const Pel* src, const ptrdiff_t stride, const int width, const int height, const int value );
155
156
private:
157
  bool isInitSIMDDone = false;
158
159
#if ENABLE_SIMD_OPT_BUFFER && defined(TARGET_SIMD_X86)
160
  void initPelBufOpsX86();
161
  template<X86_VEXT vext>
162
  void _initPelBufOpsX86();
163
#endif
164
165
#if ENABLE_SIMD_OPT_BUFFER && defined( TARGET_SIMD_ARM )
166
  void initPelBufOpsARM();
167
  template<ARM_VEXT vext>
168
  void _initPelBufOpsARM();
169
#endif
170
};
171
172
extern PelBufferOps g_pelBufOP;
173
174
// the C version of PelBufferOps::sumSquaredError, also used by the SIMD versions for the widths 1 and 3
175
uint64_t sumSquaredErrorCore( const Pel* src0, const ptrdiff_t stride0, const Pel* src1, const ptrdiff_t stride1, const int width, const int height );
176
// the C version of PelBufferOps::highPassCorrelation, also used by the SIMD versions for the last columns and for
177
// bit depths above 10
178
int64_t highPassCorrelationCore( const Pel* cb, const ptrdiff_t cbStride, const Pel* cr, const ptrdiff_t crStride, const int width, const int height, const int bitDepth );
179
// the C version of PelBufferOps::blockStats4x4, also used by the SIMD versions for the last blocks and for bit depths
180
// above 10
181
void blockStats4x4Core( const Pel* src, const ptrdiff_t stride, const int numBlocks, const int bitDepth, int* sum, int* absDev );
182
// the C version of PelBufferOps::absGradientSums, also used by the SIMD versions for narrow blocks
183
void absGradientSumsCore( const Pel* src, const ptrdiff_t stride, const int width, const int height, int* sums );
184
185
template<typename T>
186
struct AreaBuf : public Size
187
{
188
  T*        buf;
189
  int       stride;
190
  // the proper type causes awful lot of errors
191
192
9.03M
  AreaBuf()                                                                               : Size(),                  buf( NULL ), stride( 0 )          { }
vvenc::AreaBuf<short>::AreaBuf()
Line
Count
Source
192
7.74M
  AreaBuf()                                                                               : Size(),                  buf( NULL ), stride( 0 )          { }
vvenc::AreaBuf<short const>::AreaBuf()
Line
Count
Source
192
1.28M
  AreaBuf()                                                                               : Size(),                  buf( NULL ), stride( 0 )          { }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo>::AreaBuf()
193
9.10M
  AreaBuf( T *_buf, const Size& size )                                                    : Size( size ),            buf( _buf ), stride( size.width ) { }
vvenc::AreaBuf<short>::AreaBuf(short*, vvenc::Size const&)
Line
Count
Source
193
3.12M
  AreaBuf( T *_buf, const Size& size )                                                    : Size( size ),            buf( _buf ), stride( size.width ) { }
vvenc::AreaBuf<short const>::AreaBuf(short const*, vvenc::Size const&)
Line
Count
Source
193
2.37M
  AreaBuf( T *_buf, const Size& size )                                                    : Size( size ),            buf( _buf ), stride( size.width ) { }
vvenc::AreaBuf<vvenc::LoopFilterParam>::AreaBuf(vvenc::LoopFilterParam*, vvenc::Size const&)
Line
Count
Source
193
9.94k
  AreaBuf( T *_buf, const Size& size )                                                    : Size( size ),            buf( _buf ), stride( size.width ) { }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::LoopFilterParam const>::AreaBuf(vvenc::LoopFilterParam const*, vvenc::Size const&)
vvenc::AreaBuf<int>::AreaBuf(int*, vvenc::Size const&)
Line
Count
Source
193
3.59M
  AreaBuf( T *_buf, const Size& size )                                                    : Size( size ),            buf( _buf ), stride( size.width ) { }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo const>::AreaBuf(vvenc::MotionInfo const*, vvenc::Size const&)
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo>::AreaBuf(vvenc::MotionInfo*, vvenc::Size const&)
194
27.4M
  AreaBuf( T *_buf, const int& _stride, const Size& size )                                : Size( size ),            buf( _buf ), stride( _stride )    { }
vvenc::AreaBuf<short>::AreaBuf(short*, int const&, vvenc::Size const&)
Line
Count
Source
194
26.9M
  AreaBuf( T *_buf, const int& _stride, const Size& size )                                : Size( size ),            buf( _buf ), stride( _stride )    { }
vvenc::AreaBuf<short const>::AreaBuf(short const*, int const&, vvenc::Size const&)
Line
Count
Source
194
52.1k
  AreaBuf( T *_buf, const int& _stride, const Size& size )                                : Size( size ),            buf( _buf ), stride( _stride )    { }
vvenc::AreaBuf<vvenc::MotionInfo>::AreaBuf(vvenc::MotionInfo*, int const&, vvenc::Size const&)
Line
Count
Source
194
442k
  AreaBuf( T *_buf, const int& _stride, const Size& size )                                : Size( size ),            buf( _buf ), stride( _stride )    { }
vvenc::AreaBuf<vvenc::LoopFilterParam>::AreaBuf(vvenc::LoopFilterParam*, int const&, vvenc::Size const&)
Line
Count
Source
194
9.94k
  AreaBuf( T *_buf, const int& _stride, const Size& size )                                : Size( size ),            buf( _buf ), stride( _stride )    { }
195
2.30M
  AreaBuf( T *_buf, const SizeType& _width, const SizeType& _height )                     : Size( _width, _height ), buf( _buf ), stride( _width )     { }
vvenc::AreaBuf<short const>::AreaBuf(short const*, unsigned int const&, unsigned int const&)
Line
Count
Source
195
2.24M
  AreaBuf( T *_buf, const SizeType& _width, const SizeType& _height )                     : Size( _width, _height ), buf( _buf ), stride( _width )     { }
vvenc::AreaBuf<short>::AreaBuf(short*, unsigned int const&, unsigned int const&)
Line
Count
Source
195
59.7k
  AreaBuf( T *_buf, const SizeType& _width, const SizeType& _height )                     : Size( _width, _height ), buf( _buf ), stride( _width )     { }
196
3.59M
  AreaBuf( T *_buf, const int& _stride, const SizeType& _width, const SizeType& _height ) : Size( _width, _height ), buf( _buf ), stride( _stride )    { }
vvenc::AreaBuf<short>::AreaBuf(short*, int const&, unsigned int const&, unsigned int const&)
Line
Count
Source
196
2.82M
  AreaBuf( T *_buf, const int& _stride, const SizeType& _width, const SizeType& _height ) : Size( _width, _height ), buf( _buf ), stride( _stride )    { }
vvenc::AreaBuf<short const>::AreaBuf(short const*, int const&, unsigned int const&, unsigned int const&)
Line
Count
Source
196
770k
  AreaBuf( T *_buf, const int& _stride, const SizeType& _width, const SizeType& _height ) : Size( _width, _height ), buf( _buf ), stride( _stride )    { }
197
198
  AreaBuf( const AreaBuf& )  = default;
199
  AreaBuf(       AreaBuf&& ) = default;
200
  AreaBuf& operator=( const AreaBuf& )  = default;
201
  AreaBuf& operator=(       AreaBuf&& ) = default;
202
203
  // conversion from AreaBuf<const T> to AreaBuf<T>
204
  template<bool T_IS_CONST = std::is_const<T>::value>
205
33.0M
  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 ) { }
vvenc::AreaBuf<short const>::AreaBuf<true>(vvenc::AreaBuf<short> const&, std::__1::enable_if<true, void>::type*)
Line
Count
Source
205
29.3M
  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 ) { }
vvenc::AreaBuf<vvenc::MotionInfo const>::AreaBuf<true>(vvenc::AreaBuf<vvenc::MotionInfo> const&, std::__1::enable_if<true, void>::type*)
Line
Count
Source
205
66.7k
  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 ) { }
vvenc::AreaBuf<int const>::AreaBuf<true>(vvenc::AreaBuf<int> const&, std::__1::enable_if<true, void>::type*)
Line
Count
Source
205
3.55M
  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 ) { }
206
207
  void fill                 ( const T &val );
208
  void memset               ( const int val );
209
210
  void copyFrom             ( const AreaBuf<const T>& other );
211
  void reconstruct          ( const AreaBuf<const T>& pred, const AreaBuf<const T>& resi, const ClpRng& clpRng);
212
  void copyClip             ( const AreaBuf<const T>& src, const ClpRng& clpRng);
213
214
  void subtract             ( const AreaBuf<const T>& minuend, const AreaBuf<const T>& subtrahend );
215
  void calcVarianceSplit    ( const AreaBuf<const T>& Org, const uint32_t  size,int& varh,int& varv ) const;
216
  void extendBorderPel      ( unsigned marginX, unsigned marginY );
217
218
  void addAvg               ( const AreaBuf<const T>& other1, const AreaBuf<const T>& other2, const ClpRng& clpRng );
219
  T    getAvg               () const;
220
  void padBorderPel         ( unsigned marginX, unsigned marginY, int dir );
221
  void addWeightedAvg       ( const AreaBuf<const T>& other1, const AreaBuf<const T>& other2, const ClpRng& clpRng, const int8_t BcwIdx );
222
  void removeHighFreq       ( const AreaBuf<const T>& other, const bool bClip, const ClpRng& clpRng);
223
  void extendBorderPelTop   ( int x, int size, int margin );
224
  void extendBorderPelBot   ( int x, int size, int margin );
225
  void extendBorderPelLft   ( int y, int size, int margin );
226
  void extendBorderPelRgt   ( int y, int size, int margin );
227
228
  void linearTransform      ( const int scale, const unsigned shift, const int offset, bool bClip, const ClpRng& clpRng );
229
230
  void transposedFrom       ( const AreaBuf<const T>& other );
231
  void weightCiip           ( const AreaBuf<const T>& intra, const int numIntra );
232
233
  bool compare              ( const AreaBuf<const T>& other ) const;
234
235
350M
        T& at( const int& x, const int& y )          { return buf[y * stride + x]; }
vvenc::AreaBuf<short>::at(int const&, int const&)
Line
Count
Source
235
350M
        T& at( const int& x, const int& y )          { return buf[y * stride + x]; }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo>::at(int const&, int const&)
236
264M
  const T& at( const int& x, const int& y ) const    { return buf[y * stride + x]; }
vvenc::AreaBuf<short const>::at(int const&, int const&) const
Line
Count
Source
236
264M
  const T& at( const int& x, const int& y ) const    { return buf[y * stride + x]; }
Unexecuted instantiation: vvenc::AreaBuf<short>::at(int const&, int const&) const
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo const>::at(int const&, int const&) const
Unexecuted instantiation: vvenc::AreaBuf<int const>::at(int const&, int const&) const
237
238
2.81M
        T& at( const Position& pos )                 { return buf[pos.y * stride + pos.x]; }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo>::at(vvenc::Position const&)
Unexecuted instantiation: vvenc::AreaBuf<short const>::at(vvenc::Position const&)
vvenc::AreaBuf<short>::at(vvenc::Position const&)
Line
Count
Source
238
2.80M
        T& at( const Position& pos )                 { return buf[pos.y * stride + pos.x]; }
vvenc::AreaBuf<vvenc::LoopFilterParam>::at(vvenc::Position const&)
Line
Count
Source
238
9.94k
        T& at( const Position& pos )                 { return buf[pos.y * stride + pos.x]; }
239
44.6k
  const T& at( const Position& pos ) const           { return buf[pos.y * stride + pos.x]; }
vvenc::AreaBuf<short const>::at(vvenc::Position const&) const
Line
Count
Source
239
14.9k
  const T& at( const Position& pos ) const           { return buf[pos.y * stride + pos.x]; }
vvenc::AreaBuf<short>::at(vvenc::Position const&) const
Line
Count
Source
239
29.7k
  const T& at( const Position& pos ) const           { return buf[pos.y * stride + pos.x]; }
240
241
242
941k
        T* bufAt( const int& x, const int& y )       { return &at( x, y ); }
243
1.12M
  const T* bufAt( const int& x, const int& y ) const { return &at( x, y ); }
vvenc::AreaBuf<short const>::bufAt(int const&, int const&) const
Line
Count
Source
243
1.12M
  const T* bufAt( const int& x, const int& y ) const { return &at( x, y ); }
Unexecuted instantiation: vvenc::AreaBuf<short>::bufAt(int const&, int const&) const
244
245
2.81M
        T* bufAt( const Position& pos )              { return &at( pos ); }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo>::bufAt(vvenc::Position const&)
Unexecuted instantiation: vvenc::AreaBuf<short const>::bufAt(vvenc::Position const&)
vvenc::AreaBuf<short>::bufAt(vvenc::Position const&)
Line
Count
Source
245
2.80M
        T* bufAt( const Position& pos )              { return &at( pos ); }
vvenc::AreaBuf<vvenc::LoopFilterParam>::bufAt(vvenc::Position const&)
Line
Count
Source
245
9.94k
        T* bufAt( const Position& pos )              { return &at( pos ); }
246
44.6k
  const T* bufAt( const Position& pos ) const        { return &at( pos ); }
vvenc::AreaBuf<short const>::bufAt(vvenc::Position const&) const
Line
Count
Source
246
14.9k
  const T* bufAt( const Position& pos ) const        { return &at( pos ); }
vvenc::AreaBuf<short>::bufAt(vvenc::Position const&) const
Line
Count
Source
246
29.7k
  const T* bufAt( const Position& pos ) const        { return &at( pos ); }
247
248
  AreaBuf<      T> subBuf( const Area& area )                                                         { return AreaBuf<      T>( bufAt( area ), stride, area   ); }
249
  AreaBuf<const T> subBuf( const Area& area )                                                   const { return AreaBuf<const T>( bufAt( area ), stride, area   ); }
250
9.94k
  AreaBuf<      T> subBuf( const Position& pos, const Size& size )                                    { return AreaBuf<      T>( bufAt( pos  ), stride, size   ); }
Unexecuted instantiation: vvenc::AreaBuf<vvenc::MotionInfo>::subBuf(vvenc::Position const&, vvenc::Size const&)
Unexecuted instantiation: vvenc::AreaBuf<short>::subBuf(vvenc::Position const&, vvenc::Size const&)
vvenc::AreaBuf<vvenc::LoopFilterParam>::subBuf(vvenc::Position const&, vvenc::Size const&)
Line
Count
Source
250
9.94k
  AreaBuf<      T> subBuf( const Position& pos, const Size& size )                                    { return AreaBuf<      T>( bufAt( pos  ), stride, size   ); }
251
14.9k
  AreaBuf<const T> subBuf( const Position& pos, const Size& size )                              const { return AreaBuf<const T>( bufAt( pos  ), stride, size   ); }
vvenc::AreaBuf<short const>::subBuf(vvenc::Position const&, vvenc::Size const&) const
Line
Count
Source
251
14.9k
  AreaBuf<const T> subBuf( const Position& pos, const Size& size )                              const { return AreaBuf<const T>( bufAt( pos  ), stride, size   ); }
Unexecuted instantiation: vvenc::AreaBuf<short>::subBuf(vvenc::Position const&, vvenc::Size const&) const
252
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 ); }
253
  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 ); }
254
};
255
256
typedef AreaBuf<      Pel>  PelBuf;
257
typedef AreaBuf<const Pel> CPelBuf;
258
259
typedef AreaBuf<      TCoeff>  CoeffBuf;
260
typedef AreaBuf<const TCoeff> CCoeffBuf;
261
262
typedef AreaBuf<      TCoeffSig>  CoeffSigBuf;
263
typedef AreaBuf<const TCoeffSig> CCoeffSigBuf;
264
265
typedef AreaBuf<      MotionInfo>  MotionBuf;
266
typedef AreaBuf<const MotionInfo> CMotionBuf;
267
268
typedef AreaBuf<      TCoeff>  PLTescapeBuf;
269
typedef AreaBuf<const TCoeff> CPLTescapeBuf;
270
271
typedef AreaBuf<      bool>  PLTtypeBuf;
272
typedef AreaBuf<const bool> CPLTtypeBuf;
273
274
typedef AreaBuf<      LoopFilterParam>  LFPBuf;
275
typedef AreaBuf<const LoopFilterParam> CLFPBuf;
276
277
5.73M
#define SIZE_AWARE_PER_EL_OP( OP, INC )                     \
278
5.73M
if( ( width & 7 ) == 0 )                                    \
279
4.89M
{                                                           \
280
80.9M
  for( int y = 0; y < height; y++ )                         \
281
76.0M
  {                                                         \
282
309M
    for( int x = 0; x < width; x += 8 )                     \
283
233M
    {                                                       \
284
233M
      OP( x + 0 );                                          \
285
233M
      OP( x + 1 );                                          \
286
233M
      OP( x + 2 );                                          \
287
233M
      OP( x + 3 );                                          \
288
233M
      OP( x + 4 );                                          \
289
233M
      OP( x + 5 );                                          \
290
233M
      OP( x + 6 );                                          \
291
233M
      OP( x + 7 );                                          \
292
233M
    }                                                       \
293
76.0M
                                                            \
294
76.0M
    INC;                                                    \
295
76.0M
  }                                                         \
296
4.89M
}                                                           \
297
5.73M
else if( ( width & 3 ) == 0 )                               \
298
844k
{                                                           \
299
11.0M
  for( int y = 0; y < height; y++ )                         \
300
10.2M
  {                                                         \
301
20.4M
    for( int x = 0; x < width; x += 4 )                     \
302
10.2M
    {                                                       \
303
10.2M
      OP( x + 0 );                                          \
304
10.2M
      OP( x + 1 );                                          \
305
10.2M
      OP( x + 2 );                                          \
306
10.2M
      OP( x + 3 );                                          \
307
10.2M
    }                                                       \
308
10.2M
                                                            \
309
10.2M
    INC;                                                    \
310
10.2M
  }                                                         \
311
844k
}                                                           \
312
18.4E
else if( ( width & 1 ) == 0 )                               \
313
0
{                                                           \
314
0
  for( int y = 0; y < height; y++ )                         \
315
0
  {                                                         \
316
0
    for( int x = 0; x < width; x += 2 )                     \
317
0
    {                                                       \
318
0
      OP( x + 0 );                                          \
319
0
      OP( x + 1 );                                          \
320
0
    }                                                       \
321
0
                                                            \
322
0
    INC;                                                    \
323
0
  }                                                         \
324
0
}                                                           \
325
18.4E
else                                                        \
326
18.4E
{                                                           \
327
18.4E
  for( int y = 0; y < height; y++ )                         \
328
18.4E
  {                                                         \
329
0
    for( int x = 0; x < width; x++ )                        \
330
0
    {                                                       \
331
0
      OP( x );                                              \
332
0
    }                                                       \
333
0
                                                            \
334
0
    INC;                                                    \
335
0
  }                                                         \
336
18.4E
}
337
338
339
template<typename T>
340
T AreaBuf <T> ::getAvg() const
341
{
342
  const T* src = buf;
343
  int64_t  acc = 0;
344
345
#define AVG_INC      src += stride
346
#define AVG_OP(ADDR) acc += src[ADDR]
347
  SIZE_AWARE_PER_EL_OP(AVG_OP, AVG_INC);
348
#undef AVG_INC
349
#undef AVG_OP
350
351
  return T ((acc + (area() >> 1)) / area());
352
}
353
354
template<> Pel AreaBuf<Pel>::getAvg() const;
355
template<> const Pel AreaBuf<const Pel>::getAvg() const;
356
357
template<>
358
void AreaBuf<MotionInfo>::fill( const MotionInfo& val );
359
360
template<typename T>
361
void AreaBuf<T>::fill(const T &val)
362
2.24M
{
363
2.24M
  if( T( 0 ) == val )
364
2.09M
  {
365
2.09M
    GCC_WARNING_DISABLE_class_memaccess
366
2.09M
    if( width == stride )
367
2.09M
    {
368
2.09M
      ::memset( buf, 0, width * height * sizeof( T ) );
369
2.09M
    }
370
4.49k
    else
371
4.49k
    {
372
4.49k
      T* dest = buf;
373
4.49k
      size_t line = width * sizeof( T );
374
375
170k
      for( unsigned y = 0; y < height; y++ )
376
166k
      {
377
166k
        ::memset( dest, 0, line );
378
379
166k
        dest += stride;
380
166k
      }
381
4.49k
    }
382
2.09M
    GCC_WARNING_RESET
383
2.09M
  }
384
143k
  else
385
143k
  {
386
143k
    if( width == stride )
387
143k
    {
388
143k
      std::fill_n( buf, width * height, val );
389
143k
    }
390
18.4E
    else
391
18.4E
    {
392
18.4E
      T* dest = buf;
393
394
18.4E
      for( int y = 0; y < height; y++, dest += stride )
395
0
      {
396
0
        std::fill_n( dest, width, val );
397
0
      }
398
18.4E
    }
399
143k
  }
400
2.24M
}
401
402
template<typename T>
403
void AreaBuf<T>::memset( const int val )
404
296k
{
405
296k
  GCC_WARNING_DISABLE_class_memaccess
406
296k
  if( width == stride )
407
288k
  {
408
288k
    ::memset( buf, val, width * height * sizeof( T ) );
409
288k
  }
410
7.79k
  else
411
7.79k
  {
412
7.79k
    T* dest = buf;
413
7.79k
    size_t line = width * sizeof( T );
414
415
184k
    for( int y = 0; y < height; y++, dest += stride )
416
176k
    {
417
176k
      ::memset( dest, val, line );
418
176k
    }
419
7.79k
  }
420
296k
  GCC_WARNING_RESET
421
296k
}
vvenc::AreaBuf<vvenc::MotionInfo>::memset(int)
Line
Count
Source
404
279k
{
405
279k
  GCC_WARNING_DISABLE_class_memaccess
406
279k
  if( width == stride )
407
279k
  {
408
279k
    ::memset( buf, val, width * height * sizeof( T ) );
409
279k
  }
410
0
  else
411
0
  {
412
0
    T* dest = buf;
413
0
    size_t line = width * sizeof( T );
414
415
0
    for( int y = 0; y < height; y++, dest += stride )
416
0
    {
417
0
      ::memset( dest, val, line );
418
0
    }
419
0
  }
420
279k
  GCC_WARNING_RESET
421
279k
}
vvenc::AreaBuf<vvenc::LoopFilterParam>::memset(int)
Line
Count
Source
404
9.94k
{
405
9.94k
  GCC_WARNING_DISABLE_class_memaccess
406
9.94k
  if( width == stride )
407
2.14k
  {
408
2.14k
    ::memset( buf, val, width * height * sizeof( T ) );
409
2.14k
  }
410
7.79k
  else
411
7.79k
  {
412
7.79k
    T* dest = buf;
413
7.79k
    size_t line = width * sizeof( T );
414
415
184k
    for( int y = 0; y < height; y++, dest += stride )
416
176k
    {
417
176k
      ::memset( dest, val, line );
418
176k
    }
419
7.79k
  }
420
9.94k
  GCC_WARNING_RESET
421
9.94k
}
vvenc::AreaBuf<short>::memset(int)
Line
Count
Source
404
6.97k
{
405
6.97k
  GCC_WARNING_DISABLE_class_memaccess
406
6.97k
  if( width == stride )
407
6.97k
  {
408
6.97k
    ::memset( buf, val, width * height * sizeof( T ) );
409
6.97k
  }
410
0
  else
411
0
  {
412
0
    T* dest = buf;
413
0
    size_t line = width * sizeof( T );
414
415
0
    for( int y = 0; y < height; y++, dest += stride )
416
0
    {
417
0
      ::memset( dest, val, line );
418
0
    }
419
0
  }
420
6.97k
  GCC_WARNING_RESET
421
6.97k
}
422
423
template<typename T>
424
void AreaBuf<T>::copyFrom( const AreaBuf<const T>& other )
425
10.7M
{
426
#if !defined(__GNUC__) || __GNUC__ > 5
427
  static_assert( std::is_trivially_copyable<T>::value, "Type T is not trivially_copyable" );
428
#endif
429
430
10.7M
  g_pelBufOP.copyBuffer( ( const char* ) other.buf, other.stride * sizeof( T ), ( char* ) buf, stride * sizeof( T ), width * sizeof( T ), height );
431
10.7M
}
vvenc::AreaBuf<vvenc::MotionInfo>::copyFrom(vvenc::AreaBuf<vvenc::MotionInfo const> const&)
Line
Count
Source
425
66.7k
{
426
#if !defined(__GNUC__) || __GNUC__ > 5
427
  static_assert( std::is_trivially_copyable<T>::value, "Type T is not trivially_copyable" );
428
#endif
429
430
66.7k
  g_pelBufOP.copyBuffer( ( const char* ) other.buf, other.stride * sizeof( T ), ( char* ) buf, stride * sizeof( T ), width * sizeof( T ), height );
431
66.7k
}
vvenc::AreaBuf<short>::copyFrom(vvenc::AreaBuf<short const> const&)
Line
Count
Source
425
10.7M
{
426
#if !defined(__GNUC__) || __GNUC__ > 5
427
  static_assert( std::is_trivially_copyable<T>::value, "Type T is not trivially_copyable" );
428
#endif
429
430
10.7M
  g_pelBufOP.copyBuffer( ( const char* ) other.buf, other.stride * sizeof( T ), ( char* ) buf, stride * sizeof( T ), width * sizeof( T ), height );
431
10.7M
}
432
433
template<typename T>
434
void AreaBuf<T>::subtract( const AreaBuf<const T>& minuend, const AreaBuf<const T>& subtrahend )
435
{
436
  THROW( "Type not supported" );
437
}
438
439
template<>
440
void AreaBuf<Pel>::subtract( const AreaBuf<const Pel>& minuend, const AreaBuf<const Pel>& subtrahend );
441
442
template<typename T>
443
void AreaBuf<T>::calcVarianceSplit( const AreaBuf<const T>& Org, const uint32_t  size,int& varh,int& varv ) const 
444
{
445
  THROW( "Type not supported" );
446
}
447
448
template<>
449
void AreaBuf<const Pel>::calcVarianceSplit( const AreaBuf<const Pel>& Org, const uint32_t  size, int& varh,int&varv ) const;
450
451
template<typename T>
452
void AreaBuf<T>::copyClip( const AreaBuf<const T>& src, const ClpRng& clpRng )
453
{
454
  THROW( "Type not supported" );
455
}
456
457
template<>
458
void AreaBuf<Pel>::copyClip( const AreaBuf<const Pel>& src, const ClpRng& clpRng );
459
460
template<typename T>
461
void AreaBuf<T>::reconstruct( const AreaBuf<const T>& pred, const AreaBuf<const T>& resi, const ClpRng& clpRng )
462
{
463
  THROW( "Type not supported" );
464
}
465
466
template<>
467
void AreaBuf<Pel>::reconstruct( const AreaBuf<const Pel>& pred, const AreaBuf<const Pel>& resi, const ClpRng& clpRng );
468
469
template<typename T>
470
void AreaBuf<T>::addAvg( const AreaBuf<const T>& other1, const AreaBuf<const T>& other2, const ClpRng& clpRng )
471
{
472
  THROW( "Type not supported" );
473
}
474
475
template<>
476
void AreaBuf<Pel>::addAvg( const AreaBuf<const Pel>& other1, const AreaBuf<const Pel>& other2, const ClpRng& clpRng );
477
478
template<typename T>
479
void AreaBuf<T>::linearTransform( const int scale, const unsigned shift, const int offset, bool bClip, const ClpRng& clpRng )
480
{
481
  THROW( "Type not supported" );
482
}
483
484
template<>
485
void AreaBuf<Pel>::linearTransform( const int scale, const unsigned shift, const int offset, bool bClip, const ClpRng& clpRng );
486
487
template<typename T>
488
void AreaBuf<T>::removeHighFreq( const AreaBuf<const T>& other, const bool bClip, const ClpRng& clpRng )
489
0
{
490
0
  const T*  src       = other.buf;
491
0
  const int srcStride = other.stride;
492
493
0
        T*  dst       = buf;
494
0
  const int dstStride = stride;
495
496
0
#if ENABLE_SIMD_OPT_BCW
497
0
  if (!bClip)
498
0
  {
499
0
    if(!(width & 7))
500
0
      g_pelBufOP.removeHighFreq8(dst, dstStride, src, srcStride, width, height);
501
0
    else if (!(width & 3))
502
0
      g_pelBufOP.removeHighFreq4(dst, dstStride, src, srcStride, width, height);
503
0
    else
504
0
      CHECK(true, "Not supported");
505
0
  }
506
0
  else
507
0
  {
508
0
#endif
509
510
0
#define REM_HF_INC  \
511
0
  src += srcStride; \
512
0
  dst += dstStride; \
513
0
514
0
#define REM_HF_OP_CLIP( ADDR ) dst[ADDR] = ClipPel<T>( 2 * dst[ADDR] - src[ADDR], clpRng )
515
0
#define REM_HF_OP( ADDR )      dst[ADDR] =             2 * dst[ADDR] - src[ADDR]
516
517
0
  if( bClip )
518
0
  {
519
0
    SIZE_AWARE_PER_EL_OP( REM_HF_OP_CLIP, REM_HF_INC );
520
0
  }
521
0
  else
522
0
  {
523
0
    SIZE_AWARE_PER_EL_OP( REM_HF_OP,      REM_HF_INC );
524
0
  }
525
526
0
#undef REM_HF_INC
527
0
#undef REM_HF_OP
528
0
#undef REM_HF_OP_CLIP
529
530
0
#if ENABLE_SIMD_OPT_BCW
531
0
  }
532
0
#endif
533
0
}
534
535
536
template<typename T>
537
void AreaBuf<T>::extendBorderPelLft( int y, int size, int margin )
538
{
539
  T* p = buf + y * stride;
540
  int h = size + y;
541
542
  // do left and right margins
543
  for (; y < h; y++)
544
  {
545
    for (int x = 0; x < margin; x++)
546
    {
547
      *(p - margin + x) = p[0];
548
    }
549
    p += stride;
550
  }
551
}
552
553
template<typename T>
554
void AreaBuf<T>::extendBorderPelTop( int x, int size, int margin )
555
12.4k
{
556
12.4k
  T* p = buf + x;
557
558
  // p is now (-marginX, 0)
559
463k
  for (int y = 0; y < margin; y++)
560
451k
  {
561
451k
    ::memcpy(p - (y + 1) * stride, p, sizeof(T) * size);
562
451k
  }
563
12.4k
}
564
565
template<typename T>
566
void AreaBuf<T>::extendBorderPelRgt( int y, int size, int margin )
567
{
568
  T* p = buf + y * stride;
569
  int h = size + y;
570
571
  // do left and right margins
572
  for( ; y < h; y++)
573
  {
574
    for (int x = 0; x < margin; x++)
575
    {
576
      p[width + x] = p[width - 1];
577
    }
578
    p += stride;
579
  }
580
}
581
582
template<typename T>
583
void AreaBuf<T>::extendBorderPelBot( int x, int size, int margin )
584
12.4k
{
585
12.4k
  T* p = buf + (height-1)*stride + x;
586
587
  // p is now the (-margin, height-1)
588
463k
  for (int y = 0; y < margin; y++)
589
451k
  {
590
451k
    ::memcpy(p + (y + 1) * stride, p, sizeof(T) * size);
591
451k
  }
592
12.4k
}
593
594
template<typename T>
595
void AreaBuf<T>::extendBorderPel(unsigned marginX, unsigned marginY)
596
{
597
  T* p = buf;
598
  int h = height;
599
  int w = width;
600
  int s = stride;
601
602
  CHECK((w + 2 * marginX) > s, "Size of buffer too small to extend");
603
  // do left and right margins
604
  for (int y = 0; y < h; y++)
605
  {
606
    for (int x = 0; x < marginX; x++)
607
    {
608
      *(p - marginX + x) = p[0];
609
      p[w + x] = p[w - 1];
610
    }
611
    p += s;
612
  }
613
614
  // p is now the (0,height) (bottom left of image within bigger picture
615
  p -= (s + marginX);
616
  // p is now the (-margin, height-1)
617
  for (int y = 0; y < marginY; y++)
618
  {
619
    ::memcpy(p + (y + 1) * s, p, sizeof(T) * (w + (marginX << 1)));
620
  }
621
622
  // p is still (-marginX, height-1)
623
  p -= ((h - 1) * s);
624
  // p is now (-marginX, 0)
625
  for (int y = 0; y < marginY; y++)
626
  {
627
    ::memcpy(p - (y + 1) * s, p, sizeof(T) * (w + (marginX << 1)));
628
  }
629
}
630
631
template<> void AreaBuf<Pel>::extendBorderPelLft( int y, int size, int margin );
632
template<> void AreaBuf<Pel>::extendBorderPelRgt( int y, int size, int margin );
633
template<> void AreaBuf<Pel>::extendBorderPel( unsigned marginX, unsigned marginY );
634
635
template<typename T>
636
void AreaBuf<T>::padBorderPel( unsigned marginX, unsigned marginY, int dir )
637
0
{
638
0
  T*  p = buf;
639
0
  int s = stride;
640
0
  int h = height;
641
0
  int w = width;
642
643
0
  CHECK( w  > s, "Size of buffer too small to extend" );
644
645
  // top-left margin
646
0
  if ( dir == 1 )
647
0
  {
648
0
    for( int y = 0; y < marginY; y++ )
649
0
    {
650
0
      for( int x = 0; x < marginX; x++ )
651
0
      {
652
0
        p[x] = p[marginX];
653
0
      }
654
0
      p += s;
655
0
    }
656
0
  }
657
658
  // bottom-right margin
659
0
  if ( dir == 2 )
660
0
  {
661
0
    p = buf + s * ( h - marginY ) + w - marginX;
662
663
0
    for( int y = 0; y < marginY; y++ )
664
0
    {
665
0
      for( int x = 0; x < marginX; x++ )
666
0
      {
667
0
        p[x] = p[-1];
668
0
      }
669
0
      p += s;
670
0
    }
671
0
  }
672
0
}
673
674
675
#if ENABLE_SIMD_OPT_BUFFER
676
template<> void AreaBuf<Pel>::transposedFrom( const AreaBuf<const Pel>& other );
677
#endif
678
679
template<typename T>
680
void AreaBuf<T>::transposedFrom( const AreaBuf<const T>& other )
681
{
682
  CHECK( width * height != other.width * other.height, "Incompatible size" );
683
684
        T* dst  =       buf;
685
  const T* src  = other.buf;
686
  width         = other.height;
687
  height        = other.width;
688
  stride        = stride < width ? width : stride;
689
690
  for( unsigned y = 0; y < other.height; y++ )
691
  {
692
    for( unsigned x = 0; x < other.width; x++ )
693
    {
694
      dst[y + x*stride] = src[x + y*other.stride];
695
    }
696
  }
697
}
698
699
template<typename T>
700
bool AreaBuf <T> ::compare( const AreaBuf<const T>& other ) const
701
{
702
        T* mine   =       buf;
703
  const T* theirs = other.buf;
704
  if( width != other.width) return false;
705
  if( height != other.height) return false;
706
707
  for( unsigned y = 0; y < other.height; y++ )
708
  {
709
    for( unsigned x = 0; x < other.width; x++ )
710
    {
711
      if( mine[x + y*stride] != theirs[x+y*other.stride])
712
      {
713
        return false;
714
      }
715
    }
716
  }
717
  return true;
718
}
719
720
#ifndef DONT_UNDEF_SIZE_AWARE_PER_EL_OP
721
#undef SIZE_AWARE_PER_EL_OP
722
#endif // !DONT_UNDEF_SIZE_AWARE_PER_EL_OP
723
724
// ---------------------------------------------------------------------------
725
// UnitBuf struct
726
// ---------------------------------------------------------------------------
727
728
struct UnitArea;
729
730
template<typename T>
731
struct UnitBuf
732
{
733
  typedef static_vector<AreaBuf<T>,       MAX_NUM_COMP> UnitBufBuffers;
734
  typedef static_vector<AreaBuf<const T>, MAX_NUM_COMP> ConstUnitBufBuffers;
735
736
  ChromaFormat chromaFormat;
737
  UnitBufBuffers bufs;
738
739
1.39M
  UnitBuf() : chromaFormat( NUM_CHROMA_FORMAT ) { }
vvenc::UnitBuf<short>::UnitBuf()
Line
Count
Source
739
1.39M
  UnitBuf() : chromaFormat( NUM_CHROMA_FORMAT ) { }
Unexecuted instantiation: vvenc::UnitBuf<short const>::UnitBuf()
740
  UnitBuf( const ChromaFormat _chromaFormat, const UnitBufBuffers&  _bufs ) : chromaFormat( _chromaFormat ), bufs( _bufs ) { }
741
  UnitBuf( const ChromaFormat _chromaFormat,       UnitBufBuffers&& _bufs ) : chromaFormat( _chromaFormat ), bufs( std::forward<UnitBufBuffers>( _bufs ) ) { }
742
0
  UnitBuf( const ChromaFormat _chromaFormat, const AreaBuf<T>&  blkY )      : chromaFormat( _chromaFormat ), bufs{ blkY } { }
743
0
  UnitBuf( const ChromaFormat _chromaFormat,       AreaBuf<T>&& blkY )      : chromaFormat( _chromaFormat ), bufs{ std::forward<AreaBuf<T> >(blkY) } { }
Unexecuted instantiation: vvenc::UnitBuf<short>::UnitBuf(vvencChromaFormat, vvenc::AreaBuf<short>&&)
Unexecuted instantiation: vvenc::UnitBuf<short const>::UnitBuf(vvencChromaFormat, vvenc::AreaBuf<short const>&&)
744
4.97k
  UnitBuf( const ChromaFormat _chromaFormat, const AreaBuf<T>&  blkY, const AreaBuf<T>&  blkCb, const AreaBuf<T>  &blkCr ) : chromaFormat( _chromaFormat ), bufs{ blkY, blkCb, blkCr } { }
745
783k
  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) } { }
vvenc::UnitBuf<short>::UnitBuf(vvencChromaFormat, vvenc::AreaBuf<short>&&, vvenc::AreaBuf<short>&&, vvenc::AreaBuf<short>&&)
Line
Count
Source
745
783k
  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) } { }
Unexecuted instantiation: vvenc::UnitBuf<short const>::UnitBuf(vvencChromaFormat, vvenc::AreaBuf<short const>&&, vvenc::AreaBuf<short const>&&, vvenc::AreaBuf<short const>&&)
746
747
68.4k
  UnitBuf( const UnitBuf& other )  = default;
748
  UnitBuf(       UnitBuf&& other ) = default;
749
  UnitBuf& operator=( const UnitBuf& other )  = default;
750
  UnitBuf& operator=(       UnitBuf&& other ) = default;
751
752
  // conversion from UnitBuf<const T> to UnitBuf<T>
753
  template<bool T_IS_COST = std::is_const<T>::value>
754
398k
  UnitBuf( const UnitBuf<typename std::remove_const<T>::type>& other, std::enable_if<T_IS_COST>* = 0 ) : chromaFormat( other.chromaFormat ), bufs( other.bufs.begin(), other.bufs.end() ) { }
755
756
10.5M
        AreaBuf<T>& get( const ComponentID comp )        { return bufs[comp]; }
757
98.1k
  const AreaBuf<T>& get( const ComponentID comp )  const { return bufs[comp]; }
vvenc::UnitBuf<short>::get(vvenc::ComponentID) const
Line
Count
Source
757
89.1k
  const AreaBuf<T>& get( const ComponentID comp )  const { return bufs[comp]; }
vvenc::UnitBuf<short const>::get(vvenc::ComponentID) const
Line
Count
Source
757
9.02k
  const AreaBuf<T>& get( const ComponentID comp )  const { return bufs[comp]; }
758
759
2.18M
        AreaBuf<T>& Y()        { return bufs[0]; }
vvenc::UnitBuf<short>::Y()
Line
Count
Source
759
2.18M
        AreaBuf<T>& Y()        { return bufs[0]; }
Unexecuted instantiation: vvenc::UnitBuf<short const>::Y()
760
4.47k
  const AreaBuf<T>& Y()  const { return bufs[0]; }
761
734k
        AreaBuf<T>& Cb()       { return bufs[1]; }
762
  const AreaBuf<T>& Cb() const { return bufs[1]; }
763
734k
        AreaBuf<T>& Cr()       { return bufs[2]; }
764
  const AreaBuf<T>& Cr() const { return bufs[2]; }
765
230k
  bool valid          () const { return bufs.size() != 0; }
766
767
  void fill                 ( const T& val );
768
  void copyFrom             ( const UnitBuf<const T> &other, const bool luma = true, const bool chroma = true );
769
  void reconstruct          ( const UnitBuf<const T>& pred, const UnitBuf<const T>& resi, const ClpRngs& clpRngs );
770
  void copyClip             ( const UnitBuf<const T> &src, const ClpRngs& clpRngs, const bool lumaOnly = false, const bool chromaOnly = false );
771
  void subtract             ( const UnitBuf<const T>& minuend, const UnitBuf<const T>& subtrahend );
772
  void addAvg               ( const UnitBuf<const T>& other1, const UnitBuf<const T>& other2, const ClpRngs& clpRngs, const bool chromaOnly = false, const bool lumaOnly = false);
773
  void addWeightedAvg       ( const UnitBuf<const T>& other1, const UnitBuf<const T>& other2, const ClpRngs& clpRngs, const uint8_t BcwIdx = BCW_DEFAULT, const bool chromaOnly = false, const bool lumaOnly = false);
774
  void padBorderPel         ( unsigned margin, int dir );
775
  void extendBorderPel      ( unsigned margin, bool scale = false);
776
  void extendBorderPelTop   ( int x, int size, int margin );
777
  void extendBorderPelBot   ( int x, int size, int margin );
778
  void extendBorderPelLft   ( int y, int size, int margin );
779
  void extendBorderPelRgt   ( int y, int size, int margin );
780
781
  void removeHighFreq       ( const UnitBuf<const T>& other, const bool bClip, const ClpRngs& clpRngs);
782
783
        UnitBuf<      T> subBuf (const UnitArea& subArea);
784
  const UnitBuf<const T> subBuf (const UnitArea& subArea) const;
785
};
786
787
typedef UnitBuf<      Pel>  PelUnitBuf;
788
typedef UnitBuf<const Pel> CPelUnitBuf;
789
790
typedef UnitBuf<      TCoeff>  CoeffUnitBuf;
791
typedef UnitBuf<const TCoeff> CCoeffUnitBuf;
792
793
template<typename T>
794
void UnitBuf<T>::fill( const T &val )
795
0
{
796
0
  for( int i = 0; i < bufs.size(); i++ )
797
0
  {
798
0
    bufs[i].fill( val );
799
0
  }
800
0
}
801
802
803
template<typename T>
804
void UnitBuf<T>::copyFrom(const UnitBuf<const T> &other, const bool luma, const bool chroma)
805
537k
{
806
537k
  CHECK( chromaFormat != other.chromaFormat, "Incompatible formats" );
807
537k
  CHECK( !luma && !chroma, "At least one channel has to be selected" );
808
809
537k
  const size_t compStart = luma   ? 0           : 1;
810
537k
  const size_t compEnd   = chroma ? bufs.size() : 1;
811
812
2.14M
  for( size_t i = compStart; i < compEnd; i++ )
813
1.61M
  {
814
1.61M
    if( bufs[ i ].buf != nullptr && other.bufs[ i ].buf != nullptr )
815
1.08M
      bufs[i].copyFrom( other.bufs[i] );
816
1.61M
  }
817
537k
}
818
819
template<typename T>
820
void UnitBuf<T>::subtract( const UnitBuf<const T>& minuend, const UnitBuf<const T>& subtrahend )
821
{
822
  CHECK( chromaFormat != minuend.chromaFormat, "Incompatible formats" );
823
  CHECK( chromaFormat != subtrahend.chromaFormat, "Incompatible formats");
824
825
  for( int i = 0; i < bufs.size(); i++ )
826
  {
827
    bufs[i].subtract( minuend.bufs[i], subtrahend.bufs[i] );
828
  }
829
}
830
831
template<typename T>
832
void UnitBuf<T>::copyClip(const UnitBuf<const T> &src, const ClpRngs &clpRngs, const bool lumaOnly, const bool chromaOnly)
833
0
{
834
0
  CHECK( chromaFormat != src.chromaFormat, "Incompatible formats" );
835
836
0
  CHECK(lumaOnly && chromaOnly, "Not allowed to have both lumaOnly and chromaOnly selected");
837
0
  const int compStart = chromaOnly ? 1 : 0;
838
0
  const int compEnd   = lumaOnly   ? 1 : ( int ) bufs.size();
839
0
  for( int i = compStart; i < compEnd; i++ )
840
0
  {
841
0
    bufs[i].copyClip( src.bufs[i], clpRngs[i] );
842
0
  }
843
0
}
844
845
template<typename T>
846
void UnitBuf<T>::reconstruct(const UnitBuf<const T>& pred, const UnitBuf<const T>& resi, const ClpRngs& clpRngs)
847
0
{
848
0
  CHECK( chromaFormat != pred.chromaFormat, "Incompatible formats" );
849
0
  CHECK( chromaFormat != resi.chromaFormat, "Incompatible formats" );
850
851
0
  for( int i = 0; i < bufs.size(); i++ )
852
0
  {
853
0
    bufs[i].reconstruct( pred.bufs[i], resi.bufs[i], clpRngs[i] );
854
0
  }
855
0
}
856
857
template<typename T>
858
void UnitBuf<T>::addAvg(const UnitBuf<const T>& other1, const UnitBuf<const T>& other2, const ClpRngs& clpRngs, const bool chromaOnly /* = false */, const bool lumaOnly /* = false */)
859
0
{
860
0
  const int istart = chromaOnly ? 1 : 0;
861
0
  const int iend   = lumaOnly   ? 1 : ( int ) bufs.size();
862
863
0
  CHECK( lumaOnly && chromaOnly, "should not happen" );
864
865
0
  for( int i = istart; i < iend; i++)
866
0
  {
867
0
    bufs[i].addAvg( other1.bufs[i], other2.bufs[i], clpRngs[i]);
868
0
  }
869
0
}
870
871
template<typename T>
872
void UnitBuf<T>::addWeightedAvg(const UnitBuf<const T>& other1, const UnitBuf<const T>& other2, const ClpRngs& clpRngs, const uint8_t BcwIdx /* = BCW_DEFAULT */, const bool chromaOnly /* = false */, const bool lumaOnly /* = false */)
873
0
{
874
0
  const int istart = chromaOnly ? 1 : 0;
875
0
  const int iend   = lumaOnly   ? 1 : ( int ) bufs.size();
876
877
0
  CHECK( lumaOnly && chromaOnly, "should not happen" );
878
879
0
  for ( int i = istart; i < iend; i++)
880
0
  {
881
0
    bufs[i].addWeightedAvg(other1.bufs[i], other2.bufs[i], clpRngs[i], BcwIdx);
882
0
  }
883
0
}
884
885
template<typename T>
886
void UnitBuf<T>::extendBorderPelTop   ( int x, int size, int margin )
887
4.13k
{
888
16.5k
  for( int i = 0; i < bufs.size(); i++ )
889
12.4k
  {
890
12.4k
    int csx = getComponentScaleX(ComponentID(i), chromaFormat);
891
12.4k
    int csy = getComponentScaleY(ComponentID(i), chromaFormat);
892
12.4k
    bufs[i].extendBorderPelTop( x>>csx, size>>csx, margin>>csy );
893
12.4k
  }
894
4.13k
}
895
896
template<typename T>
897
void UnitBuf<T>::extendBorderPelBot   ( int x, int size, int margin )
898
4.13k
{
899
16.5k
  for( int i = 0; i < bufs.size(); i++ )
900
12.4k
  {
901
12.4k
    int csx = getComponentScaleX(ComponentID(i), chromaFormat);
902
12.4k
    int csy = getComponentScaleY(ComponentID(i), chromaFormat);
903
12.4k
    bufs[i].extendBorderPelBot( x>>csx, size>>csx, margin>>csy );
904
12.4k
  }
905
4.13k
}
906
907
template<typename T>
908
void UnitBuf<T>::extendBorderPelLft   ( int y, int size, int margin )
909
5.37k
{
910
21.5k
  for( int i = 0; i < bufs.size(); i++ )
911
16.1k
  {
912
16.1k
    int csx = getComponentScaleX(ComponentID(i), chromaFormat);
913
16.1k
    int csy = getComponentScaleY(ComponentID(i), chromaFormat);
914
16.1k
    bufs[i].extendBorderPelLft( y>>csy, size>>csy, margin>>csx );
915
16.1k
  }
916
5.37k
}
917
918
template<typename T>
919
void UnitBuf<T>::extendBorderPelRgt   ( int y, int size, int margin )
920
5.38k
{
921
21.5k
  for( int i = 0; i < bufs.size(); i++ )
922
16.1k
  {
923
16.1k
    int csx = getComponentScaleX(ComponentID(i), chromaFormat);
924
16.1k
    int csy = getComponentScaleY(ComponentID(i), chromaFormat);
925
16.1k
    bufs[i].extendBorderPelRgt( y>>csy, size>>csy, margin>>csx );
926
16.1k
  }
927
5.38k
}
928
929
template<typename T>
930
void UnitBuf<T>::extendBorderPel( unsigned margin, bool scaleMargin )
931
1.49k
{
932
1.49k
  if( ! scaleMargin )
933
0
  {
934
0
    for( int i = 0; i < bufs.size(); i++ )
935
0
    {
936
0
      bufs[i].extendBorderPel( margin, margin );
937
0
    }
938
0
  }
939
1.49k
  else
940
1.49k
  {
941
5.97k
    for ( int i = 0; i < bufs.size(); i++)
942
4.47k
    {
943
4.47k
      bufs[i].extendBorderPel(margin >> getComponentScaleX(ComponentID(i), chromaFormat), margin >> getComponentScaleY(ComponentID(i), chromaFormat));
944
4.47k
    }
945
1.49k
  }
946
1.49k
}
947
948
template<typename T>
949
void UnitBuf<T>::padBorderPel( unsigned margin, int dir )
950
0
{
951
0
  for( int i = 0; i < bufs.size(); i++ )
952
0
  {
953
0
    bufs[i].padBorderPel( margin >> getComponentScaleX( ComponentID( i ), chromaFormat ), margin >> getComponentScaleY( ComponentID( i ), chromaFormat ), dir );
954
0
  }
955
0
}
956
957
template<typename T>
958
void UnitBuf<T>::removeHighFreq( const UnitBuf<const T>& other, const bool bClip, const ClpRngs& clpRngs)
959
0
{
960
0
  bufs[0].removeHighFreq(other.bufs[0], bClip, clpRngs[0]);
961
0
}
962
963
template<typename T>
964
UnitBuf<T> UnitBuf<T>::subBuf( const UnitArea& subArea )
965
0
{
966
0
  UnitBuf<T> subBuf;
967
0
  subBuf.chromaFormat = chromaFormat;
968
0
  unsigned blockIdx = 0;
969
970
0
  for( auto &subAreaBuf : bufs )
971
0
  {
972
0
    subBuf.bufs.push_back( subAreaBuf.subBuf( subArea.blocks[blockIdx].pos(), subArea.blocks[blockIdx].size() ) );
973
0
    blockIdx++;
974
0
  }
975
976
0
  return subBuf;
977
0
}
978
979
980
template<typename T>
981
const UnitBuf<const T> UnitBuf<T>::subBuf( const UnitArea& subArea ) const
982
0
{
983
0
  UnitBuf<const T> subBuf;
984
0
  subBuf.chromaFormat = chromaFormat;
985
0
  unsigned blockIdx = 0;
986
987
0
  for( const auto &subAreaBuf : bufs )
988
0
  {
989
0
    subBuf.bufs.push_back( subAreaBuf.subBuf( subArea.blocks[blockIdx].pos(), subArea.blocks[blockIdx].size() ) );
990
0
    blockIdx++;
991
0
  }
992
993
0
  return subBuf;
994
0
}
995
996
// ---------------------------------------------------------------------------
997
// PelStorage struct (PelUnitBuf which allocates its own memory)
998
// ---------------------------------------------------------------------------
999
1000
struct UnitArea;
1001
struct CompArea;
1002
1003
struct PelStorage : public PelUnitBuf
1004
{
1005
  PelStorage();
1006
  ~PelStorage();
1007
1008
  void swap( PelStorage& other );
1009
  void createFromBuf( PelUnitBuf buf );
1010
  void takeOwnership( PelStorage& other );
1011
  void create( const UnitArea& _unit );
1012
  void create( const ChromaFormat &_chromaFormat, const Area& _area );
1013
  void create( const ChromaFormat &_chromaFormat, const Area& _area, const unsigned _maxCUSize, const unsigned _margin = 0, const unsigned _alignment = 0, const bool _scaleChromaMargin = true );
1014
  void destroy();
1015
  void compactResize( const UnitArea& area );
1016
1017
         PelBuf getBuf( const CompArea& blk );
1018
  const CPelBuf getBuf( const CompArea& blk ) const;
1019
1020
         PelBuf getBuf( const ComponentID CompID );
1021
  const CPelBuf getBuf( const ComponentID CompID ) const;
1022
1023
         PelUnitBuf getBuf( const UnitArea& unit );
1024
  const CPelUnitBuf getBuf( const UnitArea& unit ) const;
1025
11.9k
               Pel* getOrigin( const int id ) const { return m_origin[id]; }
1026
1027
         PelUnitBuf getBuf(const int strY, const int strCb, const int strCr, const UnitArea& unit);
1028
  const CPelUnitBuf getBuf(const int strY, const int strCb, const int strCr, const UnitArea& unit) const;
1029
1030
         PelUnitBuf getBufPart( const UnitArea& unit );
1031
  const CPelUnitBuf getBufPart( const UnitArea& unit ) const;
1032
1033
         PelUnitBuf getCompactBuf(const UnitArea& unit);
1034
  const CPelUnitBuf getCompactBuf(const UnitArea& unit) const;
1035
1036
         PelBuf     getCompactBuf(const CompArea& blk);
1037
  const CPelBuf     getCompactBuf(const CompArea& blk) const;
1038
1039
private:
1040
1041
  UnitArea m_maxArea;
1042
  Pel* m_origin[MAX_NUM_COMP];
1043
};
1044
1045
struct CompStorage : public PelBuf
1046
{
1047
107k
  ~CompStorage() { if( valid() ) delete[] m_memory; }
1048
1049
  void compactResize( const Size& size )
1050
3.58M
  {
1051
3.58M
    CHECK( size.area() > m_allocSize, "Resizing causes buffer overflow!" );
1052
3.58M
    Size::operator=( size );
1053
3.58M
    stride = size.width;
1054
3.58M
  }
1055
  void create( const Size& size )
1056
107k
  {
1057
107k
    CHECK( m_memory, "Trying to re-create an already initialized buffer" );
1058
107k
    m_allocSize = size.area();
1059
107k
    m_memory = new Pel[m_allocSize];
1060
107k
    PelBuf::operator=( PelBuf( m_memory, size ) );
1061
107k
  }
1062
  void destroy()
1063
0
  {
1064
0
    if( valid() ) delete[] m_memory;
1065
0
    m_memory    = nullptr;
1066
0
    m_allocSize = 0;
1067
0
  }
1068
776k
  bool valid() { return m_memory != nullptr; }
1069
private:
1070
  ptrdiff_t m_allocSize = 0;
1071
  Pel*      m_memory    = nullptr;
1072
};
1073
1074
template<int NumEntries>
1075
struct SortedPelUnitBufs
1076
{
1077
  void create(ChromaFormat cform, int maxWidth, int maxHeight)
1078
5.97k
  {
1079
5.97k
    m_pacBufs.resize(NumEntries + 1);
1080
5.97k
    m_acStorage.resize(NumEntries + 1);
1081
65.6k
    for (size_t i = 0; i <= NumEntries; i++)
1082
59.7k
    {
1083
59.7k
      m_acStorage[i].create(cform, Area(0, 0, maxWidth, maxHeight));
1084
59.7k
    }
1085
5.97k
  }
1086
1087
  void destroy()
1088
5.97k
  {
1089
65.6k
    for (size_t i = 0; i <= NumEntries; i++)
1090
59.7k
    {
1091
59.7k
      m_acStorage[i].destroy();
1092
59.7k
    }
1093
5.97k
  }
1094
1095
  void reset()
1096
  {
1097
    m_sortedList.clear();
1098
  }
1099
1100
  void reduceTo(int numModes)
1101
24.8k
  {
1102
24.8k
    CHECK( numModes > m_sortedList.size(), "not enough buffers");
1103
24.8k
    m_sortedList.resize(numModes);
1104
24.8k
  }
1105
1106
  void prepare( const UnitArea& ua, int numModes)
1107
32.4k
  {
1108
32.4k
    CHECK( numModes > NumEntries, "not enough buffers");
1109
32.4k
    m_sortedList.resize(numModes);
1110
154k
    for (size_t i = 0; i < numModes; i++)
1111
122k
    {
1112
122k
      m_pacBufs[i] = m_acStorage[i].getCompactBuf(ua);
1113
122k
      m_sortedList[i] = &m_pacBufs[i];
1114
122k
    }
1115
1116
32.4k
    m_pacBufs[numModes] = m_acStorage[numModes].getCompactBuf(ua);
1117
32.4k
    m_TestBuf = &m_pacBufs[numModes];
1118
32.4k
  }
1119
1120
148k
  PelUnitBuf* getBufFromSortedList( int idx)              const { return m_sortedList.size() > idx ? m_sortedList[idx]: nullptr; }
1121
32.4k
  PelBuf&     getTestBuf          ( ComponentID compId)   const { return m_TestBuf->bufs[compId]; }
1122
1.21M
  PelUnitBuf& getTestBuf          ()                      const { return *m_TestBuf; }
1123
1124
  void swap( unsigned pos1, unsigned pos2 )
1125
0
  {
1126
0
    CHECK( pos1 >= m_sortedList.size(), "index out of range" );
1127
0
    CHECK( pos2 >= m_sortedList.size(), "index out of range" );
1128
0
    std::swap(m_sortedList[pos1], m_sortedList[pos2]);
1129
0
  }
1130
1131
  void insert(int insertPos, int RdListSize)
1132
1.21M
  {
1133
1.21M
    if (insertPos != -1)
1134
171k
    {
1135
187k
      for (int i = RdListSize - 1; i > insertPos; i--)
1136
15.3k
      {
1137
15.3k
        std::swap(m_sortedList[i - 1], m_sortedList[i]);
1138
15.3k
      }
1139
171k
      std::swap(m_TestBuf, m_sortedList[insertPos]);
1140
171k
    }
1141
1.21M
  }
1142
1143
private:
1144
  PelUnitBuf*                             m_TestBuf;
1145
  static_vector<PelUnitBuf*,NumEntries>   m_sortedList;
1146
  static_vector<PelUnitBuf, NumEntries+1> m_pacBufs;
1147
  static_vector<PelStorage, NumEntries+1> m_acStorage;
1148
};
1149
1150
struct Window;
1151
1152
void copyPadToPelUnitBuf( PelUnitBuf pelUnitBuf, const vvencYUVBuffer& yuvBuffer, const ChromaFormat& chFmt );
1153
//void setupPelUnitBuf( const YUVBuffer& yuvBuffer, PelUnitBuf& pelUnitBuf, const ChromaFormat& chFmt );
1154
void setupYuvBuffer ( const PelUnitBuf& pelUnitBuf, vvencYUVBuffer& yuvBuffer, const Window* confWindow );
1155
1156
} // namespace vvenc
1157
1158
//! \}
1159