[FFmpeg-devel] [PATCH] Common ACELP routines (3/3) - LPC decoding routines
Vladimir Voroshilov
voroshil
Fri Apr 25 03:26:35 CEST 2008
On Fri, Apr 25, 2008 at 1:39 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Thu, Apr 24, 2008 at 09:44:17PM +0700, Vladimir Voroshilov wrote:
> > On Thu, Apr 24, 2008 at 7:21 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > > On Thu, Apr 24, 2008 at 02:53:33AM +0700, Vladimir Voroshilov wrote:
> > > > Michael Niedermayer wrote:
> > > [...]
> > >
> > > >
> > > > >
> > > > > [...]
> > > > > > +void ff_acelp_reorder_lsf(int16_t* lsfq, int16_t lsfq_min_distance, int16_t lsfq_min, int16_t lsfq_max)
> > > > > > +{
> > > > > > + int i;
> > > > > > +
> > > > > > + lsfq[0] = FFMAX(lsfq[0], lsfq_min); //Is warning required ?
> > > > > > +
> > > > > > + for(i=0;i<9; i++)
> > > > > > + lsfq[i+1] = FFMAX(lsfq[i+1], lsfq[i] + lsfq_min_distance);
> > > > >
> > > > > simplification stolen from soc/amrnbdec.c:
> > > > >
> > > > > for(i=0; i<10; i++){
> > > > > lsf[i] = FFMAX(lsf[i], lsf_min);
> > > > > lsf_min = lsf[i] + min_distance;
> > > > > }
> > > > >
> > > > > also id make lsfq_min_distance and lsfq_min/max int
> > > > >
> > > > > ahh, and reorder_lsf() in soc/amrnbdec.c is buggy (uninitalized var)
> > > >
> > > > It also assumes that LSFs already ordered.
> > > > G.729 explicitly sorts them.
> > > > Should i put sorting code inside routine?
> > >
> > > If its fast for the case that they are already sorted ...
> >
> > It was written by you :)
>
> Indeed, but ive not written it to be fast but rather simple.
> Heres one which should be O(n) for already sorted lists.
>
> for(i=0; i<N-1; i++){
> for(j=i; j>=0 && lsfq[j] > lsfq[j+1]; j--)
> FFSWAP(int16_t, lsfq[j], lsfq[j+1]);
>
> }
Fixed.
> > > > +/**
> > > > + * \brief decodes polynomial coefficients from LSP
> > >
> > > > + * \param f [out] (Q24) decoded polynomial coefficients
> > > > + * \param lsp (Q15) LSP coefficients
> > > > + */
> > > > +static void lsp2poly(int* f, const int16_t* lsp)
> > >
> > > > +{
> > > > + int i, j;
> > > > +
> > > > + f[0] = 0x1000000; // 1.0 in Q24
> > > > + f[1] = -lsp[0] << 10; // *2 and Q15 -> Q24
> > > > +
> > > > + for(i=2; i<=5; i++)
> > > > + {
> > > > + f[i] = f[i-2];
> > > > +
> > > > + for(j=i; j>1; j--)
> > > > +#ifdef G729_BITEXACT
> > >
> > > > + f[j] -= (mul_24_15(f[j-1]>>1, lsp[2*i-2])<<2) - f[j-2];
> > > > +#else
> > >
> > > > + f[j] -= (mul_24_15(f[j-1], lsp[2*i-2])<<1) - f[j-2];
> > >
> > > Does this need the cliping from mul_24_15() ? or can it be replaced
> > > by a simple * (int64_t) ?
> >
> > Clipping is required (absence leads to all tests failure).
>
> Didnt you say in the other mail that mul_24_15() doesnt need any cliping ?
Yes, i did and was wrong. The reason was in incorrect testing (missed ">>15"
in testing code). And mail was sent before reply to "math" thread
mul_32_16 definitely cannot overflow due to parameters types.
--
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: acelp_lpc_25.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080425/bf0cbd29/attachment.asc>
More information about the ffmpeg-devel
mailing list