[vlc-devel] [PATCH 2/3] swscale: do not initialize swscale again if only aspect-ratio is different

Felix Abecassis felix.abecassis at gmail.com
Fri Feb 21 19:49:39 CET 2014


---
 modules/video_chroma/swscale.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/video_chroma/swscale.c b/modules/video_chroma/swscale.c
index 1751131..11a8ecb 100644
--- a/modules/video_chroma/swscale.c
+++ b/modules/video_chroma/swscale.c
@@ -250,6 +250,13 @@ static int GetSwsCpuMask(void)
     return i_sws_cpu;
 }
 
+static bool IsFmtSimilar( const video_format_t *p_fmt1, const video_format_t *p_fmt2 )
+{
+    return p_fmt1->i_chroma == p_fmt2->i_chroma &&
+        p_fmt1->i_visible_width  == p_fmt2->i_visible_width &&
+        p_fmt1->i_visible_height == p_fmt2->i_visible_height;
+}
+
 static void FixParameters( int *pi_fmt, bool *pb_has_a, bool *pb_swap_uv, vlc_fourcc_t fmt )
 {
     switch( fmt )
@@ -355,8 +362,9 @@ static int Init( filter_t *p_filter )
     const video_format_t *p_fmti = &p_filter->fmt_in.video;
     video_format_t       *p_fmto = &p_filter->fmt_out.video;
 
-    if( video_format_IsSimilar( p_fmti, &p_sys->fmt_in ) &&
-        video_format_IsSimilar( p_fmto, &p_sys->fmt_out ) &&
+    /* If only aspect-ratio is different, do not initialize the module again. */
+    if( IsFmtSimilar( p_fmti, &p_sys->fmt_in ) &&
+        IsFmtSimilar( p_fmto, &p_sys->fmt_out ) &&
         p_sys->ctx )
     {
         return VLC_SUCCESS;
-- 
1.8.3.2




More information about the vlc-devel mailing list