[FFmpeg-devel] [PATCH] Add ceil(log2(x)) to libavutil/common.h

Thilo Borgmann thilo.borgmann
Mon Aug 24 12:38:49 CEST 2009


Michael Niedermayer schrieb:
> On Mon, Aug 24, 2009 at 11:59:11AM +0200, Diego Biurrun wrote:
>> On Sun, Aug 23, 2009 at 07:14:42PM +0200, Thilo Borgmann wrote:
>>> Revision 2 attached.
>>>
>>> --- libavutil/common.h	(revision 19682)
>>> +++ libavutil/common.h	(working copy)
>>> @@ -225,6 +225,14 @@
>>>  
>>> +/** Computes ceil(log2(x)).
>>> + * @param x value used to compute ceil(log2(x))
>>> + * @return computed ceiling of log2(x)
>>> + */
>>> +static inline av_const int av_ceil_log2(int x) {
>>> +    return x - 1 ? av_log2((x - 1) << 1) : 0;
>>> +}
>> Format this in K&R style please.  You should not just disregard what the
>> surrounding code looks like when you edit a file.
What a shame I didn't realize that before...


> 
> may i suggest
> static inline av_const int av_ceil_log2(int x)
> {
>     return av_log2((x - 1) << 1);
> }
Done.

-Thilo



More information about the ffmpeg-devel mailing list