[Ffmpeg-devel] [PATCH] plain malloc in output_example.c
Michael Niedermayer
michaelni
Mon Aug 21 03:46:56 CEST 2006
Hi
On Sun, Aug 20, 2006 at 09:11:54PM -0300, Ramiro Polla wrote:
> Michael Niedermayer wrote:
> >>>nope, sorry ...
> >>>the original patch is ok if you add some note which says that the
> >>>buffers passed into lav* can be allocated any way the user likes
> >>>as long as they are aligned by enough for the architecture
> >>>
> New patch attached. Is the info text good?
ok
>
>
> >>In output_example.c, we have some calls to av_free in which the memory
> >>has been allocated internally by lav*, such as
> >>av_free(picture->data[0]); in line 400. So that memory has been
> >>allocated by av_malloc() (possibly with the memalign hack), and must
> >>therefore be freed by av_free().
> >>Also, av_freep is used, which internally uses av_free. So that buffer
> >>must also have been allocated with av_malloc() to be correctly
> >>deallocated by av_free().
> >>
> >>Wouldn't it be best to suggest that all memory fed to lav* in a program
> >>be allocated and freed by the av_{malloc,free}() functions? Otherwise,
> >>
> >
> >no
> >
>
> May I receive a better explanation given the scenario I described? Or a
> pointer to a previous discussion on the issue.
> I know it's not a problem on linux systems, but it is an issue on
> systems that use the memalign hack, since the wrong pointer is passed to
> the system's free function.
if the user would be required to always use av_malloc() then she would
have to memcpy things around and that defeats half of the speed advantage
of aligned data and SIMD so requireing that is simply not an option
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the ffmpeg-devel
mailing list