summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-21 13:37:29 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-21 13:37:29 -0400
commit866cf24a3e5951ae57f6285e801691c5057aaf23 (patch)
tree6c54b94dee87e7358085844765f945d0360ceb81
parentcbf03a3f7a2f0f16567fb596a600ebc8a800fc1e (diff)
downloadopus-exp_fec_tune.tar.gz
Tune SILK rate for hybrid with FEC enabledexp_fec_tune
-rw-r--r--src/opus_encoder.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 3358a627..299c0b08 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -985,23 +985,24 @@ static int decide_fec(int useInBandFEC, int PacketLoss_perc, int last_fec, int m
return 0;
}
-static int compute_silk_rate_for_hybrid(int rate, int bandwidth, int frame20ms, int vbr) {
+static int compute_silk_rate_for_hybrid(int rate, int bandwidth, int frame20ms, int vbr, int fec) {
int entry;
int i;
int N;
int silk_rate;
static int rate_table[][5] = {
/* |total| |-------- SILK------------|
- SWB-10 FB-10 SWB-20 FB-20 */
+ |-- No FEC -| |--- FEC ---|
+ 10ms 20ms 10ms 20ms */
{ 0, 0, 0, 0, 0},
- {12000, 10000, 10000, 10000, 10000},
- {16000, 14000, 14000, 14000, 13500},
- {20000, 16000, 16000, 16000, 16000},
- {24000, 18000, 18000, 18000, 18000},
- {32000, 22000, 22000, 22000, 22000},
- {64000, 38000, 38000, 38000, 38000}
+ {12000, 10000, 10000, 11000, 11000},
+ {16000, 13500, 13500, 15000, 15000},
+ {20000, 16000, 16000, 18000, 18000},
+ {24000, 18000, 18000, 21000, 21000},
+ {32000, 22000, 22000, 28000, 28000},
+ {64000, 38000, 38000, 50000, 50000}
};
- entry = 1 + 2*frame20ms + (bandwidth==OPUS_BANDWIDTH_FULLBAND);
+ entry = 1 + frame20ms + 2*fec;
N = sizeof(rate_table)/sizeof(rate_table[0]);
for (i=1;i<N;i++)
{
@@ -1025,6 +1026,8 @@ static int compute_silk_rate_for_hybrid(int rate, int bandwidth, int frame20ms,
/* Tiny boost to SILK for CBR. We should probably tune this better. */
silk_rate += 100;
}
+ if (bandwidth==OPUS_BANDWIDTH_SUPERWIDEBAND)
+ silk_rate += 300;
return silk_rate;
}
@@ -1732,7 +1735,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
if( st->mode == MODE_HYBRID ) {
/* Base rate for SILK */
st->silk_mode.bitRate = compute_silk_rate_for_hybrid(total_bitRate,
- curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr);
+ curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr, st->silk_mode.LBRR_coded);
if (!st->energy_masking)
{
/* Increasingly attenuate high band when it gets allocated fewer bits */
@@ -1841,7 +1844,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
{
/* Compute SILK bitrate corresponding to the max total bits available */
opus_int32 maxBitRate = compute_silk_rate_for_hybrid(nBytes*8*st->Fs / frame_size,
- curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr);
+ curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr, st->silk_mode.LBRR_coded);
st->silk_mode.maxBits = maxBitRate * frame_size / st->Fs;
}
}