[FFmpeg-cvslog] avfilter/framepool: align the frame buffers
James Almer
git at videolan.org
Sun Nov 17 17:37:38 EET 2024
ffmpeg | branch: release/7.1 | James Almer <jamrial at gmail.com> | Sat Nov 9 11:20:59 2024 -0300| [fa15e3839dae0139ffc13fa02a41ff87065096e5] | committer: James Almer
avfilter/framepool: align the frame buffers
And not just the linesizes. Use the extra align bytes allocated for this purpose.
Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit f15fc27db5b30365f2aec474bae9b8095d6d2197)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa15e3839dae0139ffc13fa02a41ff87065096e5
---
libavfilter/framepool.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index e8621e07ac..1a1fc0de1e 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -139,7 +139,9 @@ FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(size_t size),
if (ret < 0)
goto fail;
- pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);
+ if (pool->linesize[0] > SIZE_MAX - align)
+ goto fail;
+ pool->pools[0] = av_buffer_pool_init(pool->linesize[0] + align, NULL);
if (!pool->pools[0])
goto fail;
@@ -219,7 +221,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
if (!frame->buf[i])
goto fail;
- frame->data[i] = frame->buf[i]->data;
+ frame->data[i] = (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
}
if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
@@ -256,13 +258,15 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
if (!frame->buf[i])
goto fail;
- frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
+ frame->extended_data[i] = frame->data[i] =
+ (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
}
for (i = 0; i < frame->nb_extended_buf; i++) {
frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
if (!frame->extended_buf[i])
goto fail;
- frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data;
+ frame->extended_data[i + AV_NUM_DATA_POINTERS] =
+ (uint8_t *)FFALIGN((uintptr_t)frame->extended_buf[i]->data, pool->align);
}
break;
More information about the ffmpeg-cvslog
mailing list