[Ffmpeg-devel] [PATCH] move utf8 writing to libavutil

Michael Niedermayer michaelni
Sat Jul 8 22:11:22 CEST 2006


On Sat, Jul 08, 2006 at 08:56:18PM +0100, M?ns Rullg?rd wrote:
> Justin Ruggles <jruggle at earthlink.net> writes:
> > Please explain the benefit of the do/while. What does it protect against?
> Without it,
> if(whatever)
>     PUT_UTF8(...);
> will have some quite unintended results without so much as a warning.
> The idea with a do { } while(0) construct is to turn the entire macro
> body into a single statement while still keeping the semicolon
> (usually) placed after the macro invocation part of this same
> statement.  Simply enclosing the body in braces will make the final
> semicolon form a new, empty statement, which will break things like
> if(foo)
>     PUT_UTF8(...);
> else
>     PUT_UTF8(...);

the intended use of thet GET/PUT_UTF8 macros was so that each application
could easily build their own utf8 reading and writing functions with their
own get_bits / put_bits system
they where not really intended to be inlined every time utf8 needs to be
read or written, i belive utf8 reading isnt speedcritical in any application
that uses libavutil, though noone stops you from inlining it every time ...

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