[FFmpeg-devel] [PATCH] G.729 LSF decoding
Vladimir Voroshilov
voroshil
Mon Jun 22 12:38:58 CEST 2009
2009/6/22 Michael Niedermayer <michaelni at gmx.at>:
> On Sat, Jun 20, 2009 at 02:23:07PM +0700, Vladimir Voroshilov wrote:
>> >> ?g729data.h | ? 11 +++++++++
>> >> ?g729dec.c ?| ? 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> >> ?2 files changed, 81 insertions(+)
>> >> 180ee12ea9d2d6990454e9bc3a25d29828c2e0b2 ?0001-LSF-decoding-routines.161.patch
>> >> From e2e6b6b18255c9d24f9cc0cf60dfbd1c4ccbcef1 Mon Sep 17 00:00:00 2001
>> >> From: Vladimir Voroshilov <voroshil at gmail.com>
>> >> Date: Sat, 6 Jun 2009 08:00:56 +0700
>> >> Subject: [PATCH] LSF decoding routines
>> >>
>> >>
>> >> diff --git ffmpeg-r19218/libavcodec/g729data.h ffmpeg-r19218_v161/libavcodec/g729data.h
>> >> index 796d24e..587db67 100644
>> >> --- ffmpeg-r19218/libavcodec/g729data.h
>> >> +++ ffmpeg-r19218_v161/libavcodec/g729data.h
>> >> @@ -262,4 +262,15 @@ static const int16_t cb_ma_predictor[2][MA_NP][10] = { /* (0.15) */
>> >> ? ? ?{ 3024, ?1592, ? 940, ?1631, ?1723, ?1579, ?2034, ?2084, ?1913, ?2601}
>> >> ? ?}
>> >> ?};
>> >> +
>> >> +/**
>> >> + * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3
>> >> + * ff_g720_cb_ma_predictor_sum[j][i] = ?1 - sum ( ff_g729_cb_ma_predictor[k][i] ), j=0..1, i=0..9
>> >> + * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?k=0
>> >> + */
>> >
>> > this doesnt look correct
>>
>> It does in floating-point.
>
> no it does not, this formula is not correct and this is not a matter of
> scaling some constant
>
>
>> I've changed "1" to "32765" (now it is correct for fixed-point) and added notice
>> why values may slightly differ in array and formula.
>
> I think ive said it many month ago already but if you cannot write
> documentation that matches the code then do NOT write documentation. Wrong
> documentation is far worse than no documentation.
>
> first, this set all entries [j][i] for j=0..1, i=0..9, but j is never
> used in the formula, still [0][i] is very different from [1][i], thats not
> just sloppy, then you used constants like 1 instead of 32765 thats also not
> a little off
Yes, i really missed third dimension at right side.
With below formula i get about +/-1 differences between formula and
table values.
3
ff_g720_cb_ma_predictor_sum[j][i] = 32765 - sum (
ff_g729_cb_ma_predictor[j][k][i] ), j=0..1, i=0..9
k=0
> and finally it still doesnt match the table and your solution is just adding
> a note saying that initial calculation was done in floating point, what is
> that supposed to mean? Is summing 16bit values in float giving differnt
> results than integers for you? what kind of cpu is that?
I'm afraid you don't understand me.
Imagine there is some array X[N] (floating-point). S=sum(X[n])
and there is another array X_fp[N] (foxed-point) X_fp[n]= X[n] * FP_BASE
S_fp=sum(X_fp[n])
I just wanted to say that S and S_fp in above sample can slightly differ.
In my case S_fp is ff_g720_cb_ma_predictor_sum and X_fp is
ff_g720_cb_ma_predictor.
I've written small C program to check them. Largest difference between
table and formula is "2".
--
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719
More information about the ffmpeg-devel
mailing list