[FFmpeg-devel] [PATCH] QCELP decoder
Kenan Gillet
kenan.gillet
Tue Nov 25 22:17:04 CET 2008
On Nov 22, 2008, at 2:22 PM, Michael Niedermayer wrote:
> On Fri, Nov 21, 2008 at 09:46:05AM -0800, Kenan Gillet wrote:
>>
>> On Nov 21, 2008, at 3:26 AM, Michael Niedermayer wrote:
>>
>>> On Thu, Nov 20, 2008 at 05:51:22PM -0800, Kenan Gillet wrote:
>>>> Hi,
>>>> On Nov 20, 2008, at 5:08 PM, Michael Niedermayer wrote:
>>>>
>>>>>>>
>>>>>>>
>>>>>>> [...]
>>>>>>>> +/**
>>>>>>>> + * Computes the Pa or Qa coefficients needed for LSP to LPC
>>>>>>>> conversion.
>>>>>>>> + * We only need to calculate the 6 first elements of the
>>>>>>>> polynomial.
>>>>>>>> + *
>>>>>>>> + * @param lspf line spectral pair frequencies
>>>>>>>> + * @param v_poly polynomial input/output as a vector
>>>>>>>> + *
>>>>>>>> + * TIA/EIA/IS-733 2.4.3.3.5-1/2
>>>>>>>> + */
>>>>>>>> +static void lsp2poly(const float *lspf,
>>>>>>>> + float *v_poly) {
>>>>>>>> + float val, *v;
>>>>>>>> + int i;
>>>>>>>> +
>>>>>>>> + // optimization to simplify calculation in loop
>>>>>>>> + v_poly++;
>>>>>>>> +
>>>>>>>> + for (i = 0; i < 10; i += 2) {
>>>>>>>> + val = -2 * cos(M_PI * *lspf);
>>>>>>>> + lspf += 2;
>>>>>>>> + v = v_poly + FFMIN(4, i);
>>>>>>>> +
>>>>>>>> + if (i < 4) {
>>>>>>>> + v[2] = v[0];
>>>>>>>> + v[1] = v[0] * val + v[-1];
>>>>>>>> + }
>>>>>>>> + for ( ; v > v_poly; v--)
>>>>>>>> + v[0] = v[0]
>>>>>>>> + + v[-1] * val
>>>>>>>> + + v[-2];
>>>>>>>> + v[0] += v[-1] * val;
>>>>>>>> + }
>>>>>>>> +}
>>>>>>>> +
>>>>>>>> +/**
>>>>>>>> + * Reconstructs LPC coefficients from the line spectral pair
>>>>>>>> frequencies
>>>>>>>> + * and performs bandwidth expansion.
>>>>>>>> + *
>>>>>>>> + * @param lspf line spectral pair frequencies
>>>>>>>> + * @param lpc linear predictive coding coefficients
>>>>>>>> + *
>>>>>>>> + * @note: bandwith_expansion_coeff could be precalculated
>>>>>>>> into a
>>>>>>>> table
>>>>>>>> + * but it seems to be slower on x86
>>>>>>>> + *
>>>>>>>> + * TIA/EIA/IS-733 2.4.3.3.5
>>>>>>>> + */
>>>>>>>> +void qcelp_lspf2lpc(const float *lspf,
>>>>>>>> + float *lpc) {
>>>>>>>> + float pa[6], qa[6];
>>>>>>>> + int i;
>>>>>>>> + float bandwith_expansion_coeff = -
>>>>>>>> QCELP_BANDWITH_EXPANSION_COEFF;
>>>>>>>> +
>>>>>>>
>>>>>>>> + pa[0] = 0.5;
>>>>>>>> + pa[1] = 0.5;
>>>>>>>> + lsp2poly(lspf, pa);
>>>>>>>> +
>>>>>>>> + qa[0] = 0.5;
>>>>>>>> + qa[1] = -0.5;
>>>>>>>> + lsp2poly(lspf + 1, qa);
>>>>>>>
>>>>>>> it should be faster to deal with 0.5 + 0.5x / 0.5 - 0.5x after
>>>>>>> building
>>>>>>> the polynomials
>>>>>>
>>>>>> done
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> anyway, see ff_acelp_lsp2lpc
>>>>>>
>>>>>> done, it is globally ~10% faster.
>>>>>>
>>>>>> but it gives some significant difference in the WAV output.
>>>>>> I doule check, and it seems to come from the float rounding :(
>>>>>> here is the list of result of 'tiny_psnr old.wav new.wav'.
>>>>>
>>>>> what happens with double instead of float?
>>>>
>>>> with keeping the signature of qcelp_lspf2lpc(float *, float *)
>>>> and changing all the calculation into double for
>>>> the code before and after optimization:
>>>
>>> hmm
>>> old vs. new
>>> float ~3 -5 stddev
>>> double ~0.5-1 stddev
>>>
>>> it seems this code is rather sensitive to rounding
>>>
>>> how do the differences look for
>>> float vs. double
>>> new
>>> old
>>>
>>> ?
>>
>> 101.mov: audio mismatchs from previous build
>> stddev: 0.02 PSNR: 78.92 bytes: 250284/ 250284
>>
>> V6_text.mov: audio mismatchs from previous build
>> stddev: 0.50 PSNR: 54.00 bytes: 11371244/ 11371244
>>
>> blue_earth.mov: audio mismatchs from previous build
>> stddev: 0.40 PSNR: 55.92 bytes: 19681324/ 19681324
>>
>> codeblue-interrupt01.mov: audio mismatchs from previous build
>> stddev: 0.02 PSNR: 79.21 bytes: 276524/ 276524
>>
>> codeblue-interrupt06.mov: audio mismatchs from previous build
>> stddev: 0.31 PSNR: 58.03 bytes: 642924/ 642924
>>
>> codeblue-plot08motor.mov: audio mismatchs from previous build
>> stddev: 0.29 PSNR: 58.81 bytes: 1534764/ 1534764
>>
>> h263.mov: audio mismatchs from previous build
>> stddev: 0.46 PSNR: 54.85 bytes: 13511404/ 13511404
>>
>> h263.trashed.mov: audio mismatchs from previous build
>> stddev: 0.46 PSNR: 54.85 bytes: 13511404/ 13511404
>>
>> installfect_export.mov: audio mismatchs from previous build
>> stddev: 1.19 PSNR: 46.60 bytes: 10448044/ 10448044
>>
>> oldepisode.mov: audio mismatchs from previous build
>> stddev: 1.09 PSNR: 47.35 bytes: 4588844/ 4588844
>>
>> schlangenmannliten.mov: audio mismatchs from previous build
>> stddev: 0.28 PSNR: 59.01 bytes: 8820844/ 8820844
>>
>> surge-1-16-B-Qclp.mov: audio mismatchs from previous build
>> stddev: 1.52 PSNR: 44.48 bytes: 1156524/ 1156524
>>
>> 8fe3b9dcd6d7e6db3375521c5c1b_Video_041606_002.3g2: audio mismatchs
>> from previous build
>> stddev: 0.02 PSNR: 78.98 bytes: 721004/ 721004
>>
>> Test3gpp-mp4a.3g2: audio mismatchs from previous build
>> stddev: 0.01 PSNR: 90.74 bytes: 219244/ 219244
>>
>> c8wwz2m0.3g2: audio mismatchs from previous build
>> stddev: 0.00 PSNR: 91.54 bytes: 241964/ 241964
>>
>> qtaudio-qcelp-problem.3g2: audio mismatchs from previous build
>> stddev: 0.02 PSNR: 80.33 bytes: 208044/ 208044
>>
>> test.3g2: audio same as previous build
>>
>> tube.3g2: audio mismatchs from previous build
>> stddev: 0.00 PSNR: 98.65 bytes: 113004/ 113004
>>
>> zg3dx2d6.3g2: audio mismatchs from previous build
>> stddev: 0.36 PSNR: 56.84 bytes: 486444/ 486444
>>
>> vidoo_MP4_audio_Qcelp13k.k3g: audio mismatchs from previous build
>> stddev: 0.41 PSNR: 55.68 bytes: 743724/ 743724
>
> well, what i meant was a comparission between
> old float and old double and a second
> comparission between new float and new double
>
> you posted just one so i really dont know what these compare ...
>
sorry for the delay,
old float vs old double:
101.mov: audio mismatchs from previous build
stddev: 2.10 PSNR: 41.65 bytes: 250284/ 250284
V6_text.mov: audio mismatchs from previous build
stddev: 2.54 PSNR: 40.00 bytes: 11371244/ 11371244
blue_earth.mov: audio mismatchs from previous build
stddev: 1.86 PSNR: 42.73 bytes: 19681324/ 19681324
codeblue-interrupt01.mov: audio mismatchs from previous build
stddev: 2.52 PSNR: 40.08 bytes: 276524/ 276524
codeblue-interrupt06.mov: audio mismatchs from previous build
stddev: 1.88 PSNR: 42.61 bytes: 642924/ 642924
codeblue-plot08motor.mov: audio mismatchs from previous build
stddev: 2.05 PSNR: 41.88 bytes: 1534764/ 1534764
h263.mov: audio mismatchs from previous build
stddev: 2.00 PSNR: 42.07 bytes: 13511404/ 13511404
h263.trashed.mov: audio mismatchs from previous build
stddev: 2.00 PSNR: 42.07 bytes: 13511404/ 13511404
installfect_export.mov: audio mismatchs from previous build
stddev: 3.80 PSNR: 36.51 bytes: 10448044/ 10448044
oldepisode.mov: audio mismatchs from previous build
stddev: 5.06 PSNR: 34.02 bytes: 4588844/ 4588844
schlangenmannliten.mov: audio mismatchs from previous build
stddev: 1.60 PSNR: 44.00 bytes: 8820844/ 8820844
surge-1-16-B-Qclp.mov: audio mismatchs from previous build
stddev: 3.79 PSNR: 36.53 bytes: 1156524/ 1156524
8fe3b9dcd6d7e6db3375521c5c1b_Video_041606_002.3g2: audio mismatchs
from previous build
stddev: 2.55 PSNR: 39.98 bytes: 721004/ 721004
Test3gpp-mp4a.3g2: audio mismatchs from previous build
stddev: 0.77 PSNR: 50.38 bytes: 219244/ 219244
c8wwz2m0.3g2: audio mismatchs from previous build
stddev: 0.51 PSNR: 53.81 bytes: 241964/ 241964
qtaudio-qcelp-problem.3g2: audio mismatchs from previous build
stddev: 1.94 PSNR: 42.36 bytes: 208044/ 208044
test.3g2: audio same as previous build
tube.3g2: audio mismatchs from previous build
stddev: 0.01 PSNR: 84.50 bytes: 113004/ 113004
zg3dx2d6.3g2: audio mismatchs from previous build
stddev: 2.28 PSNR: 40.94 bytes: 486444/ 486444
vidoo_MP4_audio_Qcelp13k.k3g: audio mismatchs from previous build
stddev: 1.18 PSNR: 46.64 bytes: 743724/ 743724
new float vs new double:
101.mov: audio mismatchs from previous build
stddev: 3.10 PSNR: 38.28 bytes: 250284/ 250284
V6_text.mov: audio mismatchs from previous build
stddev: 4.26 PSNR: 35.52 bytes: 11371244/ 11371244
blue_earth.mov: audio mismatchs from previous build
stddev: 3.16 PSNR: 38.11 bytes: 19681324/ 19681324
codeblue-interrupt01.mov: audio mismatchs from previous build
stddev: 4.36 PSNR: 35.31 bytes: 276524/ 276524
codeblue-interrupt06.mov: audio mismatchs from previous build
stddev: 3.36 PSNR: 37.57 bytes: 642924/ 642924
codeblue-plot08motor.mov: audio mismatchs from previous build
stddev: 3.12 PSNR: 38.23 bytes: 1534764/ 1534764
h263.mov: audio mismatchs from previous build
stddev: 3.39 PSNR: 37.50 bytes: 13511404/ 13511404
h263.trashed.mov: audio mismatchs from previous build
stddev: 3.39 PSNR: 37.50 bytes: 13511404/ 13511404
installfect_export.mov: audio mismatchs from previous build
stddev: 5.43 PSNR: 33.42 bytes: 10448044/ 10448044
oldepisode.mov: audio mismatchs from previous build
stddev: 7.25 PSNR: 30.91 bytes: 4588844/ 4588844
schlangenmannliten.mov: audio mismatchs from previous build
stddev: 2.38 PSNR: 40.56 bytes: 8820844/ 8820844
surge-1-16-B-Qclp.mov: audio mismatchs from previous build
stddev: 5.76 PSNR: 32.90 bytes: 1156524/ 1156524
8fe3b9dcd6d7e6db3375521c5c1b_Video_041606_002.3g2: audio mismatchs
from previous build
stddev: 3.40 PSNR: 37.49 bytes: 721004/ 721004
Test3gpp-mp4a.3g2: audio mismatchs from previous build
stddev: 1.44 PSNR: 44.94 bytes: 219244/ 219244
c8wwz2m0.3g2: audio mismatchs from previous build
stddev: 0.73 PSNR: 50.81 bytes: 241964/ 241964
qtaudio-qcelp-problem.3g2: audio mismatchs from previous build
stddev: 2.02 PSNR: 42.01 bytes: 208044/ 208044
test.3g2: audio same as previous build
tube.3g2: audio mismatchs from previous build
stddev: 0.01 PSNR: 84.67 bytes: 113004/ 113004
zg3dx2d6.3g2: audio mismatchs from previous build
stddev: 2.31 PSNR: 40.82 bytes: 486444/ 486444
vidoo_MP4_audio_Qcelp13k.k3g: audio mismatchs from previous build
stddev: 1.14 PSNR: 46.92 bytes: 743724/ 743724
More information about the ffmpeg-devel
mailing list