[vlc-devel] [PATCH] display: apply the same source aspect ratio cleaning on init and source update

Steve Lhomme robux4 at ycbcr.xyz
Wed Jun 19 07:09:43 CEST 2019


In push we still need to clean the format every time the source changes. Before
it was done before the display pool was allocated and kept all along.
---
 src/video_output/display.c      | 22 ++++++++++++++++------
 src/video_output/display.h      |  1 +
 src/video_output/video_output.c |  7 +------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index f295ad6731..2173bb084e 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -588,18 +588,28 @@ static int vout_SetSourceAspect(vout_display_t *vd,
     return ret;
 }
 
+void VoutFixFormatAR(video_format_t *fmt)
+{
+    vlc_ureduce( &fmt->i_sar_num, &fmt->i_sar_den,
+                 fmt->i_sar_num,  fmt->i_sar_den, 50000 );
+    if (fmt->i_sar_num <= 0 || fmt->i_sar_den <= 0) {
+        fmt->i_sar_num = 1;
+        fmt->i_sar_den = 1;
+    }
+}
+
 void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *source)
 {
     vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
     int err1 = 0, err2 = 0;
 
-    if (source->i_sar_num * osys->source.i_sar_den !=
-        source->i_sar_den * osys->source.i_sar_num) {
+    video_format_t fixed_src = *source;
+    VoutFixFormatAR( &fixed_src );
+    if (fixed_src.i_sar_num * osys->source.i_sar_den !=
+        fixed_src.i_sar_den * osys->source.i_sar_num) {
 
-        osys->source.i_sar_num = source->i_sar_num;
-        osys->source.i_sar_den = source->i_sar_den;
-        vlc_ureduce(&osys->source.i_sar_num, &osys->source.i_sar_den,
-                    osys->source.i_sar_num, osys->source.i_sar_den, 0);
+        osys->source.i_sar_num = fixed_src.i_sar_num;
+        osys->source.i_sar_den = fixed_src.i_sar_den;
 
         /* FIXME it will override any AR that the user would have forced */
         err1 = vout_SetSourceAspect(vd, osys->source.i_sar_num,
diff --git a/src/video_output/display.h b/src/video_output/display.h
index f9100d98ef..35138c5c70 100644
--- a/src/video_output/display.h
+++ b/src/video_output/display.h
@@ -23,3 +23,4 @@
 #include "vout_wrapper.h"
 
 void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *);
+void VoutFixFormatAR(video_format_t *);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 1ae84bbb1c..a3ef144da1 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -87,12 +87,7 @@ static void VoutFixFormat(video_format_t *dst, const video_format_t *src)
 {
     video_format_Copy(dst, src);
     dst->i_chroma = vlc_fourcc_GetCodec(VIDEO_ES, src->i_chroma);
-    vlc_ureduce( &dst->i_sar_num, &dst->i_sar_den,
-                 src->i_sar_num,  src->i_sar_den, 50000 );
-    if (dst->i_sar_num <= 0 || dst->i_sar_den <= 0) {
-        dst->i_sar_num = 1;
-        dst->i_sar_den = 1;
-    }
+    VoutFixFormatAR( dst );
     video_format_FixRgb(dst);
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list