From 5c1fe520102cdfb5e47f6be87d314585e9e2a3c6 Mon Sep 17 00:00:00 2001 From: sudden6 Date: Sat, 3 Nov 2018 15:11:16 +0100 Subject: [PATCH] fix(video): correctly align data passed to toxcore fixes #5402 c-toxcore requires each plane to be aligned at 1 byte boundaries. Because of this bug we alligned it at 32 byte boundaries if the height and width were a multiple of 8. --- src/video/videoframe.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video/videoframe.cpp b/src/video/videoframe.cpp index a58bf72ac..fd742f1d3 100644 --- a/src/video/videoframe.cpp +++ b/src/video/videoframe.cpp @@ -575,7 +575,9 @@ AVFrame* VideoFrame::generateAVFrame(const QSize& dimensions, const int pixelFor int bufSize; - if (!requireAligned || (dimensions.width() % 8 == 0 && dimensions.height() % 8 == 0)) { + const bool alreadyAligned = dimensions.width() % dataAlignment == 0 && dimensions.height() % dataAlignment == 0; + + if (!requireAligned || alreadyAligned) { bufSize = av_image_alloc(ret->data, ret->linesize, dimensions.width(), dimensions.height(), static_cast(pixelFormat), dataAlignment); } else {