From 20c9538e3236779fabe21c6fbdb7e6e039bd32b1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2019 15:30:29 +0100 Subject: audio: more alignment nonsense It's hard to see what FFmpeg does or what its API requires. It looks like the alignment in our own allocation code might be slightly too lenient, but who knows. Even if this is not needed, upping the alignment only wastes memory and doesn't do anything bad. (Note that the only reason why we have our own code is because FFmpeg doesn't even provide it as API. API users are forced to recreate this, even if they have no need for custom allocation!) --- audio/aframe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/audio/aframe.c b/audio/aframe.c index 118962f35b..655a4a38c3 100644 --- a/audio/aframe.c +++ b/audio/aframe.c @@ -598,7 +598,11 @@ int mp_aframe_pool_allocate(struct mp_aframe_pool *pool, struct mp_aframe *frame { int planes = mp_aframe_get_planes(frame); size_t sstride = mp_aframe_get_sstride(frame); - int plane_size = MP_ALIGN_UP(sstride * MPMAX(samples, 1), 32); + // FFmpeg hardcodes similar hidden possibly-requirements in a number of + // places: av_frame_get_buffer(), libavcodec's get_buffer(), mem.c, + // probably more. + int align_samples = MP_ALIGN_UP(MPMAX(samples, 1), 32); + int plane_size = MP_ALIGN_UP(sstride * align_samples, 64); int size = plane_size * planes; if (size <= 0 || mp_aframe_is_allocated(frame)) -- cgit v1.2.3