[FFmpeg-devel] [PATCH] Make ff_lpc_calc_coefs order estimation?flexible by passing parameters
Michael Niedermayer
michaelni
Sun Aug 17 18:10:55 CEST 2008
On Sun, Aug 17, 2008 at 11:43:05AM -0400, Justin Ruggles wrote:
> Michael Niedermayer wrote:
> > On Sat, Aug 16, 2008 at 08:29:34PM -0400, Justin Ruggles wrote:
[...]
> >
> >> + * @param[in] samples input audio samples for a single channel.
> >> + * @param[in] blocksize number of input samples.
> >> + * @param[in] min_order lowest LPC order to generate coefficients for.
> >> + * @param[in] max_order highest LPC order to generate coefficients for.
> >
> >> + * @param[in] use_lpc determines which LPC algorithm to use.
> >
> > it should be a enum (or well documented what is what)
>
> enum {
> ...
> USE_LPC_CHOLESKY_1_PASS
> ...
> USE_LPC_CHOLESKY_2147483646_PASS
> }
>
> I'll document it instead... :) Even if we cap the value it doesn't seem
> like a good use of enum.
ooops ^^;;
>
> >
> >> + * @param[out] lpc LPC coefficients for multiple orders.
> >> + * @param[out] ref reflection coefficients up to \p max_order.
> >> */
> >> -int ff_lpc_calc_coefs(DSPContext *s,
> >> +void ff_lpc_calc_coefs(DSPContext *s,
> >> const int32_t *samples, int blocksize, int min_order,
> >> - int max_order, int precision,
> >> - int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
> >> - int omethod, int max_shift, int zero_shift);
> >> + int max_order, int use_lpc, double lpc[][MAX_LPC_ORDER],
> >> + double ref[MAX_LPC_ORDER]);
> >>
> >
> >> +/**
> >> + * Estimate the best LPC order based on the reflection coefficients.
> >> + * This does a reverse iteration through the coeffs and compares against a
> >> + * fixed threshold to estimate a good order.
> >> + *
> >> + * @param ref reflection coefficients from 0 to \p max_order.
> >> + * @param min_order lowest LPC order to choose from.
> >> + * @param max_order highest LPC order to choose from.
> >> + * @return estimated best LPC order.
> >> + */
> >> +int ff_lpc_estimate_best_order(double *ref, int min_order, int max_order);
> >
> > why not estimate the bits needed to store LPC coeffs & prediction residual?
>
> If you mean by using the error value during Levinson-Durbin, that is
> what the reference FLAC encoder does. I tried it and it doesn't seem to
> give as good results (and is slower).
>
> Other than that, estimating the residual bits would be about the same as
> actually calculating the residual bits, which is what the other search
> methods do. I was going for something better than just using the max
> order, but significantly faster than the search methods.
moment ...
the number of bits each of the quantized coeffs would need is easy to find
as there are few such coeffs, the exact value should be cheap to calculate
the other thing is the bits of the residual this is harder ...
id suggest that you dump the standard deviation or variance which are known
IIRC and the actual true bits in a file, look with gnuplot at it and find
the approximate relation. From this you can estimate the bits based on the
std deviation of the residual which is known.
then its a matter of selecting the order that has the fewest bits possibly
with some slight speed/compression tradeoff offset added to to higher orders.
>
> >
> >> +
> >> +/**
> >> + * Quantize the LPC coefficients.
> >> + *
> >> + * @param[in] lpc floating-point LPC coefficients for multiple orders.
> >> + * @param[in] min_order lowest LPC order to quantize.
> >> + * @param[in] max_order highest LPC order to quantize.
> >> + * @param[in] precision largest number of bits in the quantized coefficients.
> >> + * @param[in] max_shift largest left-shift value to apply when quantizing coefficients.
> >> + * @param[in] zero_shift value to set \p shift to when all coefficients
> >> + * quantize to zero when using \p max_shift.
> >> + * @param[out] coefs quantized coefficients for multiple orders.
> >> + * @param[out] shift left-shift which was applied to coefficients during quantization.
> >> + */
> >> +void ff_lpc_quantize_coefs(double lpc[][MAX_LPC_ORDER], int min_order,
> >> + int max_order, int precision, int max_shift,
> >> + int zero_shift, int32_t coefs[][MAX_LPC_ORDER],
> >> + int *shift);
> >> +
> >
> > scalar quantization of LPC coeffs is not good, some more sane variant should
> > be tried, like all that are within a small distance from the correct but not
> > representable vector.
>
> My goal here was to move and document what we have now.
I know, iam just trying to squeeze as much usefull code out of everyone as i
can ;)
its of course ok to move code and document it as needed ...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- 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/20080817/fa8b20e4/attachment.pgp>
More information about the ffmpeg-devel
mailing list