Commit 16e0ddc40d for ffmpeg
commit 16e0ddc40d7d8c59967ff712861d97d5e7978cf8
Author: Lynne <dev@lynne.ee>
Date: Thu Oct 8 13:27:18 2026 +0900
lavu/frame: allow left cropping of formats with multi-byte pixels
av_frame_apply_cropping() returned AVERROR_BUG when the plane offset was
more aligned than crop_left, which is always the case for single-plane
formats with more than a byte per pixel (gray16, rgb48, 16-bit Bayer,
p010). The rounding that follows already handles it.
diff --git a/libavutil/frame.c b/libavutil/frame.c
index be30eb09d2..ca8e8486a3 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -803,11 +803,8 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
min_log2_align = FFMIN(log2_align, min_log2_align);
}
- /* we assume, and it should always be true, that the data alignment is
- * related to the cropping alignment by a constant power-of-2 factor */
- if (log2_crop_align < min_log2_align)
- return AVERROR_BUG;
-
+ /* The data alignment is the cropping alignment scaled by a power of 2,
+ * up for multi-byte pixels and down for subsampled planes */
if (min_log2_align < 5 && log2_crop_align != INT_MAX) {
frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1);
ret = calc_cropping_offsets(offsets, frame, desc);