View Full Version : Pascal conversion of avisynth_c.h
Myrsloik
7th August 2005, 00:00
One day I got bored and tried to do a conversion. It failed. Then I continued just to not let the computer win (then they'll think they can win every time) and finished it after figuring out how records are passed.
This should allow you to write filters in delphi and free pascal using the avisynth_c interface. It was tested with delphi 7 and free pascal 2.0.2 but will probably work in earlier versions of both. A conversion of the invert sample from avisynth_c is also included to show how it's used.
Version 5 (https://vapoursynth.com/ivtc/avisynth/avisynth_pascal_v5.rar)
vhelp
7th August 2005, 20:33
First, GOD bless you, for breaking the barrior between Delphi and
AVIsynth and making a wider street for more languages to create filters
for AVIsynth. (after looking over your source code for this, it was all
spagetti to me -- good work)
Now, I'd like to ask a question.
I am running Delphi 6 (personal edition) under win98x, and I was able to
compile the project successfully, by creating a new invert.dll file :)
But, in the package you provided (thank you) there were no examples to
begin exploring with as a basic starting point.
Could you please provide a couple of examples (something very, very basic)
that we all could start with ??
Thank you,
-vhelp
EDIT:
The invert.dll was the example in the package.. though it looks a bit
complicted at the moment.. but i'm studying it now.
vhelp
7th August 2005, 22:28
Just a quick update.
I am experiencing trouble w/ loading the plugin. When I try and open
my avs script (called, default.avs) with the invert plugin, it pops
up an error message:
AVIsynth open failure..
Plugin c:\invert.dll is not an AviSynth 2.5 plugin.
I've tried various scenarios, including visiting AVIsynth help pages
and using the ..loadpluginEX.dll and loadpluginEX2.dll but same basic
error message.
I think i'm at a dead end, for the time being :(
-vhelp
Myrsloik
7th August 2005, 22:42
Unfortunately I think you've already seen most of the documentation that exists, I still haven't figured out some important parts myself. You can however find the original examples and files with all comments intact here (http://kevin.atkinson.dhs.org/avisynth_c/) which should make some things clearer (invert.pas is a line by line conversion).
If I figure out the last things annoying me I'll try to write something a bit more helpful tomorrow.
Hint: LoadCPlugin
vhelp
7th August 2005, 23:09
It works!! Fantastic!!
Right now, I'm studying your invert example. I just noticed you had another
link of info.., I'll head on over there shortly. I hope I can create something
simple with this plugin of yours.
I know I'll have add'l questions, but if I can ask..
When starting a new filter, I would use something like this:
( ie, library myFilterA; )
Also, if its not asking too much, could you provide an example or two, of
creating a filter with 1 or more params? I ask, because at the moment, it all
looks cryptic to me :)
BWY, your code (at bottom) has this strange char.
// Result := '`Invert'' sample plugin';
I think you ment for it to be this way:
Result := '"Invert" sample plugin';
Great work!
-vhelp
IanB
8th August 2005, 02:49
@Myrsloik,
There is an outstanding issue (http://forum.doom9.org/showthread.php?p=688163#post688163) with the avisynth_c.dll/loadCplugin interface which effects the calling convention and entry point names.
Your thoughts and comments on the issue....
IanB
Myrsloik
8th August 2005, 07:37
That explains why I had to export avisynth_c_plugin_init and why it didn't work with avisynth_c_plugin_init_s. After looking at avisynth_c.* I think it'd be best to just keep the current entry point name and remove everything that's in the now not used stdcall ifdefs. At least it should leave everything working and make the entry point name a bit more official.
Fizick
9th August 2005, 04:54
I think, we must analyze every useful avisynth_c filters, what interface it use.
All Kevin (smartdecimate, conditionaltemoralmedian) filters use oldest C interface.
My C-plugins (genmotion, equlines, old ctmedian=despot) use old C interface too, but all are obsolete.
I remember some Visual plugin (from vion ?)
Please add the list.
IanB
9th August 2005, 09:03
Okay, here is what I propose :-
1. Formally loose the "_s" from the entry point name it has never been able to be used because of a source bug.
2. Support the @4 suffix decoration as an option. This is how __stdcall is supposed to be.
3. Build Avisynth.dll with __stdcall calling sequence. This is how previous versions have been done. And it allows allows langauges like Delphi, Pascal, VB, Fortran, etc to call the C interfaces.
4. Add a Load_Stdcall_Plugin() alias for LoadCPlugin(). Loading avisynth_c.dll nukes the internal LoadCPlugin() verb.
This will maintain consistancy of interface, and clarify the world.
Kevins filters all link to avisynth_c.dll and use __cdecl so they are not part of this equation and will continue to work as before, the new Load_StdCall_Plugin() verb avoids the conflict with LoadCPlugin() verb.
Thorts anybody! :)
IanB
Fizick
9th August 2005, 18:43
Albertgasset old suggestion:
http://forum.doom9.org/showthread.php?t=69624&highlight=loadcplugin
By the way, he released "transition" C-plugin
http://forum.doom9.org/showthread.php?t=69155&highlight=loadcplugin
unmei
9th August 2005, 18:49
Great Job, Myrsloik.
I didn't test it so far, but i tried to translate the header too, about a year ago ..but oh well, then i let the computer win and wrote a C++ wrapper to load my delphi DLL :)
Maybe i should go back and try to use your work, it would sure eliminate some "sucky hacks".
IanB
10th August 2005, 08:18
Point of clarification.
If you use avisynth_c.dll it is nothing to do with this thread, it is the original independant implementation. You need to first LoadPlugin("Avisynth_c.dll") and then LoadCPlugin("c_plugin.dll"). The entrypoint names and linkage are whatever they are for the version of avisynth_c.dll you are using. The licence is as Kevin specifies.
This thread is talking about the AviSynth.dll internal implementation and support of the C interface defined by Kevin Atkinson. You link with avisynth.lib iff required and use only LoadCPlugin("stdcall_plugin.dll") [ or soon Load_StdCall_Plugin() ]
If you link with avisynth.lib you must comply with the full AviSynth GPL licence i.e. release the source! If you #include "avisynth_c.h" you must comply with Kevin's licence. (If you do both you must satisfy both) If you just call the entry points you can do as you wish.
IanB
Myrsloik
10th August 2005, 13:56
Updated the link in the first post to v3. It adds some useful functions (equivalents for avsvalue.AsType(default)) and changes some things back to enumerated types.
vhelp
11th August 2005, 05:29
@ Myrsloik
Just wanted to give you a heads-up on my experience w/ your on-going updates.
So far, so good. I have been very successful at reproducing your example filters functions.
But, I do have an issue with trying to set other variables inside the code
snip below, I get hard crashes when I run the .avs script inside vdub.
..
var
i: integer;
begin
.
.
i:=1; // give I an default number to start with..
for y := 0 to height - 1 do
begin
inc(I,2)
for x := 0 to row_size - 1 do
PByteArray(src_data)^[x] := PByteArray(src_data)^[x+I] xor settings^.XorVal;
Inc(src_data, src_pitch);
end;
Inside the line above.. PByteArray.. ^[x+i] is where it crashes.
If I leave out the I, ie, ^[x] then everything is fine, even though
there is code above ( ie, inc(i,2) )
I know I am missing something, and it probably has something to do
with pointers, but I just don't get it. Its like I get the feeling that
you can't have your own variables. I don't know. I can't quite explain
it in words.
Can you (or anyone else) explain what is going on (why) and if there
is another thing I can do ??
Otherwise, I don't see how I can't alter pixels if this problem stops me.
Thanks again for this avisynth_c port.
-vhelp
Myrsloik
11th August 2005, 06:55
I have no idea what you're trying to do but as you increment i by 2 for every line and initialize it to 1 you'll be reading 2*height+1 pixels beyond the image end. That is generally a bad idea.
vhelp
12th August 2005, 03:16
I was experimenting on what-if scenarios with changing pixel data around
for effects and things. Just trying to get a feel for how things work.
You gotta start somewhere's. And this was the first place I started :)
(I've been busy w/ other projects and things, and haven't tried further.
But I will have another try tonight, regarding your comment on my code)
-vhelp
Amnon82
5th February 2006, 16:39
Here some samples for using AVISYNTH_C in Delphi:
http://img145.imageshack.us/img145/4881/untitled21ov.th.png (http://img145.imageshack.us/my.php?image=untitled21ov.png)
Original sample by Myrsloik (http://yatta.mellbin.org/misc/avisynth_c_sample.rar)
Updated sample by Amnon82 (RGB-Preview) (http://scifi.pages.at/amsoft/files/avisynth_c_sample_v3.7z)
Myrsloik
5th February 2006, 23:01
When looking some more at the avisynth_c stuff I realized that at least from delphi it seem impossible to destroy a script environment created with avs_create_script_environment(). This seems to be because avisynth_c assumes that you'll use free() or something similar. This however seems to be impossible due to how delphi handles memory. Adding an avs_destroy_script_environment() would probably be the best solution for this. Either that or I'm completely wrong.
Inc
6th February 2006, 11:39
Why do u use a delphi "CopyMemory()" command to perform an image blocktransfer? I dont know its speed in delphi (neither I do know if delphi generates its executable out of a generated asm code).
//get a pointer to the frame, has to be released later
frame:=avs_get_frame(clip,TrackBar1.Position);
//retrieve all values needed to copy the frame
rp:=avs_get_read_ptr(frame);
pitch:=avs_get_pitch(frame);
rs:=avs_get_row_size(frame);
//while BitBlt would be simple and more efficient to use here
//the image would be shown upside down
for counter:=vi.height-1 downto 0 do
begin
CopyMemory(Image1.Picture.Bitmap.ScanLine[counter],rp,rs);
Inc(rp,pitch);
end;
Image1.Repaint;
avs_release_video_frame(frame);
In AVSredirect.dll I do use Bitblt() to copy the imagedata from the smartpointer to the determined final frame-imagepointer. And its not showed upside down.
How do Delphi's internally image procedures handle raw bitmap data to be converted to a compatible bitmap incl. BITMAPINFO and BITMAPINFOHEADER?
A SetDIBits() could be integrated as it could directly use the resulted GetReadPtr() within the function, so the smart pointer problem could be solved by this and the RGB32 Data at GetReadPtr() is imho DWORD aligned which is also the prefered alignement by the GDI functions (like SetDIBits).
Something like this ...
(written out of head so only to be seen as an approach ... reference from here: http://www.everything2.com/index.pl?node_id=918688)
int __stdcall avs_getvframeRGB32(IScriptEnvironment* env, int clip_num, BYTE *buf, int frm, HBITMAP myBitmap, HWND hwnd )
{
BITMAPINFO bmInfo;
HDC myDC;
HDC myCompatibleDC;
VideoInfo vi = clip[clip_num]->GetVideoInfo();
ZeroMemory(&bmInfo, sizeof(BITMAPINFO));
bmInfo.bmiHeader.biWidth = vi.width;
bmInfo.bmiHeader.biHeight = vi.height; // use negative value if image flipping is whished
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 32; // RGB32!
bmInfo.bmiHeader.biCompression = BI_RGB;
try {
PVideoFrame f = clip[clip_num]->GetFrame(frm, env);
myDC = GetDC(NULL)
myCompatibleDC = CreateCompatibleDC(myDC);
SelectObject(myCompatibleDC, myBitmap);
SetDIBits(myCompatibleDC, myBitmap, 0, vi.height, f->GetReadPtr(), &bmInfo, 0);
DeleteDC(myCompatibleDC);
ReleaseDC(NULL, myDC);
g_lasterr[0] = 0;
return 0;
}
catch(AvisynthError err) {
strncpy(g_lasterr,err.msg,ERRMSG_LEN-1);
return -1;
}
}
So you enter in your function using myBitmap as your CompatibleBitmap created in your appl. where the video will be shown, and hwnd as your appl. Window handle where the video CompatibleBitmap will be shown.
Myrsloik
6th February 2006, 22:06
CopyMemory is straight from the windows api so I guess you should be able to figure out its performance if you really want to.
I also just realized that TBitmap.scanline[line] doesn't do something like (image data start)+pitch*line but instead you seem to get (image data start)+pitch*(height-line-1). That at least allows you to simplify it to this.
with Image1.Picture.Bitmap do
avs_bit_blt(env,ScanLine[vi.height-1],Integer(ScanLine[0])-
Integer(ScanLine[1]),avs_get_read_ptr(frame),avs_get_pitch(frame),
avs_get_row_size(frame),vi.height);
Inc
7th February 2006, 10:40
Assuming the following incoming script ...
Avisource("xxxxxx.avi")
Bicubicresize(xxx,yyy)
ConverttoRGB32()
For BitBlt() in avs imho you should use in case of a resulted RGB32 stream...
VideoInfo vi = clip[clip_num]->GetVideoInfo();
int destpitch = (vi.width)*4; // *4 cause of RGB32 (B,G,R,A) DWORD aligned
PVideoFrame f = clip[clip_num]->GetFrame(frm, env);
env->BitBlt(buf, destpitch, f->GetReadPtr(), f->GetPitch(),
f->GetRowSize(), f->GetHeight());
Load a video via the avisynth interface and apply for instance "BicubicResize(351,288)", if you would straightly use the SourcePitch as Destpitch in BitBlt() the Output would be messed up. But if you would use a pitch of width*4 (offset in "bytes" to the next scanline) in RGB32 outputmode the result appears ok.
Myrsloik
9th February 2006, 21:25
Updated it to version 4 now, link is in the first post. Fixes many things and adds a delphi only version of my previous freeframe plugin to the samples.
Fixed handling of boolean AVS_Values and named arguments in Invoke
Fixed several issues with pixel_type and image_type where Delphi and FPC would optimize away checks in different ways
Added the Show Video Info and FreeFrame samples
Amnon82
17th March 2006, 18:08
Still get Errors using this code:
//call avisource with the selected filename with audio=false,
//uses named arguments an AVS_Value array since it needs more
//than 1 argument to do this
argarray[0] := avs_new_value_string(PChar(OpenDialog1.FileName));
argarray[1] := avs_new_value_bool(false);
argnamearray[0]:=nil;
argnamearray[1]:='audio';
avsval1 := avs_invoke(env, 'DirectShowSource', avs_new_value_array(@argarray, 2),@argnamearray);
//check for errors, only AVS_Values containing clips need to be freed
//which it won't here if it's an error
CheckForErrors(avsval1);
Seems something goes wrong and audio=false didn't get added ...
http://img141.imageshack.us/img141/6619/error7ru.png
Inc
17th March 2006, 20:53
My skills on delphi are near '0' but ...
Did you try invoking (env, 'ConvertAudioTo16bit', .....)
or ... leave the audio=false argument at your first Invoke of DirectShowsource out and let follow an invoke(env, 'KillAudio' ...)
Myrsloik
17th March 2006, 21:05
Can't reproduce it. Tried with random avis with avisource as seen in the sample but avs_has_audio always returns false of me.
Amnon82
17th March 2006, 22:21
I've a return of true:
if clip <> nil then
MessageDlg('File already open', mtError, [mbOK], 0)
else if OpenDialog1.Execute then
begin
//call avisource with the selected filename with audio=false,
//uses named arguments an AVS_Value array since it needs more
//than 1 argument to do this
argarray[0] := avs_new_value_string(PChar(OpenDialog1.FileName));
argarray[1] := avs_new_value_bool(false);
argnamearray[0]:=nil;
argnamearray[1]:='audio';
avsval1 := avs_invoke(env, 'DirectShowSource', avs_new_value_array(@argarray, 2),@argnamearray);
//check for errors, only AVS_Values containing clips need to be freed
//which it won't here if it's an error
CheckForErrors(avsval1);
//convert to rgb, avisynth does nothing if it already is rgb
avsval2 := avs_invoke(env, 'ConvertToRGB', avsval1);
//dispose of the intermediate clip in the AVS_Value
avs_release_value(avsval1);
//check for errors after freeing all arguments used to avoid leaks
//getting an error here is however extremely unlikely
CheckForErrors(avsval2);
//get a clip from the AVS_Value
clip := avs_take_clip(avsval2, env);
//release the AVS_Value since it contained a clip, releasing an AVS_Value
//without a clip does nothing
avs_release_value(avsval2);
//get video information and adjust window
vi := avs_get_video_info(clip);
//set up the trackbar and image
TrackBar1.Max := vi^.num_frames - 1;
ClientWidth := vi^.width;
ClientHeight := vi^.height + TrackBar1.Height;
if avs_has_audio(clip) then showmessage('has audio') else showmessage('no audio');
Also 'KillAudio' didn't work
//call avisource with the selected filename with audio=false,
//uses named arguments an AVS_Value array since it needs more
//than 1 argument to do this
argarray[0] := avs_new_value_string(PChar(OpenDialog1.FileName));
argarray[1] := avs_new_value_bool(false);
argnamearray[0]:=nil;
argnamearray[1]:='audio';
avsval1 := avs_invoke(env, 'DirectShowSource', avs_new_value_array(@argarray, 2),@argnamearray);
//check for errors, only AVS_Values containing clips need to be freed
//which it won't here if it's an error
CheckForErrors(avsval1);
//convert to rgb, avisynth does nothing if it already is rgb
avsval2 := avs_invoke(env, 'ConvertToRGB', avsval1);
//dispose of the intermediate clip in the AVS_Value
avs_release_value(avsval1);
//check for errors after freeing all arguments used to avoid leaks
//getting an error here is however extremely unlikely
CheckForErrors(avsval2);
avsval1 := avs_invoke(env, 'KillAudio',avsval2);
//get a clip from the AVS_Value
clip := avs_take_clip(avsval1, env);
avs_release_value(avsval1);
//release the AVS_Value since it contained a clip, releasing an AVS_Value
//without a clip does nothing
avs_release_value(avsval2);
//get video information and adjust window
vi := avs_get_video_info(clip);
When I open the AVI alone I get the 'no audio' message. Using the AVS it get 'has audio'.
I want to open AVS-files with AVIsource in it and get audio=false patched on the fly like ConverttoRGB I did in the last sample I compiled.
TestAVI+TestAVS (http://www.megaupload.com/?d=EQDEEXDJ)
Myrsloik
17th March 2006, 22:48
You're passing a PAVS_Clip to avs_has_audio when it actually takes a PAVS_Videoinfo. (all the fun of untyped pointers)
Amnon82
17th March 2006, 23:09
Upps, I used clip instead of vi. But I still get the error image. Please download the uploaded avi file (http://www.megaupload.com/?d=D91D03T5).
http://img375.imageshack.us/img375/2438/error22sc.png
argarray[0] := avs_new_value_string(PChar(OpenDialog1.FileName));
argarray[1] := avs_new_value_bool(false);
argnamearray[0]:=nil;
argnamearray[1]:='audio';
avsval1 := avs_invoke(env, 'DirectShowSource', avs_new_value_array(@argarray, 2),@argnamearray);
//check for errors, only AVS_Values containing clips need to be freed
//which it won't here if it's an error
CheckForErrors(avsval1);
//convert to rgb, avisynth does nothing if it already is rgb
avsval2 := avs_invoke(env, 'ConvertToRGB', avsval1);
//dispose of the intermediate clip in the AVS_Value
avs_release_value(avsval1);
//check for errors after freeing all arguments used to avoid leaks
//getting an error here is however extremely unlikely
CheckForErrors(avsval2);
//get a clip from the AVS_Value
clip := avs_take_clip(avsval2, env);
//release the AVS_Value since it contained a clip, releasing an AVS_Value
//without a clip does nothing
avs_release_value(avsval2);
//get video information and adjust window
vi := avs_get_video_info(clip);
if avs_has_audio(vi)=true then showmessage('has audio') else showmessage('no audio');
//set up the trackbar and image
Amnon82
17th March 2006, 23:51
If I use this script:
# -= AviSynth v2.5.6.0 script by FitCD v1.2.8 =-
AVISource("H:\test.avi",pixel_type="YUY2",audio=false)
LanczosResize(704,480,4,0,600,336)
#Trim(0,59839).FadeOut(150)
I got this:
http://img376.imageshack.us/img376/7315/error311ln.png
With this script:
# -= AviSynth v2.5.6.0 script by FitCD v1.2.8 =-
AVISource("H:\test.avi",pixel_type="YUY2")
KillAudio()
LanczosResize(704,480,4,0,600,336)
#Trim(0,59839).FadeOut(150)
this:
http://img218.imageshack.us/img218/1903/error323jp.png
And with the last script:
# -= AviSynth v2.5.6.0 script by FitCD v1.2.8 =-
AVISource("H:\test.avi",pixel_type="YUY2")
LanczosResize(704,480,4,0,600,336)
#Trim(0,59839).FadeOut(150)
this:
http://img218.imageshack.us/img218/7161/error334qb.png
Infos out of gspot:
--- Audio Information ---
MPEG Stream ID (e.g. "0xbd"):
MPEG VOB file Substream(e.g. "0x80"):
Audio Codec (e.g. "AC3"): 0x0055(MP3, ISO) MPEG-1 Layer 3
Audio Codec Status (e.g. "Codec Is Installed"): Codec(s) are Installed
Audio Sample Rate (Hz): 48000
Audio Bitrate(kbps): 128
Audio Bitrate Type ("CBR" or "VBR"): VBR
Audio Channel Count (e.g. "2" for stereo): 2
btw.
If I load the AVI directly, no problem. Only using it in a AVSScript.
Myrsloik
17th March 2006, 23:54
Is this some kind of trick question?
When you use a script and open it with avisource the full script is first rendered (with audio) and then the audio is discarded later on. You will always need a decompressor to do what you tried to do.
Amnon82
18th March 2006, 01:11
It isn't a trick question. Some AVIs have bugs in it. It is a cause of lameMP3. If I patch the AVS with audio=false by adding it to the AVS before I load it into AVS_Invoke all went fine.
Is there a way to discarde the audio on the fly before it gets rendered? If you want to try your self download the junk of avi I uploaded.
Myrsloik
18th March 2006, 01:33
The possible ways are:
Don't use an intermediate script.
Use audio=false in the intermediate script.
Write a parser capable of successfully adding audio=false to all forms of sources and that also can remove all audio references without changing the video part of the script.
Pick one.
Amnon82
18th March 2006, 10:46
I already did it in AutoQ2. I only thougth I can remove it with v4. Never mind. Thx.
Inc
18th March 2006, 20:03
# -= AviSynth v2.5.6.0 script by FitCD v1.2.8 =-
AVISource("H:\test.avi",pixel_type="YUY2")
KillAudio()
LanczosResize(704,480,4,0,600,336)
#Trim(0,59839).FadeOut(150)
Here Avisynth internally tries to open the video using the matching vfw videocodec on your system, same thing with audio where a matching ACM codec is used.
But as no ACM audiocodec is found it even dosnt reach the KillAudio() line! and quits before.
# -= AviSynth v2.5.6.0 script by FitCD v1.2.8 =-
AVISource("H:\test.avi",pixel_type="YUY2", audio=false)
LanczosResize(704,480,4,0,600,336)
#Trim(0,59839).FadeOut(150)
In here Avisynth internally just tries to open the video using the matching vfw codec BUT overrides the audio decoding totally, it even doesnt touch it. Thats why u dont get an error message.
To me it looks like that your system isn't capable trying to decode the audiostream out of the avi using a matching ACM audio codec. So the Pascal Avisynth interface seems not to be the guilty.
so WHAT's the type of the audiostream in your source?
If its a PCM Wav, then which type? raw 16bit, 20bit, 24bit or whatever.
bagheera1
18th March 2006, 20:17
It looks like it's the same thing that is going on in this (http://forum.doom9.org/showthread.php?p=790729#post790729) thread.
a non compliant audio stream.
I have since tried the hex edit fix, and it did work for me (I tried it on a copy just to be safe)
Amnon82
18th March 2006, 22:24
It is lameMP3 (see post #31)
bagheera1
20th March 2006, 15:02
Right, an Mp3.
my point is you can modify the source avi to get it to work correctly.
Unmodified
http://img132.imageshack.us/img132/8886/unmodified7ix.jpg
Hex View
http://img214.imageshack.us/img214/7685/unmodifiedhex8pv.jpg
Modified by changing the 10 00 to 00 00
http://img214.imageshack.us/img214/3486/afterhexedit9gk.jpg
as you can see , after the Vdubmod hex edit, the file has audio in a usuable state that doesn't require audio=false, and demuxing, processing, and remuxing in avisynth.
I have tested this on other files and it works. It seems to work on the avi that you uploaded, but since it's a xvid segment the video part of the avi will not decompress for me.
unmei
29th March 2006, 23:08
Finally i got also around to use it, and so far it works great =) Thanks again.
Myrsloik
11th April 2006, 16:36
Released v5 which fixes the last annoying things with invoke. There probably won't be any more changes until avisynth also changes. Download link is in the first post as usual.
The changes:
Improved named argument and invoke argument handling
Use avisource and not directshowsource in Show Video Info sample
Added experimental avisynth functions in ifdef blocks
squid_80
12th April 2006, 09:20
Just in case you guys didn't know, the latest beta of avisynth makes a more determined effort to open the audio successfully by patching the bad mp3 format headers. So we shouldn't need to hex edit files or use audio=false any more.
LigH
13th October 2024, 07:15
Both links in the thread start are gone AWOL.
Myrsloik
13th October 2024, 12:54
Both links in the thread start are gone AWOL.
18 year thread necro. Good job. Link fixed.
You really shouldn't be using this thing still.
LigH
13th October 2024, 12:56
:thanks:
Unfortunately, nobody can help me making a plugin in C++. So I am desperate and have to do it myself in Pascal...
LigH
13th October 2024, 13:15
Ah, now I realise, it is the AviSynth-C interface which is not recommended. The main AviSynth (C++) interface is harder to convert? I tried it automatically. The best converter I could find yet was Swig; it failed.
Myrsloik
13th October 2024, 14:14
Ah, now I realise, it is the AviSynth-C interface which is not recommended. The main AviSynth (C++) interface is harder to convert? I tried it automatically. The best converter I could find yet was Swig; it failed.
Can't mix C++ with other languages due to exceptions and other fun stuff.
Go find me on discord or IRC if you need help with plugin writing.
LigH
13th October 2024, 14:22
I see, it's like chasing a shadow ... a recent FreePascal does not like converting the AVS_VALUE variable record to Int64 (via MSVC_AVS_VALUE). May need new tricks to relax type checking.
gispos
21st November 2024, 19:05
I see, it's like chasing a shadow ... a recent FreePascal does not like converting the AVS_VALUE variable record to Int64 (via MSVC_AVS_VALUE). May need new tricks to relax type checking.
Maybe you can use it?
https://github.com/gispos/AvsPThumb/blob/master/Units/avisynth.pas
Myrsloik
21st November 2024, 19:08
I see, it's like chasing a shadow ... a recent FreePascal does not like converting the AVS_VALUE variable record to Int64 (via MSVC_AVS_VALUE). May need new tricks to relax type checking.
It could also depend on which enabled language extensions you're using. I seem to recall lots of delphi compatibility stuff isn't enabled by default. But what do I know, I didn't check anything since I made the original release...
LigH
21st November 2024, 19:34
I tried unit avisynth_c.pas with {$mode DelphiUnicode} but FPC still insisted in an Illegal type conversion: "AVS_Value" to "Int64".
The Lazarus forum (https://forum.lazarus.freepascal.org/index.php/topic,68968.0.html) possibly misunderstood the point to some degree.
gispos
22nd November 2024, 13:30
I tried unit avisynth_c.pas with {$mode DelphiUnicode} but FPC still insisted in an Illegal type conversion: "AVS_Value" to "Int64".
The Lazarus forum (https://forum.lazarus.freepascal.org/index.php/topic,68968.0.html) possibly misunderstood the point to some degree.
You should have taken a look at my linked version.
I also had PChar, PByte versions, but it's been a while and I can't remember where I put them.
With x64, the MSVC_AVS_Value must simply be declared as type AVS_Value and not as type Int64.
AVS_Value = record
vtype: WideChar;
array_size: Smallint;
case AnsiChar of
'c': (vclip: Pointer);
'b': (vboolean: LongBool);
'i': (vinteger: Integer);
'f': (vfloating_pt: Single);
's': (vstring: PAnsiChar);
'a': (varray: PAVS_Value_array);
end;
{$IFDEF WIN32}
MSVC_AVS_Value = type Int64;
{$ELSE}
MSVC_AVS_Value = type AVS_Value;
{$ENDIF}
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.