Exemplo n.º 1
0
/**
 * Common open function
 */
static int OpenCommon(vlc_object_t *p_this, bool b_sub)
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;

    /* */
    if (!b_sub && !es_format_IsSimilar(&p_filter->fmt_in, &p_filter->fmt_out)) {
        msg_Err(p_filter, "Input and output format does not match");
        return VLC_EGENERIC;
    }


    /* */
    p_filter->p_sys = p_sys = malloc(sizeof(*p_sys));
    if (!p_sys)
        return VLC_ENOMEM;

    /* */
    p_sys->p_blend = NULL;
    if (!b_sub) {
        p_sys->p_blend = filter_NewBlend(VLC_OBJECT(p_filter),
                                          &p_filter->fmt_in.video);
        if (!p_sys->p_blend) {
            free(p_sys);
            return VLC_EGENERIC;
        }
    }

    /* */
    config_ChainParse(p_filter, CFG_PREFIX, ppsz_filter_options,
                       p_filter->p_cfg);

    /* create and initialize variables */
    p_sys->i_pos = var_CreateGetInteger(p_filter, CFG_PREFIX "position");
    p_sys->i_pos_x = var_CreateGetInteger(p_filter, CFG_PREFIX "x");
    p_sys->i_pos_y = var_CreateGetInteger(p_filter, CFG_PREFIX "y");
    BarGraph_t *p_BarGraph = &p_sys->p_BarGraph;
    p_BarGraph->p_pic = NULL;
    p_BarGraph->i_alpha = var_CreateGetInteger(p_filter, CFG_PREFIX "transparency");
    p_BarGraph->i_alpha = VLC_CLIP(p_BarGraph->i_alpha, 0, 255);
    p_BarGraph->i_values = NULL;
    parse_i_values(p_BarGraph, &(char){ 0 });
Exemplo n.º 2
0
Arquivo: chain.c Projeto: mstorsjo/vlc
static int CreateChain( filter_t *p_parent, const es_format_t *p_fmt_mid )
{
    filter_sys_t *p_sys = p_parent->p_sys;
    filter_chain_Reset( p_sys->p_chain, &p_parent->fmt_in, &p_parent->fmt_out );

    filter_t *p_filter;

    if( p_parent->fmt_in.video.orientation != p_fmt_mid->video.orientation)
    {
        p_filter = AppendTransform( p_sys->p_chain, &p_parent->fmt_in, p_fmt_mid );
        // Check if filter was enough:
        if( p_filter == NULL )
            return VLC_EGENERIC;
        if( es_format_IsSimilar(&p_filter->fmt_out, &p_parent->fmt_out ))
           return VLC_SUCCESS;
    }
    else
    {
        if( filter_chain_AppendConverter( p_sys->p_chain,
                                          NULL, p_fmt_mid ) )
            return VLC_EGENERIC;
    }

    if( p_fmt_mid->video.orientation != p_parent->fmt_out.video.orientation)
    {
        if( AppendTransform( p_sys->p_chain, p_fmt_mid,
                             &p_parent->fmt_out ) == NULL )
            goto error;
    }
    else
    {
        if( filter_chain_AppendConverter( p_sys->p_chain,
                                          p_fmt_mid, &p_parent->fmt_out ) )
            goto error;
    }
    return VLC_SUCCESS;
error:
    //Clean up.
    filter_chain_Reset( p_sys->p_chain, NULL, NULL );
    return VLC_EGENERIC;
}
Exemplo n.º 3
0
Arquivo: puzzle.c Projeto: paa/vlc
/**
 * Open the filter
 */
static int Open( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;

    /* */
    if( !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) )
    {
        msg_Err( p_filter, "Input and output format does not match" );
        return VLC_EGENERIC;
    }

    /* Allocate structure */
    p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) );
    if( !p_sys )
        return VLC_ENOMEM;

    config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                       p_filter->p_cfg );

    p_sys->pi_order = NULL;

    vlc_mutex_init( &p_sys->lock );
    p_sys->change.i_rows =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "rows" );
    p_sys->change.i_cols =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "cols" );
    p_sys->change.b_blackslot =
        var_CreateGetBoolCommand( p_filter, CFG_PREFIX "black-slot" );
    p_sys->b_change = true;

    var_AddCallback( p_filter, CFG_PREFIX "rows", PuzzleCallback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "cols", PuzzleCallback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "black-slot", PuzzleCallback, p_sys );

    p_filter->pf_video_filter = Filter;
    p_filter->pf_video_mouse = Mouse;

    return VLC_SUCCESS;
}
Exemplo n.º 4
0
static int CreateChain( filter_t *p_parent, es_format_t *p_fmt_mid, config_chain_t *p_cfg )
{
    filter_chain_Reset( p_parent->p_sys->p_chain, &p_parent->fmt_in, &p_parent->fmt_out );

    filter_t *p_filter;

    if( p_parent->fmt_in.video.orientation != p_fmt_mid->video.orientation)
    {
        p_filter = AppendTransform( p_parent->p_sys->p_chain, &p_parent->fmt_in, p_fmt_mid );
    }
    else
    {
        p_filter = filter_chain_AppendFilter( p_parent->p_sys->p_chain, NULL, p_cfg, NULL, p_fmt_mid );
    }

    if( !p_filter )
        return VLC_EGENERIC;

    //Check if first filter was enough (transform filter most likely):
    if( es_format_IsSimilar(&p_filter->fmt_out, &p_parent->fmt_out ))
        return VLC_SUCCESS;

    if( p_fmt_mid->video.orientation != p_parent->fmt_out.video.orientation)
    {
        p_filter = AppendTransform( p_parent->p_sys->p_chain, p_fmt_mid, &p_parent->fmt_out );
    }
    else
    {
        p_filter = filter_chain_AppendFilter( p_parent->p_sys->p_chain, NULL, p_cfg, p_fmt_mid, NULL );
    }

    if( !p_filter )
    {
        //Clean up.
        filter_chain_Reset( p_parent->p_sys->p_chain, NULL, NULL );
        return VLC_EGENERIC;
    }

    return VLC_SUCCESS;
}
Exemplo n.º 5
0
/**
 * Common open function
 */
static int OpenCommon( vlc_object_t *p_this, bool b_sub )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;
    char *psz_filename;

    /* */
    if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) )
    {
        msg_Err( p_filter, "Input and output format does not match" );
        return VLC_EGENERIC;
    }

    /* */
    p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) );
    if( !p_sys )
        return VLC_ENOMEM;

    /* */
    p_sys->p_blend = NULL;
    if( !b_sub )
    {

        p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter),
                                          &p_filter->fmt_in.video );
        if( !p_sys->p_blend )
        {
            free( p_sys );
            return VLC_EGENERIC;
        }
    }

    /* */
    config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                       p_filter->p_cfg );

    /* */
    logo_list_t *p_list = &p_sys->list;

    psz_filename = var_CreateGetStringCommand( p_filter, "logo-file" );
    if( !psz_filename )
    {
        if( p_sys->p_blend )
            filter_DeleteBlend( p_sys->p_blend );
        free( p_sys );
        return VLC_ENOMEM;
    }
    if( *psz_filename == '\0' )
        msg_Warn( p_this, "no logo file specified" );

    p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
    p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 );
    p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
    p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );

    p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" );
    p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" );
    p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "logo-y" );

    /* Ignore aligment if a position is given for video filter */
    if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 )
        p_sys->i_pos = 0;

    vlc_mutex_init( &p_sys->lock );
    LogoListLoad( p_this, p_list, psz_filename );
    p_sys->b_spu_update = true;
    p_sys->b_mouse_grab = false;

    for( int i = 0; ppsz_filter_callbacks[i]; i++ )
        var_AddCallback( p_filter, ppsz_filter_callbacks[i],
                         LogoCallback, p_sys );

    /* Misc init */
    if( b_sub )
    {
        p_filter->pf_sub_source = FilterSub;
    }
    else
    {
        p_filter->pf_video_filter = FilterVideo;
        p_filter->pf_video_mouse = Mouse;
    }

    free( psz_filename );
    return VLC_SUCCESS;
}
Exemplo n.º 6
0
/**
 * Common open function
 */
static int OpenCommon( vlc_object_t *p_this, bool b_sub )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;
    BarGraph_t *p_BarGraph;
    char* i_values = NULL;

    /* */
    if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) )
    {
        msg_Err( p_filter, "Input and output format does not match" );
        return VLC_EGENERIC;
    }


    /* */
    p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) );
    if( !p_sys )
        return VLC_ENOMEM;
    p_BarGraph = &(p_sys->p_BarGraph);

    /* */
    p_sys->p_blend = NULL;
    if( !b_sub )
    {

        p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter),
                                          &p_filter->fmt_in.video );
        if( !p_sys->p_blend )
        {
            //free( p_BarGraph );
            free( p_sys );
            return VLC_EGENERIC;
        }
    }

    /* */
    config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                       p_filter->p_cfg );

    /* create and initialize variables */
    p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-position" );
    p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-x" );
    p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-y" );
    p_BarGraph->i_alpha = var_CreateGetIntegerCommand( p_filter,
                                                        "audiobargraph_v-transparency" );
    p_BarGraph->i_alpha = VLC_CLIP( p_BarGraph->i_alpha, 0, 255 );
    i_values = var_CreateGetStringCommand( p_filter, "audiobargraph_v-i_values" );
    //p_BarGraph->nbChannels = 0;
    //p_BarGraph->i_values = NULL;
    parse_i_values(p_BarGraph, i_values);
    p_BarGraph->alarm = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-alarm" );
    p_BarGraph->barWidth = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-barWidth" );
    p_BarGraph->scale = 400;

    /* Ignore aligment if a position is given for video filter */
    if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 )
        p_sys->i_pos = 0;

    vlc_mutex_init( &p_sys->lock );
    LoadBarGraph( p_this, p_BarGraph );
    p_sys->b_spu_update = true;

    for( int i = 0; ppsz_filter_callbacks[i]; i++ )
        var_AddCallback( p_filter, ppsz_filter_callbacks[i],
                         BarGraphCallback, p_sys );

    /* Misc init */
    if( b_sub )
    {
        p_filter->pf_sub_source = FilterSub;
    }
    else
    {
        p_filter->pf_video_filter = FilterVideo;
    }

    free( i_values );
    return VLC_SUCCESS;
}
Exemplo n.º 7
0
Arquivo: puzzle.c Projeto: qdk0901/vlc
/**
 * Open the filter
 */
int Open( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;

    /* Assert video in match with video out */
    if( !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) ) {
        msg_Err( p_filter, "Input and output format does not match" );
        return VLC_EGENERIC;
    }

    const vlc_chroma_description_t *p_chroma =
        vlc_fourcc_GetChromaDescription( p_filter->fmt_in.video.i_chroma );
    if( p_chroma == NULL || p_chroma->plane_count == 0 )
        return VLC_EGENERIC;

    /* Allocate structure */
    p_filter->p_sys = p_sys = calloc(1, sizeof( *p_sys ) );
    if( !p_sys )
        return VLC_ENOMEM;

    /* init some values */
    p_sys->b_shuffle_rqst    = true;
    p_sys->b_change_param    = true;
    p_sys->i_mouse_drag_pce  = NO_PCE;
    p_sys->i_pointed_pce     = NO_PCE;
    p_sys->i_magnet_accuracy = 3;

    /* Generate values of random bezier shapes */
    p_sys->ps_bezier_pts_H = calloc( SHAPES_QTY, sizeof( point_t *) );
    if( !p_sys->ps_bezier_pts_H )
    {
        free(p_filter->p_sys);
        p_filter->p_sys = NULL;
        return VLC_ENOMEM;
    }
    for (int32_t i_shape = 0; i_shape<SHAPES_QTY; i_shape++)
        p_sys->ps_bezier_pts_H[i_shape] = puzzle_rand_bezier(7);


    config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                       p_filter->p_cfg );

    vlc_mutex_init( &p_sys->lock );
    vlc_mutex_init( &p_sys->pce_lock );

    p_sys->s_new_param.i_rows =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "rows" );
    p_sys->s_new_param.i_cols =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "cols" );
    p_sys->s_new_param.i_border =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "border" );
    p_sys->s_new_param.b_preview =
        var_CreateGetBoolCommand( p_filter, CFG_PREFIX "preview" );
    p_sys->s_new_param.i_preview_size =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "preview-size" );
    p_sys->s_new_param.i_shape_size =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "shape-size" );
    p_sys->s_new_param.i_auto_shuffle_speed =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "auto-shuffle" );
    p_sys->s_new_param.i_auto_solve_speed =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "auto-solve" );
    p_sys->s_new_param.i_rotate =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "rotation" );
    p_sys->s_new_param.i_mode =
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "mode" );

    var_AddCallback( p_filter, CFG_PREFIX "rows",         puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "cols",         puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "border",       puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "preview",      puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "preview-size", puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "shape-size",   puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "auto-shuffle", puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "auto-solve",   puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "rotation",     puzzle_Callback, p_sys );
    var_AddCallback( p_filter, CFG_PREFIX "mode",     puzzle_Callback, p_sys );

    p_filter->pf_video_filter = Filter;
    p_filter->pf_video_mouse = puzzle_mouse;

    return VLC_SUCCESS;
}