View Single Post
Old 22nd October 2007, 18:56   #658  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
What if multithreded SetMTMode(2,2) is on?
I do not know exactly, probably it use one thread for even output frames, and second thread for odd frames.
In example above, the "idx clip" some frame may be calculated by else even thread or odd thread.
Buffer size is limited, so sometimes it's memory is overwritten.
IMO it is the MOST DANGEROUS OPERATION (around line 493 of MVFrame.cpp).
If one thread is reading frame from buffer (it is not momentary process), and at same time other thread is overwriting this frame buffer (by other frame), we will get mess. Probability is not high (time to read is small relatively to other calculations).
If this unknown value is about 1/10000, then every 1 from 10000 frames is bad, i.e. 10 bad frames per 1 hour.
IMO it is dependent on mumber MV functions in script, number of CPU (thread) and on buffer array size.
Probably it may depend on some other processes in system.

Partial workaround: increase constant MV_BUFFER_FRAMES array size. Now it is 10.
Here is test versions with different array sizes (4,5,6,15):
http://avisynth.org.ru/tmp/mvtools4.dll
http://avisynth.org.ru/tmp/mvtools5.dll
http://avisynth.org.ru/tmp/mvtools6.dll
http://avisynth.org.ru/tmp/mvtools15.dll

Please test.

Better workaround: use counter of threads (or functions) accessed the frame, like smart pointers. Increment it while access, decrement it when leave.

May be try use variable array size and increment it if all current buffers are filled (locked).
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.

Last edited by Fizick; 23rd October 2007 at 16:42. Reason: links
Fizick is offline   Reply With Quote