changeset 36262:703a51ce08c8

Enable the change of the movie aspect ratio on the fly. The change of the ratio won't restart the movie any longer now. Based on a patch by Stephen Sheldon, sfsheldo gmail com.
author ib
date Sat, 13 Jul 2013 19:45:12 +0000
parents ca1d4a7bb751
children ea4c4dbae852
files gui/interface.c gui/interface.h gui/ui/actions.c gui/win32/gui.c gui/win32/interface.c
diffstat 5 files changed, 32 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Sat Jul 13 19:42:44 2013 +0000
+++ b/gui/interface.c	Sat Jul 13 19:45:12 2013 +0000
@@ -640,6 +640,7 @@
         /* video */
 
         guiInfo.sh_video = data;
+        guiInfo.VideoAspect = 0;
 
         nfree(guiInfo.CodecName);
 
--- a/gui/interface.h	Sat Jul 13 19:42:44 2013 +0000
+++ b/gui/interface.h	Sat Jul 13 19:45:12 2013 +0000
@@ -104,6 +104,7 @@
     int VideoWindow;
     int VideoWidth;
     int VideoHeight;
+    float VideoAspect;
 
     char *CodecName;
 
--- a/gui/ui/actions.c	Sat Jul 13 19:42:44 2013 +0000
+++ b/gui/ui/actions.c	Sat Jul 13 19:45:12 2013 +0000
@@ -48,7 +48,6 @@
 #include "mpcommon.h"
 #include "mplayer.h"
 #include "input/input.h"
-#include "libmpcodecs/vd.h"
 #include "libmpdemux/demuxer.h"
 #include "libvo/video_out.h"
 #include "libvo/wskeys.h"
@@ -93,6 +92,8 @@
 {
     int iparam     = (int)param, osd;
     mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext);
+    float aspect;
+    char cmd[32];
 
     switch (ev) {
 /* user events */
@@ -424,30 +425,29 @@
 
     case evSetAspect:
 
+        if (guiInfo.VideoAspect == 0)
+            guiInfo.VideoAspect = guiInfo.sh_video->aspect;
+
         switch (iparam) {
         case 2:
-            movie_aspect = 16.0f / 9.0f;
+            aspect = 16.0f / 9.0f;
             break;
 
         case 3:
-            movie_aspect = 4.0f / 3.0f;
+            aspect = 4.0f / 3.0f;
             break;
 
         case 4:
-            movie_aspect = 2.35;
+            aspect = 2.35;
             break;
 
         case 1:
         default:
-            movie_aspect = -1;
+            aspect = guiInfo.VideoAspect;
         }
 
-        if (guiInfo.StreamType == STREAMTYPE_VCD)
-            uiEvent(evPlayVCD, 0);
-        else if (guiInfo.StreamType == STREAMTYPE_DVD)
-            uiEvent(ivPlayDVD, 0);
-        else
-            guiInfo.NewPlay = GUI_FILE_NEW;
+        snprintf(cmd, sizeof(cmd), "switch_ratio %f", aspect);
+        mp_input_queue_cmd(mp_input_parse_cmd(cmd));
 
         break;
 
--- a/gui/win32/gui.c	Sat Jul 13 19:42:44 2013 +0000
+++ b/gui/win32/gui.c	Sat Jul 13 19:45:12 2013 +0000
@@ -353,6 +353,8 @@
 
 static LRESULT CALLBACK VideoProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
+    float aspect;
+    char cmd[32];
     gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
     if (gui && (gui->videowindow != hWnd)) return FALSE;
 
@@ -468,16 +470,27 @@
                     mp_input_queue_cmd(mp_input_parse_cmd("mute"));
                     break;
                 case ID_ASPECT1:
-                    mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.777777"));
+                case ID_ASPECT2:
+                case ID_ASPECT3:
+                case ID_ASPECT4:
+                    if (guiInfo.VideoAspect == 0) guiInfo.VideoAspect = guiInfo.sh_video->aspect;
+                    switch (LOWORD(wParam))
+                    {
+                case ID_ASPECT1:
+                    aspect = 16.0f / 9.0f;
                     break;
                 case ID_ASPECT2:
-                    mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.333333"));
+                    aspect = 4.0f / 3.0f;
                     break;
                 case ID_ASPECT3:
-                    mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 2.35"));
+                    aspect = 2.35;
                     break;
-                case ID_ASPECT4:
-                    mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 0"));
+                default:
+                    aspect = guiInfo.VideoAspect;
+                    break;
+                    }
+                    snprintf(cmd, sizeof(cmd), "switch_ratio %f", aspect);
+                    mp_input_queue_cmd(mp_input_parse_cmd(cmd));
                     break;
                 case IDSUB_TOGGLE:
                     mp_input_queue_cmd(mp_input_parse_cmd("sub_visibility"));
--- a/gui/win32/interface.c	Sat Jul 13 19:42:44 2013 +0000
+++ b/gui/win32/interface.c	Sat Jul 13 19:45:12 2013 +0000
@@ -628,6 +628,7 @@
         case GUI_SET_VIDEO:
         {
             guiInfo.sh_video = data;
+            guiInfo.VideoAspect = 0;
             if (data)
             {
                 sh_video_t *sh = data;