From 73607a465ac08fb20f8985c7cb28f7e0fb2764c1 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 23 Aug 2009 07:03:28 +0000 Subject: [PATCH] applied some patch to CELT library --- ChangeLog | 8 ++++++++ libs/celt/README_LLCON | 3 ++- libs/celt/celt.c | 38 +++++++++++++++++++++++--------------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5af672b5..1f73df40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +3.0.1 + +- bug fix: buzzing occurred when audio stream was interrupted (e.g. in case + of network trouble) + +- in case "Open Chat on New Message" is not enabled, a hint in the status bar + is shown when a message is received + 3.0.0 - introduced new audio codec "CELT", not compatible to old versions diff --git a/libs/celt/README_LLCON b/libs/celt/README_LLCON index 58d3d542..1c435233 100755 --- a/libs/celt/README_LLCON +++ b/libs/celt/README_LLCON @@ -1,4 +1,5 @@ -The CELT library version 0.6.1 is used. +The CELT library version 0.6.1 is uses, including git patch "0f0da999ae82a2b73974cc73a1a19d79a23ba8cd" +of celt.c by Jean-Marc "Better fading for PLC: no fading for the first loss, muting after 6". Basically the files in celt-0.6.1/libcelt are used. diff --git a/libs/celt/celt.c b/libs/celt/celt.c index cef5fecc..07d3cd78 100755 --- a/libs/celt/celt.c +++ b/libs/celt/celt.c @@ -1111,6 +1111,7 @@ struct CELTDecoder { celt_word16_t *oldBandE; int last_pitch_index; + int loss_count; }; int check_decoder(const CELTDecoder *st) @@ -1157,7 +1158,7 @@ CELTDecoder *celt_decoder_create(const CELTMode *mode) st->preemph_memD = (celt_sig_t*)celt_alloc(C*sizeof(celt_sig_t)); - st->last_pitch_index = 0; + st->loss_count = 0; if ((st->decode_mem!=NULL) && (st->out_mem!=NULL) && (st->oldBandE!=NULL) && (st->preemph_memD!=NULL)) @@ -1214,6 +1215,7 @@ static void celt_decode_lost(CELTDecoder * __restrict st, celt_word16_t * __rest { int c, N; int pitch_index; + celt_word16_t fade = Q15ONE; int i, len; VARDECL(celt_sig_t, freq); const int C = CHANNELS(st->mode); @@ -1223,25 +1225,27 @@ static void celt_decode_lost(CELTDecoder * __restrict st, celt_word16_t * __rest ALLOC(freq,C*N, celt_sig_t); /**< Interleaved signal MDCTs */ len = N+st->mode->overlap; -#if 0 - pitch_index = st->last_pitch_index; - /* Use the pitch MDCT as the "guessed" signal */ - compute_mdcts(st->mode, st->mode->window, st->out_mem+pitch_index*C, freq); + if (st->loss_count == 0) + { + find_spectral_pitch(st->mode, st->mode->fft, &st->mode->psy, st->out_mem+MAX_PERIOD-len, st->out_mem, st->mode->window, NULL, len, MAX_PERIOD-len-100, &pitch_index); + pitch_index = MAX_PERIOD-len-pitch_index; + st->last_pitch_index = pitch_index; + } else { + pitch_index = st->last_pitch_index; + if (st->loss_count < 5) + fade = QCONST16(.8f,15); + else + fade = 0; + } -#else - find_spectral_pitch(st->mode, st->mode->fft, &st->mode->psy, st->out_mem+MAX_PERIOD-len, st->out_mem, st->mode->window, NULL, len, MAX_PERIOD-len-100, &pitch_index); - pitch_index = MAX_PERIOD-len-pitch_index; offset = MAX_PERIOD-pitch_index; while (offset+len >= MAX_PERIOD) offset -= pitch_index; compute_mdcts(st->mode, 0, st->out_mem+offset*C, freq); for (i=0;iout_mem, st->out_mem+C*N, C*(MAX_PERIOD+st->mode->overlap-N)); /* Compute inverse MDCTs */ compute_inv_mdcts(st->mode, 0, freq, -1, 0, st->out_mem); @@ -1257,6 +1261,9 @@ static void celt_decode_lost(CELTDecoder * __restrict st, celt_word16_t * __rest pcm[C*j+c] = SCALEOUT(SIG2WORD16(tmp)); } } + + st->loss_count++; + RESTORE_STACK; } #endif @@ -1316,6 +1323,8 @@ int celt_decode_float(CELTDecoder * __restrict st, const unsigned char *data, in celt_decode_lost(st, pcm); RESTORE_STACK; return 0; + } else { + st->loss_count = 0; } if (len<0) { RESTORE_STACK; @@ -1347,7 +1356,6 @@ int celt_decode_float(CELTDecoder * __restrict st, const unsigned char *data, in if (has_pitch) { pitch_index = ec_dec_uint(&dec, MAX_PERIOD-(2*N-2*N4)); - st->last_pitch_index = pitch_index; } else { pitch_index = 0; for (i=0;imode->nbPBands;i++) @@ -1524,7 +1532,7 @@ int celt_decoder_ctl(CELTDecoder * __restrict st, int request, ...) CELT_MEMSET(st->preemph_memD, 0, C); - st->last_pitch_index = 0; + st->loss_count = 0; } break; default: