ffmpeg media add-on: add padding around video buffers

The video buffer used for colorspace conversion was not aligned enough
(it could need as much as 64 bytes alignment) and did not include enough
padding (the functions work on 64 bytes blocks at once in some cases).

This code could be made simpler by using sws_scale_frame instead of
sws_scale, but that's more refactoring than I'm willing to do right now.

Thanks to k32n13 for providing a script to generate test videos!

Fixes #20200.

Change-Id: I8b51fd777201cdb899ce1834152066378b258521
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11343
Reviewed-by: waddlesplash <[email protected]>
(cherry picked from commit a0bfeae472eee24a9855e9685a507f6f85d91673)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11344
This commit is contained in:
PulkoMandy
2026-07-23 18:11:57 +00:00
committed by waddlesplash
parent b812cfe777
commit 63b8fe3ae8
@@ -1671,9 +1671,9 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame()
fDecodedDataSizeInBytes = fHeader.size_used;
if (fDecodedData == NULL) {
const size_t kOptimalAlignmentForColorConversion = 32;
const size_t kOptimalAlignmentForColorConversion = 64;
posix_memalign(reinterpret_cast<void**>(&fDecodedData),
kOptimalAlignmentForColorConversion, fDecodedDataSizeInBytes);
kOptimalAlignmentForColorConversion, fDecodedDataSizeInBytes + 63);
}
if (fDecodedData == NULL)
return B_NO_MEMORY;