示例#1
0
static void *open_file( char *file_name, reader_option_t *opt )
{
    /* Check file extension. */
    if( lw_check_file_extension( file_name, "avs" ) < 0 )
        return NULL;
    /* Try to open the file as avisynth script. */
    avs_handler_t *hp = lw_malloc_zero( sizeof(avs_handler_t) );
    if( !hp )
        return NULL;
    AVS_Value res = initialize_avisynth( hp, file_name );
    if( !avs_is_clip( res ) )
    {
        if( hp->library )
            close_avisynth_dll( hp );
        lw_free( hp );
        return NULL;
    }
    hp->func.avs_release_value( res );
    return hp;
}
示例#2
0
static void *open_file
(
    char            *file_name,
    reader_option_t *opt
)
{
    /* Check file extension. */
    if( lw_check_file_extension( file_name, "vpy" ) < 0 )
        return NULL;
    /* Try to open the file as VapourSynth script. */
    vpy_handler_t *hp = lw_malloc_zero( sizeof(vpy_handler_t) );
    if( !hp )
        return NULL;
    if( load_vsscript_dll( hp ) < 0 )
    {
        free( hp );
        return NULL;
    }
    if( hp->vsscript.func.init() == 0 )
        goto fail;
    hp->vsapi = hp->vsscript.func.getVSApi();
    if( !hp->vsapi || hp->vsscript.func.evaluateFile( &hp->vsscript.handle, file_name, efSetWorkingDir ) )
        goto fail;
    hp->node = hp->vsscript.func.getOutput( hp->vsscript.handle, 0 );
    if( !hp->node )
        goto fail;
    hp->vi = hp->vsapi->getVideoInfo( hp->node );
    /* */
    hp->ctx = avcodec_alloc_context3( NULL );
    if( !hp->ctx )
        goto fail;
    return hp;
fail:
    if( hp->library )
        close_vsscript_dll( hp );
    free( hp );
    return NULL;
}