diff --git a/CMakeLists.txt b/CMakeLists.txt index f28fe9bf0..b8c4b51fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ if(CMAKE_CONFIGURATION_TYPES) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Reset the configurations to what we need" FORCE) endif() -IF( MSVC_IDE ) # Check for Visual Studio +IF( MSVC ) # Check for Visual Studio #1800 = VS 12.0 (v120 toolset) #1900 = VS 14.0 (v140 toolset) @@ -30,25 +30,27 @@ IF( MSVC_IDE ) # Check for Visual Studio file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Output/system") file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Output/c_api") - IF(CMAKE_GENERATOR_TOOLSET STREQUAL "v141_clang_c2") - #1900 is reported - message("v141_clang_c2 toolset was specified via -T. Reported MSVC_VERSION is: ${MSVC_VERSION}") - set(CLANG_IN_VS "1") - ENDIF() + IF(MSVC_IDE) + IF(CMAKE_GENERATOR_TOOLSET STREQUAL "v141_clang_c2") + #1900 is reported + message("v141_clang_c2 toolset was specified via -T. Reported MSVC_VERSION is: ${MSVC_VERSION}") + set(CLANG_IN_VS "1") + ENDIF() - # We want our project to also run on Windows XP - # 1900 (VS2015) is not supported but we leave here - IF(MSVC_VERSION VERSION_LESS 1910 ) - IF(NOT CLANG_IN_VS STREQUAL "1") - set(CMAKE_GENERATOR_TOOLSET "v140_xp" CACHE STRING "The compiler toolset to use for Visual Studio." FORCE) # VS2015 - # https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics - add_definitions("/Zc:threadSafeInit-") - ENDIF() - ELSE() - IF(NOT CLANG_IN_VS STREQUAL "1") - set(CMAKE_GENERATOR_TOOLSET "v141_xp" CACHE STRING "The compiler toolset to use for Visual Studio." FORCE) # VS2017 - # https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics - add_definitions("/Zc:threadSafeInit-") + # We want our project to also run on Windows XP + # 1900 (VS2015) is not supported but we leave here + IF(MSVC_VERSION VERSION_LESS 1910 ) + IF(NOT CLANG_IN_VS STREQUAL "1") + set(CMAKE_GENERATOR_TOOLSET "v140_xp" CACHE STRING "The compiler toolset to use for Visual Studio." FORCE) # VS2015 + # https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics + add_definitions("/Zc:threadSafeInit-") + ENDIF() + ELSE() + IF(NOT CLANG_IN_VS STREQUAL "1") + set(CMAKE_GENERATOR_TOOLSET "v141_xp" CACHE STRING "The compiler toolset to use for Visual Studio." FORCE) # VS2017 + # https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics + add_definitions("/Zc:threadSafeInit-") + ENDIF() ENDIF() ENDIF() @@ -58,28 +60,33 @@ IF( MSVC_IDE ) # Check for Visual Studio set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-inconsistent-missing-override") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") ELSE() - # Enable C++ with SEH exceptions - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /EHa") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa") - # or add_compile_options( /EHa ) for CMake>=3? + # Enable C++ with SEH exceptions + # Avoid an obnoxious 'overrriding /EHsc with /EHa' warning when + # using something other than MSBuild + STRING( REPLACE "/EHsc" "/EHa" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + STRING( REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ENDIF() # Prevent VC++ from complaining about not using MS-specific functions add_definitions("/D _CRT_SECURE_NO_WARNINGS /D _SECURE_SCL=0") # Enable CRT heap debugging - only effective in debug builds add_definitions("/D _CRTDBG_MAP_ALLOC") - + add_definitions("/D __SSE2__") if(CMAKE_SIZEOF_VOID_P EQUAL 4) - # VC++ enables the SSE2 instruction set by default even on 32-bits. Step back a bit. - #add_definitions("/arch:SSE") - add_definitions("/arch:SSE2") # Better use this one, it's 2017 now, and helps optimizing hbd stuff still in C - endif() + # CPU_ARCH can be overridden with the corresponding values when using MSVC: + # IA32 (disabled), + # SSE (Pentium III and higher, 1999), + # SSE2 (Pentium 4 and higher, 2000/2001), + # AVX (Sandy Bridge and higher, 2011), + # AVX2 (Haswell and higher, 2013) + set(MSVC_CPU_ARCH "SSE2" CACHE STRING "Set MSVC architecture optimization level (default: SSE2)") + endif() # Set additional optimization flags - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oy /Ot /GS- /Oi") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oy /Ot /GS- /Oi") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oy /Ot /GS- /Oi /arch:${MSVC_CPU_ARCH}") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oy /Ot /GS- /Oi /arch:${MSVC_CPU_ARCH}") # Set C++17 flag set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c++17") @@ -89,6 +96,7 @@ ELSE() # c++17: if constexpr() and others from gcc 7 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17" ) # or -std=c++17 w/o gnu c++17 extensions SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native" ) + SET( CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-stdcall-fixup" ) ENDIF() @@ -104,4 +112,4 @@ configure_file( IMMEDIATE @ONLY) add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) \ No newline at end of file + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) diff --git a/avs_core/CMakeLists.txt b/avs_core/CMakeLists.txt index 6823b1701..cb22248a1 100644 --- a/avs_core/CMakeLists.txt +++ b/avs_core/CMakeLists.txt @@ -54,7 +54,7 @@ elseif (MINGW) # special AVX2 option for source files with *_avx2.cpp pattern file(GLOB_RECURSE SRCS_AVX2 "*_avx2.cpp") - set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS -mavx2 -mfma) + set_source_files_properties(${SRCS_AVX2} PROPERTIES COMPILE_FLAGS "-mavx2 -mfma") endif() # Specify include directories @@ -63,10 +63,8 @@ target_include_directories("AvsCore" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_compile_definitions("AvsCore" PRIVATE BUILDING_AVSCORE) # Windows DLL dependencies -if (MSVC_IDE) - target_link_libraries("AvsCore" "Winmm.lib" "Vfw32.lib" "Msacm32.lib" "Gdi32.lib" "User32.lib" "Advapi32.lib" "Ole32.lib" "ImageHlp.lib") -elseif (MINGW) - target_link_libraries("AvsCore" "uuid" "winmm" "vfw32" "msacm32" "gdi32" "user32" "advapi32" "ole32" "imagehlp.lib") +if (MSVC OR MINGW) + target_link_libraries("AvsCore" "uuid" "winmm" "vfw32" "msacm32" "gdi32" "user32" "advapi32" "ole32" "imagehlp") endif() if (MSVC_IDE) diff --git a/avs_core/Files.cmake b/avs_core/Files.cmake index 87a6387ed..13c5cd446 100644 --- a/avs_core/Files.cmake +++ b/avs_core/Files.cmake @@ -13,7 +13,6 @@ FILE(GLOB AvsCore_Sources RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "core/*.c" "core/*.cpp" "core/*.h" - "core/avisynth.rc" "core/parser/*.c" "core/parser/*.cpp" @@ -39,7 +38,7 @@ FILE(GLOB AvsCore_Sources RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "filters/exprfilter/*.h" ) -IF( MSVC_IDE ) +IF( MSVC OR MINGW ) # Export definitions in general are not needed on x64 and only cause warnings, # unfortunately we still must need a .def file for some COM functions. if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -47,4 +46,9 @@ IF( MSVC_IDE ) else() LIST(APPEND AvsCore_Sources "core/avisynth.def") endif() -ENDIF() \ No newline at end of file +ENDIF() + +IF( MSVC_IDE ) + # Ninja, unfortunately, seems to have some issues with using rc.exe + LIST(APPEND AvsCore_Sources "core/avisynth.rc") +ENDIF() diff --git a/avs_core/core/PluginManager.cpp b/avs_core/core/PluginManager.cpp index 02bd15476..074eabf27 100644 --- a/avs_core/core/PluginManager.cpp +++ b/avs_core/core/PluginManager.cpp @@ -5,15 +5,19 @@ #include "strings.h" #include "InternalEnvironment.h" #include -#include +#include typedef const char* (__stdcall *AvisynthPluginInit3Func)(IScriptEnvironment* env, const AVS_Linkage* const vectors); typedef const char* (__stdcall *AvisynthPluginInit2Func)(IScriptEnvironment* env); typedef const char* (AVSC_CC *AvisynthCPluginInitFunc)(AVS_ScriptEnvironment* env); const char RegAvisynthKey[] = "Software\\Avisynth"; +#if defined (__GNUC__) +const char RegPluginDirPlus_GCC[] = "PluginDir+GCC"; +#else const char RegPluginDirClassic[] = "PluginDir2_5"; const char RegPluginDirPlus[] = "PluginDir+"; +#endif /* --------------------------------------------------------------------------------- @@ -79,25 +83,25 @@ static std::string GetFullPathNameWrap(const std::string &f) delete [] fullPathName; return result; } - -static bool IsParameterTypeSpecifier(char c) { - switch (c) { - case 'b': case 'i': case 'f': case 's': case 'c': case '.': -#ifdef NEW_AVSVALUE - case 'a': // Arrays as function parameters -#endif - return true; - default: - return false; + +static bool IsParameterTypeSpecifier(char c) { + switch (c) { + case 'b': case 'i': case 'f': case 's': case 'c': case '.': +#ifdef NEW_AVSVALUE + case 'a': // Arrays as function parameters +#endif + return true; + default: + return false; } } -static bool IsParameterTypeModifier(char c) { - switch (c) { - case '+': case '*': - return true; - default: - return false; +static bool IsParameterTypeModifier(char c) { + switch (c) { + case '+': case '*': + return true; + default: + return false; } } @@ -229,86 +233,86 @@ bool AVSFunction::empty() const bool AVSFunction::IsScriptFunction() const { -#ifdef DEBUG_GSCRIPTCLIP_MT - /* - if (!strcmp(this->name, "YPlaneMax")) - return true; - if (!strcmp(this->name, "YPlaneMin")) - return true; - if (!strcmp(this->name, "LumaDifference")) - return true; - */ -/* - if (!stricmp(this->name, "yplanemax")) - return true; - if (!stricmp(this->name, "yplanemin")) - return true; - if (!stricmp(this->name, "lumadifference")) - return true; - */ - //if (!stricmp(this->name, "srestore_inside_1")) - // return true; -#endif - return ( (apply == &(ScriptFunction::Execute)) +#ifdef DEBUG_GSCRIPTCLIP_MT + /* + if (!strcmp(this->name, "YPlaneMax")) + return true; + if (!strcmp(this->name, "YPlaneMin")) + return true; + if (!strcmp(this->name, "LumaDifference")) + return true; + */ +/* + if (!stricmp(this->name, "yplanemax")) + return true; + if (!stricmp(this->name, "yplanemin")) + return true; + if (!stricmp(this->name, "lumadifference")) + return true; + */ + //if (!stricmp(this->name, "srestore_inside_1")) + // return true; +#endif + return ( (apply == &(ScriptFunction::Execute)) || (apply == &Eval) || (apply == &EvalOop) || (apply == &Import) ); } -#ifdef DEBUG_GSCRIPTCLIP_MT -bool AVSFunction::IsRuntimeScriptFunction() const -{ - - if (!strcmp(this->name, "YPlaneMax")) - return true; - if (!strcmp(this->name, "YPlaneMin")) - return true; - if (!strcmp(this->name, "LumaDifference")) - return true; - - //if (!stricmp(this->name, "srestore_inside_1")) - // return true; - - return (apply == &(ScriptFunction::Execute)); -} -#endif - +#ifdef DEBUG_GSCRIPTCLIP_MT +bool AVSFunction::IsRuntimeScriptFunction() const +{ + + if (!strcmp(this->name, "YPlaneMax")) + return true; + if (!strcmp(this->name, "YPlaneMin")) + return true; + if (!strcmp(this->name, "LumaDifference")) + return true; + + //if (!stricmp(this->name, "srestore_inside_1")) + // return true; + + return (apply == &(ScriptFunction::Execute)); +} +#endif + bool AVSFunction::SingleTypeMatch(char type, const AVSValue& arg, bool strict) { switch (type) { case '.': return true; case 'b': return arg.IsBool(); case 'i': return arg.IsInt(); - case 'f': return arg.IsFloat() && (!strict || !arg.IsInt()); - case 's': return arg.IsString(); - case 'c': return arg.IsClip(); -#ifdef NEW_AVSVALUE - case 'a': return arg.IsArray(); // PF 161028 AVS+ script arrays -#endif - default: return false; - } + case 'f': return arg.IsFloat() && (!strict || !arg.IsInt()); + case 's': return arg.IsString(); + case 'c': return arg.IsClip(); +#ifdef NEW_AVSVALUE + case 'a': return arg.IsArray(); // PF 161028 AVS+ script arrays +#endif + default: return false; + } } bool AVSFunction::TypeMatch(const char* param_types, const AVSValue* args, size_t num_args, bool strict, IScriptEnvironment* env) { bool optional = false; - /* - { "StackHorizontal", BUILTIN_FUNC_PREFIX, "cc+", StackHorizontal::Create }, - { "Spline", BUILTIN_FUNC_PREFIX, "[x]ff+[cubic]b", Spline }, - { "Select", BUILTIN_FUNC_PREFIX, "i.+", Select }, - { "Array", BUILTIN_FUNC_PREFIX, ".#", ArrayCreate }, // # instead of +: creates script array - - { "IsArray", BUILTIN_FUNC_PREFIX, ".", IsArray }, - { "ArrayGet", BUILTIN_FUNC_PREFIX, "ai", ArrayGet }, - { "ArrayGet", BUILTIN_FUNC_PREFIX, "as", ArrayGet }, - { "ArraySize", BUILTIN_FUNC_PREFIX, "a", ArraySize }, - */ - // arguments are provided in a flattened way (flattened=array elements extracted) - // e.g. string array is provided here string,string,string - size_t i = 0; - while (i < num_args) { - + /* + { "StackHorizontal", BUILTIN_FUNC_PREFIX, "cc+", StackHorizontal::Create }, + { "Spline", BUILTIN_FUNC_PREFIX, "[x]ff+[cubic]b", Spline }, + { "Select", BUILTIN_FUNC_PREFIX, "i.+", Select }, + { "Array", BUILTIN_FUNC_PREFIX, ".#", ArrayCreate }, // # instead of +: creates script array + + { "IsArray", BUILTIN_FUNC_PREFIX, ".", IsArray }, + { "ArrayGet", BUILTIN_FUNC_PREFIX, "ai", ArrayGet }, + { "ArrayGet", BUILTIN_FUNC_PREFIX, "as", ArrayGet }, + { "ArraySize", BUILTIN_FUNC_PREFIX, "a", ArraySize }, + */ + // arguments are provided in a flattened way (flattened=array elements extracted) + // e.g. string array is provided here string,string,string + size_t i = 0; + while (i < num_args) { + if (*param_types == '\0') { // more args than params return false; @@ -332,37 +336,37 @@ bool AVSFunction::TypeMatch(const char* param_types, const AVSValue* args, size_ if (param_types[1] == '*') { // skip over initial test of type for '*' (since zero matches is ok) ++param_types; - } - - switch (*param_types) { - case 'b': case 'i': case 'f': case 's': case 'c': -#ifdef NEW_AVSVALUE - case 'a': // PF Arrays -#endif - if ( (!optional || args[i].Defined()) - && !SingleTypeMatch(*param_types, args[i], strict)) - return false; + } + + switch (*param_types) { + case 'b': case 'i': case 'f': case 's': case 'c': +#ifdef NEW_AVSVALUE + case 'a': // PF Arrays +#endif + if ( (!optional || args[i].Defined()) + && !SingleTypeMatch(*param_types, args[i], strict)) + return false; // fall through case '.': ++param_types; - ++i; - break; - case '+': case '*': -#ifdef NEW_AVSVALUE - if (param_types[-1] != '.' && args[i].IsArray()) { // PF new Arrays - // all elements in the array should match with the type char preceding '+*' - // only one array level is enough - for (int j = 0; j < args[i].ArraySize(); j++) - { - if (!SingleTypeMatch(param_types[-1], args[i][j], strict)) - return false; - } - // we're done with the + or * - ++param_types; - ++i; - } - else -#endif + ++i; + break; + case '+': case '*': +#ifdef NEW_AVSVALUE + if (param_types[-1] != '.' && args[i].IsArray()) { // PF new Arrays + // all elements in the array should match with the type char preceding '+*' + // only one array level is enough + for (int j = 0; j < args[i].ArraySize(); j++) + { + if (!SingleTypeMatch(param_types[-1], args[i][j], strict)) + return false; + } + // we're done with the + or * + ++param_types; + ++i; + } + else +#endif if (!SingleTypeMatch(param_types[-1], args[i], strict)) { // we're done with the + or * ++param_types; @@ -378,13 +382,13 @@ bool AVSFunction::TypeMatch(const char* param_types, const AVSValue* args, size_ // We're out of args. We have a match if one of the following is true: // (a) we're out of params. - // (b) remaining params are named i.e. optional. - // (c) we're at a '+' or '*' and any remaining params are optional. - - if (*param_types == '+' || *param_types == '*') - param_types += 1; - - if (*param_types == '\0' || *param_types == '[') + // (b) remaining params are named i.e. optional. + // (c) we're at a '+' or '*' and any remaining params are optional. + + if (*param_types == '+' || *param_types == '*') + param_types += 1; + + if (*param_types == '\0' || *param_types == '[') return true; while (param_types[1] == '*') { @@ -515,6 +519,12 @@ void PluginManager::AddAutoloadDir(const std::string &dirPath, bool toFront) replace_beginning(dir, "PROGRAMDIR", ExeFileDir); std::string plugin_dir; +#if defined (__GNUC__) + if (GetRegString(HKEY_CURRENT_USER, RegAvisynthKey, RegPluginDirPlus_GCC, &plugin_dir)) + replace_beginning(dir, "USER_PLUS_PLUGINS", plugin_dir); + if (GetRegString(HKEY_LOCAL_MACHINE, RegAvisynthKey, RegPluginDirPlus_GCC, &plugin_dir)) + replace_beginning(dir, "MACHINE_PLUS_PLUGINS", plugin_dir); +#else if (GetRegString(HKEY_CURRENT_USER, RegAvisynthKey, RegPluginDirPlus, &plugin_dir)) replace_beginning(dir, "USER_PLUS_PLUGINS", plugin_dir); if (GetRegString(HKEY_LOCAL_MACHINE, RegAvisynthKey, RegPluginDirPlus, &plugin_dir)) @@ -523,6 +533,7 @@ void PluginManager::AddAutoloadDir(const std::string &dirPath, bool toFront) replace_beginning(dir, "USER_CLASSIC_PLUGINS", plugin_dir); if (GetRegString(HKEY_LOCAL_MACHINE, RegAvisynthKey, RegPluginDirClassic, &plugin_dir)) replace_beginning(dir, "MACHINE_CLASSIC_PLUGINS", plugin_dir); +#endif // replace backslashes with forward slashes replace(dir, '\\', '/'); diff --git a/avs_core/core/avisynth.def b/avs_core/core/avisynth.def index 259eb3918..add53ad04 100644 --- a/avs_core/core/avisynth.def +++ b/avs_core/core/avisynth.def @@ -1,4 +1,4 @@ -LIBRARY +LIBRARY AviSynth.dll EXPORTS DllGetClassObject PRIVATE DllCanUnloadNow PRIVATE diff --git a/avs_core/core/avisynth64.def b/avs_core/core/avisynth64.def index 6851f636a..0f035e58f 100644 --- a/avs_core/core/avisynth64.def +++ b/avs_core/core/avisynth64.def @@ -1,4 +1,4 @@ -LIBRARY +LIBRARY AviSynth.dll EXPORTS DllGetClassObject PRIVATE DllCanUnloadNow PRIVATE diff --git a/avs_core/core/memcpy_amd.cpp b/avs_core/core/memcpy_amd.cpp index 66657d3f7..e0d4e7765 100644 --- a/avs_core/core/memcpy_amd.cpp +++ b/avs_core/core/memcpy_amd.cpp @@ -91,18 +91,18 @@ void memcpy_amd(void *dest, const void *src, size_t n) cmp ecx, TINY_BLOCK_COPY jb $memcpy_ic_3 ; tiny? skip mmx copy - cmp ecx, 32*1024 ; don't align between 32k-64k because + cmp ecx, 32*1024 ; // don't align between 32k-64k because jbe $memcpy_do_align ; it appears to be slower cmp ecx, 64*1024 jbe $memcpy_align_done $memcpy_do_align: - mov ecx, 8 ; a trick that's faster than rep movsb... + mov ecx, 8 ; // a trick that's faster than rep movsb... sub ecx, edi ; align destination to qword and ecx, 111b ; get the low bits sub ebx, ecx ; update copy count neg ecx ; set up to jump into the array add ecx, offset $memcpy_align_done - jmp ecx ; jump to array of movsb's + jmp ecx ; // jump to array of movsb's align 4 movsb @@ -159,7 +159,7 @@ align 16 and ecx, 1111b ; only look at the "remainder" bits neg ecx ; set up to jump into the array add ecx, offset $memcpy_last_few - jmp ecx ; jump to array of movsd's + jmp ecx ; // jump to array of movsd's $memcpy_uc_test: cmp ecx, UNCACHED_COPY/64 ; big enough? use block prefetch copy @@ -222,7 +222,7 @@ align 16 dec eax ; count down the cache lines jnz $memcpy_bp_2 ; keep grabbing more lines into cache - mov eax, CACHEBLOCK ; now that it's in cache, do the copy + mov eax, CACHEBLOCK ; // now that it's in cache, do the copy align 16 $memcpy_bp_3: movq mm0, [esi ] ; read 64 bits @@ -270,10 +270,10 @@ align 4 movsd movsd -$memcpy_last_few: ; dword aligned from before movsd's +$memcpy_last_few: ; // dword aligned from before movsd's mov ecx, ebx ; has valid low 2 bits of the byte count and ecx, 11b ; the last few cows must come home - jz $memcpy_final ; no more, let's leave + jz $memcpy_final ; // no more, let's leave rep movsb ; the last 1, 2, or 3 bytes $memcpy_final: diff --git a/avs_core/core/parser/script.cpp b/avs_core/core/parser/script.cpp index 5a865a368..a7e111d49 100644 --- a/avs_core/core/parser/script.cpp +++ b/avs_core/core/parser/script.cpp @@ -49,6 +49,10 @@ #include "../InternalEnvironment.h" #include +#ifndef MINGW_HAS_SECURE_API +#define sprintf_s sprintf +#endif + /******************************************************************** diff --git a/avs_core/filters/convolution.cpp b/avs_core/filters/convolution.cpp index 58c09410e..889da0bae 100644 --- a/avs_core/filters/convolution.cpp +++ b/avs_core/filters/convolution.cpp @@ -86,6 +86,17 @@ __forceinline int static_clip(int value) { return value; } +template +__forceinline int static_clip(int value) { + if (value < mi) { + return mi; + } + if (value > ma) { + return ma; + } + return value; +} + /***************************************** ****** General Convolution 2D filter ***** *****************************************/ diff --git a/avs_core/include/avs/capi.h b/avs_core/include/avs/capi.h index f45bdcbde..8799bf1fb 100644 --- a/avs_core/include/avs/capi.h +++ b/avs_core/include/avs/capi.h @@ -39,16 +39,44 @@ # define EXTERN_C #endif -#ifdef MSVC -#ifndef AVSC_USE_STDCALL -# define AVSC_CC __cdecl -#else -# define AVSC_CC __stdcall -#endif -#else -# define AVSC_CC +#ifdef BUILDING_AVSCORE +# if defined(GCC) && defined(X86_32) +# define AVSC_CC +# else // MSVC builds and 64-bit GCC +# ifndef AVSC_USE_STDCALL +# define AVSC_CC __cdecl +# else +# define AVSC_CC __stdcall +# endif +# endif +#else // needed for programs that talk to AviSynth+ +# ifndef AVSC_WIN32_GCC32 // see comment below +# ifndef AVSC_USE_STDCALL +# define AVSC_CC __cdecl +# else +# define AVSC_CC __stdcall +# endif +# else +# define AVSC_CC +# endif #endif +// On 64-bit Windows, there's only one calling convention, +// so there is no difference between MSVC and GCC. On 32-bit, +// this isn't true. The convention that GCC needs to use to +// even build AviSynth+ as 32-bit makes anything that uses +// it incompatible with 32-bit MSVC builds of AviSynth+. +// The AVSC_WIN32_GCC32 define is meant to provide a user +// switchable way to make builds of FFmpeg to test 32-bit +// GCC builds of AviSynth+ without having to screw around +// with alternate headers, while still default to the usual +// situation of using 32-bit MSVC builds of AviSynth+. + +// Hopefully, this situation will eventually be resolved +// and a broadly compatible solution will arise so the +// same 32-bit FFmpeg build can handle either MSVC or GCC +// builds of AviSynth+. + #define AVSC_INLINE static __inline #ifdef BUILDING_AVSCORE diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 7fcba2aff..b0ae113d2 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -12,7 +12,7 @@ if (BUILD_IMAGESEQ) add_subdirectory("ImageSeq") endif() -if (MSVC_IDE OR MINGW) +if (MSVC OR MINGW) if(BUILD_DIRECTSHOWSOURCE) add_subdirectory("DirectShowSource") endif() diff --git a/plugins/DirectShowSource/CMakeLists.txt b/plugins/DirectShowSource/CMakeLists.txt index b391243a0..bd8156d1d 100644 --- a/plugins/DirectShowSource/CMakeLists.txt +++ b/plugins/DirectShowSource/CMakeLists.txt @@ -5,15 +5,17 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.8.11 ) set(PluginName "DirectShowSource") set(ProjectName "Plugin${PluginName}") -# We need these variables set by the user to compile successfully -set(DSHOWSRC_BASECLASSES_PATH "C:/Program Files/Microsoft SDKs/Windows/v7.0/Samples/multimedia/directshow/baseclasses" CACHE STRING "Folder path to the DirectShow example baseclasses.") -#set(DSHOWSRC_BASECLASSES_PATH "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Samples/multimedia/directshow/baseclasses" CACHE STRING "Folder path to the DirectShow example baseclasses.") -if(CMAKE_SIZEOF_VOID_P EQUAL 4) -set(DSHOWSRC_BASECLASSES_LIB "c:/Program Files/Microsoft SDKs/Windows/v7.0/Samples/multimedia/directshow/baseclasses/Release_MBCS/strmbase.lib" CACHE FILEPATH "File path to the DirectShow example baseclasses precompiled static library ('strmbase.lib').") -else() -set(DSHOWSRC_BASECLASSES_LIB "c:/Program Files/Microsoft SDKs/Windows/v7.0/Samples/multimedia/directshow/baseclasses/x64/Release_MBCS/strmbase.lib" CACHE FILEPATH "File path to the DirectShow example baseclasses precompiled static library ('strmbase.lib').") +# Sensible defaults that should just work if WINSDK is installed and baseclasses built +set(DEFAULT_BASECLASSES_PATH "C:/Program Files/Microsoft SDKs/Windows/v7.1/Samples/multimedia/directshow/baseclasses") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32-bit + set(DEFAULT_BASECLASSES_LIB "${DEFAULT_BASECLASSES_PATH}/Release/strmbase.lib") +else() # 64-bit + set(DEFAULT_BASECLASSES_LIB "${DEFAULT_BASECLASSES_PATH}/x64/Release/strmbase.lib") endif() -set(DSHOWSRC_DX_INCLUDE_PATH "C:/Program Files/Microsoft DirectX SDK (August 2009)/Include" CACHE STRING "Include folder path to the DirectX headers.") + +# We need these variables set by the user to compile successfully +set(DSHOWSRC_BASECLASSES_PATH "${DEFAULT_BASECLASSES_PATH}" CACHE STRING "Folder path to the DirectShow example baseclasses.") +set(DSHOWSRC_BASECLASSES_LIB "${DEFAULT_BASECLASSES_LIB}" CACHE FILEPATH "File path to the DirectShow example baseclasses precompiled static library ('strmbase.lib').") # Create library project(${ProjectName}) @@ -27,15 +29,8 @@ set_target_properties(${ProjectName} PROPERTIES "OUTPUT_NAME" ${PluginName}) # Library dependencies target_link_libraries(${ProjectName} "Winmm.lib" "Quartz.lib" "Ole32.lib" "User32.lib" "Oleaut32.lib" "Advapi32.lib" ${DSHOWSRC_BASECLASSES_LIB}) -# Allow back permissive C++ Standard conformance, because old DX headers would fail to compile otherwise -if( MSVC_IDE ) # Check for Visual Studio -remove_definitions("/permissive-") -endif() - - - # Include directories -target_include_directories(${ProjectName} PRIVATE ${AvsCore_SOURCE_DIR} ${DSHOWSRC_BASECLASSES_PATH} ${DSHOWSRC_DX_INCLUDE_PATH}) +target_include_directories(${ProjectName} PRIVATE ${AvsCore_SOURCE_DIR} ${DSHOWSRC_BASECLASSES_PATH}) if (MSVC_IDE) # Copy output to a common folder for easy deployment