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 19th October 2021, 14:31   #1  |  Link
arnea
Registered User
 
Join Date: Oct 2005
Posts: 7
Using plugins from plugins?

I'm writing (yet another) stabilization plugin. Last step of the processing would be panning the image. Basically I need to crop the image from one side and add borders to other side. I looked at the Crop and AddBorders plugins code - it's quite complicated, handles all the different formats and corner-cases, etc. I could just copypaste it, but I was wondering is it possible to actually call Crop and AddBorders from my own plugin to do the job? Sure, it's not so efficient, but the trying out things it would be sufficient.
arnea is offline   Reply With Quote
Old 19th October 2021, 19:09   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Uglarm plugin:- https://forum.doom9.org/showthread.php?t=176891
does quite a few Invoke()'s, suggest take a peek at the source code.

here just a little bit

Code:
    if(ShowMode >= 2) {
        DPRINTF("ShowMode=%d",ShowMode)
        ret = new Uglarm(ret,Pat_X,Pat_Y,Pat_W,Pat_H,SAR,BlurPower,Msk,xmod,ymod,hasChroma,ShowMode,env);
        DPRINTF("Returned from Uglarm constructor")
        // Blank Border
        if(Blank) {
            DPRINTF("Showing BLANK LetterBox")
            // Letterbox (clip, int top, int bottom, [int left], [int right], int "color")
            // un-named args NULL names
            AVSValue    LetterBox_Args[6]   = {  ret,   ClipY, vi.height-ClipY-ClipH,  ClipX, vi.width-ClipX-ClipW, 0x000000 };
            const char* LetterBox_Names[6]  = {  NULL,   NULL,                  NULL,   NULL,              NULL,     "color" };
            try {
                DPRINTF("Calling Invoke LetterBox (Blank)")
                ret = env->Invoke("LetterBox", AVSValue(LetterBox_Args,6),LetterBox_Names).AsClip();
                DPRINTF("Invoke LetterBox Succeeds (Blank)")
            } catch (IScriptEnvironment::NotFound) {
                DPRINTF("Invoke LetterBox Fails (Blank)")
                env->ThrowError("%sWhoa! Could not Invoke LetterBox! (Blank)",myName);
            }
            DPRINTF("Done Uglarm Blank")
        }
    } else {
The DPRINTF() calls just output some stuff to DebugView window [#ifdef BUG, otherwise outputs nothing].

and a bit more with crop
Code:
            DPRINTF("Showing Hollow")
            // Layer(c.crop(ClipX,ClipY,ClipW,ClipH).ExL_ResetMask,"add", Amount_Max, ClipX,ClipY) : Last          #     Hollow out non clipped area, with clip normal
            AVSValue CropClip_Args[6]     = {  HollowSrc, ClipX, ClipY, ClipW, ClipH,    true };
            const char* CropClip_Names[6] = { NULL,  NULL,  NULL,  NULL,  NULL, "align" };
            PClip CropClip;
            try {
                DPRINTF("Calling Invoke Crop (Hollow)")
                CropClip = env->Invoke("Crop", AVSValue(CropClip_Args,6),CropClip_Names).AsClip();
                DPRINTF("Invoke Crop Succeeds (Hollow)")
            } catch (IScriptEnvironment::NotFound) {
                DPRINTF("Invoke Crop Fails (Hollow)")
                env->ThrowError("%sWhoa! Could not Invoke Crop! (Hollow)",myName);
            }
            if(vi.IsRGB32() || ConvRGB24) { // If RGB32 or RGB24 Converted to RGB32
                DPRINTF("ResetMask on RGB32")
                AVSValue ResetMask_Args[1]     = { CropClip};
                const char* ResetMask_Names[1] = {     NULL};
                try {
                    DPRINTF("Calling Invoke ResetMask (Hollow)")
                    CropClip = env->Invoke("ResetMask", AVSValue(ResetMask_Args,1),ResetMask_Names).AsClip();
                    DPRINTF("Invoke ResetMask Succeeds (Hollow)")
                } catch (IScriptEnvironment::NotFound) {
                    DPRINTF("Invoke ResetMask Fails (Hollow)")
                    env->ThrowError("%sWhoa! Could not Invoke ResetMask! (Hollow)",myName);
                }
            }
EDIT: Above, CropClip_Names NULL's are for un-named args, the last one "align" is optional named.

EDIT: Invoke on wiki:- http://avisynth.nl/index.php/Filter_SDK/Env_Invoke

My code does some Invokes (eg ConvertToRGB32) in the 'Create_Uglarm' function which calls the constructor,
and then does more invokes on the clip returned from the constructor, to eg convert back to YV12 or whatever.

EDIT: Below, Wonkey suggests resizer rather than crop, yes, that is better than crop.
__________________
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; 20th October 2021 at 09:30.
StainlessS is offline   Reply With Quote
Old 19th October 2021, 19:10   #3  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,492
For that you can use env->Invoke(...)

http://avisynth.nl/index.php/Filter_SDK/Env_Invoke

Crop and AddBorders will only get you pixel-accurate (or less, depending on colour format) panning, though. Instead you can use one of the resizers with offsets (be warned that bicubicresize will soften your image unless you set b = 0 and c = 0.5, if I remember correctly).
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey 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 04:13.


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