/* Get/parse options and open device(s) */
string vdevname, adevname;
- int i_width = 0, i_height = 0, i_chroma = 0;
+ int i_width = 0, i_height = 0;
+ vlc_fourcc_t i_chroma = 0;
bool b_use_audio = true;
bool b_use_video = true;
p_sys->b_chroma = false;
var_Create( p_this, "dshow-chroma", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_this, "dshow-chroma", &val );
- if( val.psz_string && strlen( val.psz_string ) >= 4 )
- {
- i_chroma = vlc_fourcc_GetCodec( UNKNOWN_ES,
- VLC_FOURCC( val.psz_string[0], val.psz_string[1],
- val.psz_string[2], val.psz_string[3] ) );
- p_sys->b_chroma = true;
- }
+
+ i_chroma = vlc_fourcc_GetCodecFromString( UNKNOWN_ES, val.psz_string );
+ p_sys->b_chroma = i_chroma != 0;
free( val.psz_string );
var_Create( p_this, "dshow-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
static const struct
{
int i_v4l;
- int i_fourcc;
+ vlc_fourcc_t i_fourcc;
} v4lchroma_to_fourcc[] =
{
p_sys->i_fourcc = 0;
psz = var_CreateGetString( p_demux, "v4l-chroma" );
- if( strlen( psz ) >= 4 )
+
+ const vlc_fourcc_t i_chroma =
+ vlc_fourcc_GetCodecFromString( VIDEO_ES, psz );
+ if( i_chroma )
{
vid_picture.palette = 0;
- int i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz[0], psz[1], psz[2], psz[3] ) );
/* Find out v4l chroma code */
for( i = 0; v4lchroma_to_fourcc[i].i_v4l != 0; i++ )
static const struct
{
unsigned int i_v4l2;
- int i_fourcc;
+ vlc_fourcc_t i_fourcc;
int i_rmask;
int i_gmask;
int i_bmask;
/* Test and set Chroma */
fmt.fmt.pix.pixelformat = 0;
- if( p_sys->psz_requested_chroma && strlen( p_sys->psz_requested_chroma ) > 0 )
+ if( p_sys->psz_requested_chroma && *p_sys->psz_requested_chroma )
{
/* User specified chroma */
- if( strlen( p_sys->psz_requested_chroma ) >= 4 )
+ const vlc_fourcc_t i_requested_fourcc =
+ vlc_fourcc_GetCodecFromString( VIDEO_ES, p_sys->psz_requested_chroma );
+
+ for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
{
- int i_requested_fourcc = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC(
- p_sys->psz_requested_chroma[0], p_sys->psz_requested_chroma[1],
- p_sys->psz_requested_chroma[2], p_sys->psz_requested_chroma[3] ) );
- for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
+ if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
{
- if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
- {
- fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
- break;
- }
+ fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
+ break;
}
}
/* Try and set user chroma */
var_AddCallback( p_dec, "fake-file-reload", FakeCallback , p_dec );
psz_chroma = var_CreateGetString( p_dec, "fake-chroma" );
- if( strlen( psz_chroma ) != 4 )
+ fmt_out.i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+ if( !fmt_out.i_chroma )
{
msg_Warn( p_dec, "Invalid chroma (%s). Using I420.", psz_chroma );
fmt_out.i_chroma = VLC_CODEC_I420;
}
- else
- {
- fmt_out.i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz_chroma[0],
- psz_chroma[1],
- psz_chroma[2],
- psz_chroma[3] ) );
- }
free( psz_chroma );
var_Create( p_dec, "fake-keep-ar", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
es_format_Init( &p_sys->fmt, AUDIO_ES, 0 );
char *psz_fourcc = var_CreateGetString( p_demux, "rawaud-fourcc" );
+ p_sys->fmt.i_codec = vlc_fourcc_GetCodecFromString( AUDIO_ES, psz_fourcc );
+ free( psz_fourcc );
- if( ( psz_fourcc == NULL ? 0 : strlen( psz_fourcc ) ) != 4 )
+ if( !p_sys->fmt.i_codec )
{
msg_Err( p_demux, "rawaud-fourcc must be a 4 character string");
- free( psz_fourcc );
es_format_Clean( &p_sys->fmt );
free( p_sys );
return VLC_EGENERIC;
}
- p_sys->fmt.i_codec = vlc_fourcc_GetCodec( AUDIO_ES,
- VLC_FOURCC( psz_fourcc[0], psz_fourcc[1],
- psz_fourcc[2], psz_fourcc[3] ) );
-
- free( psz_fourcc );
// get the bits per sample ratio based on codec
switch( p_sys->fmt.i_codec )
{
bool b_chroma = 0;
psz_chroma = config_GetPsz( p_vout, "dummy-chroma" );
- if( psz_chroma )
- {
- if( strlen( psz_chroma ) >= 4 )
- {
- i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz_chroma[0], psz_chroma[1],
- psz_chroma[2], psz_chroma[3] ) );
- b_chroma = 1;
- }
-
- free( psz_chroma );
- }
+ i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+ b_chroma = i_chroma != 0;
+ free( psz_chroma );
I_OUTPUTPICTURES = 0;
psz_chroma = var_CreateGetNonEmptyString( p_vout, "fb-chroma" );
if( psz_chroma )
{
- if( strlen( psz_chroma ) == 4 )
+ const vlc_fourcc_t i_chroma =
+ vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+
+ if( i_chroma )
{
- p_sys->i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz_chroma[0],
- psz_chroma[1],
- psz_chroma[2],
- psz_chroma[3] ) );
+ p_sys->i_chroma = i_chroma;
msg_Dbg( p_vout, "forcing chroma '%s'", psz_chroma );
}
else
/* SDL fucked up fourcc definitions on bigendian machines */
uint32_t i_sdl_chroma;
char *psz_chroma = NULL;
- uint32_t i_chroma = 0;
+ vlc_fourcc_t i_chroma = 0;
bool b_overlay = config_GetInt( p_vout, "overlay" );
if( ( psz_chroma = config_GetPsz( p_vout, "sdl-chroma" ) ) )
{
- if( strlen( psz_chroma ) >= 4 )
+ i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+ if( i_chroma )
{
- memcpy(&i_chroma, psz_chroma, 4);
- i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, i_chroma );
msg_Dbg( p_vout, "Forcing chroma to 0x%.8x (%4.4s)", i_chroma, (char*)&i_chroma );
}
else
picture_t *p_pic;
vlc_value_t val;
char* psz_chroma;
- int i_chroma;
+ vlc_fourcc_t i_chroma;
int i_width;
int i_height;
int i_datasize;
i_height = config_GetInt( p_vout, "snapshot-height" );
psz_chroma = config_GetPsz( p_vout, "snapshot-chroma" );
- if( psz_chroma )
+ if( !psz_chroma )
{
- if( strlen( psz_chroma ) < 4 )
- {
- msg_Err( p_vout, "snapshot-chroma should be 4 characters long" );
- return VLC_EGENERIC;
- }
- i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz_chroma[0], psz_chroma[1],
- psz_chroma[2], psz_chroma[3] ) );
- free( psz_chroma );
+ msg_Err( p_vout, "Cannot find chroma information." );
+ return VLC_EGENERIC;
}
- else
+
+ i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+ free( psz_chroma );
+
+ if( !i_chroma )
{
- msg_Err( p_vout, "Cannot find chroma information." );
+ msg_Err( p_vout, "snapshot-chroma should be 4 characters long" );
return VLC_EGENERIC;
}
int i_index;
picture_t *p_pic;
char *psz_chroma, *psz_tmp;
- int i_width, i_height, i_pitch, i_chroma;
+ int i_width, i_height, i_pitch;
+ vlc_fourcc_t i_chroma;
i_width = var_CreateGetInteger( p_vout, "vmem-width" );
i_height = var_CreateGetInteger( p_vout, "vmem-height" );
i_pitch = var_CreateGetInteger( p_vout, "vmem-pitch" );
psz_chroma = var_CreateGetString( p_vout, "vmem-chroma" );
- if( psz_chroma )
+ if( !psz_chroma )
{
- if( strlen( psz_chroma ) < 4 )
- {
- msg_Err( p_vout, "vmem-chroma should be 4 characters long" );
- free( psz_chroma );
- return VLC_EGENERIC;
- }
- i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz_chroma[0], psz_chroma[1],
- psz_chroma[2], psz_chroma[3] ) );
- free( psz_chroma );
+ msg_Err( p_vout, "Cannot find chroma information." );
+ return VLC_EGENERIC;
}
- else
+
+ i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+ free( psz_chroma );
+
+ if( !i_chroma )
{
- msg_Err( p_vout, "Cannot find chroma information." );
+ msg_Err( p_vout, "vmem-chroma should be 4 characters long" );
return VLC_EGENERIC;
}
}
psz_fcc = var_CreateGetNonEmptyString( p_this, CFG_PREFIX "chroma" );
- if( psz_fcc && (strlen( psz_fcc ) == 4) )
- {
- p_sys->i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
- VLC_FOURCC( psz_fcc[0], psz_fcc[1],
- psz_fcc[2], psz_fcc[3] ) );
- }
+ const vlc_fourcc_t i_requested_chroma =
+ vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_fcc );
+ if( i_requested_chroma )
+ p_sys->i_chroma = i_requested_chroma;
free( psz_fcc );
if( p_sys->b_yuv4mpeg2 )