Commit ee6b4822 authored by Steven Walters's avatar Steven Walters Committed by Fiona Glaser

Detect Avisynth initialization failures

Detect if there is a critical Avisynth initialization failure and print the associated error.
This, however, requires a feature present in the latest version of Avisynth alpha (2.6).
Previous versions are unaffected.
parent 5b5b7468
......@@ -552,7 +552,7 @@ AVSC_INLINE int avs_array_size(AVS_Value v)
AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
{ return avs_is_array(v) ? v.d.array[index] : v; }
// only use these functions on am AVS_Value that does not already have
// only use these functions on an AVS_Value that does not already have
// an active value. Remember, treat AVS_Value as a fat pointer.
AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
{ AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
......@@ -660,6 +660,7 @@ enum {
AVS_CPUF_SSE4_2 = 0x800, // Nehalem
};
AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
AVSC_API(long, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
......@@ -771,6 +772,7 @@ struct AVS_Library {
AVSC_DECLARE_FUNC(avs_function_exists);
AVSC_DECLARE_FUNC(avs_get_audio);
AVSC_DECLARE_FUNC(avs_get_cpu_flags);
AVSC_DECLARE_FUNC(avs_get_error);
AVSC_DECLARE_FUNC(avs_get_frame);
AVSC_DECLARE_FUNC(avs_get_parity);
AVSC_DECLARE_FUNC(avs_get_var);
......@@ -829,6 +831,7 @@ AVSC_INLINE AVS_Library * avs_load_library() {
AVSC_LOAD_FUNC(avs_function_exists);
AVSC_LOAD_FUNC(avs_get_audio);
AVSC_LOAD_FUNC(avs_get_cpu_flags);
AVSC_LOAD_FUNC(avs_get_error);
AVSC_LOAD_FUNC(avs_get_frame);
AVSC_LOAD_FUNC(avs_get_parity);
AVSC_LOAD_FUNC(avs_get_var);
......
......@@ -61,6 +61,7 @@ typedef struct
AVSC_DECLARE_FUNC( avs_clip_get_error );
AVSC_DECLARE_FUNC( avs_create_script_environment );
AVSC_DECLARE_FUNC( avs_delete_script_environment );
AVSC_DECLARE_FUNC( avs_get_error );
AVSC_DECLARE_FUNC( avs_get_frame );
AVSC_DECLARE_FUNC( avs_get_video_info );
AVSC_DECLARE_FUNC( avs_function_exists );
......@@ -81,6 +82,7 @@ static int x264_avs_load_library( avs_hnd_t *h )
LOAD_AVS_FUNC( avs_clip_get_error, 0 );
LOAD_AVS_FUNC( avs_create_script_environment, 0 );
LOAD_AVS_FUNC( avs_delete_script_environment, 1 );
LOAD_AVS_FUNC( avs_get_error, 1 );
LOAD_AVS_FUNC( avs_get_frame, 0 );
LOAD_AVS_FUNC( avs_get_video_info, 0 );
LOAD_AVS_FUNC( avs_function_exists, 0 );
......@@ -132,7 +134,11 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
return -1;
FAIL_IF_ERROR( x264_avs_load_library( h ), "failed to load avisynth\n" )
h->env = h->func.avs_create_script_environment( AVS_INTERFACE_25 );
FAIL_IF_ERROR( !h->env, "failed to initiate avisynth\n" )
if( h->func.avs_get_error )
{
const char *error = h->func.avs_get_error( h->env );
FAIL_IF_ERROR( error, "%s\n", error );
}
AVS_Value arg = avs_new_value_string( psz_filename );
AVS_Value res;
char *filename_ext = get_filename_extension( psz_filename );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment