]> git.sesse.net Git - vlc/commitdiff
Used vlc_fourcc_GetCodecFromString where applicable.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 14 May 2009 20:06:58 +0000 (22:06 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 15 May 2009 20:05:37 +0000 (22:05 +0200)
modules/access/dshow/dshow.cpp
modules/access/v4l.c
modules/access/v4l2.c
modules/codec/fake.c
modules/demux/rawaud.c
modules/misc/dummy/vout.c
modules/video_output/fb.c
modules/video_output/sdl.c
modules/video_output/snapshot.c
modules/video_output/vmem.c
modules/video_output/yuv.c

index 9a6cf7cd3bfd3f63b2c5cea64f5615fc7546cf02..c2dfd9c685a5ca5105bb79ed68a65fe7e94b353c 100644 (file)
@@ -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 );
index 197756cf3768f5b8b76ea3c336b8760d8e380678..16e408a7920992bb70c22f76ae7096cd6563502e 100644 (file)
@@ -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++ )
index c6688d6b1114bd4fbc5bdfcf084cd3097b684708..aa511ee06d95dd6862e6828c0f5215ffe1bdf4b7 100644 (file)
@@ -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 */
index b9787851c7bf2428357f81516acb7bcf7a91127c..a13b6717905b3f786f89c04d8a670ebc477fbfae 100644 (file)
@@ -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 );
index 4d5476fdee1e1b1d2a950e55afb0815d4a600378..a9473a0606d41ee561fbef9a76684f94b901f20c 100644 (file)
@@ -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 )
     {
index 5d5e7aced5e7cb66f0a1bfe510122b1cbc7198b9..3311041e03d671edbbf29cd578ef21809d39442f 100644 (file)
@@ -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;
 
index 36bf04e2aed41d09d93bf6ec10714d0683caac3e..95f17c1d36d5221ac12e43158a1b3fa176f9295e 100644 (file)
@@ -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
index f2cfa7449a489dd2e02a2702bc956e98e0fb4423..e3f4a9264390390ae3b0e834f8782f9d91258962 100644 (file)
@@ -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
index 0dedf12ffb5f120f59acb671fed6486e3493bcc2..5b6c4c330add7296b59898af02ab7ea4430109ed 100644 (file)
@@ -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;
     }
 
index 17ba736ff3fb2b5d9eb3e6f312a1320254a35cea..21bd8b622b0aa3207a41811e934339f78879dc7a 100644 (file)
@@ -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;
     }
 
index fffb6009b8c5ada07ea0c54f49c36762f1037ed2..35542ebfa99295816f8851c23fe5898eb9d1f81f 100644 (file)
@@ -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 )