Ejemplo n.º 1
0
static void create_bmp_header(avs_hnd_t *ah)
{
    int pix_type = avs_is_planar(ah->vi) ? 0 : avs_is_rgb(ah->vi) ? 1 : 2;
    LONG width = ah->vi->width >> (!pix_type * ah->highbit_depth);
    LONG height = ah->vi->height;
    struct {
        WORD  bit_cnt;
        DWORD fourcc;
        DWORD bmp_size;
    } color_table[3] = {
        { 48, MAKEFOURCC('Y', 'C', '4', '8'), (((width * 6 + 3) >> 2) << 2) * height },
Ejemplo n.º 2
0
static AVS_Value initialize_avisynth( avs_handler_t *hp, char *input )
{
    if( load_avisynth_dll( hp ) )
        return avs_void;
    hp->env = hp->func.avs_create_script_environment( AVS_INTERFACE_25 );
    if( hp->func.avs_get_error && hp->func.avs_get_error( hp->env ) )
        return avs_void;
    AVS_Value arg = avs_new_value_string( input );
    AVS_Value res = hp->func.avs_invoke( hp->env, "Import", arg, NULL );
    if( avs_is_error( res ) )
        return res;
    AVS_Value mt_test = hp->func.avs_invoke( hp->env, "GetMTMode", avs_new_value_bool( 0 ), NULL );
    int mt_mode = avs_is_int( mt_test ) ? avs_as_int( mt_test ) : 0;
    hp->func.avs_release_value( mt_test );
    if( mt_mode > 0 && mt_mode < 5 )
    {
        AVS_Value temp = hp->func.avs_invoke( hp->env, "Distributor", res, NULL );
        hp->func.avs_release_value( res );
        res = temp;
    }
    hp->clip = hp->func.avs_take_clip( res, hp->env );
    hp->vi = hp->func.avs_get_video_info( hp->clip );
    if( avs_is_planar( hp->vi ) )
    {
        if( !(hp->vi->width & 1) )
            res = invoke_filter( hp, res, "ConvertToYUY2" );
        else
        {
            hp->func.avs_release_value( res );
            return avs_void;
        }
    }
    if( hp->vi->sample_type & AVS_SAMPLE_FLOAT )
        res = invoke_filter( hp, res, "ConvertAudioTo16bit" );
    return avs_is_rgb32( hp->vi ) ? invoke_filter( hp, res, "ConvertToRGB24" ) : res;
}
Ejemplo n.º 3
0
static AVS_Value initialize_avisynth(avs_hnd_t *ah, LPSTR input)
{
    if (load_avisynth_dll(ah))
        return avs_void;

    ah->env = ah->func.avs_create_script_environment(AVS_INTERFACE_25);
    if (ah->func.avs_get_error && ah->func.avs_get_error(ah->env))
        return avs_void;

    ah->version = get_avisynth_version(ah);

    AVS_Value res = avs_void;
    switch (ah->ext) {
    case TYPE_AVS:
        res = import_avs(ah, input);
        break;
    case TYPE_D2V_DONALD:
        res = import_d2v_donald(ah, input);
        break;
    case TYPE_D2V_JACKIE:
#ifdef D2V_DVD2AVI_ENABLED
        res = import_d2v_jackie(ah, input);
        break;
#endif
    default:
        break;
    }

    if (avs_is_error(res) || !avs_defined(res))
        return res;

    if (ah->ext == TYPE_D2V_DONALD && ah->d2v.keyframe_judge)
        create_index(ah, input);

    if (ah->adjust_audio_length) {
        AVS_Value arg_arr[3] = {res, avs_new_value_int(0), avs_new_value_int(0)};
        AVS_Value tmp = ah->func.avs_invoke(ah->env, "Trim", avs_new_value_array(arg_arr, 3), NULL);
        ah->func.avs_release_value(res);
        res = tmp;
    }

    AVS_Value mt_test = ah->func.avs_invoke(ah->env, "GetMTMode", avs_new_value_bool(0), NULL);
    int mt_mode = avs_is_int(mt_test) ? avs_as_int(mt_test) : 0;
    ah->func.avs_release_value(mt_test);
    if (mt_mode > 0 && mt_mode < 5) {
        AVS_Value temp = ah->func.avs_invoke(ah->env, "Distributor", res, NULL);
        ah->func.avs_release_value(res);
        res = temp;
    }

    ah->clip = ah->func.avs_take_clip(res, ah->env);
    ah->vi = ah->func.avs_get_video_info(ah->clip);

    if (ah->highbit_depth && ah->version >= 260 && avs_is_planar(ah->vi)) {
        if (avs_is_yv411(ah->vi) ||
            ((avs_is_yv24(ah->vi) || avs_is_y8(ah->vi)) && (ah->vi->width & 1)) ||
            ((avs_is_yv16(ah->vi) || avs_is_yv12(ah->vi)) && (ah->vi->width & 3))) {
            ah->func.avs_release_value(res);
            return avs_void;
        }
        if (avs_is_yv12(ah->vi))
            res = invoke_filter(ah, res, "ConvertToYV16");

    } else if (avs_is_yv12(ah->vi) || avs_is_yv16(ah->vi) || avs_is_yv411(ah->vi)) {
        if (ah->func.avs_function_exists(ah->env, ah->yuy2converter))
            res = invoke_filter(ah, res, ah->yuy2converter);
        else
            res = invoke_filter(ah, res, "ConvertToYUY2");
    }

    if (avs_is_rgb32(ah->vi))
        res = invoke_filter(ah, res, "ConvertToRGB24");

    if (ah->vi->sample_type & 0x1C)
        res = invoke_filter(ah, res, "ConvertAudioTo16bit");

    return res;
}