vapoursynth-mvtools
vapoursynth-mvtools copied to clipboard
Request for MScaleVect port
Would it be possible to have the smart MScaleVect functionality in Vapoursynth's MVTools as well? It can be used to speedup analysing by doing analysis on the original 8-bit clip and then using the vectors in high bit depth degraining etc. It would also make dct=5 usable, which helps with the quality of the vectors. In 16-bit analysis, it tends to slow things down quite a lot.
https://forum.doom9.org/showthread.php?p=1826390#post1826390
What happens if you try to run Analyse on 8 bit video and Degrain on 16 bit video?
No errors appear at least. I never thought trying that as it's always been a no-no to mix clips of different formats.. Some changes when comparing the results of 8-bit and 16-bit analysis and amplifying the change, but that is expected, of course.
clp = core.dgdecodenv.DGSource(source=r"whatever.dgi")
degrain16 = core.fmtc.bitdepth(clp, bits=16)
superanalyse8 = core.mv.Super(clp, pel=2, chroma=True, rfilter=4, sharp=1)
supermdg16 = core.mv.Super(degrain16, pel=2, chroma=True, rfilter=4, levels=1, sharp=1)
clp16 = core.fmtc.bitdepth(clp, bits=16)
superanalyse16 = core.mv.Super(clp16, pel=2, chroma=True, rfilter=4, sharp=1)
analyze_args = dict(blksize=32, overlap=16, search=5, searchparam=8, pelsearch=8, truemotion=False)
degrain_args_16 = dict(thsad=200, thsadc=100, limit=1*256, limitc=2*256, thscd1=300, thscd2=80)
bv1_8 = core.mv.Analyse(superanalyse8, isb=True, delta=1, **analyze_args)
fv1_8 = core.mv.Analyse(superanalyse8, isb=False, delta=1, **analyze_args)
bv1_16 = core.mv.Analyse(superanalyse16, isb=True, delta=1, **analyze_args)
fv1_16 = core.mv.Analyse(superanalyse16, isb=False, delta=1, **analyze_args)
finalclip8 = core.mv.Degrain1(clp16, supermdg16, bv1_8, fv1_8, **degrain_args_16)
finalclip16 = core.mv.Degrain1(clp16, supermdg16, bv1_16, fv1_16, **degrain_args_16)
result = core.std.MakeDiff(finalclip8, finalclip16)
result = core.std.Levels(result, min_in=125*256, max_in=132*256, min_out=0, max_out=255*256, planes=[0])
result.set_output()
So are you saying that code-wise, it should be safe to go without any problems with scaling values etc.?
Original:
Diffs:
What happens if you try to run Analyse on 8 bit video and Degrain on 16 bit video?
VectorStructure::sad would be corrupted (invalid range).
Is it something that should be immediately visible or just in some corner cases? I tried looking at different places in that test video but couldn't find anything totally strange.
In fact, if the whole function seems too big to port, I think the bitdepth scaling would already cover most use cases easily without any noticable quality loss. In UHD resolutions, motion analysis at high bitdepth gets very slow and dct=5 is totally unusable.
The actual code to do this isn't that complicated, if we use pinterf's version as an example: https://github.com/pinterf/mvtools/blob/mvtools-pfmod/Sources/MScaleVect.cpp
Should be easy for anyone to do, but I'll add this to my todo list. Might get to it sometime in 2023... ha