[FFmpeg-devel] [PATCH] libavcodec/utils: Simplify get_buffer compatibility wrapper.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Feb 16 23:43:44 CET 2014


On Sun, Feb 16, 2014 at 11:34:23PM +0100, Reimar Döffinger wrote:
> On Sun, Feb 16, 2014 at 11:17:05PM +0100, wm4 wrote:
> > The assumption of the AVFrame API is that all memory ranges referenced
> > are covered by buffer refs. You seem to think that it's ok to have
> > merely an abstract reference for the entire frame, but apparently this
> > is not enough. The code you remove is an attempt to account for all
> > data correctly. Since you don't know whether all the planes are
> > allocated with a single memory allocation or whether they're separate
> > allocations, you have to assume the worst case, and use a buffer per
> > plane.
> 
> The problem is the only thing in the documentation hinting at this is:
> > every single data plane must be contained in one of the buffers
> 
> However a single buffer starting at address 0 and going all the way up
> to the highest addressable address would fulfill this, which is
> almost what my patch does.
> If there are other assumptions this documentation needs to describe them
> properly instead of it being magic that nobody can use except by
> copy-pasting code from FFmpeg.

Also, more specifically this might reveal other ways to solve this that
does not require so much messy code.
Also slightly related, can someone explain to me these code snippets which
I've seen in multiple places (e.g. at the end of av_frame_make_writable in libavutil/frame.c)
>    *frame = tmp;
>    if (tmp.data == tmp.extended_data)
>        frame->extended_data = frame->data;

Because either the "if" part
a) is a completely obvious and stupid no-op, but I can't understand how this was missed, in multiple places to top it off
b) isn't a no-op and I don't understand how I can't see it


More information about the ffmpeg-devel mailing list