fix av_image_alloc alignment && check allocation error

This commit is contained in:
Armstrong
2025-01-24 16:24:23 +08:00
committed by huanghongbo
parent dd2a70c9f2
commit e9999adda9

View File

@@ -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);