Changeset 6c9013a9d8c430c0c91e38ff204e7db72183bf70

Show
Ignore:
Timestamp:
07/17/07 23:59:22 (1 year ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1184709562 +0000
git-parent:

[2fd187de931769cef2128cd7f0ede41f71732fda]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1184709562 +0000
Message:

Automatically load files with the following extension using the rawvid module (and set height, width, aspect ratio, chroma and fps correctly): sqcif, qcif, cif, 4cif, 16cif, yuv.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/rawvid.c

    r2fd187d r6c9013a  
    6565    set_callbacks( Open, Close ); 
    6666    add_shortcut( "rawvideo" ); 
    67     add_float( "rawvid-fps", 25, 0, FPS_TEXT, FPS_LONGTEXT, VLC_FALSE ); 
    68     add_integer( "rawvid-width", 176, 0, WIDTH_TEXT, WIDTH_LONGTEXT, 0 ); 
    69     add_integer( "rawvid-height", 144, 0, HEIGHT_TEXT, HEIGHT_LONGTEXT, 0 ); 
     67    add_float( "rawvid-fps", 0, 0, FPS_TEXT, FPS_LONGTEXT, VLC_FALSE ); 
     68    add_integer( "rawvid-width", 0, 0, WIDTH_TEXT, WIDTH_LONGTEXT, 0 ); 
     69    add_integer( "rawvid-height", 0, 0, HEIGHT_TEXT, HEIGHT_LONGTEXT, 0 ); 
    7070    add_string( "rawvid-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, 
    7171                VLC_TRUE ); 
     
    9393static int Demux( demux_t * ); 
    9494static int Control( demux_t *, int i_query, va_list args ); 
     95 
     96struct preset_t 
     97{ 
     98    const char *psz_ext; 
     99    int i_width; 
     100    int i_height; 
     101    double f_fps; 
     102    const char *psz_aspect_ratio; 
     103    const char *psz_chroma; 
     104}; 
     105 
     106static struct preset_t p_presets[] = 
     107{ 
     108    { "sqcif", 128, 96, 29.97, "4:3", "YV12" }, 
     109    { "qcif", 176, 144, 29.97, "4:3", "YV12" }, 
     110    { "cif", 352, 288, 29.97, "4:3", "YV12" }, 
     111    { "4cif", 704, 576, 29.97, "4:3", "YV12" }, 
     112    { "16cif", 1408, 1152, 29.97, "4:3", "YV12" }, 
     113    { "yuv", 176, 144, 25, "4:3", "YV12" }, 
     114    { "", 0, 0, 0., "", "" } 
     115}; 
    95116 
    96117/***************************************************************************** 
     
    107128    char *psz_aspect_ratio; 
    108129    unsigned int i_aspect; 
     130    struct preset_t *p_preset = NULL; 
    109131 
    110132    /* Check for YUV file extension */ 
    111133    psz_ext = strrchr( p_demux->psz_path, '.' ); 
    112     if( ( !psz_ext || strcasecmp( psz_ext, ".yuv") ) && 
     134 
     135    if( psz_ext ) 
     136    { 
     137        psz_ext++; 
     138        for( p_preset = p_presets; *p_preset->psz_ext; p_preset++ ) 
     139            if( !strcasecmp( psz_ext, p_preset->psz_ext ) ) 
     140                break; 
     141    } 
     142    if( ( !p_preset || !*p_preset->psz_ext ) && 
    113143        strcmp(p_demux->psz_demux, "rawvid") ) 
    114144    { 
     
    123153 
    124154    p_sys->f_fps = var_CreateGetFloat( p_demux, "rawvid-fps" ); 
    125  
    126155    i_width = var_CreateGetInteger( p_demux, "rawvid-width" ); 
    127156    i_height = var_CreateGetInteger( p_demux, "rawvid-height" ); 
     157    psz_chroma = var_CreateGetString( p_demux, "rawvid-chroma" ); 
     158    psz_aspect_ratio = var_CreateGetString( p_demux, "rawvid-aspect-ratio" ); 
     159 
     160    if( p_preset && *p_preset->psz_ext ) 
     161    { 
     162        if( !i_width ) i_width = p_preset->i_width; 
     163        if( !i_height ) i_height = p_preset->i_height; 
     164        if( !p_sys->f_fps ) p_sys->f_fps = p_preset->f_fps; 
     165        if( !*psz_aspect_ratio ) 
     166        { 
     167            free( psz_aspect_ratio ); 
     168            psz_aspect_ratio = strdup( psz_aspect_ratio ); 
     169        } 
     170        if( !*psz_chroma ) 
     171        { 
     172            free( psz_chroma ); 
     173            psz_chroma = strdup( psz_chroma ); 
     174        } 
     175    } 
     176 
    128177    if( i_width <= 0 || i_height <= 0 ) 
    129178    { 
    130179        msg_Err( p_demux, "width and height must be strictly positive." ); 
     180        free( psz_aspect_ratio ); 
     181        free( psz_chroma ); 
    131182        free( p_sys ); 
    132183        return VLC_EGENERIC; 
    133184    } 
    134  
    135     psz_chroma = var_CreateGetString( p_demux, "rawvid-chroma" ); 
    136     psz_aspect_ratio = var_CreateGetString( p_demux, "rawvid-aspect-ratio" ); 
    137185 
    138186    if( psz_aspect_ratio && *psz_aspect_ratio )