From e9999adda9ae1044fca9aa5ad41f1b719ccd4360 Mon Sep 17 00:00:00 2001 From: Armstrong Date: Fri, 24 Jan 2025 16:24:23 +0800 Subject: [PATCH] fix av_image_alloc alignment && check allocation error --- src/FFmpegReader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 1d5064c36..3fe0e2bdc 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -1269,7 +1269,11 @@ bool FFmpegReader::GetAVFrame() { frameFinished = 1; packet_status.video_decoded++; - av_image_alloc(pFrame->data, pFrame->linesize, info.width, info.height, (AVPixelFormat)(pStream->codecpar->format), 1); + // align 32 for simd + if (av_image_alloc(pFrame->data, pFrame->linesize, info.width, + info.height, (AVPixelFormat)(pStream->codecpar->format), 32) <= 0) { + throw OutOfMemory("Failed to allocate image buffer", path); + } av_image_copy(pFrame->data, pFrame->linesize, (const uint8_t**)next_frame->data, next_frame->linesize, (AVPixelFormat)(pStream->codecpar->format), info.width, info.height);