PDA

View Full Version : How does MakeWriteable work?


trbarry
20th January 2003, 19:03
A couple threads recently have mentioned some sort of MakeWriteable call.

I have a case now where I'm writing a simple filter that would run much faster if I just modified a few bytes of the existing frame instead of copying to a new one.

Does MakeWriteable allow this?

If so, can anyone point out a good source example of a standalone filter that does this?

I didn't find anything on this with a search at Avisynth.org.

- Tom

sh0dan
20th January 2003, 19:30
Many filters use it - the problem was elsewhere (filters that assumed that pitch would be the same for all frames). Fixed and very safe to use :)

Guest
20th January 2003, 20:01
MakeWritable will test whether anyone else has a reference to the frame. If not, it is safe for you to write directly on it and that's what will happen. Otherwise it gets transparently copied and your PVideoFrame variable gets modified to point to the copy. So if a copy is avoidable it will be. That is at least better than always copying.

Look at the source code for Dup. It uses MakeWritable before writing its show=true data onto the frame. One gotcha to watch out for: The pitch can change after calling MakeWritable, so you should reload it.

Bidoche
21st January 2003, 11:31
MakeWritable is a necessity due to the flaw of the PVideoFrame Interface.
In a perfect World, it's the GetWritePtr call who would make frame writable.
But as it it now it would end up changing cached frames... :/

sh0dan
21st January 2003, 12:52
I disabled the makewritable returning, if the frame already was writable - apparently we cannot rely on this. :(

Included in the latest binary.

trbarry
21st January 2003, 16:46
Donald -

Thanks. I'll have a look at the Dup source.

sh0dan -

"I disabled the makewritable returning, if the frame already was writable - apparently we cannot rely on this."

Not sure I understand the implications of this. Is it safe to use MakeWritable now? And does it still give a performance benefit over just copying the frame to a new one?

- Tom

Richard Berg
22nd January 2003, 11:26
Is it safe to use MakeWritable now? And does it still give a performance benefit over just copying the frame to a new one?
Yes, it's safe. No, there's not a performance benefit (other that the fact it'll use the iSSE code in BitBlt), but there will be once it's fixed, so use it anyway.

trbarry
22nd January 2003, 16:47
Ahhh, a "temporary" disablement.

Thanks, I'll code it with makewritable anyway just to see.

- Tom