diff options
Diffstat (limited to 'video/out/aspect.c')
-rw-r--r-- | video/out/aspect.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/video/out/aspect.c b/video/out/aspect.c index dc13d4e447..6e1cd63b02 100644 --- a/video/out/aspect.c +++ b/video/out/aspect.c @@ -31,8 +31,6 @@ static void aspect_calc_panscan(struct mp_vo_opts *opts, int window_w, int window_h, double monitor_par, int *out_w, int *out_h) { - w *= monitor_par; - int fwidth = window_w; int fheight = (float)window_w / d_w * d_h / monitor_par; if (fheight > window_h || fheight < h) { @@ -77,19 +75,22 @@ static void clamp_size(int size, int *start, int *end) static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size, - float zoom, float align, float pan, + float zoom, float align, float pan, float scale, int *src_start, int *src_end, int *dst_start, int *dst_end, int *osd_margin_a, int *osd_margin_b) { - scaled_src_size *= powf(2, zoom); + scaled_src_size *= powf(2, zoom) * scale; + scaled_src_size = MPMAX(scaled_src_size, 1); align = (align + 1) / 2; - *src_start = 0; - *src_end = src_size; *dst_start = (dst_size - scaled_src_size) * align + pan * scaled_src_size; *dst_end = *dst_start + scaled_src_size; + // Distance of screen frame to video + *osd_margin_a = *dst_start; + *osd_margin_b = dst_size - *dst_end; + // Clip to screen int s_src = *src_end - *src_start; int s_dst = *dst_end - *dst_start; @@ -107,10 +108,6 @@ static void src_dst_split_scaling(int src_size, int dst_size, // For sanity: avoid bothering VOs with corner cases clamp_size(src_size, src_start, src_end); clamp_size(dst_size, dst_start, dst_end); - - // Distance of screen frame to video - *osd_margin_a = *dst_start; - *osd_margin_b = dst_size - *dst_end; } static void calc_margin(float opts[2], int out[2], int size) @@ -137,10 +134,6 @@ void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, int src_dw, src_dh; mp_image_params_get_dsize(video, &src_dw, &src_dh); - if (video->rotate % 180 == 90 && (vo_caps & VO_CAP_ROTATE90)) { - MPSWAP(int, src_w, src_h); - MPSWAP(int, src_dw, src_dh); - } window_w = MPMAX(1, window_w); window_h = MPMAX(1, window_h); @@ -156,6 +149,17 @@ void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, struct mp_rect dst = {0, 0, window_w, window_h}; struct mp_rect src = {0, 0, src_w, src_h}; + if (mp_image_crop_valid(video)) + src = video->crop; + + if (vo_caps & VO_CAP_ROTATE90) { + if (video->rotate % 180 == 90) { + MPSWAP(int, src_w, src_h); + MPSWAP(int, src_dw, src_dh); + } + mp_rect_rotate(&src, src_w, src_h, video->rotate); + } + struct mp_osd_res osd = { .w = window_w, .h = window_h, @@ -168,11 +172,11 @@ void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, vid_window_w, vid_window_h, monitor_par, &scaled_width, &scaled_height); src_dst_split_scaling(src_w, vid_window_w, scaled_width, - opts->zoom, opts->align_x, opts->pan_x, + opts->zoom, opts->align_x, opts->pan_x, opts->scale_x, &src.x0, &src.x1, &dst.x0, &dst.x1, &osd.ml, &osd.mr); src_dst_split_scaling(src_h, vid_window_h, scaled_height, - opts->zoom, opts->align_y, opts->pan_y, + opts->zoom, opts->align_y, opts->pan_y, opts->scale_y, &src.y0, &src.y1, &dst.y0, &dst.y1, &osd.mt, &osd.mb); } |