[vlc-devel] [PATCH] scene: respect the input picture aspect ratio when calculating the output picture size

Adrien Maglo magsoft at videolan.org
Mon Feb 29 16:49:32 CET 2016


---
 modules/video_filter/scene.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/modules/video_filter/scene.c b/modules/video_filter/scene.c
index 3b8ad6f..c072ca5 100644
--- a/modules/video_filter/scene.c
+++ b/modules/video_filter/scene.c
@@ -235,6 +235,9 @@ static void SnapshotRatio( filter_t *p_filter, picture_t *p_pic )
 {
     filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys;
 
+    unsigned int i_sar_num = p_pic->format.i_sar_num;
+    unsigned int i_sar_den = p_pic->format.i_sar_den;
+
     if( !p_pic ) return;
 
     if( p_sys->i_frames % p_sys->i_ratio != 0 )
@@ -250,15 +253,27 @@ static void SnapshotRatio( filter_t *p_filter, picture_t *p_pic )
     if( (p_sys->i_width <= 0) && (p_sys->i_height > 0) )
     {
         p_sys->i_width = (p_pic->format.i_width * p_sys->i_height) / p_pic->format.i_height;
+        if( p_pic->format.i_sar_num != p_pic->format.i_sar_den )
+            p_sys->i_width = (int64_t)p_sys->i_width * i_sar_num / i_sar_den;
     }
     else if( (p_sys->i_height <= 0) && (p_sys->i_width > 0) )
     {
         p_sys->i_height = (p_pic->format.i_height * p_sys->i_width) / p_pic->format.i_width;
+        if( p_pic->format.i_sar_num != p_pic->format.i_sar_den )
+            p_sys->i_height = (int64_t)p_sys->i_height * i_sar_den / i_sar_num;
     }
     else if( (p_sys->i_width <= 0) && (p_sys->i_height <= 0) )
     {
         p_sys->i_width = p_pic->format.i_width;
         p_sys->i_height = p_pic->format.i_height;
+
+        if( p_pic->format.i_sar_num != p_pic->format.i_sar_den )
+        {
+            if( i_sar_num >= i_sar_den )
+                p_sys->i_width = (int64_t)p_sys->i_width * i_sar_num / i_sar_den;
+            else
+                p_sys->i_height = (int64_t)p_sys->i_height * i_sar_den / i_sar_num;
+        }
     }
 
     p_sys->scene.p_pic = picture_NewFromFormat( &p_pic->format );
-- 
2.5.0



More information about the vlc-devel mailing list