⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mosaic.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX #name ) ) );      \    var_AddCallback( p_filter, CFG_PREFIX #name, MosaicCallback, p_sys );    GET_VAR( width, 0, INT_MAX );    GET_VAR( height, 0, INT_MAX );    GET_VAR( xoffset, 0, INT_MAX );    GET_VAR( yoffset, 0, INT_MAX );    GET_VAR( align, 0, 10 );    if( p_sys->i_align == 3 || p_sys->i_align == 7 )        p_sys->i_align = 5;    GET_VAR( borderw, 0, INT_MAX );    GET_VAR( borderh, 0, INT_MAX );    GET_VAR( rows, 1, INT_MAX );    GET_VAR( cols, 1, INT_MAX );    GET_VAR( alpha, 0, 255 );    GET_VAR( position, 0, 2 );    GET_VAR( delay, 100, INT_MAX );    p_sys->i_delay *= 1000;    p_sys->b_ar = var_CreateGetBoolCommand( p_filter,                                            CFG_PREFIX "keep-aspect-ratio" );    var_AddCallback( p_filter, CFG_PREFIX "keep-aspect-ratio", MosaicCallback,                     p_sys );    p_sys->b_keep = var_CreateGetBoolCommand( p_filter,                                              CFG_PREFIX "keep-picture" );    if ( !p_sys->b_keep )    {        p_sys->p_image = image_HandlerCreate( p_filter );    }    p_sys->i_order_length = 0;    p_sys->ppsz_order = NULL;    psz_order = var_CreateGetStringCommand( p_filter, CFG_PREFIX "order" );    _psz_order = psz_order;    var_AddCallback( p_filter, CFG_PREFIX "order", MosaicCallback, p_sys );    if( *psz_order )    {        char *psz_end = NULL;        i_index = 0;        do        {            psz_end = strchr( psz_order, ',' );            i_index++;            p_sys->ppsz_order = realloc( p_sys->ppsz_order,                                         i_index * sizeof(char *) );            p_sys->ppsz_order[i_index - 1] = strndup( psz_order,                                           psz_end - psz_order );            psz_order = psz_end+1;        } while( psz_end );        p_sys->i_order_length = i_index;    }    free( _psz_order );    /* Manage specific offsets for substreams */    psz_offsets = var_CreateGetStringCommand( p_filter, CFG_PREFIX "offsets" );    p_sys->i_offsets_length = 0;    p_sys->pi_x_offsets = NULL;    p_sys->pi_y_offsets = NULL;    mosaic_ParseSetOffsets( p_filter, p_sys, psz_offsets );    free( psz_offsets );    var_AddCallback( p_filter, CFG_PREFIX "offsets", MosaicCallback, p_sys );    vlc_mutex_unlock( &p_sys->lock );    return VLC_SUCCESS;}/***************************************************************************** * DestroyFilter: destroy mosaic video filter *****************************************************************************/static void DestroyFilter( vlc_object_t *p_this ){    filter_t *p_filter = (filter_t*)p_this;    filter_sys_t *p_sys = p_filter->p_sys;    int i_index;    vlc_mutex_lock( &p_sys->lock );    if( !p_sys->b_keep )    {        image_HandlerDelete( p_sys->p_image );    }    if( p_sys->i_order_length )    {        for( i_index = 0; i_index < p_sys->i_order_length; i_index++ )        {            free( p_sys->ppsz_order[i_index] );        }        free( p_sys->ppsz_order );    }    if( p_sys->i_offsets_length )    {        free( p_sys->pi_x_offsets );        free( p_sys->pi_y_offsets );        p_sys->i_offsets_length = 0;    }    vlc_mutex_unlock( &p_sys->lock );    vlc_mutex_destroy( &p_sys->lock );    free( p_sys );}/***************************************************************************** * MosaicReleasePicture : Hack to avoid picture duplication *****************************************************************************/static void MosaicReleasePicture( picture_t *p_picture ){    picture_t *p_original_pic = (picture_t *)p_picture->p_sys;    picture_Release( p_original_pic );}/***************************************************************************** * Filter *****************************************************************************/static subpicture_t *Filter( filter_t *p_filter, mtime_t date ){    filter_sys_t *p_sys = p_filter->p_sys;    bridge_t *p_bridge;    subpicture_t *p_spu;    int i_index, i_real_index, i_row, i_col;    int i_greatest_real_index_used = p_sys->i_order_length - 1;    unsigned int col_inner_width, row_inner_height;    subpicture_region_t *p_region;    subpicture_region_t *p_region_prev = NULL;    /* Allocate the subpicture internal data. */    p_spu = filter_NewSubpicture( p_filter );    if( !p_spu )        return NULL;    /* Initialize subpicture */    p_spu->i_channel = 0;    p_spu->i_start  = date;    p_spu->i_stop = 0;    p_spu->b_ephemer = true;    p_spu->i_alpha = p_sys->i_alpha;    p_spu->i_flags = p_sys->i_align;    p_spu->b_absolute = false;    vlc_mutex_lock( &p_sys->lock );    vlc_mutex_lock( p_sys->p_lock );    p_bridge = GetBridge( p_filter );    if ( p_bridge == NULL )    {        vlc_mutex_unlock( p_sys->p_lock );        vlc_mutex_unlock( &p_sys->lock );        return p_spu;    }    if ( p_sys->i_position == position_offsets )    {        /* If we have either too much or not enough offsets, fall-back         * to automatic positioning. */        if ( p_sys->i_offsets_length != p_sys->i_order_length )        {            msg_Err( p_filter,                     "Number of specified offsets (%d) does not match number "                     "of input substreams in mosaic-order (%d), falling back "                     "to mosaic-position=0",                     p_sys->i_offsets_length, p_sys->i_order_length );            p_sys->i_position = position_auto;        }    }    if ( p_sys->i_position == position_auto )    {        int i_numpics = p_sys->i_order_length; /* keep slots and all */        for ( i_index = 0; i_index < p_bridge->i_es_num; i_index++ )        {            bridged_es_t *p_es = p_bridge->pp_es[i_index];            if ( !p_es->b_empty )            {                i_numpics ++;                if( p_sys->i_order_length && p_es->psz_id != 0 )                {                    /* We also want to leave slots for images given in                     * mosaic-order that are not available in p_vout_picture */                    int i;                    for( i = 0; i < p_sys->i_order_length ; i++ )                    {                        if( !strcmp( p_sys->ppsz_order[i], p_es->psz_id ) )                        {                            i_numpics--;                            break;                        }                    }                }            }        }        p_sys->i_rows = ceil(sqrt( (double)i_numpics ));        p_sys->i_cols = ( i_numpics % p_sys->i_rows == 0 ?                            i_numpics / p_sys->i_rows :                            i_numpics / p_sys->i_rows + 1 );    }    col_inner_width  = ( ( p_sys->i_width - ( p_sys->i_cols - 1 )                       * p_sys->i_borderw ) / p_sys->i_cols );    row_inner_height = ( ( p_sys->i_height - ( p_sys->i_rows - 1 )                       * p_sys->i_borderh ) / p_sys->i_rows );    i_real_index = 0;    for ( i_index = 0; i_index < p_bridge->i_es_num; i_index++ )    {        bridged_es_t *p_es = p_bridge->pp_es[i_index];        video_format_t fmt_in, fmt_out;        picture_t *p_converted;        memset( &fmt_in, 0, sizeof( video_format_t ) );        memset( &fmt_out, 0, sizeof( video_format_t ) );        if ( p_es->b_empty )            continue;        while ( p_es->p_picture != NULL                 && p_es->p_picture->date + p_sys->i_delay < date )        {            if ( p_es->p_picture->p_next != NULL )            {                picture_t *p_next = p_es->p_picture->p_next;                picture_Release( p_es->p_picture );                p_es->p_picture = p_next;            }            else if ( p_es->p_picture->date + p_sys->i_delay + BLANK_DELAY <                        date )            {                /* Display blank */                picture_Release( p_es->p_picture );                p_es->p_picture = NULL;                p_es->pp_last = &p_es->p_picture;                break;            }            else            {                msg_Dbg( p_filter, "too late picture for %s (%"PRId64 ")",                         p_es->psz_id,                         date - p_es->p_picture->date - p_sys->i_delay );                break;            }        }        if ( p_es->p_picture == NULL )            continue;        if ( p_sys->i_order_length == 0 )        {            i_real_index++;        }        else        {            int i;            for ( i = 0; i <= p_sys->i_order_length; i++ )            {                if ( i == p_sys->i_order_length ) break;                if ( strcmp( p_es->psz_id, p_sys->ppsz_order[i] ) == 0 )                {                    i_real_index = i;                    break;                }            }            if ( i == p_sys->i_order_length )                i_real_index = ++i_greatest_real_index_used;        }        i_row = ( i_real_index / p_sys->i_cols ) % p_sys->i_rows;        i_col = i_real_index % p_sys->i_cols ;        if ( !p_sys->b_keep )        {            /* Convert the images */            fmt_in.i_chroma = p_es->p_picture->format.i_chroma;            fmt_in.i_height = p_es->p_picture->format.i_height;            fmt_in.i_width = p_es->p_picture->format.i_width;            if( fmt_in.i_chroma == VLC_FOURCC('Y','U','V','A') ||                fmt_in.i_chroma == VLC_FOURCC('R','G','B','A') )                fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');            else                fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');            fmt_out.i_width = col_inner_width;            fmt_out.i_height = row_inner_height;            if( p_sys->b_ar ) /* keep aspect ratio */            {                if( (float)fmt_out.i_width / (float)fmt_out.i_height                      > (float)fmt_in.i_width / (float)fmt_in.i_height )                {                    fmt_out.i_width = ( fmt_out.i_height * fmt_in.i_width )                                         / fmt_in.i_height;                }                else                {                    fmt_out.i_height = ( fmt_out.i_width * fmt_in.i_height )                                        / fmt_in.i_width;                }             }            fmt_out.i_visible_width = fmt_out.i_width;            fmt_out.i_visible_height = fmt_out.i_height;            p_converted = image_Convert( p_sys->p_image, p_es->p_picture,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -