diff options
author | Niklas Haas <git@haasn.dev> | 2024-12-19 14:41:34 +0100 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2024-12-23 11:31:58 +0100 |
commit | 77db7f9b87811aa588e6ab6a7256f7cd8267265d (patch) | |
tree | b17f7f041a08da1446805ad67cfa62b5bd424a06 | |
parent | c6bf7f664527842fa3b89e49dc2a43f639430c33 (diff) | |
download | ffmpeg-77db7f9b87811aa588e6ab6a7256f7cd8267265d.tar.gz |
swscale/unscaled: correctly copy semiplanar formats
This fixes multiple bugs with semiplanar formats like NV12. Not only do these
false positive the grayscale format checks (because dst[2] in NULL), but they
also copied an incorrect number of pixels.
Fixes conversions such as nv12 -> nv12, gray8 -> nv12, nv20le -> nv20be, etc.
Fixes: #11239
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: Sovereign Tech Fund
-rw-r--r-- | libswscale/swscale_unscaled.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index f0fe8304f5..a4d18bf63e 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -2148,10 +2148,12 @@ static int planarCopyWrapper(SwsInternal *c, const uint8_t *const src[], const uint8_t *srcPtr = src[plane]; uint8_t *dstPtr = dst[plane] + dstStride[plane] * y; int shiftonly = plane == 1 || plane == 2 || (!c->opts.src_range && plane == 0); + if (plane == 1 && isSemiPlanarYUV(c->opts.dst_format)) + length *= 2; // ignore palette for GRAY8 - if (plane == 1 && !dst[2]) continue; - if (!src[plane] || (plane == 1 && !src[2])) { + if (plane == 1 && desc_dst->nb_components < 3) continue; + if (!src[plane] || (plane == 1 && desc_src->nb_components < 3)) { if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) { fillPlane16(dst[plane], dstStride[plane], length, height, y, plane == 3, desc_dst->comp[plane].depth, |