Hi,

2011/5/13 Måns Rullgård <[email protected]>:
> I'd prefer if argument were the number of bits to saturate at.  It could
> also be used in few places in ac3dsp.c.
>
> Here's a patch I had sitting around for the unsigned version:
>
> diff --git a/libavutil/common.h b/libavutil/common.h
> index 5814297..b694e63 100644
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -169,6 +169,12 @@ static av_always_inline av_const int32_t 
> av_clipl_int32_c(int64_t a)
>     else                                         return a;
>  }
>
> +static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
> +{
> +    if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
> +    else                   return  a;
> +}
> +
>  /**
>  * Clip a float value into the amin-amax range.
>  * @param a value to clip
> @@ -362,6 +368,9 @@ static av_always_inline av_const int 
> av_popcount_c(uint32_t x)
>  #ifndef av_clipl_int32
>  #   define av_clipl_int32   av_clipl_int32_c
>  #endif
> +#ifndef av_clip_uintp2
> +#   define av_clip_uintp2   av_clip_uintp2_c
> +#endif
>  #ifndef av_clipf
>  #   define av_clipf         av_clipf_c
>  #endif

Looks fantastic to me, please apply, or else I'll integrate it here
and redo my patches on top of it.

Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to