View Full Version : Treat interlaced as temporary progressive
Cary Knoop
18th September 2018, 06:34
This works fine:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
#c = core.std.SetFieldBased(c, 0)
#c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
But comment out both SetFieldBased functions, there is a vertical shift.
Is it a bug or am I doing something wrong?
Myrsloik
18th September 2018, 09:40
This works fine:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
#c = core.std.SetFieldBased(c, 0)
#c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
But comment out both SetFieldBased functions, there is a vertical shift.
Is it a bug or am I doing something wrong?
Possibly because if it's neither frame/tff it must be bff. You then weave it as tff? Maybe the mismatch has something to do with it.
Cary Knoop
18th September 2018, 15:26
The source is definitely TFF.
Interestingly this does work:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=False)[::2]
And the stream actually remains TFF after the DoubleWeave!
Edited to add: uncommented the SetFieldBased functions
poisondeathray
19th September 2018, 17:34
I can't reproduce the original issue or vertical shift
I started with a 4:2:0 8bit TFF source . I checked with core.text.ClipInfo , and it's "labelled" TFF internally, and also checked with separatefields, so verified the content is also TFF . Also verified in avisynth
I tried both fmtc (going back to 8bit 4:2:0 with point), and zimg/zlib resizers, both work ok . You would expect it to be lossless operation using Point/nearest neighbor
No difference with MakeDiff, or amplified differences
poisondeathray
19th September 2018, 17:59
using fmtc
(because fmtc resample only uses 16bit or 32bit , you have to go back down to 8bit 4:2:0 to compare to original)
a = core.d2v.Source(input=r'blah.d2v')
b = core.std.SeparateFields(a, tff=True)
b = core.fmtc.resample(b, scalev=2, css="444", kernel="point")
b = core.fmtc.resample(b, scalev=0.5, css="444", kernel="point")
b = core.fmtc.resample (b, css="420", kernel="point")
b = core.fmtc.bitdepth (b, bits=8)
b = core.std.DoubleWeave(b, tff=True)[::2]
d = core.std.MakeDiff(a,b, planes=[0,1,2])
da = core.std.Levels(d, min_in=127, max_in=129, gamma=1, min_out=0, max_out=255, planes=[0,1,2])
da.set_output()
For the DoubleWeave TFF vs BFF - if you wanted BFF , you would need to offset and select "odd" fields instead
so it would be
[1::2] instead of [::2]
or
clip = core.std.SelectEvery(clip, cycle=2, offsets=1)
And that works ok too
If there still is an issue, provide more info on the source, source filter , maybe upload a sample
Cary Knoop
19th September 2018, 18:32
The problem I have is not the resize, without the two SetFieldBased functions the resize works fine.
The problem comes when I add the two SetFieldBased functions.
poisondeathray
19th September 2018, 19:01
But comment out both SetFieldBased functions, there is a vertical shift.
The problem I have is not the resize, without the two SetFieldBased functions the resize works fine.
The problem comes when I add the two SetFieldBased functions.
?? Which is it ? With or without ?
Check both the flagging / internal field order with core.text.ClipInfo , and the actual field order by bobbing or separating fields
Cary Knoop
19th September 2018, 19:04
?? Which is it ? With or without ?
Check both the flagging / internal field order with core.text.ClipInfo , and the actual field order by bobbing or separating fields
I am sorry, yes I was not very clear about that.
Without the two SetFieldBased functions, everything works fine.
With the two SetFieldBased functions there is a shift that goes away when I set the DoubleWeave to BFF instead of TFF.
poisondeathray
19th September 2018, 19:21
What are you trying to do exactly ??
Why would you apply those two SetFieldBased functions after separating fields ?
Cary Knoop
19th September 2018, 20:21
What are you trying to do exactly ??
Why would you apply those two SetFieldBased functions after separating fields ?
Obviously, between those two functions, I do various forms of processing.
poisondeathray
19th September 2018, 20:34
Obviously, between those two functions, I do various forms of processing.
It's not that obvious.
Can you give a scenario where you would actually use that?
When you separate fields , it's no longer field based ... technically all operations should be progressive after that point
Once you weave it back into fields, then it's field based. Then all operations should be treated as fields
Cary Knoop
19th September 2018, 20:43
When you separate fields , it's no longer field based ... technically all operations should be progressive after that point
Once you weave it back into fields, then it's field based. Then all operations should be treated as fields
And that is exactly what I am doing. But what I get is a shift unless I set TFF = False during the DoubleWeave().
That seems like a bug to me.
I isolated the problem I found during coding, not sure why questioning what I am using it for has any bearing if something is a bug or not.
poisondeathray
19th September 2018, 21:04
And that is exactly what I am doing. But what I get is a shift unless I set TFF = False during the DoubleWeave().
That seems like a bug to me.
I isolated the problem I found during coding, not sure why questioning what I am using it for has any bearing if something is a bug or not.
But why add the SetFieldBased lines at all??
When you separate fields, it's no longer "field based", nothing has to be "set" .
You would apply whatever operations/filters in a progressive manner (because fields are current separated it's technically progressive)
You don't have to manually override anything. Setting props are only used when you have something flagged incorrectly (e.g. content might be TFF, but flagged BFF or vice versa) , or progressive content flagged incorrectly or vice versa . That can affect other operations e.g if you resize interlaced material in a progressive manner, it will produce artifacts .
Cary Knoop
19th September 2018, 21:16
Perhaps I was wrong in even reporting this on this forum, how silly of me thinking I was doing a service to the Vapoursynth product, reporting that something might be a bug :(
SeeMoreDigital
19th September 2018, 21:22
How about posting a short sample of your source?
poisondeathray
19th September 2018, 21:48
Perhaps I was wrong in even reporting this on this forum, how silly of me thinking I was doing a service to the Vapoursynth product, reporting that something might be a bug :(
Don't be discouraged to report bugs...
I can reproduce the behaviour, and I guess you could argue it's a "bug" ... maybe it's a glass half empty / half full thing
But on the other hand , you could argue it's not "field based", and you shouldn't be using SetFieldBased for that...
If you wanted to do this for some reason, you should be using SetFrameProp after separatefields, which works and passes that info to the next filter like fmtc
e.g
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
#0=frame based (progressive), 1=bottom field first, 2=top field first.
Of course in real life that makes no sense to have interlaced separated fields, but....it works
Cary Knoop
19th September 2018, 21:48
How about posting a short sample of your source?
I already did that:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
#c = core.std.SetFieldBased(c, 0)
#c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
Easy to reproduce, get an interlaced TFF file and assign it to c and see if you observe a shift once you uncomment the SetFieldBased functions.
poisondeathray
19th September 2018, 21:52
It looks to me like the SetFieldBased isn't being passed to the 2nd fmtc.resample correctly
If you "forced" it by adding interlaced=True, tff=1, to make it matching it also works
c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444", kernel="point", interlaced=True, tff=1)
But SetFrameProp seems more robust and can set/override more parameters
Cary Knoop
19th September 2018, 21:56
If you wanted to do this for some reason, you should be using SetFrameProp after separatefields, which works and passes that info to the next filter like fmtc
e.g
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
#0=frame based (progressive), 1=bottom field first, 2=top field first.
Thank you, that is helpful!
Of course in real life that makes no sense to have interlaced separated fields, but....it works
Code sometimes works in mysterious ways :)
Cary Knoop
20th September 2018, 06:29
If you wanted to do this for some reason, you should be using SetFrameProp after separatefields, which works and passes that info to the next filter like fmtc
e.g
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
#0=frame based (progressive), 1=bottom field first, 2=top field first.
Hmm, I have trouble to get this to work properly, can you confirm this actually works for you in the test case I provided?
poisondeathray
20th September 2018, 07:03
Hmm, I have trouble to get this to work properly, can you confirm this actually works for you in the test case I provided?
Yes, in the test case I provided (8bit 4:2:0 source)
Just replace the SetFieldBased lines with SetFrameProp lines between the resample lines
You can verify with MakeDiff , as shown in the earlier example
Cary Knoop
20th September 2018, 07:12
Yes, in the test case I provided (8bit 4:2:0 source)
Just replace the SetFieldBased lines with SetFrameProp lines between the resample lines
You can verify with MakeDiff , as shown in the earlier example
But that case is different right?
This does NOT work for me:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
Remove both SetFieldBased functions and it works.
This does NOT work for me either:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
However, this does work (and the source is definitely TFF):
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=False)[::2]
poisondeathray
20th September 2018, 07:24
You forgot to replace the other SetFieldBased. (Don't use SetFieldBased. At all)
Just replace the SetFieldBased lines with SetFrameProp lines between the resample lines
ie
instead of
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFieldBased(c, 2)
use
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
Cary Knoop
20th September 2018, 07:42
You forgot to replace the other SetFieldBased. (Don't use SetFieldBased. At all)
ie
instead of
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFieldBased(c, 2)
use
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
I tried that but it does not work for me.
But, this does work:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
ntval=2)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=False)[::2]
In effect:
c = core.std.SetFieldBased(c, 0)
c = core.std.SetFieldBased(c, 2)
And
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0)
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
Are equivalent, and both require the Double Weave to use BFF to work correctly.
poisondeathray
20th September 2018, 07:50
It works here. There is a clear handling difference, and you can verify it again by explicitly forcing the resample switch for interlaced=True/False, tff=0/1 . In one case the behaviour of resample follows what the props are set to (SetFrameProp). In the other, they are not (SetFieldBased) .
If it doesn't work for you, we are back to : what is your source, what is your source filter
Cary Knoop
20th September 2018, 08:22
It works here. There is a clear handling difference, and you can verify it again by explicitly forcing the resample switch for interlaced=True/False, tff=0/1 . In one case the behaviour of resample follows what the props are set to (SetFrameProp). In the other, they are not (SetFieldBased) .
So to confirm, this one does not work for you:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFieldBased(c, 0)
#
# Some progressive processing
#
c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
But this one does:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0)
#
# Some progressive processing
#
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
For me, they both do not work, and if I change tff=False in the DoubleWeave() they both work!
poisondeathray
20th September 2018, 15:11
So to confirm, this one does not work for you:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFieldBased(c, 0)
#
# Some progressive processing
#
c = core.std.SetFieldBased(c, 2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
But this one does:
c = core.std.SeparateFields(c, tff=True)
c = core.fmtc.resample(c, scalev=2, css="444",
kernel="point")
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0)
#
# Some progressive processing
#
c = core.std.SetFrameProp(c, prop="_FieldBased", intval=2)
c = core.fmtc.resample(c, scalev=0.5, css="444",
kernel="point")
c = core.std.DoubleWeave(c, tff=True)[::2]
For me, they both do not work, and if I change tff=False in the DoubleWeave() they both work!
Yes; and "not work" means shifting or difference . "Work" means no shifting or difference (confirmed by MakeDiff) . "Work" means the props are passed to the next filter
If you explicitly set interlaced=True, tff=1 for the 2nd fmtc.resample (and keeping DoubleWeave tff=true) what happens ?
Recall I said if you use c=core.std.SetFieldBased(c,2) , you can also "fix" it by explicitly forcing the next resample to interlaced=True, tff=1 (ie. c = core.fmtc.resample(c, scalev=0.5, css="444", kernel="point", interlaced=True, tff=1). At least those are what I'm seeing here. That suggests those SetFieldBased properties are not being passed to the next filter (the behaviour of the next filter isn't taking your SetFieldBased override into account automatically).
But when you use SetFrameProp(c,prop="_FieldBased", intval=2) it works, whether or not you explicitly set interlaced=True, tff=1 . That suggests that info is being passed to the next filter automatically and it's being used .But, if you force interlaced=False or tff=0, you get artifacts and shifting too because it's being done differently
This is potentially important because not all filters have explicit interlaced=true/false, TFF/BFF switches. Some rely on what the props are.
So how are you "viewing" this or converting to RGB for viewing ?
For me, SetFieldBased doesn't work as expected and it says in the documentation it's experimental. But SetFrameProp works, and works on many parameters , not just the ones here
Cary Knoop
20th September 2018, 17:17
I can confirm that for TFF sources, in trivial cases, the SetFrameProp with DoubleWeave() using TFF works.
But it does not work for the code I use, perhaps this is related to some filters not using the props.
Adding the code I use, which uses all kinds of filters, is simply too complex to put here.
But the code does work if DoubleWeave() uses BFF both for SetFrameProp() and SetFieldBased().
I suspect something in Vapoursynth sets information always to BFF regardless whether the source is TFF or BFF after applying SeparateFields().
poisondeathray
20th September 2018, 20:05
I can confirm that for TFF sources, in trivial cases, the SetFrameProp with DoubleWeave() using TFF works.
But it does not work for the code I use, perhaps this is related to some filters not using the props.
Adding the code I use, which uses all kinds of filters, is simply too complex to put here.
But the code does work if DoubleWeave() uses BFF both for SetFrameProp() and SetFieldBased().
Since you agree in the simple case SetFrameProp is working as expected, and when you add your code it's not working as expected, doesn't that logically suggest it's an issue with your additional code / filters ?
I suspect something in Vapoursynth sets information always to BFF regardless whether the source is TFF or BFF after applying SeparateFields().
Maybe, but that's not supported by what you have provided or my observations
You're probably going to have to provide something more concrete and tangible, something that can be reproduced to demonstrate the problem clearly
Cary Knoop
20th September 2018, 22:11
I draw my conclusion, I will use BFF for DoubleWeave, right now that works in all cases.
Cary Knoop
24th September 2018, 21:25
Since you agree in the simple case SetFrameProp is working as expected, and when you add your code it's not working as expected, doesn't that logically suggest it's an issue with your additional code / filters ?
After research of the code in between every time SetFieldBased() is used a problem appears.
I would not use SetFieldBased() at all.
Thanks for your help!
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.