[FFmpeg-devel] [PATCH] G.729 Frame erasure support for LSF decoding

Michael Niedermayer michaelni
Wed Jun 24 22:38:15 CEST 2009


On Wed, Jun 24, 2009 at 08:18:23PM +0700, Vladimir Voroshilov wrote:
> 2009/6/24 Michael Niedermayer <michaelni at gmx.at>:
> > On Sat, Jun 20, 2009 at 02:26:59PM +0700, Vladimir Voroshilov wrote:
> >
> > [...]
> >> diff --git ffmpeg-r19218/libavcodec/g729data.h ffmpeg-r19218_v163/libavcodec/g729data.h
> >> index a70c705..e202331 100644
> >> --- ffmpeg-r19218/libavcodec/g729data.h
> >> +++ ffmpeg-r19218_v163/libavcodec/g729data.h
> >> @@ -275,4 +275,14 @@ static const int16_t cb_ma_predictor_sum[2][10] = { /* (0.15) */
> >> ? ?{14585, 18333, 19772, 17344, 16426, 16459, 15155, 15220, 16043, 15708}
> >> ?};
> >>
> >> +/**
> >> + * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2^27
> >> + * ff_g729_cb_ma_predictor_sum_inv[j][i] = ---------------------------------
> >> + * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ff_g720_cb_ma_predictor_sum[j][i]
> >> + */
> >
> > my guess would be that this is also not really "="
> >
> >
> > [...]
> >> - ? ?ma_predictor ? ? = get_bits(&gb, 1);
> >> - ? ?quantizer_1st ? ?= get_bits(&gb, VQ_1ST_BITS);
> >> - ? ?quantizer_2nd_lo = get_bits(&gb, VQ_2ND_BITS);
> >> - ? ?quantizer_2nd_hi = get_bits(&gb, VQ_2ND_BITS);
> >> +
> >> + ? ?if(frame_erasure) {
> >> + ? ? ? ?skip_bits(&gb, 1 + VQ_1ST_BITS + VQ_2ND_BITS + VQ_2ND_BITS);
> >> +
> >> + ? ? ? ?lsf_restore_from_previous(ctx->lsfq, ctx->past_quantizer_outputs,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ctx->ma_predictor);
> >> + ? ?} else {
> >> + ? ? ? ?uint8_t quantizer_1st; ? ?///< first stage vector of quantizer
> >> + ? ? ? ?uint8_t quantizer_2nd_lo; ///< second stage lower vector of quantizer (size in bits)
> >> + ? ? ? ?uint8_t quantizer_2nd_hi; ///< second stage higher vector of quantizer (size in bits)
> >> +
> >> + ? ? ? ?ctx->ma_predictor = get_bits(&gb, 1);
> >> + ? ? ? ?quantizer_1st ? ? = get_bits(&gb, VQ_1ST_BITS);
> >> + ? ? ? ?quantizer_2nd_lo ?= get_bits(&gb, VQ_2ND_BITS);
> >> + ? ? ? ?quantizer_2nd_hi ?= get_bits(&gb, VQ_2ND_BITS);
> >>
> >
> > reindent besides i dont like the change, its useless to replace them
> > by skip
> 
> I though this version is more clean due to localized usage of variables.
> It also shows that in erasure case reading of quantizer values is not used.
> 
> here is my early version without skip, but with two variables per MA
> predictor (current/prev values).

[...]

> @@ -162,6 +164,27 @@ static void lsf_decode(int16_t* lsfq, int16_t* past_quantizer_outputs[MA_NP + 1]
>      ff_acelp_reorder_lsf(lsfq, LSFQ_DIFF_MIN, LSFQ_MIN, LSFQ_MAX, 10);
>  }
>  
> +static void lsf_restore_from_previous(int16_t* lsfq,
> +                                      int16_t* past_quantizer_outputs[MA_NP + 1],
> +                                      int ma_predictor_prev)
> +{
> +    int16_t* quantizer_output = past_quantizer_outputs[MA_NP];
> +    int i,k;
> +
> +    for (i = 0; i < 10; i++) {
> +        int tmp = lsfq[i] << 15;
> +
> +        for (k = 0; k < MA_NP; k++)
> +            tmp -= past_quantizer_outputs[k][i] * cb_ma_predictor[ma_predictor_prev][k][i];
> +
> +        quantizer_output[i] = ((tmp >> 15) * cb_ma_predictor_sum_inv[ma_predictor_prev][i]) >> 12;
> +    }
> +
> +    /* Rotate past_quantizer_outputs. */
> +    memmove(past_quantizer_outputs + 1, past_quantizer_outputs, MA_NP * sizeof(int16_t*));
> +    past_quantizer_outputs[0] = quantizer_output;
> +}

this code is duplicated


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Thouse who are best at talking, realize last or never when they are wrong.
-------------- 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/20090624/dfc9e60b/attachment.pgp>



More information about the ffmpeg-devel mailing list