summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-11 18:44:27 +0100
committerwm4 <wm4@nowhere>2014-01-11 18:58:06 +0100
commitd956bbc065d570f425f402c83d69957584591dbd (patch)
treea515ffd2ada6a21d583e00f22079c0e33ff0dc76 /video
parent3b8e457379586b3400ede0b3ca96baa15aa1ab06 (diff)
downloadmpv-d956bbc065d570f425f402c83d69957584591dbd.tar.bz2
mpv-d956bbc065d570f425f402c83d69957584591dbd.tar.xz
video/out: simplify monitor aspect handling
For some reason, this made all VO backends both set the screen resolution in opts->screenwidth/height, and call aspect_save_screenres(). Remove the latter. Move the code to calculate the PAR-corrected window size from aspect.c to vo.c, and make it so that the monitor PAR is recalculated when it makes sense.
Diffstat (limited to 'video')
-rw-r--r--video/out/aspect.c25
-rw-r--r--video/out/aspect.h3
-rw-r--r--video/out/cocoa_common.m1
-rw-r--r--video/out/vo.c23
-rw-r--r--video/out/vo.h6
-rw-r--r--video/out/vo_sdl.c1
-rw-r--r--video/out/w32_common.c2
-rw-r--r--video/out/wayland_common.c2
-rw-r--r--video/out/x11_common.c1
9 files changed, 25 insertions, 39 deletions
diff --git a/video/out/aspect.c b/video/out/aspect.c
index 0e2e926c0f..b7c6c61e07 100644
--- a/video/out/aspect.c
+++ b/video/out/aspect.c
@@ -35,37 +35,16 @@ void aspect_save_videores(struct vo *vo, int w, int h, int d_w, int d_h)
vo->aspdat.par = (double)d_w / d_h * h / w;
}
-void aspect_save_screenres(struct vo *vo, int scrw, int scrh)
-{
- MP_DBG(vo, "aspect_save_screenres %dx%d\n", scrw, scrh);
- struct mp_vo_opts *opts = vo->opts;
- if (scrw > 0 && scrh > 0 && opts->force_monitor_aspect)
- vo->aspdat.monitor_par = opts->force_monitor_aspect * scrh / scrw;
- else
- vo->aspdat.monitor_par = 1.0 / opts->monitor_pixel_aspect;
-}
-
-void aspect_calc_monitor(struct vo *vo, int *w, int *h)
-{
- float pixelaspect = vo->aspdat.monitor_par;
-
- if (pixelaspect < 1) {
- *h /= pixelaspect;
- } else {
- *w *= pixelaspect;
- }
-}
-
static void aspect_calc(struct vo *vo, int *srcw, int *srch)
{
struct aspect_data *aspdat = &vo->aspdat;
- float pixelaspect = aspdat->monitor_par;
+ float pixelaspect = vo->monitor_par;
int fitw = FFMAX(1, vo->dwidth);
int fith = FFMAX(1, vo->dheight);
MP_DBG(vo, "aspect(0) fitin: %dx%d monitor_par: %.2f\n",
- fitw, fith, aspdat->monitor_par);
+ fitw, fith, pixelaspect);
*srcw = fitw;
*srch = (float)fitw / aspdat->prew * aspdat->preh / pixelaspect;
MP_DBG(vo, "aspect(1) wh: %dx%d (org: %dx%d)\n",
diff --git a/video/out/aspect.h b/video/out/aspect.h
index 8455985153..afff7e5dcb 100644
--- a/video/out/aspect.h
+++ b/video/out/aspect.h
@@ -23,9 +23,6 @@
struct vo;
void aspect_save_videores(struct vo *vo, int w, int h, int d_w, int d_h);
-void aspect_save_screenres(struct vo *vo, int scrw, int scrh);
-
-void aspect_calc_monitor(struct vo *vo, int *w, int *h);
void aspect_calc_panscan(struct vo *vo, int *out_w, int *out_h);
#endif /* MPLAYER_ASPECT_H */
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 2f50102257..8bec8ae80b 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -219,7 +219,6 @@ static void vo_cocoa_update_screen_info(struct vo *vo)
NSRect r = [s->current_screen frame];
- aspect_save_screenres(vo, r.size.width, r.size.height);
opts->screenwidth = r.size.width;
opts->screenheight = r.size.height;
}
diff --git a/video/out/vo.c b/video/out/vo.c
index 99efc9eec9..1952f14294 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -165,7 +165,7 @@ static struct vo *vo_create(struct mpv_global *global,
.input_ctx = input_ctx,
.event_fd = -1,
.registered_fd = -1,
- .aspdat = { .monitor_par = 1 },
+ .monitor_par = 1,
.next_pts = MP_NOPTS_VALUE,
.next_pts2 = MP_NOPTS_VALUE,
};
@@ -339,6 +339,21 @@ autoprobe:
return NULL;
}
+static void calc_monitor_aspect(struct mp_vo_opts *opts, int scr_w, int scr_h,
+ float *pixelaspect, int *w, int *h)
+{
+ *pixelaspect = 1.0 / opts->monitor_pixel_aspect;
+
+ if (scr_w > 0 && scr_h > 0 && opts->force_monitor_aspect)
+ *pixelaspect = opts->force_monitor_aspect * scr_h / scr_w;
+
+ if (*pixelaspect < 1) {
+ *h /= *pixelaspect;
+ } else {
+ *w *= *pixelaspect;
+ }
+}
+
// Fit *w/*h into the size specified by geo.
static void apply_autofit(int *w, int *h, int scr_w, int scr_h,
struct m_geometry *geo, bool allow_upscale)
@@ -378,7 +393,9 @@ static void determine_window_geometry(struct vo *vo, int d_w, int d_h)
int scr_w = opts->screenwidth;
int scr_h = opts->screenheight;
- aspect_calc_monitor(vo, &d_w, &d_h);
+ MP_DBG(vo, "screen size: %dx%d\n", scr_w, scr_h);
+
+ calc_monitor_aspect(opts, scr_w, scr_h, &vo->monitor_par, &d_w, &d_h);
apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit, true);
apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit_larger, false);
@@ -572,7 +589,7 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src,
struct mp_osd_res osd = {
.w = vo->dwidth,
.h = vo->dheight,
- .display_par = vo->aspdat.monitor_par,
+ .display_par = vo->monitor_par,
};
if (opts->keepaspect) {
int scaled_width, scaled_height;
diff --git a/video/out/vo.h b/video/out/vo.h
index 2309e905d1..900fc96e28 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -265,12 +265,12 @@ struct vo {
int xinerama_x;
int xinerama_y;
+ float monitor_par;
struct aspect_data {
- float monitor_par; // out of screen size or from options
- int orgw; // real width
+ int orgw; // real width (same as params->w and h)
int orgh; // real height
- int prew; // prescaled width
+ int prew; // prescaled width (same as params->d_w and d_h)
int preh; // prescaled height
float par; // pixel aspect ratio out of orgw/orgh and prew/preh
} aspdat;
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index cff02731cb..893279a8f4 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -892,7 +892,6 @@ static void update_screeninfo(struct vo *vo)
struct mp_vo_opts *opts = vo->opts;
opts->screenwidth = mode.w;
opts->screenheight = mode.h;
- aspect_save_screenres(vo, opts->screenwidth, opts->screenheight);
}
static struct mp_image *get_screenshot(struct vo *vo)
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index b30e1ad020..6de008433d 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -617,8 +617,6 @@ static void w32_update_xinerama_info(struct vo *vo)
w32->mon_id = screen;
EnumDisplayMonitors(NULL, NULL, mon_enum, (LONG_PTR)vo);
}
-
- aspect_save_screenres(vo, vo->opts->screenwidth, vo->opts->screenheight);
}
static void updateScreenProperties(struct vo *vo)
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 716a0c2b65..086be41ea5 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1107,8 +1107,6 @@ static void vo_wayland_update_screeninfo (struct vo *vo)
wl->window.fs_width = opts->screenwidth;
wl->window.fs_height = opts->screenheight;
-
- aspect_save_screenres(vo, opts->screenwidth, opts->screenheight);
}
int vo_wayland_control (struct vo *vo, int *events, int request, void *arg)
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 2c25c19437..8bdc845523 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -470,7 +470,6 @@ static void vo_x11_update_screeninfo(struct vo *vo)
XFree(screens);
}
#endif
- aspect_save_screenres(vo, opts->screenwidth, opts->screenheight);
}
int vo_x11_init(struct vo *vo)