Skip to content

Commit 0361d4b

Browse files
committed
Add parameter int 'optPredictorType' to MAnalyse/MRecalculate
0: use PseudoEPZSearch (as before) 1: use PseudoEPZSearch_glob_med_pred (test) 2: use PseudoEPZSearch_no_pred test
1 parent d61df2b commit 0361d4b

9 files changed

Lines changed: 60 additions & 28 deletions

Sources/GroupOfPlanes.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ void GroupOfPlanes::SearchMVs(
113113
int badrange,
114114
bool meander,
115115
int * vecPrev,
116-
bool tryMany)
116+
bool tryMany,
117+
int optPredictorType)
117118
{
118119
nFlags |= flags;
119120

@@ -176,7 +177,8 @@ void GroupOfPlanes::SearchMVs(
176177
badrange,
177178
meander,
178179
vecPrev,
179-
tryManyLevel
180+
tryManyLevel,
181+
optPredictorType
180182
);
181183

182184
out += planes[nLevelCount - 1]->GetArraySize(divideExtra);
@@ -244,7 +246,8 @@ void GroupOfPlanes::SearchMVs(
244246
badrange,
245247
meander,
246248
vecPrev,
247-
tryManyLevel
249+
tryManyLevel,
250+
optPredictorType
248251
);
249252

250253
out += planes[i]->GetArraySize(divideExtra);
@@ -272,7 +275,8 @@ void GroupOfPlanes::RecalculateMVs(
272275
int fieldShift,
273276
sad_t thSAD,
274277
int smooth,
275-
bool meander)
278+
bool meander,
279+
int optPredictorType)
276280
{
277281
nFlags |= flags;
278282

@@ -305,7 +309,8 @@ void GroupOfPlanes::RecalculateMVs(
305309
thSAD,
306310
divideExtra,
307311
smooth,
308-
meander
312+
meander,
313+
optPredictorType
309314
);
310315

311316
out += planes[0]->GetArraySize(divideExtra);

Sources/GroupOfPlanes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public :
6262
SearchType searchType, int nSearchParam, int _PelSearch, int _nLambda,
6363
sad_t _lsad, int _pnew, int _plevel, bool _global, int flags, int *out,
6464
short * outfilebuf, int fieldShift, int _pzero, int _pglobal, sad_t badSAD,
65-
int badrange, bool meander, int *vecPrev, bool tryMany);
65+
int badrange, bool meander, int *vecPrev, bool tryMany, int optPredictorType);
6666
void WriteDefaultToArray (int *array);
6767
int GetArraySize ();
6868
void ExtraDivide (int *out, int flags);
6969
void RecalculateMVs (
7070
MVClip &mvClip, MVGroupOfFrames *pSrcGOF, MVGroupOfFrames *pRefGOF,
7171
SearchType _searchType, int _nSearchParam, int _nLambda, sad_t _lsad,
7272
int _pnew, int flags, int *out, short * outfilebuf, int fieldShift,
73-
sad_t thSAD, int smooth, bool meander);
73+
sad_t thSAD, int smooth, bool meander, int optPredictorType);
7474
};
7575

7676
#endif

Sources/Interface.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ AVSValue __cdecl Create_MVAnalyse(AVSValue args, void* user_data, IScriptEnviron
192192
args[31].AsBool(true), // mt
193193
args[32].AsInt(0), // scaleCSAD
194194
args[33].AsInt(0), // optsearchoption 2.2.46
195+
args[34].AsInt(0), // optpredictortype 2.2.46
195196
env
196197
);
197198
}
@@ -562,6 +563,7 @@ AVSValue __cdecl Create_MVRecalculate(AVSValue args, void*, IScriptEnvironment*
562563
args[21].AsBool(true), // mt
563564
args[22].AsInt(0), // scaleCSAD
564565
args[23].AsInt(0), // optsearchoption 2.7.46
566+
args[24].AsInt(0), // optpredictortype 2.7.46
565567
env
566568
);
567569
}
@@ -679,7 +681,7 @@ AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
679681
AVS_linkage = vectors;
680682
#endif
681683
env->AddFunction("MShow", "cc[scale]i[sil]i[tol]i[showsad]b[number]i[thSCD1]i[thSCD2]i[isse]b[planar]b", Create_MVShow, 0);
682-
env->AddFunction("MAnalyse", "c[blksize]i[blksizeV]i[levels]i[search]i[searchparam]i[pelsearch]i[isb]b[lambda]i[chroma]b[delta]i[truemotion]b[lsad]i[plevel]i[global]b[pnew]i[pzero]i[pglobal]i[overlap]i[overlapV]i[outfile]s[dct]i[divide]i[sadx264]i[badSAD]i[badrange]i[isse]b[meander]b[temporal]b[trymany]b[multi]b[mt]b[scaleCSAD]i[optsearchoption]i", Create_MVAnalyse, 0);
684+
env->AddFunction("MAnalyse", "c[blksize]i[blksizeV]i[levels]i[search]i[searchparam]i[pelsearch]i[isb]b[lambda]i[chroma]b[delta]i[truemotion]b[lsad]i[plevel]i[global]b[pnew]i[pzero]i[pglobal]i[overlap]i[overlapV]i[outfile]s[dct]i[divide]i[sadx264]i[badSAD]i[badrange]i[isse]b[meander]b[temporal]b[trymany]b[multi]b[mt]b[scaleCSAD]i[optsearchoption]i[optpredictortype]i", Create_MVAnalyse, 0);
683685
env->AddFunction("MMask", "cc[ml]f[gamma]f[kind]i[time]f[Ysc]i[thSCD1]i[thSCD2]i[isse]b[planar]b", Create_MVMask, 0);
684686
env->AddFunction("MCompensate", "ccc[scbehavior]b[recursion]f[thSAD]i[fields]b[time]f[thSCD1]i[thSCD2]i[isse]b[planar]b[mt]b[tr]i[center]b[cclip]c[thSAD2]i", Create_MVCompensate, 0);
685687
env->AddFunction("MSCDetection", "cc[Ysc]i[thSCD1]i[thSCD2]i[isse]b", Create_MVSCDetection, 0);
@@ -695,7 +697,7 @@ AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
695697
env->AddFunction("MDegrain5", "cccccccccccc[thSAD]i[thSADC]i[plane]i[limit]f[limitC]f[thSCD1]i[thSCD2]i[isse]b[planar]b[lsb]b[mt]b[out16]b[out32]b", Create_MVDegrainX, (void *)5);
696698
env->AddFunction("MDegrain6", "cccccccccccccc[thSAD]i[thSADC]i[plane]i[limit]f[limitC]f[thSCD1]i[thSCD2]i[isse]b[planar]b[lsb]b[mt]b[out16]b[out32]b", Create_MVDegrainX, (void *)6);
697699
env->AddFunction("MDegrainN", "ccci[thSAD]i[thSADC]i[plane]i[limit]f[limitC]f[thSCD1]i[thSCD2]i[isse]b[planar]b[lsb]b[thsad2]i[thsadc2]i[mt]b[out16]b", Create_MDegrainN, 0);
698-
env->AddFunction("MRecalculate", "cc[thsad]i[smooth]i[blksize]i[blksizeV]i[search]i[searchparam]i[lambda]i[chroma]b[truemotion]b[pnew]i[overlap]i[overlapV]i[outfile]s[dct]i[divide]i[sadx264]i[isse]b[meander]b[tr]i[mt]b[scaleCSAD]i[optsearchoption]i", Create_MVRecalculate, 0);
700+
env->AddFunction("MRecalculate", "cc[thsad]i[smooth]i[blksize]i[blksizeV]i[search]i[searchparam]i[lambda]i[chroma]b[truemotion]b[pnew]i[overlap]i[overlapV]i[outfile]s[dct]i[divide]i[sadx264]i[isse]b[meander]b[tr]i[mt]b[scaleCSAD]i[optsearchoption]i[optpredictortype]i", Create_MVRecalculate, 0);
699701
env->AddFunction("MBlockFps", "cccc[num]i[den]i[mode]i[ml]f[blend]b[thSCD1]i[thSCD2]i[isse]b[planar]b[mt]b", Create_MVBlockFps, 0);
700702
env->AddFunction("MSuper", "c[hpad]i[vpad]i[pel]i[levels]i[chroma]b[sharp]i[rfilter]i[pelclip]c[isse]b[planar]b[mt]b", Create_MVSuper, 0);
701703
env->AddFunction("MStoreVect", "c+[vccs]s", Create_MStoreVect, 0);

Sources/MVAnalyse.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ MVAnalyse::MVAnalyse(
4343
int _overlapx, int _overlapy, const char* _outfilename, int _dctmode,
4444
int _divide, int _sadx264, sad_t _badSAD, int _badrange, bool _isse,
4545
bool _meander, bool temporal_flag, bool _tryMany, bool multi_flag,
46-
bool mt_flag, int _chromaSADScale, int _optSearchOption, IScriptEnvironment* env
46+
bool mt_flag, int _chromaSADScale, int _optSearchOption, int _optPredictorType, IScriptEnvironment* env
4747
)
4848
: ::GenericVideoFilter(_child)
4949
, _srd_arr(1)
@@ -55,6 +55,7 @@ MVAnalyse::MVAnalyse(
5555
, _dct_pool()
5656
, _delta_max(0)
5757
, optSearchOption(_optSearchOption)
58+
, optPredictorType(_optPredictorType)
5859

5960
{
6061
has_at_least_v8 = true;
@@ -90,6 +91,11 @@ MVAnalyse::MVAnalyse(
9091
env->ThrowError("MAnalyse: Clip must be YUV or YUY2");
9192
}
9293

94+
if (_optPredictorType != 0 && _optPredictorType != 1 && _optPredictorType != 2)
95+
{
96+
env->ThrowError("MAnalyse: parameter 'optPredictorType' must be 0, 1 or 2");
97+
}
98+
9399
if (vi.IsY())
94100
chroma = false; // silent fallback
95101

@@ -631,7 +637,7 @@ PVideoFrame __stdcall MVAnalyse::GetFrame(int n, IScriptEnvironment* env)
631637
searchType, nSearchParam, nPelSearch, nLambda, lsad, pnew, plevel,
632638
global, srd._analysis_data.nFlags, reinterpret_cast<int*>(pDst),
633639
outfilebuf, fieldShift, pzero, pglobal, badSAD, badrange,
634-
meander, pVecPrevOrNull, tryMany
640+
meander, pVecPrevOrNull, tryMany, optPredictorType
635641
);
636642

637643
if (divideExtra)

Sources/MVAnalyse.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ class MVAnalyse
9191
const bool _multi_flag;
9292
const bool _temporal_flag;
9393
const bool _mt_flag;
94+
// 'opt' beginning until live during tests
9495
int optSearchOption; // DTL test
96+
int optPredictorType; // DTL test
9597

9698
int pixelsize; // PF
9799
int bits_per_pixel;
@@ -122,7 +124,7 @@ class MVAnalyse
122124
int _overlapx, int _overlapy, const char* _outfilename, int _dctmode,
123125
int _divide, int _sadx264, sad_t _badSAD, int _badrange, bool _isse,
124126
bool _meander, bool temporal_flag, bool _tryMany, bool multi_flag,
125-
bool mt_flag, int _chromaSADScale, int _optSearchOption, IScriptEnvironment* env);
127+
bool mt_flag, int _chromaSADScale, int _optSearchOption, int _predictorType, IScriptEnvironment* env);
126128
~MVAnalyse();
127129

128130
::PVideoFrame __stdcall GetFrame(int n, ::IScriptEnvironment* env) override;

Sources/MVRecalculate.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ MVRecalculate::MVRecalculate(
4141
int _blksizex, int _blksizey, int st, int stp, int lambda, bool chroma,
4242
int _pnew, int _overlapx, int _overlapy, const char* _outfilename,
4343
int _dctmode, int _divide, int _sadx264, bool _isse, bool _meander,
44-
int trad, bool mt_flag, int _chromaSADScale, int _optSearchOption, IScriptEnvironment* env
44+
int trad, bool mt_flag, int _chromaSADScale, int _optSearchOption, int _optPredictorType, IScriptEnvironment* env
4545
)
4646
: GenericVideoFilter(_super)
4747
, _srd_arr()
@@ -51,6 +51,7 @@ MVRecalculate::MVRecalculate(
5151
, _nbr_srd((trad > 0) ? trad * 2 : 1)
5252
, _mt_flag(mt_flag)
5353
, optSearchOption(_optSearchOption)
54+
, optPredictorType(_optPredictorType)
5455
{
5556
has_at_least_v8 = true;
5657
try { env->CheckVersion(8); }
@@ -85,6 +86,11 @@ MVRecalculate::MVRecalculate(
8586
env->ThrowError("MRecalculate: Clip must be YUV or YUY2");
8687
}
8788

89+
if (_optPredictorType != 0 && _optPredictorType != 1 && _optPredictorType != 2)
90+
{
91+
env->ThrowError("MRecalculate: parameter 'optPredictorType' must be 0, 1 or 2");
92+
}
93+
8894
vi.num_frames *= _nbr_srd;
8995
vi.MulDivFPS(_nbr_srd, 1);
9096

@@ -556,7 +562,7 @@ PVideoFrame __stdcall MVRecalculate::GetFrame(int n, IScriptEnvironment* env)
556562
*(srd._clip_sptr), pSrcGOF, pRefGOF,
557563
searchType, nSearchParam, nLambda, lsad, pnew,
558564
srd._analysis_data.nFlags, reinterpret_cast <int *> (pDst),
559-
outfilebuf, fieldShift, thSAD, smooth, meander
565+
outfilebuf, fieldShift, thSAD, smooth, meander, optPredictorType
560566
);
561567

562568
if (divideExtra)

Sources/MVRecalculate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class MVRecalculate
118118
int pixelsize; // PF
119119
int bits_per_pixel;
120120
int optSearchOption; // DTL test
121+
int optPredictorType; // DTL test
121122

122123
public :
123124

@@ -126,7 +127,7 @@ public :
126127
int _blksizex, int _blksizey, int st, int stp, int lambda, bool chroma,
127128
int _pnew, int _overlapx, int _overlapy, const char* _outfilename,
128129
int _dctmode, int _divide, int _sadx264, bool _isse, bool _meander,
129-
int trad, bool mt_flag, int _chromaSADScale, int _optSearchOption, IScriptEnvironment* env
130+
int trad, bool mt_flag, int _chromaSADScale, int _optSearchOption, int _optPredictorType, IScriptEnvironment* env
130131
);
131132
~MVRecalculate();
132133

Sources/PlaneOfBlocks.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ void PlaneOfBlocks::SearchMVs(
279279
SearchType st, int stp, int lambda, sad_t lsad, int pnew,
280280
int plevel, int flags, sad_t *out, const VECTOR * globalMVec,
281281
short *outfilebuf, int fieldShift, sad_t * pmeanLumaChange,
282-
int divideExtra, int _pzero, int _pglobal, sad_t _badSAD, int _badrange, bool meander, int *vecPrev, bool _tryMany
282+
int divideExtra, int _pzero, int _pglobal, sad_t _badSAD, int _badrange, bool meander, int *vecPrev, bool _tryMany,
283+
int optPredictorType
283284
)
284285
{
285286
// - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -371,9 +372,10 @@ void PlaneOfBlocks::SearchMVs(
371372
_out = out;
372373
_outfilebuf = outfilebuf;
373374
_vecPrev = vecPrev;
374-
_meander_flag = meander;
375+
_meander_flag = meander;
375376
_pnew = pnew;
376-
_lsad = lsad;
377+
_lsad = lsad;
378+
_predictorType = optPredictorType; // v2.7.46
377379

378380
// - - - - - - - - - - - - - - - - - - - - - - - - -
379381

@@ -402,7 +404,8 @@ void PlaneOfBlocks::RecalculateMVs(
402404
MVClip & mvClip, MVFrame *_pSrcFrame, MVFrame *_pRefFrame,
403405
SearchType st, int stp, int lambda, sad_t lsad, int pnew,
404406
int flags, int *out,
405-
short *outfilebuf, int fieldShift, sad_t thSAD, int divideExtra, int smooth, bool meander
407+
short *outfilebuf, int fieldShift, sad_t thSAD, int divideExtra, int smooth, bool meander,
408+
int optPredictorType
406409
)
407410
{
408411
// - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -480,7 +483,8 @@ void PlaneOfBlocks::RecalculateMVs(
480483

481484
_out = out;
482485
_outfilebuf = outfilebuf;
483-
_meander_flag = meander;
486+
_meander_flag = meander;
487+
_predictorType = optPredictorType; // 2.7.46
484488
_pnew = pnew;
485489
_lsad = lsad;
486490
_mv_clip_ptr = &mvClip;
@@ -1165,7 +1169,7 @@ void PlaneOfBlocks::PseudoEPZSearch_no_pred(WorkingArea& workarea)
11651169
workarea.planeSAD += workarea.bestMV.sad; // for debug, plus fixme outer planeSAD is not used
11661170
}
11671171

1168-
// DTS test
1172+
// DTL test
11691173
template<typename pixel_t>
11701174
void PlaneOfBlocks::PseudoEPZSearch_glob_med_pred(WorkingArea& workarea)
11711175
{
@@ -3197,11 +3201,14 @@ void PlaneOfBlocks::search_mv_slice(Slicer::TaskData &td)
31973201
workarea.predictors[4] = ClipMV(workarea, zeroMV);
31983202
}
31993203

3200-
// Possible point of placement selection of 'predictors control'
3201-
PseudoEPZSearch<pixel_t>(workarea); // all predictors (original)
3202-
// DTL additions
3203-
// PseudoEPZSearch_glob_med_pred<pixel_t>(workarea); // partial predictors
3204-
// PseudoEPZSearch_no_pred<pixel_t>(workarea); // no predictiors
3204+
// Possible point of placement selection of 'predictors control'
3205+
if (_predictorType == 0)
3206+
PseudoEPZSearch<pixel_t>(workarea); // all predictors (original)
3207+
else if (_predictorType == 1) // DTL: partial predictors
3208+
PseudoEPZSearch_glob_med_pred<pixel_t>(workarea);
3209+
else // if (_predictorType == 2) // DTL: no predictiors
3210+
PseudoEPZSearch_no_pred<pixel_t>(workarea);
3211+
32053212
// workarea.bestMV = zeroMV; // debug
32063213

32073214
if (outfilebuf != NULL) // write vector to outfile

Sources/PlaneOfBlocks.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class PlaneOfBlocks
8181
int stp, int lambda, sad_t lsad, int pnew, int plevel,
8282
int flags, sad_t *out, const VECTOR *globalMVec, short * outfilebuf, int fieldShiftCur,
8383
int * meanLumaChange, int divideExtra,
84-
int _pzero, int _pglobal, sad_t _badSAD, int _badrange, bool meander, int *vecPrev, bool _tryMany);
84+
int _pzero, int _pglobal, sad_t _badSAD, int _badrange, bool meander, int *vecPrev, bool _tryMany,
85+
int optPredictorType);
8586

8687

8788
/* plane initialisation */
@@ -104,7 +105,8 @@ class PlaneOfBlocks
104105
void RecalculateMVs(MVClip & mvClip, MVFrame *_pSrcFrame, MVFrame *_pRefFrame, SearchType st,
105106
int stp, int _lambda, sad_t _lSAD, int _pennew,
106107
int flags, int *out, short * outfilebuf, int fieldShift, sad_t thSAD,
107-
int _divideExtra, int smooth, bool meander);
108+
int _divideExtra, int smooth, bool meander,
109+
int optPredictorType);
108110

109111

110112
private:
@@ -223,6 +225,7 @@ class PlaneOfBlocks
223225
int _smooth;
224226
sad_t _thSAD;
225227
// const VECTOR zeroMV = {0,0,(sad_t)-1};
228+
int _predictorType; // 2.7.46
226229

227230

228231
// Working area

0 commit comments

Comments
 (0)