diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-09-01 22:26:05 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-17 16:48:42 +0000 |
commit | c40b064e38b762e14f0b50229ccbf882ddb9bffe (patch) | |
tree | 1d696222c9eb46a4152e9602ad496ba7d07f9e24 /filters | |
parent | 63ca12d7bc01d20ee558f15a71adb15c895e25a0 (diff) | |
download | mpv-c40b064e38b762e14f0b50229ccbf882ddb9bffe.tar.bz2 mpv-c40b064e38b762e14f0b50229ccbf882ddb9bffe.tar.xz |
demux: add crop to mp_codec_params
Diffstat (limited to 'filters')
-rw-r--r-- | filters/f_decoder_wrapper.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index 5553002821..7e51c57a92 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -593,6 +593,25 @@ static void fix_image_params(struct priv *p, m.stereo3d = p->codec->stereo_mode; + if (!mp_rect_equals(&p->codec->crop, &(struct mp_rect){0})) { + struct mp_rect crop = p->codec->crop; + // Offset to respect existing decoder crop. + crop.x0 += m.crop.x0; + crop.x1 += m.crop.x0; + crop.y0 += m.crop.y0; + crop.y1 += m.crop.y0; + // Crop has to be inside existing image bounds. + if (mp_image_crop_valid(&(struct mp_image_params) { + .w = mp_rect_w(m.crop), .h = mp_rect_h(m.crop), .crop = crop })) + { + m.crop = crop; + } else { + MP_WARN(p, "Invalid container crop %dx%d+%d+%d for %dx%d image\n", + mp_rect_w(crop), mp_rect_h(crop), crop.x0, crop.y0, + mp_rect_w(m.crop), mp_rect_h(m.crop)); + } + } + if (opts->video_rotate < 0) { m.rotate = 0; } else { |