changeset 36186:3b15983f5e48

Add options to determine where borders will be added when adjusting for aspect.
author reimar
date Sat, 25 May 2013 06:54:41 +0000
parents 4cdc07440a68
children 09b2e3d9f51b
files DOCS/man/en/mplayer.1 cfg-mplayer.h libvo/video_out.c libvo/video_out.h libvo/vo_gl.c
diffstat 5 files changed, 31 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Fri May 24 14:20:19 2013 +0000
+++ b/DOCS/man/en/mplayer.1	Sat May 25 06:54:41 2013 +0000
@@ -3628,6 +3628,18 @@
 This feature is experimental.
 .
 .TP
+.B \-border\-pos\-x <0.0\-1.0> (-vo gl only, default 0.5)
+When black borders are added to adjust for aspect, this determines where they are placed.
+0.0 places borders on the right, 1.0 on the left.
+Values outside the range 0.0 \- 1.0 will add extra black borders on one side
+and remove part of the image on the other side.
+.
+.TP
+.B \-border\-pos\-y <0.0\-1.0> (-vo gl only, default 0.5)
+As \-border\-pos\-x but for top/bottom borders.
+0.0 places borders on the bottom, 1.0 on the top.
+.
+.TP
 .B \-monitor\-orientation <0-3> (experimental)
 Rotate display by 90, 180 or 270 degrees.
 Rotates also the OSD, not just the video image itself.
--- a/cfg-mplayer.h	Fri May 24 14:20:19 2013 +0000
+++ b/cfg-mplayer.h	Sat May 25 06:54:41 2013 +0000
@@ -173,6 +173,8 @@
     {"novsync", &vo_vsync, CONF_TYPE_FLAG, 0, 1, 0, NULL},
     {"panscan", &vo_panscan, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
     {"panscanrange", &vo_panscanrange, CONF_TYPE_FLOAT, CONF_RANGE, -19.0, 99.0, NULL},
+    {"border-pos-x", &vo_border_pos_x, CONF_TYPE_FLOAT, CONF_RANGE, -1, 2, NULL},
+    {"border-pos-y", &vo_border_pos_y, CONF_TYPE_FLOAT, CONF_RANGE, -1, 2, NULL},
     {"monitor-orientation", &vo_rotate, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
 
     {"grabpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 0, 1, NULL},
--- a/libvo/video_out.c	Fri May 24 14:20:19 2013 +0000
+++ b/libvo/video_out.c	Sat May 25 06:54:41 2013 +0000
@@ -65,6 +65,8 @@
 int vo_fs = 0;
 int vo_fsmode = 0;
 float vo_panscan = 0.0f;
+float vo_border_pos_x = 0.5;
+float vo_border_pos_y = 0.5;
 int vo_rotate;
 int vo_ontop = 0;
 int vo_adapter_num=0;
--- a/libvo/video_out.h	Fri May 24 14:20:19 2013 +0000
+++ b/libvo/video_out.h	Sat May 25 06:54:41 2013 +0000
@@ -232,6 +232,8 @@
 extern int vo_fs;
 extern int vo_fsmode;
 extern float vo_panscan;
+extern float vo_border_pos_x;
+extern float vo_border_pos_y;
 extern int vo_rotate;
 extern int vo_adapter_num;
 extern int vo_refresh_rate;
--- a/libvo/vo_gl.c	Fri May 24 14:20:19 2013 +0000
+++ b/libvo/vo_gl.c	Sat May 25 06:54:41 2013 +0000
@@ -179,6 +179,15 @@
 static float video_matrix[16];
 static float osd_matrix[16];
 
+static int apply_border_pos(int full, int part, float pos) {
+  if (pos >= 0.0 && pos <= 1.0) {
+    return pos*(full - part);
+  }
+  if (pos < 0)
+    return pos * part;
+  return full - part + (pos - 1) * part;
+}
+
 static void resize(void) {
   int i;
   draw_width  = (vo_rotate & 1) ? vo_dheight : vo_dwidth;
@@ -225,15 +234,15 @@
     scale_y = (double)new_h / (double)vo_dheight;
     video_matrix[0]  *= scale_x;
     video_matrix[4]  *= scale_x;
-    video_matrix[12] *= scale_x;
+    video_matrix[12] = -1 + apply_border_pos(vo_dwidth, new_w, vo_border_pos_x) * 2.0 / vo_dwidth;
     video_matrix[1]  *= scale_y;
     video_matrix[5]  *= scale_y;
-    video_matrix[13] *= scale_y;
+    video_matrix[13] = 1 - apply_border_pos(vo_dheight, new_h, vo_border_pos_y) * 2.0 / vo_dheight;
     if (vo_rotate & 1) {
       int tmp = new_w; new_w = new_h; new_h = tmp;
     }
-    ass_border_x = (draw_width  - new_w) / 2;
-    ass_border_y = (draw_height - new_h) / 2;
+    ass_border_x = apply_border_pos(draw_width, new_w, vo_border_pos_x);
+    ass_border_y = apply_border_pos(draw_height, new_h, vo_border_pos_y);
   }
   mpglLoadMatrixf(video_matrix);