From: Mike Jerris Date: Fri, 2 Oct 2015 17:52:51 +0000 (-0500) Subject: Merge pull request #487 in FS/freeswitch from ~DRAGOS_OANCEA/freeswitch-dragos:opus... X-Git-Tag: v1.6.3~1^2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41431c0f09a3396e4476b2cba25e0a068923a500;p=thirdparty%2Ffreeswitch.git Merge pull request #487 in FS/freeswitch from ~DRAGOS_OANCEA/freeswitch-dragos:opus-keep-fec-on-improvements-loss to master * commit '6385fb863a7e800dbb2668fd0ed4e1203b1ba18e': FS-8161: mod_opus: Keep FEC enabled only if loss > 10 ( otherwise PLC is supposed to be better) --- 41431c0f09a3396e4476b2cba25e0a068923a500 diff --cc src/mod/codecs/mod_opus/mod_opus.c index 52dbffc4aa,74f797512a..7829effd7a --- a/src/mod/codecs/mod_opus/mod_opus.c +++ b/src/mod/codecs/mod_opus/mod_opus.c @@@ -308,17 -309,37 +308,44 @@@ static switch_bool_t switch_opus_has_fe return SWITCH_FALSE; } + /* this is only useful for fs = 8000 hz, the map is only used + * at the beginning of the call. */ + static int switch_opus_get_fec_bitrate(int fs, int loss) + { + int threshold_bitrates[25] = { + 15600,15200,15200,15200,14800, + 14800,14800,14800,14400,14400, + 14400,14000,14000,14000,13600, + 13600,13600,13600,13200,13200, + 13200,12800,12800,12800,12400 + }; + + if (loss <= 0){ + return SWITCH_STATUS_FALSE; + } + + if (fs == 8000) { + if (loss >=25) { + return threshold_bitrates[24]; + } else { + return threshold_bitrates[loss-1]; + } + } + + return SWITCH_STATUS_FALSE ; + } + static switch_status_t switch_opus_info(void * encoded_data, uint32_t len, uint32_t samples_per_second, char *print_text) { - int nb_samples; - int nb_frames; + /* nb_silk_frames: number of silk-frames (10 or 20 ms) in an opus frame: 0, 1, 2 or 3 */ + /* computed from the 5 MSB (configuration) of the TOC byte (encoded_data[0]) */ + /* nb_opus_frames: number of opus frames in the packet */ + /* computed from the 2 LSB (p0p1) of the TOC byte */ + /* p0p1 = 0 => nb_opus_frames= 1 */ + /* p0p1 = 1 or 2 => nb_opus_frames= 2 */ + /* p0p1 = 3 => given by the 6 LSB of encoded_data[1] */ + + int nb_samples, nb_silk_frames, nb_opus_frames, n, i; int audiobandwidth; const char *audiobandwidth_str = "UNKNOWN"; opus_int16 frame_sizes[48];