From b7d074f5f82c1c35cebd7606c179768203201124 Mon Sep 17 00:00:00 2001 From: MartB Date: Thu, 29 Jun 2017 15:59:11 +0200 Subject: [PATCH] Update to bcg729 version 1.0.3 --- Makefile | 2 +- mod_bcg729.c | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 7cb80c5..6ad4d13 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ mod_bcg729.o: bcg729 mod_bcg729.c clone_bcg729: if [ ! -d bcg729 ]; then \ - git clone git://git.linphone.org/bcg729.git; pushd bcg729 ; git checkout 1.0.1; popd; \ + git clone git://git.linphone.org/bcg729.git; pushd bcg729 ; git checkout 1.0.3; popd; \ fi bcg729: clone_bcg729 diff --git a/mod_bcg729.c b/mod_bcg729.c index 449a934..23ca18d 100644 --- a/mod_bcg729.c +++ b/mod_bcg729.c @@ -58,7 +58,7 @@ static switch_status_t switch_bcg729_init(switch_codec_t *codec, switch_codec_fl codec->fmtp_out = switch_core_strdup(codec->memory_pool, "annexb=no"); if (encoding) { - context->encoder_object = initBcg729EncoderChannel(); + context->encoder_object = initBcg729EncoderChannel(0); } if (decoding) { @@ -103,10 +103,11 @@ static switch_status_t switch_bcg729_encode(switch_codec_t *codec, int loops = (int) decoded_data_len / 160; for (x = 0; x < loops && new_len < *encoded_data_len; x++) { - bcg729Encoder(context->encoder_object, ddp, edp); - edp += 10; - ddp += 80; - new_len += 10; + uint8_t frameSize; + bcg729Encoder(context->encoder_object, ddp, edp, &frameSize); + edp += frameSize; + ddp += frameSize * 8; + new_len += frameSize; } if (new_len <= *encoded_data_len) { @@ -141,7 +142,7 @@ static switch_status_t switch_bcg729_decode(switch_codec_t *codec, int16_t *ddp = decoded_data; if (encoded_data_len == 0) { /* Native PLC interpolation */ - bcg729Decoder(context->decoder_object, NULL, 1, ddp); + bcg729Decoder(context->decoder_object, NULL, 0, 1, 0, 0, ddp); ddp += 80; decoded_data_len = (uint32_t *) 160; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "g729 zero length frame\n"); @@ -149,12 +150,10 @@ static switch_status_t switch_bcg729_decode(switch_codec_t *codec, } for(x = 0; x < encoded_data_len && new_len < *decoded_data_len; x += framesize) { - if(encoded_data_len - x < 8) - framesize = 2; /* SID */ - else - framesize = 10; /* regular 729a frame */ + uint8_t isSID = (encoded_data_len - x < 8) ? 1 : 0; + framesize = (isSID==1) ? 2 : 10; - bcg729Decoder(context->decoder_object, edp, 0, ddp); + bcg729Decoder(context->decoder_object, edp, encoded_data_len, 0, isSID, 0, ddp); ddp += 80; edp += framesize; new_len += 160;