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 > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th March 2018, 00:06   #1  |  Link
videoh
Registered User
 
Join Date: Jul 2014
Posts: 734
Implementing dual Vapoursynth/Avisynth filters

In coding a single DGDecodeNV.dll to support native use by both Vapoursynth and Avisynth(+) I run into practical matters that I hope you may be able to suggest some good approach for. The issue is to avoid unnecessary code duplication.

For example, in Avisynth GetFrame() is nonstatic and has access to its class variables directly. In Vapoursynth, GetFrame() is static and receives an instance pointer. So I have vs-> references throughout the GetFrame() code but not for Avisynth, making it very hard to use common code. There are some other similar things but I'll concentrate on this for now.

I've been able to 'commonify' the other calls but GetFrame() is looking difficult. Naturally, I don't want to duplicate large chunks of code just to add vs-> to all the member references, etc.

Any ideas would be appreciated and could help others to make good dual plugins. Thank you.
videoh is offline   Reply With Quote
Old 24th March 2018, 00:15   #2  |  Link
Stephen R. Savage
Registered User
 
Stephen R. Savage's Avatar
 
Join Date: Nov 2009
Posts: 341
Try to make a filter class that is independent of VS and AVS APIs.

Code:
class MyFilter {
    MyFrame GetFrame(/* ... */);
};

class MyAvsFilter {
    MyFilter *pFilter;
    PVideoFrame GetFrame(/* ... */)
    {
        MyFrame frame = pFilter->GetFrame();
        PVideoFrame avs_frame = /* ... */;
        return avs_frame.
    }
};

struct MyVsFilter {
    MyFilter *filter;
};

VSFrameRef *vs_get_frame(/* ... */)
{
    MyFilter *filter = ((MyVsFilter *)instanceData)->filter;
    MyFrame frame = filter->GetFrame();
    VSFrameRef *vs_frame = /* ... */;
    return vs_frame;
}
Stephen R. Savage 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:35.


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