[FFmpeg-devel] [PATCH] libavcodec/utils: Simplify get_buffer compatibility wrapper.
Nicolas George
george at nsup.org
Sun Feb 16 23:51:25 CET 2014
L'octidi 28 pluviôse, an CCXXII, Reimar Döffinger a écrit :
> 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
Maybe you forget that data is an array while extended_data is a pointer.
"*frame = tmp" will make the pointers equal, but copy the array contents.
If extended_data points to mallocated memory, there is nothing more to do.
If tmp.extended_data points to tmp.data, then frame->extended_data must
point to frame->data, not tmp.data.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140216/dabe2558/attachment.asc>
More information about the ffmpeg-devel
mailing list