Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for MScaleVect port #45

Open
Boulder08 opened this issue Apr 28, 2020 · 8 comments
Open

Request for MScaleVect port #45

Boulder08 opened this issue Apr 28, 2020 · 8 comments

Comments

@Boulder08
Copy link

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

@dubhater
Copy link
Owner

dubhater commented May 4, 2020

What happens if you try to run Analyse on 8 bit video and Degrain on 16 bit video?

@Boulder08
Copy link
Author

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.?

@Boulder08
Copy link
Author

Original:
original

Diffs:
diffs

@IFeelBloated
Copy link
Contributor

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).

@Boulder08
Copy link
Author

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.

@Boulder08
Copy link
Author

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.

@NSQY NSQY mentioned this issue Feb 11, 2023
@adworacz
Copy link
Contributor

adworacz commented Mar 2, 2023

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

@NSQY
Copy link

NSQY commented Jan 16, 2025

Implemented as a separate plugin https://github.com/Mikewando/manipulate-motion-vectors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants