]> git.sesse.net Git - vlc/commitdiff
swscale: modify output aspect ratio if transformation is not homothetic
authorFelix Abecassis <felix.abecassis@gmail.com>
Wed, 30 Apr 2014 13:38:25 +0000 (15:38 +0200)
committerFelix Abecassis <felix.abecassis@gmail.com>
Wed, 30 Apr 2014 17:49:33 +0000 (19:49 +0200)
Close #10745

modules/video_chroma/swscale.c

index 4b763dd6e65811091843b61894ec748dc63682ab..6559078f439992c80da19aed87c22411737286b5 100644 (file)
@@ -430,6 +430,26 @@ static int Init( filter_t *p_filter )
         return VLC_EGENERIC;
     }
 
+    if (p_filter->b_allow_fmt_out_change)
+    {
+        /*
+         * If the transformation is not homothetic we must modify the
+         * aspect ratio of the output format in order to have the
+         * output picture displayed correctly and not stretched
+         * horizontally or vertically.
+         * WARNING: this is a hack, ideally this should not be needed
+         * and the vout should update its video format instead.
+         */
+        unsigned i_sar_num = p_fmti->i_sar_num * p_fmti->i_visible_width;
+        unsigned i_sar_den = p_fmti->i_sar_den * p_fmto->i_visible_width;
+        vlc_ureduce(&i_sar_num, &i_sar_den, i_sar_num, i_sar_den, 65536);
+        i_sar_num *= p_fmto->i_visible_height;
+        i_sar_den *= p_fmti->i_visible_height;
+        vlc_ureduce(&i_sar_num, &i_sar_den, i_sar_num, i_sar_den, 65536);
+        p_fmto->i_sar_num = i_sar_num;
+        p_fmto->i_sar_den = i_sar_den;
+    }
+
     p_sys->b_add_a = cfg.b_add_a;
     p_sys->b_copy = cfg.b_copy;
     p_sys->fmt_in  = *p_fmti;