Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Avisynth 2,5/2,6 Plugin (https://www.delphipraxis.net/182069-avisynth-2-5-2-6-plugin.html)

Garfield 27. Sep 2014 13:48

Avisynth 2,5/2,6 Plugin
 
Liste der Anhänge anzeigen (Anzahl: 2)
Hallo,

ich möchte ein einfaches Avisynth-Plugin schreiben und da ich keine Delphi-Beispiele fand mit dem CBuilder XE5 ein paar Avisynth Filter SDK Sample ausprobieren. Konkret habe ich dann das Filter SDK/Simple sample 1.0b und das Filter SDK/Two-Five fast Invert ausprobiert.

Das "Filter SDK/Simple sample 1.0b" wurde sofort ohne Fehler compoliert. Beim "Filter SDK/Two-Five fast Invert" musste ich #include "windows.h" einfügen und ein "```}}" entfernen damit es compiliert werden konnte. Das Ergebnis war in beiden Fällen ein schwarzes Bild mit einem weißen senkrechten Streifen und ein Absturz von Avisynth (Siehe Anhang).

Dann habe ich das AviSynth video Deringing plugin gefunden, welches in Delphi geschrieben ist. Das habe ich dann auf das nötigste reduziert und in Delphi XE 5 und Delphi 7 ausprobiert. Das Ergebnis ist, dass ich die Fehlermeldung erhalte, dass dies kein Avisynth 2.5/2.6 Plugin sei.

Im Anhang sind die beiden CBuilder XE 5 und das Delphi 7 Projekt sowie die Testscripte. Mein Testvideo habe ich von der c't. Es fehlt dann noch das Plugin FFMS zum Lesen des MP4-Videos.

Kennt sich jemand da mit aus und kann mir helfen, in irgendeiner Weise weiter zu kommen?

Garfield 27. Sep 2014 19:12

AW: Avisynth 2,5/2,6 Plugin
 
Code:
AVSValue LoadPlugin(AVSValue args, void* user_data, IScriptEnvironment* env){
  extern const AVS_Linkage* const AVS_linkage; // In interface.cpp
  bool quiet = (user_data != 0);
  args = args[0];
  const char* result=0;
  for (int i=0; i<args.ArraySize(); ++i) {
    HMODULE plugin;
    const char* plugin_name = args[i].AsString();
    if (MyLoadLibrary(plugin_name, &plugin, quiet, env)) {
      typedef const char* (__stdcall *AvisynthPluginInit3Func)(IScriptEnvironment* env, const AVS_Linkage* const vectors);
      AvisynthPluginInit3Func AvisynthPluginInit3 = (AvisynthPluginInit3Func)GetProcAddress(plugin, "AvisynthPluginInit3");
      if (!AvisynthPluginInit3) {
        AvisynthPluginInit3 = (AvisynthPluginInit3Func)GetProcAddress(plugin, "_AvisynthPluginInit3@8");
        if (!AvisynthPluginInit3) {  // Try for 2.5 version
          typedef const char* (__stdcall *AvisynthPluginInit2Func)(IScriptEnvironment* env);
          AvisynthPluginInit2Func AvisynthPluginInit2 = (AvisynthPluginInit2Func)GetProcAddress(plugin, "AvisynthPluginInit2");
          if (!AvisynthPluginInit2) {
            AvisynthPluginInit2 = (AvisynthPluginInit2Func)GetProcAddress(plugin, "_AvisynthPluginInit2@4");
            if (!AvisynthPluginInit2) {  // Older version
              FreeLibrary(plugin);
              if (quiet) {
                // remove the last handle from the list
                HMODULE* loaded_plugins = (HMODULE*)env->GetVar("$Plugins$").AsString();
                int j=0;
                while (loaded_plugins[j+1]) j++;
                loaded_plugins[j] = 0;
              } else {
                env->ThrowError("Plugin %s is not an AviSynth 2.6 or 2.5 plugin.",plugin_name);
              }
            } else {
              result = AvisynthPluginInit2(env);
            }
          } else {
            result = AvisynthPluginInit2(env);
          }
        } else {
          result = AvisynthPluginInit3(env, AVS_linkage);
        }
      } else {
        result = AvisynthPluginInit3(env, AVS_linkage);
      }
    }
  }
  if (loadplugin_prefix) free((void*)loadplugin_prefix); // Tritical May 2005
  loadplugin_prefix = 0;
  return result ? AVSValue(env->SaveString(result)) : AVSValue();
}
Das ist das einzige was ich zu den verschiedenen Versionen von AvisynthPluginInit gefunden habe.

Garfield 28. Sep 2014 08:02

AW: Avisynth 2,5/2,6 Plugin
 
Wenn ich das richtig lese, schlägt die Initialisierung fehl.

In dem Beispiel wird so initialisiert:
Code:
// This is the function that created the filter, when the filter has been called.
// This can be used for simple parameter checking, so it is possible to create different filters,
// based on the arguments recieved.

AVSValue __cdecl Create_SimpleSample(AVSValue args, void* user_data, IScriptEnvironment* env) {
    return new SimpleSample(args[0].AsClip(),env);
    // Calls the constructor with the arguments provied.
}


// The following function is the function that actually registers the filter in AviSynth
// It is called automatically, when the plugin is loaded to see which functions this filter contains.

extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
    env->AddFunction("SimpleSample", "c", Create_SimpleSample, 0);
    // The AddFunction has the following paramters:
    // AddFunction(Filtername , Arguments, Function to call,0);

    // Arguments is a string that defines the types and optional names of the arguments for you filter.
    // c - Video Clip
    // i - Integer number
    // f - Float number
    // s - String
    // b - boolean

    return "`SimpleSample' SimpleSample plugin";
    // A freeform name of the plugin.
}
In meinem Delphiprojekt:
Delphi-Quellcode:
function avisynth_c_plugin_init(env: PAVS_ScriptEnvironment): PChar; stdcall;
begin
  avs_add_function(env, 'avsBasic', avsBasic.AviSynthDescription, @create_avsBasic, nil);

  Result := 'avsBasic';
end;

exports
  avisynth_c_plugin_init;
end.
Delphi-Quellcode:
const
  AviSynthDescription = '[src]c';

function create_avsBasic(args: MSVC_AVS_Value; use_inplace: Pointer; env: PAVS_ScriptEnvironment): MSVC_AVS_Value; stdcall;
var
  avsargs : AVS_Value;
begin;
  {
  *  Parameter übernehmen.
  }
  avsargs := AVS_Value(args);
end;

Garfield 28. Sep 2014 09:51

AW: Avisynth 2,5/2,6 Plugin
 
Wenn ich das AviSynth video Deringing plugin mit Delphi 7 Personal compilieren will bekomme ich diese Meldung:
Code:
[Fataler Fehler] Package 'a429comm_dcl' wird benötigt, konnte aber nicht gefunden werden
Und das Beispiel von sf lässt sich nicht ausführen.

Zitat:

---------------------------
deringSample.exe - Systemfehler
---------------------------
Das Programm kann nicht gestartet werden, da userlib.bpl auf dem Computer fehlt. Installieren Sie das Programm erneut, um das Problem zu beheben.
---------------------------
OK
---------------------------

Garfield 28. Sep 2014 22:25

AW: Avisynth 2,5/2,6 Plugin
 
In der dering.cfg ist -$J+ und in der dering.dof J=1 und UsePackages=1 gesetzt.

Garfield 29. Sep 2014 20:33

AW: Avisynth 2,5/2,6 Plugin
 
Liste der Anhänge anzeigen (Anzahl: 2)
Die CBuilder DLL vom SimpleSample 1.7 ist 177 kB groß. Jetzt habe ich das Sample mit Microsoft Visual Studio Express 2012 zum Laufen bekommen. Da ist die DLL nur 13 kB groß.

Bei dem Delphi-Plugin habe ich den Verdacht, dass es am OS (64bit) liegt. Obwohl Avisynth und Plugin 32bit sind.

Garfield 5. Okt 2014 10:23

AW: Avisynth 2,5/2,6 Plugin
 
Ich habe die DLLs unter Windows XP getestet.
  1. Delphi -> Kein Avisynth 2.5 Plugin
  2. SDKSimpleSample 1.0b bis 1.5a -> Windows Media Player-Fehler C00D11B1 (Video kann nicht wiedergegeben werden)
  3. SDKSimpleSample 1.6 -> WMP Absturz
  4. SDKSimpleSample 1.7 -> Kein Avisynth 2.5 Plugin
  5. SDKTwo-Five fast Invert -> WMP Absturz
Die VC++ DLL funktioniert nicht.

Kann mir jemand sagen, wie ich die CBuilder DLL C++ kompatible bekomme oder wie man die VC++ zum Laufen bekommt ohne Visual Studio installieren zu müssen?

SonnyBoyPro 13. Okt 2014 20:48

AW: Avisynth 2,5/2,6 Plugin
 
Hi Garfield,

normalerweise gibts ja eine VC-Redistribution zum installieren wo die benötigten DLL's je nach Studio Version enthalten sind.

bg

Garfield 14. Okt 2014 16:23

AW: Avisynth 2,5/2,6 Plugin
 
Hallo bg,

es gibt ja eine passende Redist zum Download. Diese Installation wollte ich vermeiden.

Mittlerweile habe ich ein wenig mit den Einstellungen gespielt und die DLL ist ein wenig größer geworden. Unter XP funktioniert sie nicht, aber unter Windows 7 ohne weitere Installation.

Am liebsten wäre mir ja, wenn ich die Delphi-DLL zum funktionieren bringen könnte. Dann könnte ich in Delpi weitermachen und müsste nicht noch C++ lernen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:51 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz