[vlc-devel] [PATCH] misc/image: fixed overwriting of correct visible dimensions

Maxim Bublis b at codemonkey.ru
Fri Jan 24 15:08:51 CET 2014


In some cases fmt_in already contains correct i_visible_width and i_visible_height values.
This patch fixes incorrect overwriting of valid values.

---
 src/misc/image.c | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/src/misc/image.c b/src/misc/image.c
index 6489259..c399b8b 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -707,34 +707,39 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, video_format_t *fmt_in,
     p_enc->p_module = NULL;
     es_format_Init( &p_enc->fmt_in, VIDEO_ES, fmt_in->i_chroma );
     p_enc->fmt_in.video = *fmt_in;
-    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;
 
-        if( fmt_out->i_visible_width > 0 &&
-            fmt_out->i_visible_height > 0 )
+    if( p_enc->fmt_in.video.i_visible_width == 0 ||
+        p_enc->fmt_in.video.i_visible_height == 0 )
+    {
+        if( fmt_out->i_width > 0 && fmt_out->i_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;
+            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;
+            }
         }
-        else
+        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_visible_width = fmt_out->i_width;
-            p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
+            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;
         }
     }
-    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;
     p_enc->fmt_in.video.i_frame_rate_base = 1;
-- 
1.8.3.4 (Apple Git-47)




More information about the vlc-devel mailing list