changeset 36305:d8a13d907c61

Enable switch_ratio -1 with videos with aspect changes. The original aspect ratio may change during playback, so sh->original_aspect must be set accordingly. This is missing in r36391.
author ib
date Sun, 04 Aug 2013 20:19:58 +0000
parents 6f0ab9dd1429
children 97638800c6f3
files libmpcodecs/vd.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd.c	Sun Aug 04 18:12:24 2013 +0000
+++ b/libmpcodecs/vd.c	Sun Aug 04 20:19:58 2013 +0000
@@ -158,6 +158,7 @@
     vf_instance_t *vf = sh->vfilter, *sc = NULL;
     int palette = 0;
     int vocfg_flags = 0;
+    static float last_movie_aspect;
 
     if (w)
         sh->disp_w = w;
@@ -290,17 +291,26 @@
         vf_add_before_vo(&vf, "flip", NULL);
         sh->vfilter = vf;
     }
-    // time to do aspect ratio corrections...
+    // time to do aspect ratio corrections (after saving the original aspect ratio)...
 
-    if (sh->original_aspect == -1.0)
+    if (sh->original_aspect == -1.0) {
         sh->original_aspect = sh->stream_aspect != 0.0 ? sh->stream_aspect : sh->aspect;
+        last_movie_aspect = -1.0;
+    }
 
-    if (movie_aspect > -1.0)
+    if (movie_aspect > -1.0) {
+        if (sh->aspect != movie_aspect && movie_aspect == last_movie_aspect)
+            sh->original_aspect = sh->stream_aspect != 0.0 ? sh->stream_aspect : sh->aspect;
         sh->aspect = movie_aspect;      // cmdline overrides autodetect
+    }
     else if (sh->stream_aspect != 0.0)
-        sh->aspect = sh->stream_aspect;
+        sh->original_aspect = sh->aspect = sh->stream_aspect;
+    else
+        sh->original_aspect = sh->aspect;
 //  if(!sh->aspect) sh->aspect=1.0;
 
+    last_movie_aspect = movie_aspect;
+
     if (opt_screen_size_x || opt_screen_size_y) {
         screen_size_x = opt_screen_size_x;
         screen_size_y = opt_screen_size_y;