diff options
author | wm4 <wm4@nowhere> | 2014-01-11 18:44:27 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-11 18:58:06 +0100 |
commit | d956bbc065d570f425f402c83d69957584591dbd (patch) | |
tree | a515ffd2ada6a21d583e00f22079c0e33ff0dc76 /video/out/vo.c | |
parent | 3b8e457379586b3400ede0b3ca96baa15aa1ab06 (diff) | |
download | mpv-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/out/vo.c')
-rw-r--r-- | video/out/vo.c | 23 |
1 files changed, 20 insertions, 3 deletions
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; |