]> git.sesse.net Git - x264/commitdiff
Avisynth-MT and 2.6 compatibility fixes
authorSteven Walters <kemuri9@gmail.com>
Fri, 11 Dec 2009 03:48:51 +0000 (19:48 -0800)
committerFiona Glaser <fiona@x264.com>
Fri, 11 Dec 2009 05:15:00 +0000 (21:15 -0800)
Explain to the user why YV12 conversion is forced with Avisynth 2.6.
Fix encoding with Avisynth-MT scripts by inserting the necessary Distributor() call; speeds such scripts back up to expected levels.

input/avs.c

index b2ddc430ca0b38a961ed73ff5fdbb8e468d3cf7c..a88b86ef31565157d81ce6c45219007aace503ed 100644 (file)
@@ -155,6 +155,17 @@ static int open_file( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param
             fprintf( stderr, "avs [error]: %s\n", avs_as_string( res ) );
             return -1;
         }
+        /* check if the user is using a multi-threaded script and apply distributor if necessary.
+           adapted from avisynth's vfw interface */
+        AVS_Value mt_test = h->func.avs_invoke( h->env, "GetMTMode", avs_new_value_bool( 0 ), NULL );
+        int mt_mode = avs_is_int( mt_test ) ? avs_as_int( mt_test ) : 0;
+        h->func.avs_release_value( mt_test );
+        if( mt_mode > 0 && mt_mode < 5 )
+        {
+            AVS_Value temp = h->func.avs_invoke( h->env, "Distributor", res, NULL );
+            h->func.avs_release_value( res );
+            res = temp;
+        }
     }
     else /* non script file */
     {
@@ -213,7 +224,8 @@ static int open_file( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param
     if( !avs_is_yv12( vi ) || avs_version >= AVS_INTERFACE_OTHER_PLANAR )
     {
         h->func.avs_release_clip( h->clip );
-        fprintf( stderr, "avs [warning]: converting input clip to YV12\n" );
+        fprintf( stderr, "avs %s\n", !avs_is_yv12( vi ) ? "[warning]: converting input clip to YV12"
+               : "[info]: Avisynth 2.6+ detected, forcing conversion to YV12" );
         const char *arg_name[2] = { NULL, "interlaced" };
         AVS_Value arg_arr[2] = { res, avs_new_value_bool( p_param->b_interlaced ) };
         AVS_Value res2 = h->func.avs_invoke( h->env, "ConvertToYV12", avs_new_value_array( arg_arr, 2 ), arg_name );