[vlc-devel] [PATCH] image: remove always true test

Steve Lhomme robux4 at ycbcr.xyz
Wed Jan 13 12:27:51 UTC 2021


At this stage the whole p_enc->fmt_out.video is initialized to 0 so the test
will always pass. Later the p_enc->fmt_out.video width/height is even set to
the input values.
---
 src/misc/image.c | 41 ++++++++++++-----------------------------
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/src/misc/image.c b/src/misc/image.c
index 034b0a27d8e..3b6cece47e1 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -718,38 +718,21 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, const video_format_t *fmt
     p_enc->p_module = NULL;
     es_format_InitFromVideo( &p_enc->fmt_in, fmt_in );
 
-    if( p_enc->fmt_in.video.i_visible_width == 0 ||
-        p_enc->fmt_in.video.i_visible_height == 0 ||
-        p_enc->fmt_out.video.i_visible_width == 0 ||
-        p_enc->fmt_out.video.i_visible_height == 0 )
+    if( fmt_out->i_width > 0 && fmt_out->i_height > 0 )
     {
-        if( fmt_out->i_width > 0 && fmt_out->i_height > 0 )
-        {
-            p_enc->fmt_in.video.i_width = fmt_out->i_width;
-            p_enc->fmt_in.video.i_height = fmt_out->i_height;
+        p_enc->fmt_in.video.i_width = fmt_out->i_width;
+        p_enc->fmt_in.video.i_height = fmt_out->i_height;
 
-            if( fmt_out->i_visible_width > 0 &&
-                fmt_out->i_visible_height > 0 )
-            {
-                p_enc->fmt_in.video.i_visible_width = fmt_out->i_visible_width;
-                p_enc->fmt_in.video.i_visible_height = fmt_out->i_visible_height;
-            }
-            else
-            {
-                p_enc->fmt_in.video.i_visible_width = fmt_out->i_width;
-                p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
-            }
+        if( fmt_out->i_visible_width > 0 && fmt_out->i_visible_height > 0 )
+        {
+            p_enc->fmt_in.video.i_visible_width = fmt_out->i_visible_width;
+            p_enc->fmt_in.video.i_visible_height = fmt_out->i_visible_height;
+        }
+        else
+        {
+            p_enc->fmt_in.video.i_visible_width = fmt_out->i_width;
+            p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
         }
-    } else if( fmt_out->i_sar_num && fmt_out->i_sar_den &&
-               fmt_out->i_sar_num * fmt_in->i_sar_den !=
-               fmt_out->i_sar_den * fmt_in->i_sar_num )
-    {
-        p_enc->fmt_in.video.i_width =
-            fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den * fmt_in->i_width /
-            fmt_in->i_sar_den / fmt_out->i_sar_num;
-        p_enc->fmt_in.video.i_visible_width =
-            fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den *
-            fmt_in->i_visible_width / fmt_in->i_sar_den / fmt_out->i_sar_num;
     }
 
     p_enc->fmt_in.video.i_frame_rate = 25;
-- 
2.29.2



More information about the vlc-devel mailing list