static int get_avisynth_version(avs_hnd_t *ah) { if (!ah->func.avs_function_exists(ah->env, "VersionNumber")) return 0; AVS_Value ver = ah->func.avs_invoke(ah->env, "VersionNumber", avs_new_value_array(NULL, 0), NULL); if (avs_is_error(ver) || !avs_is_float(ver)) return 0; int version = (int)(avs_as_float(ver) * 100 + 0.5); ah->func.avs_release_value(ver); return version; }
static float get_avs_version( avs_hnd_t *h ) { /* AvxSynth has its version defined starting at 4.0, even though it's based on AviSynth 2.5.8. This is troublesome for get_avs_version and working around the new colorspaces in 2.6. So if AvxSynth is detected, explicitly define the version as 2.58. */ #if USE_AVXSYNTH return 2.58f; #else FAIL_IF_ERROR( !h->func.avs_function_exists( h->env, "VersionNumber" ), "VersionNumber does not exist\n" ); AVS_Value ver = h->func.avs_invoke( h->env, "VersionNumber", avs_new_value_array( NULL, 0 ), NULL ); FAIL_IF_ERROR( avs_is_error( ver ), "unable to determine avisynth version: %s\n", avs_as_error( ver ) ); FAIL_IF_ERROR( !avs_is_float( ver ), "VersionNumber did not return a float value\n" ); float ret = avs_as_float( ver ); h->func.avs_release_value( ver ); return ret; #endif }
int inline_avs_is_float(AVS_Value *v) { if(!v)return 0; return avs_is_float(*v); }