[FFmpeg-devel] [PATCH] Common fixed-point ACELP routines (1/3) - math

Michael Niedermayer michaelni
Fri Apr 25 14:44:19 CEST 2008


On Fri, Apr 25, 2008 at 12:19:09PM +0700, Vladimir Voroshilov wrote:
> Michael Niedermayer wrote: 
> 
>  
> > following is a tiny bit more accurate and doesnt need the 3rd table:
> 
> [...]
> 
> > Note, yes the output is scaled different again
> 
> Updated.
> 
> > > +/**
> > > + * \brief multiplies 32-bit integer by another 16-bit and divides result by 2^15
> > > + * \param var_q24 32-bit integer
> > > + * \param var_15 16-bit integer
> > > + *
> > > + * \return result of (var_q24 * var_q15 >> 15) with clipping to [INT_MIN; INT_MAX] range
> > > + */
> > > +static inline int mul_32_16(int var_q24, int16_t var_q15)
> > > +{
> > > +    return (((int64_t)var_q24 * (int64_t)var_q15) >> 15);
> > > +}
> > 
> > now this looks like it belongs to libavcodec/mathops.h
> 
> separate patch is attached.
> 
[...]

> diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
> index 65918ad..1e859ae 100644
> --- a/libavcodec/mathops.h
> +++ b/libavcodec/mathops.h
> @@ -57,6 +57,18 @@ static av_always_inline int MULH(int a, int b){
>  }
>  #endif
>  
> +/**
> + * \brief multiplies 32-bit integer by another 16-bit and divides result by 2^15
> + * \param var_q24 32-bit integer
> + * \param var_15 16-bit integer
> + *
> + * \return result of (var_q24 * var_q15 >> 15)
> + */
> +static av_always_inline int mul_32_16(int var_q24, int16_t var_q15)

q24/q15 are confusing outside g729
and the shift value should be a argument or part of the name of the function
its non obvious that mul_32_16 would shift by 15 instead of lets say 16.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080425/7786c374/attachment.pgp>



More information about the ffmpeg-devel mailing list