[vlc-devel] [PATCH 2/4] i420_yuy2: refactor intialization
Steve Lhomme
robux4 at ycbcr.xyz
Mon Oct 5 17:03:02 CEST 2020
From: Alexandre Janniaux <ajanni at videolabs.io>
Avoid switch for one case and use VLC_EGENERIC/VLC_SUCCESS when
suitable.
---
modules/video_chroma/i420_yuy2.c | 55 +++++++++++++++-----------------
1 file changed, 25 insertions(+), 30 deletions(-)
diff --git a/modules/video_chroma/i420_yuy2.c b/modules/video_chroma/i420_yuy2.c
index d7f23c6ea81..b18fea3c31f 100644
--- a/modules/video_chroma/i420_yuy2.c
+++ b/modules/video_chroma/i420_yuy2.c
@@ -118,56 +118,51 @@ static int Activate( vlc_object_t *p_this )
if( !vlc_CPU_capable() )
return VLC_EGENERIC;
+
if( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) & 1
|| (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_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;
+
+ // VLC_CODEC_YV12: FIXME invert U and V in the filters :)
+ if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_I420)
+ return VLC_EGENERIC;
- switch( p_filter->fmt_in.video.i_chroma )
+ switch( p_filter->fmt_out.video.i_chroma )
{
-// case VLC_CODEC_YV12: FIXME invert U and V in the filters :)
- case VLC_CODEC_I420:
- switch( p_filter->fmt_out.video.i_chroma )
- {
- case VLC_CODEC_YUYV:
- p_filter->pf_video_filter = I420_YUY2_Filter;
- break;
+ case VLC_CODEC_YUYV:
+ p_filter->pf_video_filter = I420_YUY2_Filter;
+ break;
- case VLC_CODEC_YVYU:
- p_filter->pf_video_filter = I420_YVYU_Filter;
- break;
+ case VLC_CODEC_YVYU:
+ p_filter->pf_video_filter = I420_YVYU_Filter;
+ break;
- case VLC_CODEC_UYVY:
- p_filter->pf_video_filter = I420_UYVY_Filter;
- break;
+ case VLC_CODEC_UYVY:
+ p_filter->pf_video_filter = I420_UYVY_Filter;
+ break;
#if !defined (MODULE_NAME_IS_i420_yuy2_altivec)
- case VLC_FOURCC('I','U','Y','V'):
- p_filter->pf_video_filter = I420_IUYV_Filter;
- break;
+ case VLC_FOURCC('I','U','Y','V'):
+ p_filter->pf_video_filter = I420_IUYV_Filter;
+ break;
#endif
#if defined (MODULE_NAME_IS_i420_yuy2)
- case VLC_CODEC_Y211:
- p_filter->pf_video_filter = I420_Y211_Filter;
- break;
-#endif
-
- default:
- return -1;
- }
+ case VLC_CODEC_Y211:
+ p_filter->pf_video_filter = I420_Y211_Filter;
break;
-
+#endif
default:
- return -1;
+ return VLC_EGENERIC;
}
- return 0;
+ return VLC_SUCCESS;
}
#if 0
--
2.26.2
More information about the vlc-devel
mailing list