/*****************************************************************************
* rawvid.c : raw video input module for vlc
*****************************************************************************
- * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2007 VLC authors and VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Antoine Cellerier <dionoea at videolan d.t org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#define FPS_TEXT N_("Frames per Second")
#define FPS_LONGTEXT N_("This is the desired frame rate when " \
- "playing raw video streams. In the form 30000/1001 or 29.97")
+ "playing raw video streams. In the form 30000/1001 or 29.97")
#define WIDTH_TEXT N_("Width")
#define WIDTH_LONGTEXT N_("This specifies the width in pixels of the raw " \
set_subcategory( SUBCAT_INPUT_DEMUX )
set_callbacks( Open, Close )
add_shortcut( "rawvideo" )
- add_string( "rawvid-fps", NULL, NULL, FPS_TEXT, FPS_LONGTEXT, false )
- add_integer( "rawvid-width", 0, 0, WIDTH_TEXT, WIDTH_LONGTEXT, 0 )
- add_integer( "rawvid-height", 0, 0, HEIGHT_TEXT, HEIGHT_LONGTEXT, 0 )
- add_string( "rawvid-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
+ add_string( "rawvid-fps", NULL, FPS_TEXT, FPS_LONGTEXT, false )
+ add_integer( "rawvid-width", 0, WIDTH_TEXT, WIDTH_LONGTEXT, 0 )
+ add_integer( "rawvid-height", 0, HEIGHT_TEXT, HEIGHT_LONGTEXT, 0 )
+ add_string( "rawvid-chroma", NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
true )
- add_string( "rawvid-aspect-ratio", NULL, NULL,
+ add_string( "rawvid-aspect-ratio", NULL,
ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, true )
vlc_module_end ()
demux_sys_t *p_sys;
int i_width=-1, i_height=-1;
unsigned u_fps_num=0, u_fps_den=1;
- char *psz_ext;
- vlc_fourcc_t i_chroma;
+ vlc_fourcc_t i_chroma = 0;
unsigned int i_sar_num = 0;
unsigned int i_sar_den = 0;
const struct preset_t *p_preset = NULL;
const uint8_t *p_peek;
- bool b_valid = false;
bool b_y4m = false;
if( stream_Peek( p_demux->s, &p_peek, 9 ) == 9 )
/* http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 */
if( !strncmp( (char *)p_peek, "YUV4MPEG2", 9 ) )
{
- b_valid = true;
b_y4m = true;
+ goto valid;
}
}
- /* guess preset based on file extension */
- psz_ext = strrchr( p_demux->psz_path, '.' );
- if( psz_ext )
+ if( !p_demux->b_force )
{
+ /* guess preset based on file extension */
+ if( !p_demux->psz_file )
+ return VLC_EGENERIC;
+
+ const char *psz_ext = strrchr( p_demux->psz_file, '.' );
+ if( !psz_ext )
+ return VLC_EGENERIC;
psz_ext++;
- for( int i = 0; p_presets[i].psz_ext ; i++ )
+
+ for( unsigned i = 0; p_presets[i].psz_ext ; i++ )
{
if( !strcasecmp( psz_ext, p_presets[i].psz_ext ) )
{
p_preset = &p_presets[i];
- b_valid = true;
- break;
+ goto valid;
}
}
- }
- if( !b_valid && !p_demux->b_force )
return VLC_EGENERIC;
-
- /* Set p_input field */
- p_demux->pf_demux = Demux;
- p_demux->pf_control = Control;
+ }
+valid:
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
goto error;
}
+ if( i_chroma == 0 )
+ {
+ msg_Err( p_demux, "invalid or no chroma specified." );
+ goto error;
+ }
+
/* fixup anything missing with sensible assumptions */
if( i_sar_num <= 0 || i_sar_den <= 0 )
{
}
es_format_Init( &p_sys->fmt_video, VIDEO_ES, i_chroma );
- video_format_Setup( &p_sys->fmt_video.video,
- i_chroma, i_width, i_height,
+ video_format_Setup( &p_sys->fmt_video.video, i_chroma,
+ i_width, i_height, i_width, i_height,
i_sar_num, i_sar_den );
vlc_ureduce( &p_sys->fmt_video.video.i_frame_rate,
* p_sys->fmt_video.video.i_bits_per_pixel / 8;
p_sys->p_es_video = es_out_Add( p_demux->out, &p_sys->fmt_video );
+ p_demux->pf_demux = Demux;
+ p_demux->pf_control = Control;
return VLC_SUCCESS;
error: