@@ -76,15 +76,15 @@ class Block
76
76
}
77
77
78
78
template < typename _St2, typename _Fn1 >
79
- void for_each (_St2 &right , _Fn1 _Func)
79
+ void for_each (_St2 &data2 , _Fn1 _Func)
80
80
{
81
- Block_For_each (*this , right , _Func);
81
+ Block_For_each (*this , data2 , _Func);
82
82
}
83
83
84
84
template < typename _St2, typename _Fn1 >
85
- void for_each (_St2 &right , _Fn1 _Func) const
85
+ void for_each (_St2 &data2 , _Fn1 _Func) const
86
86
{
87
- Block_For_each (*this , right , _Func);
87
+ Block_For_each (*this , data2 , _Func);
88
88
}
89
89
90
90
template < typename _Fn1 >
@@ -103,7 +103,7 @@ class Block
103
103
// Default constructor
104
104
Block () {}
105
105
106
- Block (PCType _Height, PCType _Width, PosType pos, bool Init = true , value_type Value = 0 )
106
+ Block (PCType _Height, PCType _Width, const PosType & pos, bool Init = true , value_type Value = 0 )
107
107
: Height_(_Height), Width_(_Width), PixelCount_(Height_ * Width_), pos_(pos)
108
108
{
109
109
AlignedMalloc (Data_, size ());
@@ -113,13 +113,13 @@ class Block
113
113
114
114
// Constructor from plane pointer and PosType
115
115
template < typename _St1 >
116
- Block (const _St1 *src, PCType src_stride, PCType _Height, PCType _Width, PosType pos)
116
+ Block (const _St1 *src, PCType src_stride, PCType _Height, PCType _Width, const PosType & pos)
117
117
: Block(_Height, _Width, pos, false )
118
118
{
119
119
From (src, src_stride);
120
120
}
121
121
122
- // Constructor from src
122
+ // Constructor from src Block
123
123
Block (const _Myt &src, bool Init, value_type Value = 0 )
124
124
: Block(src.Height_, src.Width_, src.pos_, Init, Value)
125
125
{}
@@ -275,10 +275,9 @@ class Block
275
275
}
276
276
277
277
template < typename _St1 >
278
- void From (const _St1 *src, PCType src_stride, PosType pos)
278
+ void From (const _St1 *src, PCType src_stride, const PosType & pos)
279
279
{
280
280
pos_ = pos;
281
-
282
281
From (src, src_stride);
283
282
}
284
283
@@ -303,7 +302,7 @@ class Block
303
302
// Accumulate functions
304
303
305
304
template < typename _St1 >
306
- void AddFrom (const _St1 *src, PCType src_stride, PosType pos)
305
+ void AddFrom (const _St1 *src, PCType src_stride, const PosType & pos)
307
306
{
308
307
auto dstp = data ();
309
308
auto srcp = src + pos.y * src_stride + pos.x ;
@@ -320,7 +319,7 @@ class Block
320
319
}
321
320
322
321
template < typename _St1, typename _Gt1 >
323
- void AddFrom (const _St1 *src, PCType src_stride, PosType pos, _Gt1 gain)
322
+ void AddFrom (const _St1 *src, PCType src_stride, const PosType & pos, _Gt1 gain)
324
323
{
325
324
auto dstp = data ();
326
325
auto srcp = src + pos.y * src_stride + pos.x ;
@@ -403,7 +402,7 @@ class Block
403
402
}
404
403
405
404
// //////////////////////////////////////////////////////////////
406
- // Block matching functions
405
+ // Single block- matching functions
407
406
408
407
template < typename _St1 >
409
408
PosPair BlockMatching (const _St1 *src, PCType src_height, PCType src_width, PCType src_stride, _St1 src_range,
@@ -474,6 +473,9 @@ class Block
474
473
return PosPair (static_cast <KeyType>(distMin * distMul), pos);
475
474
}
476
475
476
+ // //////////////////////////////////////////////////////////////
477
+ // Multiple block-matching functions
478
+
477
479
template < typename _St1 >
478
480
void BlockMatchingMulti (PosPairCode &match_code, const _St1 *src, PCType src_stride, _St1 src_range,
479
481
const PosCode &search_pos, double thMSE) const
@@ -798,7 +800,7 @@ class BlockGroup
798
800
799
801
// Constructor from plane pointer and Pos3PairCode
800
802
template < typename _St1 >
801
- BlockGroup (std::vector<const _St1 *> src, PCType src_stride, const Pos3PairCode &code,
803
+ BlockGroup (const std::vector<const _St1 *> & src, PCType src_stride, const Pos3PairCode &code,
802
804
PCType _GroupSize = -1 , PCType _Height = 16 , PCType _Width = 16 )
803
805
: Height_(_Height), Width_(_Width)
804
806
{
@@ -984,7 +986,7 @@ class BlockGroup
984
986
// Read/Store functions
985
987
986
988
template < typename _St1 >
987
- _Myt & From (const _St1 *src, PCType src_stride)
989
+ void From (const _St1 *src, PCType src_stride)
988
990
{
989
991
auto dstp = data ();
990
992
@@ -1002,12 +1004,10 @@ class BlockGroup
1002
1004
}
1003
1005
}
1004
1006
}
1005
-
1006
- return *this ;
1007
1007
}
1008
1008
1009
1009
template < typename _St1 >
1010
- _Myt & From (std::vector<const _St1 *> src, PCType src_stride)
1010
+ void From (const std::vector<const _St1 *> & src, PCType src_stride)
1011
1011
{
1012
1012
auto dstp = data ();
1013
1013
@@ -1025,8 +1025,6 @@ class BlockGroup
1025
1025
}
1026
1026
}
1027
1027
}
1028
-
1029
- return *this ;
1030
1028
}
1031
1029
1032
1030
template < typename _Dt1 >
@@ -1051,7 +1049,7 @@ class BlockGroup
1051
1049
}
1052
1050
1053
1051
template < typename _Dt1 >
1054
- void To (std::vector<_Dt1 *> dst, PCType dst_stride) const
1052
+ void To (const std::vector<_Dt1 *> & dst, PCType dst_stride) const
1055
1053
{
1056
1054
auto srcp = data ();
1057
1055
@@ -1117,7 +1115,7 @@ class BlockGroup
1117
1115
}
1118
1116
1119
1117
template < typename _Dt1 >
1120
- void AddTo (std::vector<_Dt1 *> dst, PCType dst_stride) const
1118
+ void AddTo (const std::vector<_Dt1 *> & dst, PCType dst_stride) const
1121
1119
{
1122
1120
auto srcp = data ();
1123
1121
@@ -1138,7 +1136,7 @@ class BlockGroup
1138
1136
}
1139
1137
1140
1138
template < typename _Dt1, typename _Gt1 >
1141
- void AddTo (std::vector<_Dt1 *> dst, PCType dst_stride, _Gt1 gain) const
1139
+ void AddTo (const std::vector<_Dt1 *> & dst, PCType dst_stride, _Gt1 gain) const
1142
1140
{
1143
1141
auto srcp = data ();
1144
1142
@@ -1197,7 +1195,7 @@ class BlockGroup
1197
1195
}
1198
1196
1199
1197
template < typename _Dt1 >
1200
- void CountTo (std::vector<_Dt1 *> dst, PCType dst_stride) const
1198
+ void CountTo (const std::vector<_Dt1 *> & dst, PCType dst_stride) const
1201
1199
{
1202
1200
for (PCType z = 0 ; z < GroupSize (); ++z)
1203
1201
{
@@ -1216,7 +1214,7 @@ class BlockGroup
1216
1214
}
1217
1215
1218
1216
template < typename _Dt1 >
1219
- void CountTo (std::vector<_Dt1 *> dst, PCType dst_stride, _Dt1 value) const
1217
+ void CountTo (const std::vector<_Dt1 *> & dst, PCType dst_stride, _Dt1 value) const
1220
1218
{
1221
1219
for (PCType z = 0 ; z < GroupSize (); ++z)
1222
1220
{
@@ -1239,7 +1237,7 @@ class BlockGroup
1239
1237
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1240
1238
1241
1239
1242
- template < typename _St1, typename _Fn1 > inline
1240
+ template < typename _St1, typename _Fn1 >
1243
1241
void Block_For_each (_St1 &data, _Fn1 &&_Func)
1244
1242
{
1245
1243
auto datap = data.data ();
@@ -1250,26 +1248,24 @@ void Block_For_each(_St1 &data, _Fn1 &&_Func)
1250
1248
}
1251
1249
}
1252
1250
1253
- template < typename _St1, typename _St2, typename _Fn1 > inline
1254
- void Block_For_each (_St1 &left , _St2 &right , _Fn1 &&_Func)
1251
+ template < typename _St1, typename _St2, typename _Fn1 >
1252
+ void Block_For_each (_St1 &data1 , _St2 &data2 , _Fn1 &&_Func)
1255
1253
{
1256
- const char *FunctionName = " Block_For_each" ;
1257
- if (left.size () != right.size ())
1254
+ if (data1.size () != data2.size ())
1258
1255
{
1259
- std::cerr << FunctionName << " : size() of left and right must be the same.\n " ;
1260
- exit (EXIT_FAILURE);
1256
+ DEBUG_FAIL (" Block_For_each: size() of data1 and data2 must be the same." );
1261
1257
}
1262
1258
1263
- auto leftp = left .data ();
1264
- auto rightp = right .data ();
1259
+ auto data1p = data1 .data ();
1260
+ auto data2p = data2 .data ();
1265
1261
1266
- for (auto upper = leftp + left .size (); leftp != upper; ++leftp , ++rightp )
1262
+ for (auto upper = data1p + data1 .size (); data1p != upper; ++data1p , ++data2p )
1267
1263
{
1268
- _Func (*leftp , *rightp );
1264
+ _Func (*data1p , *data2p );
1269
1265
}
1270
1266
}
1271
1267
1272
- template < typename _St1, typename _Fn1 > inline
1268
+ template < typename _St1, typename _Fn1 >
1273
1269
void Block_Transform (_St1 &data, _Fn1 &&_Func)
1274
1270
{
1275
1271
auto datap = data.data ();
@@ -1280,14 +1276,12 @@ void Block_Transform(_St1 &data, _Fn1 &&_Func)
1280
1276
}
1281
1277
}
1282
1278
1283
- template < typename _Dt1, typename _St1, typename _Fn1 > inline
1279
+ template < typename _Dt1, typename _St1, typename _Fn1 >
1284
1280
void Block_Transform (_Dt1 &dst, const _St1 &src, _Fn1 &&_Func)
1285
1281
{
1286
- const char *FunctionName = " Block_Transform" ;
1287
1282
if (dst.size () != src.size ())
1288
1283
{
1289
- std::cerr << FunctionName << " : size() of dst and src must be the same.\n " ;
1290
- exit (EXIT_FAILURE);
1284
+ DEBUG_FAIL (" Block_Transform: size() of dst and src must be the same." );
1291
1285
}
1292
1286
1293
1287
auto dstp = dst.data ();
0 commit comments