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

Unclear about what src_top, src_left should do,... #14

Open
Selur opened this issue Jun 5, 2021 · 12 comments
Open

Unclear about what src_top, src_left should do,... #14

Selur opened this issue Jun 5, 2021 · 12 comments

Comments

@Selur
Copy link

Selur commented Jun 5, 2021

Since I don't get the description I tried to figure out what the parameters do.
Using:

# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/ResizeFilter/DPID/vapoursynth-dpid.dll")
# source: 'F:\TestClips&Co\files\Drone_rocky.mov'

# current color space: YUV420P10, bit depth: 10, resolution: 3840x2076, fps: 23.976, color matrix: 2020ncl, yuv luminance scale: limited, scanorder: progressive
# Loading F:\TestClips&Co\files\MPEG-4 H.264\4k\Back to the Future (1985) 4k 10bit - 0.10.35-0.11.35.mkv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="F:/TestClips&Co/files/MPEG-4 H.264/4k/Back to the Future (1985) 4k 10bit - 0.10.35-0.11.35.mkv", format="YUV420P10", cache=0, prefer_hw=0)
# making sure input color matrix is set as 2020ncl
clip = core.resize.Point(clip, matrix_in_s="2020ncl",range_s="limited")
# making sure frame rate is set to 23.976
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
a = core.fmtc.resample(clip=clip, kernel="lanczos", w=720, h=300, interlaced=False, interlacedd=False)
a = core.resize.Bicubic(clip=a, format=vs.YUV420P10, range_s="limited")

b = core.dpid.Dpid(clip=clip, width=720, height=300, src_left=[99.5,16.6]);
b = core.resize.Bicubic(clip=b, format=vs.YUV420P10, matrix_s="709", range_s="limited")

c = core.std.MakeDiff(a,b,planes=[0])
d = core.std.MakeDiff(a,b)

clip = core.std.StackVertical([ core.std.StackHorizontal([a,b]),core.std.StackHorizontal([c,d])])
# set output frame rate to 23.976fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)

# Output
clip.set_output()

I got this https://i.postimg.cc/prq7qMVQ/src-left.png
To me it looks like only one plane of the color is shifted, is this a bug or intended?

=> Would be nice if you could share some details on what those parameters should do. Thanks.

@WolframRhodium
Copy link
Owner

Yes they are used for shifting, same as parameters sx and sy of fmtc.resample.

@Selur
Copy link
Author

Selur commented Jun 5, 2021

But shouldn't they shift all planes? I first assumed that those parameters are meant to shift the focus of 'what is important',...

@WolframRhodium
Copy link
Owner

The shifting of chroma channels is not clearly visible, as in the bottom right image you posted. The bottom left image contains chroma information of clip a.

You should use the following code to compare the effect of shifting.

# verify the first channel is shifted
c = core.std.Expr([a, b], ["x y - 512 +", "512"])
# verify the second channel is shifted
d = core.std.Expr([a, b], ["512", "x y - 10 * 512 +", "512"])

@Selur
Copy link
Author

Selur commented Jun 5, 2021

Yeah, but if all planes are shifted the same way, why is there a shift in the upper right image?

@WolframRhodium
Copy link
Owner

I guess you may want to use

b = core.dpid.Dpid(clip=clip, width=720, height=300, src_left=[99.5], src_top=[16.6])

And each value in the array specifies shifting of one plane.

@Selur
Copy link
Author

Selur commented Jun 5, 2021

And each value in the array specifies shifting of one plane.

so for YUV
src_left = [shift_Y_vertical, shift_U_vertical, shift_V_vertical]
src_top = [shift_Y_horizontal, shift_U_horizontal, shift_V_horizontal]
and for RGB
src_left = [shift_R_vertical, shift_G_vertical, shift_B_vertical]
src_top = [shift_R_horizontal, shift_G_horizontal, shift_B_horizontal]
and those are floats for sub-pixel shifting, right?

@WolframRhodium
Copy link
Owner

True.

@Selur
Copy link
Author

Selur commented Jun 5, 2021

Okay, thanks for clearing that up, I didn't get that from the description. :)

@WolframRhodium
Copy link
Owner

Sorry about that. I try to clarify it in a new commit.

@Selur
Copy link
Author

Selur commented Jun 5, 2021

No problem.
Got another question. If I use for example:
src_left=[5], src_top=[5] and planes=[1] will the shift be ignored since the shift is for plane 0
or will it be interpreted as src_left=[0,5,0], src_top=[0,5,0] and thus shift plane 1?
or is src_left=[5], src_top=[5] the same as src_left=[5,5,5], src_top=[5,5,5]?

@WolframRhodium
Copy link
Owner

WolframRhodium commented Jun 5, 2021

src_left=[5], src_top=[5] is interpreted as src_left=[5,5,5], src_top=[5,5,5].

In

down = core.resize.Bilinear(src, 720, 300, src_left=5, src_top=5)
clip = core.dpid.DpidRaw(src, down, src_left=[5], src_top=[5], planes=[1])

Plane 0 and 2 of clip are from down, which are shifted by 5.
Plane 1 are processed by dpid, which is also shifted by 5.

@Selur
Copy link
Author

Selur commented Jun 5, 2021

Thanks, for explaining. :)

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

2 participants