From 81102b0f6c7db956cd222ea3e81debda36de5a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 21 Oct 2023 18:09:14 +0200 Subject: [PATCH] Revert "demux_mkv: PAR should be calculated after applying crop" Matroska spec says that DisplayWidth and DisplayHeight should be applied after cropping, but this doesn't adhere to the real files which does not follow this rule. Revert the change and we can re-evaluate if someone complains with spec compliant files. See: https://datatracker.ietf.org/doc/draft-ietf-cellar-matroska/ This reverts commit f8db02b59db08f1013dfb9411bd04c6a80dc72ff. --- demux/demux_mkv.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 7f2220f552..4aa79a214e 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1505,23 +1505,20 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) sh_v->disp_w = track->v_width; sh_v->disp_h = track->v_height; - struct mp_rect crop; - crop.x0 = track->v_crop_left; - crop.y0 = track->v_crop_top; - crop.x1 = track->v_width - track->v_crop_right; - crop.y1 = track->v_height - track->v_crop_bottom; - // Keep the codec crop rect as 0s if we have no cropping since the // file may have broken width/height tags. if (track->v_crop_left || track->v_crop_top || track->v_crop_right || track->v_crop_bottom) { - sh_v->crop = crop; + sh_v->crop.x0 = track->v_crop_left; + sh_v->crop.y0 = track->v_crop_top; + sh_v->crop.x1 = track->v_width - track->v_crop_right; + sh_v->crop.y1 = track->v_height - track->v_crop_bottom; } - int dw = track->v_dwidth_set ? track->v_dwidth : mp_rect_w(crop); - int dh = track->v_dheight_set ? track->v_dheight : mp_rect_h(crop); - struct mp_image_params p = {.w = mp_rect_w(crop), .h = mp_rect_h(crop)}; + int dw = track->v_dwidth_set ? track->v_dwidth : track->v_width; + int dh = track->v_dheight_set ? track->v_dheight : track->v_height; + struct mp_image_params p = {.w = track->v_width, .h = track->v_height}; mp_image_params_set_dsize(&p, dw, dh); sh_v->par_w = p.p_w; sh_v->par_h = p.p_h;