[Freeswitch-svn] [commit] r6395 - in freeswitch/trunk/src: . mod/applications/mod_conference
Author: anthm Date: Sat Nov 24 16:48:25 2007 New Revision: 6395 Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c freeswitch/trunk/src/switch_ivr_play_say.c freeswitch/trunk/src/switch_rtp.c Log: fix energy stuff to work better on 16khz calls Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Sat Nov 24 16:48:25 2007 @@ -1382,17 +1382,23 @@ if (switch_test_flag(member, MFLAG_CAN_SPEAK) && energy_level) { uint32_t energy = 0, i = 0, samples = 0, j = 0, score = 0; int16_t *data; + int divisor = 0; data = read_frame->data; + + if (!(divisor = read_codec->implementation->actual_samples_per_second / 8000)) { + divisor = 1; + } + if ((samples = read_frame->datalen / sizeof(*data))) { for (i = 0; i < samples; i++) { energy += abs(data[j]); j += read_codec->implementation->number_of_channels; } - score = energy / samples; + score = energy / (samples / divisor); } - + if (score > energy_level) { uint32_t diff = score - energy_level; if (hangover_hits) { Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Sat Nov 24 16:48:25 2007 @@ -516,13 +516,18 @@ uint32_t samples = read_frame->datalen / sizeof(*fdata); uint32_t score, count = 0, j = 0; double energy = 0; - + int divisor = 0; + for (count = 0; count < samples; count++) { energy += abs(fdata[j]); j += read_codec->implementation->number_of_channels; } - score = (uint32_t) (energy / samples); + if (!(divisor = read_codec->implementation->actual_samples_per_second / 8000)) { + divisor = 1; + } + + score = (uint32_t) (energy / (samples / divisor)); if (score < fh->thresh) { if (!--fh->silence_hits) { break; Modified: freeswitch/trunk/src/switch_rtp.c ============================================================================== --- freeswitch/trunk/src/switch_rtp.c (original) +++ freeswitch/trunk/src/switch_rtp.c Sat Nov 24 16:48:25 2007 @@ -1375,8 +1375,13 @@ uint32_t energy = 0; uint32_t x, y = 0, z = len / sizeof(int16_t); uint32_t score = 0; - + int divisor = 0; if (z) { + + if (!(divisor = rtp_session->vad_data.read_codec->implementation->actual_samples_per_second / 8000)) { + divisor = 1; + } + for (x = 0; x < z; x++) { energy += abs(decoded[y]); y += rtp_session->vad_data.read_codec->implementation->number_of_channels; @@ -1385,7 +1390,7 @@ if (++rtp_session->vad_data.start_count < rtp_session->vad_data.start) { send = 1; } else { - score = energy / z; + score = (energy / (z / divisor)); if (score && (rtp_session->vad_data.bg_count < rtp_session->vad_data.bg_len)) { rtp_session->vad_data.bg_level += score; if (++rtp_session->vad_data.bg_count == rtp_session->vad_data.bg_len) {
participants (1)
-
Freeswitch SVN