changeset 36295:0bd0297b073a

Handle special argument -1 to switch_ratio as intended. Reset to the original aspect ratio that would have been used for the very first rescaling rather than to the display size ratio. This will now handle anamorphic videos correctly as well.
author ib
date Thu, 01 Aug 2013 21:18:14 +0000
parents a73127c786e8
children 1b84e470698c
files DOCS/tech/slave.txt command.c libmpcodecs/vd.c libmpdemux/stheader.h
diffstat 4 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/tech/slave.txt	Thu Aug 01 17:45:31 2013 +0000
+++ b/DOCS/tech/slave.txt	Thu Aug 01 21:18:14 2013 +0000
@@ -409,7 +409,8 @@
 
 switch_ratio [value]
     Change aspect ratio at runtime. [value] is the new aspect ratio expressed
-    as a float (e.g. 1.77778 for 16/9).
+    as a float (e.g. 1.77778 for 16/9), or special value -1 to reset to
+    original aspect ratio.
     There might be problems with some video filters.
 
 switch_title [value] (DVDNAV only)
--- a/command.c	Thu Aug 01 17:45:31 2013 +0000
+++ b/command.c	Thu Aug 01 21:18:14 2013 +0000
@@ -2718,7 +2718,7 @@
             if (!sh_video)
                 break;
             if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
-                movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
+                movie_aspect = sh_video->original_aspect;
             else
                 movie_aspect = cmd->args[0].v.f;
             mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0);
--- a/libmpcodecs/vd.c	Thu Aug 01 17:45:31 2013 +0000
+++ b/libmpcodecs/vd.c	Thu Aug 01 21:18:14 2013 +0000
@@ -292,6 +292,9 @@
     }
     // time to do aspect ratio corrections...
 
+    if (!sh->original_aspect)
+        sh->original_aspect = sh->stream_aspect != 0.0 ? sh->stream_aspect : sh->aspect;
+
     if (movie_aspect > -1.0)
         sh->aspect = movie_aspect;      // cmdline overrides autodetect
     else if (sh->stream_aspect != 0.0)
--- a/libmpdemux/stheader.h	Thu Aug 01 17:45:31 2013 +0000
+++ b/libmpdemux/stheader.h	Thu Aug 01 21:18:14 2013 +0000
@@ -102,7 +102,8 @@
   // output format: (set by demuxer)
   float fps;              // frames per second (set only if constant fps)
   float frametime;        // 1/fps
-  float aspect;           // aspect ratio stored in the file (for prescaling)
+  float aspect;           // current aspect ratio (for prescaling)
+  float original_aspect;  // original aspect ratio stored in the file
   float stream_aspect;  // aspect ratio stored in the media headers (e.g. in DVD IFO files)
   int i_bps;              // == bitrate  (compressed bytes/sec)
   int disp_w,disp_h;      // display size (filled by fileformat parser)