From f8db02b59db08f1013dfb9411bd04c6a80dc72ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 20 Oct 2023 04:10:19 +0200 Subject: [PATCH] demux_mkv: PAR should be calculated after applying crop DisplayWidth/DisplayHeight applies to the video frame after cropping (PixelCrop* Elements). --- demux/demux_mkv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 6a47719420..6f5600b7f1 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1510,16 +1510,6 @@ 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; - 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; - - sh_v->stereo_mode = track->stereo_mode; - sh_v->color = track->color; - sh_v->crop.x0 = track->v_crop_left_set ? track->v_crop_left : 0; sh_v->crop.y0 = track->v_crop_top_set ? track->v_crop_top : 0; sh_v->crop.x1 = track->v_width - @@ -1527,6 +1517,16 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) sh_v->crop.y1 = track->v_height - (track->v_crop_bottom_set ? track->v_crop_bottom : 0); + int dw = track->v_dwidth_set ? track->v_dwidth : mp_rect_w(sh_v->crop); + int dh = track->v_dheight_set ? track->v_dheight : mp_rect_h(sh_v->crop); + struct mp_image_params p = {.w = mp_rect_w(sh_v->crop), .h = mp_rect_h(sh_v->crop)}; + mp_image_params_set_dsize(&p, dw, dh); + sh_v->par_w = p.p_w; + sh_v->par_h = p.p_h; + + sh_v->stereo_mode = track->stereo_mode; + sh_v->color = track->color; + if (track->v_projection_pose_roll_set) { int rotate = lrintf(fmodf(fmodf(track->v_projection_pose_roll, 360) + 360, 360)); sh_v->rotate = rotate;