]> git.sesse.net Git - vlc/blobdiff - modules/video_output/vmem.c
Add some comments
[vlc] / modules / video_output / vmem.c
index 17ba736ff3fb2b5d9eb3e6f312a1320254a35cea..e4858c26ad29db99f8ca6c36445b82840b146893 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;
     }
 
@@ -167,16 +164,17 @@ static int Init( vout_thread_t *p_vout )
     p_vout->p_sys->pf_unlock = (void (*) (void *))(intptr_t)atoll( psz_tmp );
     free( psz_tmp );
 
-    psz_tmp = var_CreateGetString( p_vout, "vmem-data" );
-    p_vout->p_sys->p_data = (void *)(intptr_t)atoll( psz_tmp );
-    free( psz_tmp );
-
+    /* pf_lock and pf_unlock are mandatory */
     if( !p_vout->p_sys->pf_lock || !p_vout->p_sys->pf_unlock )
     {
         msg_Err( p_vout, "Invalid lock or unlock callbacks" );
         return VLC_EGENERIC;
     }
 
+    psz_tmp = var_CreateGetString( p_vout, "vmem-data" );
+    p_vout->p_sys->p_data = (void *)(intptr_t)atoll( psz_tmp );
+    free( psz_tmp );
+
     I_OUTPUTPICTURES = 0;
 
     /* Initialize the output structure */
@@ -234,9 +232,13 @@ static int Init( vout_thread_t *p_vout )
         return VLC_SUCCESS;
     }
 
-    vout_InitPicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
-                      p_vout->output.i_width, p_vout->output.i_height,
-                      p_vout->output.i_aspect );
+    if( picture_Setup( p_pic, p_vout->output.i_chroma,
+                       p_vout->output.i_width, p_vout->output.i_height,
+                       p_vout->output.i_aspect ) )
+    {
+        free( p_pic );
+        return VLC_EGENERIC;
+    }
 
     p_pic->p->i_pitch = i_pitch;