[vlc-commits] video_chroma: grey_yuv: refactor initialization

Alexandre Janniaux git at videolan.org
Thu Oct 8 10:28:15 CEST 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Thu Sep  3 16:36:30 2020 +0200| [85f4c0c8c3e473b4be4a219dd0a1b2449e24640c] | committer: Steve Lhomme

video_chroma: grey_yuv: refactor initialization

Remove switch used for one case and use VLC_EGENERIC/VLC_SUCCESS when
suitable.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=85f4c0c8c3e473b4be4a219dd0a1b2449e24640c
---

 modules/video_chroma/grey_yuv.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/modules/video_chroma/grey_yuv.c b/modules/video_chroma/grey_yuv.c
index 87cb323103..ea09775c9c 100644
--- a/modules/video_chroma/grey_yuv.c
+++ b/modules/video_chroma/grey_yuv.c
@@ -68,35 +68,30 @@ static int Activate( vlc_object_t *p_this )
     if( p_filter->fmt_out.video.i_width & 1
      || p_filter->fmt_out.video.i_height & 1 )
     {
-        return -1;
+        return VLC_EGENERIC;
     }
 
     if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
        || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height
        || p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation )
-        return -1;
+        return VLC_EGENERIC;
 
-    switch( p_filter->fmt_in.video.i_chroma )
+    if ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_GREY )
+        return VLC_EGENERIC;
+
+    switch( p_filter->fmt_out.video.i_chroma )
     {
-        case VLC_CODEC_GREY:
-            switch( p_filter->fmt_out.video.i_chroma )
-            {
-                case VLC_CODEC_I420:
-                    p_filter->pf_video_filter = GREY_I420_Filter;
-                    break;
-                case VLC_CODEC_YUYV:
-                    p_filter->pf_video_filter = GREY_YUY2_Filter;
-                    break;
-                default:
-                    return -1;
-            }
+        case VLC_CODEC_I420:
+            p_filter->pf_video_filter = GREY_I420_Filter;
+            break;
+        case VLC_CODEC_YUYV:
+            p_filter->pf_video_filter = GREY_YUY2_Filter;
             break;
-
         default:
-            return -1;
+            return VLC_EGENERIC;
     }
 
-    return 0;
+    return VLC_SUCCESS;
 }
 
 /* Following functions are local */



More information about the vlc-commits mailing list