[x264-devel] commit: Detect Avisynth initialization failures (Steven Walters )
git at videolan.org
git at videolan.org
Tue Dec 7 09:15:50 CET 2010
x264 | branch: master | Steven Walters <kemuri9 at gmail.com> | Wed Oct 13 21:53:50 2010 -0400| [62a2dc0a53b0eaa29daa5fc7e1586e729cb5b533] | committer: Jason Garrett-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.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=62a2dc0a53b0eaa29daa5fc7e1586e729cb5b533
---
extras/avisynth_c.h | 5 ++++-
input/avs.c | 8 +++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/extras/avisynth_c.h b/extras/avisynth_c.h
index 64deaad..5044efb 100644
--- a/extras/avisynth_c.h
+++ b/extras/avisynth_c.h
@@ -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);
diff --git a/input/avs.c b/input/avs.c
index 7cfdfd8..5bd8dcd 100644
--- a/input/avs.c
+++ b/input/avs.c
@@ -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 );
More information about the x264-devel
mailing list