Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th September 2012, 14:18   #1  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
quad - quadrilateral transform (split from New Utils thread due to bug report)

Download: quad.zip

Last update: 2012-09-30 - ~10% speed increase, bicubic interpolation
Last update: 2012-10-02 - another ~10% speed increase
Last update: 2012-10-05 - 100% speed increase!
Last update: 2012-11-01 - output levels bugfix

quad is a quadrilateral transformation filter similar to vcmohan's reform, although (so far) quad doesn't crash and does a true quadrilateral transformation. It uses bicubic interpolation (can be switched off for speed purposes) and is multi-threaded.

Minimum parameter requirements are 4 x,y pairs defining the corners of the target quadrilateral. The source quadrilateral can also be specified, if required.

No source, sorry - it makes use of too many half-written libraries scattered around my hard drive.

Code:
quad
====

An Avisynth plugin to perform quadrilateral transformations.

Usage
=====

quad(clip, tx0,ty0, tx1,tx1, tx2,ty2, tx3,ty3, [sx0,sy0, sx1,sy1, tx2,ty2, tx3,ty3, bool invert, bool normal, bool draft])

Parameters:
-----------

tx0,ty0-tx3,ty3: the four corners of the target quadrilateral.
sx0,sy0-sx3,sy3: the four corners of the source quadrilateral (default: clip's corners, clockwise from top left)
invert: invert the transformation (transpose t and s)
normal: specify that the coordinates are normalised to the range 0-1.
draft: don't use spline16 interpolation

Last edited by davidhorman; 1st November 2012 at 19:04. Reason: updated version
davidhorman is offline   Reply With Quote
Old 25th September 2012, 17:59   #2  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 405
Quote:
Originally Posted by davidhorman View Post
Can you post a screenshot?
Yes, of course. See _quad000022.jpg, made with the script
ColorBars()
quad(0,0, 1,0, 1,1, 0,1, normal=true)

...Uh., funny. There was the black area inside AvsPmod's preview, but the jpg is stored with a correct picture. I'll try on to catch the picture.

EDIT
I made screenshots now. Looks like 'the thread responsible for the upmost quarter of the image is not finished when the frame is forwarded'. Maybe the thread continues to write afterwards, and then issues the illegal access?
Attached Images
  

Last edited by martin53; 25th September 2012 at 18:11.
martin53 is offline   Reply With Quote
Old 25th September 2012, 19:03   #3  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Strange that the thread for the top strip - which is the first thread to be created - is so far behind, although you were right that the code was failing to wait for that thread (it waited for all the others). Also strange that the edge is slanted like that.

I've updated the DLL (download link as at top of thread) which also includes some very slight speed improvements, though I don't know whether that will fix your scriptclip problem.

David
davidhorman is offline   Reply With Quote
Old 25th September 2012, 22:59   #4  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 405
David,
I think you solved it!
Looks very promising:
Code:
ColorBars()
Subtitle("Flying Colorbars()",text_color=$d0c000,align=5,size=40)
ScriptClip("""
    c=last
    t=0.061*current_frame
    t2=0.127*current_frame
    a=0.501+0.5*sin(t/pi)
    t1x=-0.2*cos(t2)
    t1y=0.5-0.5*cos(t2)
    t2x=1.0+0.2*cos(t2)
    t2y=0.5-0.5*cos(t2)
    t3x=1.0+0.2*cos(t2)
    t3y=0.5+0.5*cos(t2)
    t4x=-0.2*cos(t2)
    t4y=0.5+0.5*cos(t2)
    c1x=0.5+a*cos(t)
    c1y=0.5+a*sin(t)
    c2x=0.5-a*sin(t)
    c2y=0.5+a*cos(t)
    c3x=0.5-a*cos(t)
    c3y=0.5-a*sin(t)
    c4x=0.5+a*sin(t)
    c4y=0.5-a*cos(t)
    c.quad(t1x,t1y, t2x,t2y, t3x,t3y, t4x,t4y, normal=true)
    quad(c1x,c1y, c2x,c2y, c3x,c3y, c4x,c4y, normal=true)
""")
I only once suffered a crash when I had a=0.5+0.5*sin(t/pi), i.e. a can get ==0 - and it's a hard test to set all coordinates identical! Not realistic, I think it is perfect the way it is. Thanks that you took the time to put this together. I feel that this kind of transform really fills a gap and that now, people can create cool new animations that were impossible till now.

Please add the short description file to the new dll for the future downloaders. If you don't mind, you might add the types (float...) of the parameters, and maybe a bit more precise, which ones are optional.
martin53 is offline   Reply With Quote
Old 30th September 2012, 19:13   #5  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Updated with ~10% speed increase and now using bicubic interpolation (I may make this switchable in future, sorry if you liked spline16!)

David
davidhorman is offline   Reply With Quote
Old 5th October 2012, 18:05   #6  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
http://horman.net/quad.zip

Updated again - now twice as fast as the last version

David
davidhorman is offline   Reply With Quote
Old 9th October 2012, 13:20   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,681
David, a version number or date on your zips might be good, the one in New Plugins is still the old one (with the same name).

EDIT: Suggest remove zip from New Plugins and point link here.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 9th October 2012 at 13:24.
StainlessS is offline   Reply With Quote
Old 11th October 2012, 12:16   #8  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 729
I am testing using the script given in a post above. While the earlier version of Quad was running at least through some frames prior to crashing, the latest version (oct 5) virtualdub does not start and gives a message
"An instruction not supported by the CPU was executed in module 'quad'."
My cpu is AMD two core 5000+ x2 and running windows xp.
Is there a problem?
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 11th October 2012, 12:33   #9  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Quote:
Is there a problem?
Definitely. I'd guess it's down to the SSE instructions I've used - I thought I wasn't using anything beyond regular SSE3 (and only one instruction beyond SSE2, HADDPS) but I must be wrong. I'll check my code later and add some fallback code, although I'll have to ask you to test it as I don't have any other CPUs to test it on.

David
davidhorman is offline   Reply With Quote
Old 11th October 2012, 17:40   #10  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Could you give this DLL a try?

quad(amd).zip

I inadvertently used an SSSE3 instruction, which isn't supported by the X2. This alternative DLL replaces it with pure <=SSE3 instructions, with only a minor performance hit.

David
davidhorman is offline   Reply With Quote
Old 11th October 2012, 22:26   #11  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,168
The polite thing to do is code
Code:
if (!(env->GetCPUFlags() & CPUF_SSSE3)) env->ThrowError("Help, I need the SSSE3 instruction set");
it's very poor form to just HCF (Halt and Catch Fire)
IanB is offline   Reply With Quote
Old 12th October 2012, 13:10   #12  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 729
Quote:
Originally Posted by davidhorman View Post
Could you give this DLL a try?


David
I tried and with Martin53 script above it was executing witout any crash. Thank you.
I however noted that the color strips at the edges were narrower than those inside. There is enough space on the screen to display them fully or at least lot wider. This must be true for the regular version also. It appears the edges are truncated.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 12th October 2012, 13:59   #13  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Quote:
I however noted that the color strips at the edges were narrower than those inside. There is enough space on the screen to display them fully or at least lot wider. This must be true for the regular version also. It appears the edges are truncated.
I think (if I understand the problem correctly) that's because Martin's funky script applies quad twice. The first call to quad, depending on the point in the animation, sometimes expands the image outside the frame, so when the second quad is applied, it's already cropped.

David
davidhorman is offline   Reply With Quote
Old 1st November 2012, 19:06   #14  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Hi all,

quad.dll has been updated to fix a bug which was causing RGBA values to be up to +2 above what they should have been - sorry about that!

David
davidhorman is offline   Reply With Quote
Old 11th November 2012, 17:32   #15  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 405
You can see it work here now, thanks again david.
martin53 is offline   Reply With Quote
Old 24th November 2012, 17:27   #16  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,305
I was trying to use FSubstitute, but i'm running into trouble with this plugin. It simply won't load it (error: unable to load ...quad.dll, error=0x7e ...). I have an old athlon where sse(2), SSSE3 is not supported (only mmx and isse). Perhaps this is the problem read the posts above. Could you support mmx for me too (and release the sources)?

Many thanks ...
Wilbert is offline   Reply With Quote
Old 24th November 2012, 19:30   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,681
VS6 Dependency Walker shows quad.dll as needing "Msvcr100.dll" from
Microsoft Visual C++ 2010 Redistributable Package
32 bit
http://www.microsoft.com/download/en...s.aspx?id=5555
64 bit
http://www.microsoft.com/download/en....aspx?id=14632

EDIT: Error 0x7e, missing module. Probably not even getting to the point where CPU could be an issue.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 24th November 2012 at 19:42.
StainlessS is offline   Reply With Quote
Old 24th November 2012, 20:56   #18  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,305
Quote:
VS6 Dependency Walker shows quad.dll as needing "Msvcr100.dll" from
Microsoft Visual C++ 2010 Redistributable Package
Thx, i installed it. But i get now an other warning:
Evaluate: System exception - Illegal Instruction
Wilbert is offline   Reply With Quote
Old 24th November 2012, 23:10   #19  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,418
Hi Wilbert,

Sorry you've had trouble. I've tried to use Ian's suggestion:

Code:
if (!(env->GetCPUFlags() & CPUF_SSSE3)) env->ThrowError("Help, I need the SSSE3 instruction set");
but it didn't work - perhaps it's an Avisynth 2.6 thing, while I've stuck with 2.58.

This may work for you: http://horman.net/quad-no-sse.zip

It's about half the speed of the SSE version, but since that doesn't work for you at all it shouldn't be a problem

Quote:
(and release the sources)?
Ah, sorry, I'm still reluctant to do so. The library I'm using is a tangle of inter-connected files and under constant revision/being messed about with, so I'd rather not release it until/unless I tidy it up a lot (my Avisynth filters only using a small subset of it).

David
davidhorman is offline   Reply With Quote
Old 25th November 2012, 00:07   #20  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,305
Quote:
This may work for you: http://horman.net/quad-no-sse.zip

It's about half the speed of the SSE version, but since that doesn't work for you at all it shouldn't be a problem
Sorry, i still get the same error.
Wilbert is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:54.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.