Re: [FFmpeg-devel] [PATCH] lavu/intmath: add faster clz support

2015-12-19 Thread Ganesh Ajjanagadde
On Thu, Dec 17, 2015 at 9:29 AM, Ganesh Ajjanagadde  wrote:
> On Thu, Dec 17, 2015 at 9:25 AM, Clément Bœsch  wrote:
>> On Thu, Dec 17, 2015 at 09:23:53AM -0800, Ganesh Ajjanagadde wrote:
>>> On Thu, Dec 17, 2015 at 9:20 AM, Kieran Kunhya  wrote:
>>> >>> +static av_always_inline av_const unsigned ff_clz_c(unsigned v)
>>> >>> +{
>>> >>> +unsigned i = sizeof(x) * 8;
>>> >>> +
>>> >>> +while (x) {
>>> >>> +x >>= 1;
>>> >>> +i--;
>>> >>> +}
>>> >>> +
>>> >>> +return i;
>>> >>> +}
>>> >>> +#endif
>>> >>> +
>>> >
>>> > erm, does even work?
>>>
>>> you mean in what sense? I literally copy/pasted it from 
>>> avfilter/af_sofalizer.
>>> If you mean building correctly, I don't know as I have the built-in.
>>> But then this patch does not actually use it yet; merely adds it to
>>> the header.
>>
>> v → x in arg
>
> oops, fixed, along with the signature locally.

forgot to mention that it has been pushed, thanks

>
>>
>> --
>> Clément B.
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/intmath: add faster clz support

2015-12-17 Thread Ganesh Ajjanagadde
On Thu, Dec 17, 2015 at 8:33 AM, Ganesh Ajjanagadde
 wrote:
> This should be useful for the sofalizer filter.
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/intmath.h | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/libavutil/intmath.h b/libavutil/intmath.h
> index 2016723..2bb0b62 100644
> --- a/libavutil/intmath.h
> +++ b/libavutil/intmath.h
> @@ -96,6 +96,9 @@ static av_always_inline av_const int 
> ff_log2_16bit_c(unsigned int v)
>  #ifndef ff_ctzll
>  #define ff_ctzll(v) __builtin_ctzll(v)
>  #endif
> +#ifndef ff_clz
> +#define ff_clz(v) __builtin_clz(v)
> +#endif
>  #endif
>  #endif
>
> @@ -135,6 +138,21 @@ static av_always_inline av_const int ff_ctzll_c(long 
> long v)
>  }
>  #endif
>
> +#ifndef ff_clz
> +#define ff_clz ff_clz_c
> +static av_always_inline av_const unsigned ff_clz_c(unsigned v)
> +{
> +unsigned i = sizeof(x) * 8;
> +
> +while (x) {
> +x >>= 1;
> +i--;
> +}
> +
> +return i;
> +}
> +#endif
> +
>  /**
>   * @}
>   */
> --
> 2.6.4
>

BTW, there is one very important thing to keep in mind: behavior of
__builtin_clz is undefined for input 0.
I assumed the undefined behavior is ok wrt sofalizer for instance, as
based on a cursory examination, I doubt 0 is intended to be passed
into clz.

Also, I missed the right type signature, return is an int; though I
doubt this actually matters in practice here.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/intmath: add faster clz support

2015-12-17 Thread Ganesh Ajjanagadde
On Thu, Dec 17, 2015 at 9:25 AM, Clément Bœsch  wrote:
> On Thu, Dec 17, 2015 at 09:23:53AM -0800, Ganesh Ajjanagadde wrote:
>> On Thu, Dec 17, 2015 at 9:20 AM, Kieran Kunhya  wrote:
>> >>> +static av_always_inline av_const unsigned ff_clz_c(unsigned v)
>> >>> +{
>> >>> +unsigned i = sizeof(x) * 8;
>> >>> +
>> >>> +while (x) {
>> >>> +x >>= 1;
>> >>> +i--;
>> >>> +}
>> >>> +
>> >>> +return i;
>> >>> +}
>> >>> +#endif
>> >>> +
>> >
>> > erm, does even work?
>>
>> you mean in what sense? I literally copy/pasted it from 
>> avfilter/af_sofalizer.
>> If you mean building correctly, I don't know as I have the built-in.
>> But then this patch does not actually use it yet; merely adds it to
>> the header.
>
> v → x in arg

oops, fixed, along with the signature locally.

>
> --
> Clément B.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/intmath: add faster clz support

2015-12-17 Thread Kieran Kunhya
>> +static av_always_inline av_const unsigned ff_clz_c(unsigned v)
>> +{
>> +unsigned i = sizeof(x) * 8;
>> +
>> +while (x) {
>> +x >>= 1;
>> +i--;
>> +}
>> +
>> +return i;
>> +}
>> +#endif
>> +

erm, does even work?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/intmath: add faster clz support

2015-12-17 Thread Clément Bœsch
On Thu, Dec 17, 2015 at 09:23:53AM -0800, Ganesh Ajjanagadde wrote:
> On Thu, Dec 17, 2015 at 9:20 AM, Kieran Kunhya  wrote:
> >>> +static av_always_inline av_const unsigned ff_clz_c(unsigned v)
> >>> +{
> >>> +unsigned i = sizeof(x) * 8;
> >>> +
> >>> +while (x) {
> >>> +x >>= 1;
> >>> +i--;
> >>> +}
> >>> +
> >>> +return i;
> >>> +}
> >>> +#endif
> >>> +
> >
> > erm, does even work?
> 
> you mean in what sense? I literally copy/pasted it from avfilter/af_sofalizer.
> If you mean building correctly, I don't know as I have the built-in.
> But then this patch does not actually use it yet; merely adds it to
> the header.

v → x in arg

-- 
Clément B.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/intmath: add faster clz support

2015-12-17 Thread Ganesh Ajjanagadde
On Thu, Dec 17, 2015 at 9:20 AM, Kieran Kunhya  wrote:
>>> +static av_always_inline av_const unsigned ff_clz_c(unsigned v)
>>> +{
>>> +unsigned i = sizeof(x) * 8;
>>> +
>>> +while (x) {
>>> +x >>= 1;
>>> +i--;
>>> +}
>>> +
>>> +return i;
>>> +}
>>> +#endif
>>> +
>
> erm, does even work?

you mean in what sense? I literally copy/pasted it from avfilter/af_sofalizer.
If you mean building correctly, I don't know as I have the built-in.
But then this patch does not actually use it yet; merely adds it to
the header.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel