From 189264a9090f49425f67ded0c12c5ac2a2c720bd Mon Sep 17 00:00:00 2001 From: Erich Seifert Date: Fri, 23 Oct 2026 04:09:24 +0200 Subject: [PATCH] Fix cropping of planar 10 and 16 bit images crop() only handles packed formats, so the crop filter converts yuv420p to yuv422 first, but yuv420p10, yuv444p10 and yuv422p16 were cropped as if they were packed, which garbled the image, for example with Crop: Source when exporting with pix_fmt=yuv420p10le. Convert these formats to rgba64, which keeps the bit depth. --- src/modules/core/filter_crop.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/core/filter_crop.c b/src/modules/core/filter_crop.c index b08c86038..38fda8265 100644 --- a/src/modules/core/filter_crop.c +++ b/src/modules/core/filter_crop.c @@ -125,9 +125,19 @@ static int filter_get_image(mlt_frame frame, int bpp; mlt_image_format requested_format = *format; - if (requested_format == mlt_image_yuv420p) { - // The crop function does not support planar. + // The crop function does not support planar. + switch (requested_format) { + case mlt_image_yuv420p: requested_format = mlt_image_yuv422; + break; + case mlt_image_yuv420p10: + case mlt_image_yuv444p10: + case mlt_image_yuv422p16: + // Keep the bit depth + requested_format = mlt_image_rgba64; + break; + default: + break; } if (requested_format == mlt_image_yuv422 && (left & 1 || right & 1)) { // Subsampled YUV requires even dimensions. Use RGB for odd dimensions.