Log in

View Full Version : video pitch with separatefields(). Bug?


vcmohan
12th September 2006, 08:36
I have been experiencing access violation errors while processing with my plugins when I use the following code prior to my plugin F2Quiver call. YV12, NTSC 720X480 data

assumeframebased()
separatefields()
However if I do

assumeframebased()
separatefields()
selectodd()
I have no error.

If I use crop(0.0.360,240) in place of separatefields I have no error
later I tried the following
assumeframebased()
separatefields()
info()
When I monitored the info I found that for the first two frames the video pitch is reported (correctly?) as 1440 I assume separatefields just moves the framepointer, doubles pitch and halves the height. But to my shock for the next frame onwards it is reporting as 720.
Now I am at a loss as to which is correct internally for Avisynth.
Since I use GetPitch() in the begining for my frequency transforms buffer initializations, I realize I am getting these access violations. If this is a bug request please correct.

squid_80
12th September 2006, 09:49
By "in the beginning" do you mean you call GetPitch() only once at filter construction, or once for every different frame? Pitch is not required to be consistent/constant for different frames.

vcmohan
13th September 2006, 04:42
By "in the beginning" do you mean you call GetPitch() only once at filter construction, or once for every different frame? Pitch is not required to be consistent/constant for different frames.
. Yes I thought so and thats the reason I make a fresh call to GetPitch() for each frame. Eventhough I think the pitch remains constant just after Separatefields() call, after first original frame ( after first two separated fields, or the third call to GetFrame(..)) a wrong pitch value is reported. As I use this wrong pitch value, I get access violation error. This probably is a bug in SeparateFields().

tsp
13th September 2006, 20:29
It's not a bug. The pitch is allowed to change from frame to frame.
try this script

source=blackness(length=2,pixel_type="YUY2")
pitch1=source.Crop(2, 0, -10, 0)
pitch2=source.Crop(2, 0, -10, 0,align=true)
pitch1+pitch2

for the first two frames the pitch is 1280 while for the last two frames the pitch is 1264
(avisynth 2.5.6)

vcmohan
14th September 2006, 04:13
Yes the pitch can vary from frame to frame, but this will happen only if one joins different clips. But in the case I have shown above it is one DirectShowsource("...."), followed by assumeframebased() and Separatefields(). I assume the pitch remain constant in this output. Why it does not?

tsp
14th September 2006, 22:36
I see what you mean know. The reason why info() is reporting inconsistent result is that it calls env->makewritable on the frames from seperatefields() the result from this is saved in the cache so the refcount is higher than 1. This forces Makewritable to create a new frame and copy the result from seperatefields to it and by doing this the pitch is reduced to 720. It could be something like that, that are creating problems for you (So please wait till after you have called env->Makewritable before requesting the pitch). This is just one of many example how the pitch can change from frame to frame in other way than joining two clips.
If you want to see how it works try downloading the source for avisynth compile it and step though with the debugger

vcmohan
15th September 2006, 03:51
Yes. I realized this problem yesterday and am in the process of checking up and correcting my source files. In one plugin initially I use the readptr, but later depending on the statistics either return a work frame and return work or use makewritable and return the original frame. I therefore have to call GetPitch() twice.

tsp
15th September 2006, 18:04
ehh you can just return the original frame without calling makewritable if you don't modify the frame (but I guess you are adding some text right?). Another thing most of the time you can use env->NewVideoFrame and env->bltbit instead of env->MakeWritable as the bltbit happends anyway because of the cache. See this thread: http://forum.doom9.org/showthread.php?t=100715&highlight=Fizick+makewritable+bug

Fizick
15th September 2006, 19:25
Oh, I remember that thread! :)