[FFmpeg-cvslog] swscale/unscaled: correctly copy semiplanar formats
Niklas Haas
git at videolan.org
Mon Dec 23 12:33:43 EET 2024
ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Thu Dec 19 14:41:34 2024 +0100| [77db7f9b87811aa588e6ab6a7256f7cd8267265d] | committer: Niklas Haas
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 at haasn.dev>
Sponsored-by: Sovereign Tech Fund
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77db7f9b87811aa588e6ab6a7256f7cd8267265d
---
libswscale/swscale_unscaled.c | 6 ++++--
1 file 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,
More information about the ffmpeg-cvslog
mailing list