Adding 32 bit alignment for simd into our AV_ALLOCATE_IMAGE macro, and some code cleanup

This commit is contained in:
Jonathan Thomas
2025-05-23 18:35:03 -05:00
parent 4983a45f74
commit 68b885ee77
2 changed files with 5 additions and 6 deletions

View File

@@ -1307,10 +1307,9 @@ bool FFmpegReader::GetAVFrame() {
frameFinished = 1;
packet_status.video_decoded++;
// 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);
// Allocate image (align 32 for simd)
if (AV_ALLOCATE_IMAGE(pFrame, (AVPixelFormat)(pStream->codecpar->format), info.width, info.height) <= 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);

View File

@@ -160,7 +160,7 @@ inline static bool ffmpeg_has_alpha(PixelFormat pix_fmt) {
#define MY_INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE
#define AV_ALLOCATE_FRAME() av_frame_alloc()
#define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) \
av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1)
av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 32)
#define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame)
#define AV_FREE_FRAME(av_frame) av_frame_free(av_frame)
#define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet)
@@ -198,7 +198,7 @@ inline static bool ffmpeg_has_alpha(PixelFormat pix_fmt) {
#define MY_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
#define AV_ALLOCATE_FRAME() av_frame_alloc()
#define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) \
av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1)
av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 32)
#define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame)
#define AV_FREE_FRAME(av_frame) av_frame_free(av_frame)
#define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet)