[Ffmpeg-devel] Re: av_log() bloatedness
Michael Niedermayer
michaelni
Mon Jul 24 09:51:01 CEST 2006
Hi
On Mon, Jul 24, 2006 at 02:59:32AM -0400, Rich Felker wrote:
> On Sun, Jul 23, 2006 at 11:38:01PM +0200, Michael Niedermayer wrote:
> > > IMO it would be the nicest if av_log function pointer were not stored
> > > in a global variable at all, but in the relevant context. This is the
> > > only approach that works in cases like:
> > >
> > > 1. Main application directly links libavcodec
> > > 2. Application dynamic loads a plugin linked to libavcodec.
> > > 3. Plugin sets av_log to code in the plugin to avoid spamming the
> > > calling app's stderr.
> > > 4. Main program no longer gets its log messages from its own use of
> > > libavcodec.
> > > ....... and optionally .....
> > > 5. Main program unloads plugin.
> > > 6. Main program crashes when av_log gets called.
> > >
> > > Number 5 and 6 can be avoided with a proper uninit function in the
> > > plugin, but things can still go horribly wrong if multiple plugins
> > > have been loaded and unloaded, all with this behavior.
> > >
> > > The answer to all the problems, as always, is that global variables
> > > are evil and should not be used. :)
> >
> > yes, but theres a problem, many av_log() calls exist without a context
> > grep 'av_log(NULL' {,*/,*/*/}*.{c,h} | wc -l
> > has 316 hits
>
> Ah. Why so many places that need debug output without a context?! I
i dunno, i didnt investigate why these are there
[...]
>
> > 2. we might end up having to pass some context pointer into speed-critical
> > functions
>
> IMO a speed-critical function can't have calls to av_log anyway, not
> even conditioned on a debug variable..
why?
for example:
i += run;
if(i > 63){
av_log(...
return -1;
}
block[ scantable[i] ]= level;
in that case the if is needed for obvious reasons so we shouldnt loose any
speed from the av_log()
or what about av_log under #ifdef FOOBAR ? used for debugging
[...]
--
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