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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 5th January 2020, 23:08   #5041  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 302
In that case, I wish that somebody would do it now, because all I really need is the core (by which I mean "built in", no external plugins) functionality of AviSynth(+), especially audio (as long as there would be a way to render it). It wouldn't matter to me that the only way of loading something would be to use ffmpeg, because (as you say) virtually everything on Linux uses that in the background anyway.
Richard1485 is offline  
Old 5th January 2020, 23:31   #5042  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,417
Seems like qyot27 recommended you to switch to Avisynth+. That is something you can do right now; you don't need to wait for somebody to do something.
videoh is offline  
Old 5th January 2020, 23:38   #5043  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 302
Quote:
Originally Posted by videoh View Post
Seems like qyot27 recommended you to switch to Avisynth+. That is something you can do right now; you don't need to wait for somebody to do something.
But I don't know how to get AviSynth+ working on Linux: I'd need instructions. If I were on Windows, I'd run the installer, but I'm not on Windows.

Last edited by Richard1485; 5th January 2020 at 23:58.
Richard1485 is offline  
Old 6th January 2020, 01:35   #5044  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,207
AvxSynth is what is currently available. As long as the stuff you need isn't AviSynth 2.6- or Plus-specific, it can suffice for the time being.

These instructions were written on Ubuntu 19.10. Whether Debian's basal repos use the same package names, I don't know. The version of FFmpeg provided with at least Debian Stretch has --enable-avisynth active by default, and this will also apply to anything built against it (like the kdenlive example above).

Code:
# Dependencies:
sudo apt-get install build-essential checkinstall git yasm liblog4cpp5-dev liblog4cpp5v5 libcairo2-dev libpango1.0-dev libjpeg-dev

# Build AvxSynth:
git clone git://github.com/avxsynth/avxsynth.git && \
cd avxsynth

# The following are necessary because avxframeserver fails to build:
sed -i '433d' configure.ac && \
sed -i -e '31d' -e '29d' Makefile.am

# Continue:
autoreconf -fiv && \
CPPFLAGS="-fpermissive -march=native" ./configure --enable-silent-rules --disable-avxedit --disable-ffms2 --with-pic && \
make -j$(nproc) && \
    sudo checkinstall --pkgname=avxsynth --pkgversion="1:$(grep "Version" \
    avxsynth.pc | cut -f2 -d " ")+$(git rev-list --count HEAD)-g$(git rev-parse \
    --short HEAD)-$(date +%Y%m%d)" --backup=no --deldoc=yes --delspec=yes \
    --deldesc=yes --strip=yes --stripso=yes --addso=yes --fstrans=no --default

# Build FFmpeg or install the -dev libraries relating to it (avcodec, avformat, avutil, avfilter, avdevice, swscale, postproc, swresample):


# Build FFMS2 for AvxSynth (and retain plugin compatibility with VapourSynth):
git clone git://github.com/qyot27/ffms2_cplugin.git ffms2 && \
cd ffms2 && \
git checkout c_plugin && \
./configure --enable-vapoursynth --enable-avxsynth --enable-shared --extra-cppflags="-march=native" --enable-pic && \
make -j$(nproc) && \
    sudo checkinstall --pkgname=ffms2 --pkgversion="1:$(./version.sh)-git" \
    --backup=no --deldoc=yes --delspec=yes --deldesc=yes --strip=yes --stripso=yes \
    --addso=yes --fstrans=no --default

Last edited by qyot27; 6th January 2020 at 01:58.
qyot27 is offline  
Old 6th January 2020, 04:14   #5045  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,417
I would use Vapoursynth on Linux.
videoh is offline  
Old 6th January 2020, 16:53   #5046  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Posts: 6,480
I've looked at the code from avs2pipemod, avsr and AvisynthWrapper and they all create a global variable to save the return value from GetAVSLinkage but they are not really doing anything with this variable, what's the point?
stax76 is offline  
Old 6th January 2020, 18:05   #5047  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 302
Quote:
Originally Posted by qyot27 View Post
These instructions were written on Ubuntu 19.10.
Many thanks! That's what I'm running as well. I hope that instructions for AviSynth+ might appear at some point, but I'm very grateful for these.
Quote:
Originally Posted by qyot27 View Post
# Build FFmpeg or install the -dev libraries relating to it (avcodec, avformat, avutil, avfilter, avdevice, swscale, postproc, swresample):
I don't know how to do the latter, so I'll try the former. The static binaries don't seem to have been built with -enable-avisynth.
Quote:
Originally Posted by videoh View Post
I would use Vapoursynth on Linux.
Doubtless, and I know what VapourSynth is, but there are still advantages to AviSynth, so it would be beneficial to have both.
Richard1485 is offline  
Old 6th January 2020, 20:37   #5048  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,207
Quote:
Originally Posted by Richard1485 View Post
I don't know how to do the latter, so I'll try the former. The static binaries don't seem to have been built with -enable-avisynth.
Code:
sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev libswscale-dev libpostproc-dev libswresample-dev
Should work.
qyot27 is offline  
Old 6th January 2020, 21:06   #5049  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,012
Quote:
Originally Posted by stax76 View Post
I've looked at the code from avs2pipemod, avsr and AvisynthWrapper and they all create a global variable to save the return value from GetAVSLinkage but they are not really doing anything with this variable, what's the point?
See here.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 6th January 2020 at 21:08.
Groucho2004 is offline  
Old 6th January 2020, 21:37   #5050  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Posts: 6,480
Quote:
Originally Posted by Groucho2004 View Post
See here.
So this variable is really needed and it's some advanced C++ feature I do not understand?

I've forgotten half I knew about C++, so I'm reading this tutorial to refresh it, so far am here:

https://www.learncpp.com/cpp-tutoria...null-pointers/

In managed code it might be necessary to use a variable so the GC don't collect it but since there is no GC in native code I don't understand why this variable exists.
stax76 is offline  
Old 7th January 2020, 08:10   #5051  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 302
Quote:
Originally Posted by qyot27 View Post
sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev libswscale-dev libpostproc-dev libswresample-dev
Oh, so they are just packages! Sorry: for some reason, imagined that there was more to it than that. Thanks!
Richard1485 is offline  
Old 9th January 2020, 16:12   #5052  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Posts: 6,480
I notice now it produces a linker error without this AVS_linkage variable...
stax76 is offline  
Old 9th January 2020, 22:30   #5053  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,281
stax, look in avs 2.6, or avs+ header.

The OLD v2.58 BAKED code that existed in v2.58 header was not very portable between avs versions, plugins compiled with such were basically
locked to the code in the header. The avs 2.60 header [after v2.60Alpha 4] implemented AVS_Linkage stuff when using the new AvisynthPluginInit3(), so that code is no longer BAKED into the plugin from the header,
but instead it can use code from within avisynth itself, and so is able to better adapt.
A plugin using eg Avs+ header but running under avs 2.60 standard, can still inquire stuff like bit depth, even though such functionality does not exist in avs 2.6 std(nor exists in 2.58).
[EDIT: There are kludges in the avs+ header to implement code not existing in the active version of avisynth]
For this more flexible whatsit to work proper, it is necessary to initialize AVS_Linkage with the pointer to vectors [EDIT: which is supplied by the server, usually avisynth] when
calling the instance of AvisynthPluginInit3() coded within a plugin, this replaces most of the previously BAKED-in code.

avs+ header
Code:
/*
 * Avisynth C++ plugin API code function pointers.
 *
 * In order to maintain binary compatibility with
 * future version do not change the order of the
 * existing function pointers. It will be baked
 * into all existing plugins.
 *
 * Add new function pointers to the end of the
 * structure. The linkage macros generate some
 * protection code to ensure newer plugin do not
 * call non-existing functions in an older host.
 */

struct AVS_Linkage {   // const AVS_Linkage *AVS_linkage is a pointer to struct of (mostly) function pointers to call

  int Size;

/**********************************************************************/

// struct VideoInfo
  bool    (VideoInfo::*HasVideo)() const;
  bool    (VideoInfo::*HasAudio)() const;
  bool    (VideoInfo::*IsRGB)() const;
  bool    (VideoInfo::*IsRGB24)() const;
  bool    (VideoInfo::*IsRGB32)() const;
  bool    (VideoInfo::*IsYUV)() const;

  // ... much more
Usual AvisynthPluginInit3() initializing [avisynth calls AvisynthPluginInit3() embedded into a plugin, to initialize that plugin]
Code:
/* New 2.6 requirement!!! */
// Declare and initialise server pointers static storage.
const AVS_Linkage *AVS_linkage = 0;    // UNSET as yet for current plugin, each plugin has its own instance

/* New 2.6 requirement!!! */
// DLL entry point called from LoadPlugin() to setup a user plugin.
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
             // Above vectors, pointer provided by avisynth server (v2.6, avs+ or std) enabling non baked-in stuff

    /* New 2.6 requirment!!! */
    // Save the server pointers.
    AVS_linkage = vectors;    // make everything work like magic, plug vectors into AVS_linkage
    env->AddFunction("TitleBar", "c[Tit]s[ShowFrameNo]b[Col]i[ColChr]s[Esc]b", Create_TitleBar, 0);     // Some plugin, can now use avisynth server funcs via AVS_linkage
    return "'TitleBar' TitleBar plugin"; // A freeform name of the plugin.
}

hope that 'above sort of' explains it [it is likely that it could be explained better if anyone cares to - I'm happy to accept that 'it works'].

EDIT:
Some of the Kludgy stuff in avs+ header
Code:
  // AVS+ extensions
  // 20161005:
  //   Mapping of AVS+ extensions to classic 2.6 functions.
  //   In order to use these extended AVS+ functions for plugins that should work
  //   either with AVS+ or with Classic (8 bit) Avs 2.6 ans earlier AVS+ versions, there is an
  //   automatic fallback mechanism.
  //   From AVS+'s point of view these are not "baked" codes, the primary functions should exist.
  //   Examples:
  //   Is444() is mapped to IsYV24() for classic AVS2.6
  //   ComponentSize() returns constant 1 (1 bytes per pixel component)
  //   BitsPerComponent() returns constant 8 (Classic AVS2.6 is 8 bit only)

  // Returns the number of color channels or planes in a frame
  int NumComponents() const AVS_BakedCode(return AVS_LinkCallOptDefault(NumComponents, (((AVS_LinkCall(IsYUV)()) && !(AVS_LinkCall(IsY8)())) ? 3 : AVS_LinkCall(BytesFromPixels)(1)) ) )

  // Returns the size in bytes of a single component of a pixel
  int ComponentSize() const AVS_BakedCode(return AVS_LinkCallOptDefault(ComponentSize, 1))

  // Returns the bit depth of a single component of a pixel
  int BitsPerComponent() const AVS_BakedCode(return AVS_LinkCallOptDefault(BitsPerComponent, 8))    // simply return 8 if avs std (provided as default if non avs+ avisynth)


To better understand, maybe peruse link pointed to by Groucho [not just that post, entire thread]:- https://forum.doom9.org/showthread.php?t=101730

EDIT: Also take a peek at these two later posts in same thread by IanB some years later,
https://forum.doom9.org/showthread.p...92#post1567792
https://forum.doom9.org/showthread.p...72#post1580772
There may be more on same subject when avs+ was introduced.

EDIT: And avisynth v2.60Alpha4 thread, where AVS_linkage and AvisynthPluginInit3() introduced for real:- https://forum.doom9.org/showthread.php?t=166951
__________________
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; 10th January 2020 at 00:53.
StainlessS is offline  
Old 10th January 2020, 07:54   #5054  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Posts: 6,480
@StainlessS

Thanks for the explanation! If I remember right then host apps like MeGUI or avs2pipemod set the variable to null on shutdown, that does not seem to be necessary, I think MeGUI sets it to null even if there are still instances active, isn't that wrong?

https://sourceforge.net/p/megui/code...nthWrapper.cpp
stax76 is offline  
Old 10th January 2020, 12:18   #5055  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,281
No idea, I aint not played with host apps [maybe Grouchy nose]
__________________
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 ???
StainlessS is offline  
Old 10th January 2020, 12:36   #5056  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,012
Quote:
Originally Posted by stax76 View Post
I think MeGUI sets it to null even if there are still instances active, isn't that wrong?
Instances of what? You can have more than one script environment running in separate processes/threads.

In the code to which you linked, the "AVS_linkage = 0;" statement is preceded by the proper "DeleteScriptEnvironment()" which is correct.

The "delete pstr->env;" statement for Avisynth 2.5x is however not recommended, see here.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 10th January 2020 at 12:41.
Groucho2004 is offline  
Old 10th January 2020, 14:24   #5057  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Posts: 6,480
Quote:
Instances of what? You can have more than one script environment running in separate processes/threads.
Instances of script environments, GUIs usually have the requirement using multiple environments in parallel.

I think this thing is too complicated for me to fully understand it. I understand that it's a static variable and that it holds function pointers, aren't those function pointers related to a particular script environment? In that case to me it appears that it should be set to null after the script is loaded and not when the script environment is shut down.
stax76 is offline  
Old 10th January 2020, 14:30   #5058  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,012
Quote:
Originally Posted by stax76 View Post
I think this thing is too complicated for me to fully understand it.
I'm not far behind you in that regard. I just did in my programs what IanB recommended in various posts spread across this forum. That was years ago, I have not thought about it since.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline  
Old 11th January 2020, 02:22   #5059  |  Link
stax76
Registered User
 
Join Date: Jun 2002
Posts: 6,480
I've built a sample application for learning and testing purpose, maybe the code can help somebody. What it does is render a AviSynth script using Direct2D, it uses a trackbar/slider, no playback. I don't think Direct2D can render YV12 so it invokes ConvertToRGB32, it also invokes FlipVertical, no clue why AviSynth/VapourSynth RGB32 isn't directly D2D compatible without FlipVertical.

Code:

https://pastebin.com/59f8xUqA


I'll also build a VapourSynth equivalent of this sample in case somebody is interested in code for that.
stax76 is offline  
Old 11th January 2020, 12:55   #5060  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Have you tried creating the Bitmap with a negative height or pitch? I think something like that works under GDI.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline  
Closed Thread

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 07:02.


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