Commit 57981acd authored by Laurent Aimar's avatar Laurent Aimar

Used vlc_fourcc_GetCodecFromString where applicable.

parent b5625a39
......@@ -349,7 +349,8 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
/* 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;
......@@ -419,13 +420,9 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
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 );
......
......@@ -212,7 +212,7 @@ struct quicktime_mjpeg_app1
static const struct
{
int i_v4l;
int i_fourcc;
vlc_fourcc_t i_fourcc;
} v4lchroma_to_fourcc[] =
{
......@@ -975,11 +975,12 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
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++ )
......
......@@ -393,7 +393,7 @@ static int AccessControlResetCallback( vlc_object_t *p_this,
static const struct
{
unsigned int i_v4l2;
int i_fourcc;
vlc_fourcc_t i_fourcc;
int i_rmask;
int i_gmask;
int i_bmask;
......@@ -1945,22 +1945,18 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
/* 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 */
......
......@@ -169,19 +169,12 @@ static int OpenDecoder( vlc_object_t *p_this )
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 );
......
......@@ -106,21 +106,17 @@ static int Open( vlc_object_t * p_this )
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 )
{
......
......@@ -89,18 +89,9 @@ static int Init( vout_thread_t *p_vout )
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;
......
......@@ -225,13 +225,12 @@ static int Create( vlc_object_t *p_this )
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
......
......@@ -753,7 +753,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
/* 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" );
......@@ -796,10 +796,9 @@ static int OpenDisplay( vout_thread_t *p_vout )
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
......
......@@ -152,7 +152,7 @@ static int Init( vout_thread_t *p_vout )
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;
......@@ -161,21 +161,18 @@ static int Init( vout_thread_t *p_vout )
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;
}
......
......@@ -133,29 +133,26 @@ static int Init( vout_thread_t *p_vout )
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;
}
......
......@@ -134,12 +134,10 @@ static int Create( vlc_object_t *p_this )
}
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 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment