[FFmpeg-devel] [PATCH] Common ACELP routines (3/3) - LPC decoding routines
Michael Niedermayer
michaelni
Thu Apr 24 20:39:26 CEST 2008
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]);
}
>
> > > +/**
> > > + * \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 ?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/20080424/b2ab0bb9/attachment.pgp>
More information about the ffmpeg-devel
mailing list