[FFmpeg-devel] [RFC] mem: facilitate imports into GPU memory space.

wm4 nfxjfg at googlemail.com
Sun Oct 25 14:47:48 CET 2015

On Sun, 25 Oct 2015 14:28:06 +0100
Nicolas George <george at nsup.org> wrote:

> Le quartidi 4 brumaire, an CCXXIV, Gwenole Beauchesne a écrit :
> > Allow for av_malloc() to allocate memory that could be mapped into
> > the GPU address space. This requires allocations on page boundaries.
> > On the video memory buffers side, this requires minimal alignment of
> > strides to 64 bytes.
> > 
> > Option 1: use heuristics in av_malloc()
> > - break down into mem, frame, and avcodec changes.  
> Heuristics are fragile, and the result would probably be many false
> positive, wasting quite a lot of memory.
> > Option 2: use a finer decision model
> > - mem: add av_malloc_aligned()
> > - buffer: add av_buffer_alloc2() with align and/or flags
> > - frame/avcodec: use new APIs  
> I would go for flags all the way: with an explicit align value, people will
> hardcode a random value based on whichever example they looked at, and it
> will break when CPUs are upgraded to a larger value.
> The API should probably include some kind of "av_foobar_get_align_flags()"
> for each foobar domain where alignment can become visible to the
> application.

Well, in this case, I expect vaapi code to do the allocations, and
it'll use the page size for it (as this is what the hardware apparently

People who don't know what they're doing can keep using av_malloc.

More information about the ffmpeg-devel mailing list