changeset 29524:b1a437cdc60d

Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
author reimar
date Thu, 27 Aug 2009 18:36:51 +0000
parents 00f8d4ca123f
children 41ac62d6f913
files libvo/aspect.c libvo/aspect.h libvo/video_out.h libvo/vo_gl.c
diffstat 4 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/aspect.c	Thu Aug 27 14:12:38 2009 +0000
+++ b/libvo/aspect.c	Thu Aug 27 18:36:51 2009 +0000
@@ -151,15 +151,15 @@
  vo_panscan_amount=0.0f;
 }
 
-void panscan_calc( void )
+static void panscan_calc_internal(int zoom)
 {
  int fwidth,fheight;
  int vo_panscan_area;
  int max_w, max_h;
- get_max_dims(&max_w, &max_h, A_ZOOM);
+ get_max_dims(&max_w, &max_h, zoom);
 
  if (vo_panscanrange > 0) {
-   aspect(&fwidth,&fheight,A_ZOOM);
+   aspect(&fwidth,&fheight,zoom);
    vo_panscan_area = max_h - fheight;
    if (!vo_panscan_area)
      vo_panscan_area = max_w - fwidth;
@@ -167,8 +167,21 @@
  } else
    vo_panscan_area = -vo_panscanrange * max_h;
 
- vo_panscan_amount = vo_fs ? vo_panscan : 0;
+ vo_panscan_amount = vo_fs || zoom == A_WINZOOM ? vo_panscan : 0;
  vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp;
  vo_panscan_y = vo_panscan_area * vo_panscan_amount;
 }
 
+void panscan_calc(void)
+{
+  panscan_calc_internal(A_ZOOM);
+}
+
+/**
+ * vos that set vo_dwidth and v_dheight correctly should call this to update
+ * vo_panscan_x and vo_panscan_y
+ */
+void panscan_calc_windowed(void)
+{
+  panscan_calc_internal(A_WINZOOM);
+}
--- a/libvo/aspect.h	Thu Aug 27 14:12:38 2009 +0000
+++ b/libvo/aspect.h	Thu Aug 27 18:36:51 2009 +0000
@@ -26,6 +26,7 @@
 
 void panscan_init(void);
 void panscan_calc(void);
+void panscan_calc_windowed(void);
 
 void aspect_save_orig(int orgw, int orgh);
 
--- a/libvo/video_out.h	Thu Aug 27 14:12:38 2009 +0000
+++ b/libvo/video_out.h	Thu Aug 27 18:36:51 2009 +0000
@@ -275,4 +275,9 @@
 void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst,
                         struct vo_rect *borders, const struct vo_rect *crop);
 
+static inline int aspect_scaling(void)
+{
+  return vo_fs;
+}
+
 #endif /* MPLAYER_VIDEO_OUT_H */
--- a/libvo/vo_gl.c	Thu Aug 27 14:12:38 2009 +0000
+++ b/libvo/vo_gl.c	Thu Aug 27 18:36:51 2009 +0000
@@ -163,11 +163,11 @@
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   ass_border_x = ass_border_y = 0;
-  if (vo_fs && use_aspect) {
+  if (aspect_scaling() && use_aspect) {
     int new_w, new_h;
     GLdouble scale_x, scale_y;
-    aspect(&new_w, &new_h, A_ZOOM);
-    panscan_calc();
+    aspect(&new_w, &new_h, A_WINZOOM);
+    panscan_calc_windowed();
     new_w += vo_panscan_x;
     new_h += vo_panscan_y;
     scale_x = (GLdouble)new_w / (GLdouble)x;
@@ -722,7 +722,7 @@
   if (vo_doublebuffering) {
     if (use_glFinish) glFinish();
     swapGlBuffers();
-    if (vo_fs && use_aspect)
+    if (aspect_scaling() && use_aspect)
       glClear(GL_COLOR_BUFFER_BIT);
   } else {
     do_render();
@@ -1148,7 +1148,7 @@
       r->w = vo_dwidth; r->h = vo_dheight;
       r->mt = r->mb = r->ml = r->mr = 0;
       if (scaled_osd) {r->w = image_width; r->h = image_height;}
-      else if (vo_fs) {
+      else if (aspect_scaling()) {
         r->ml = r->mr = ass_border_x;
         r->mt = r->mb = ass_border_y;
       }