diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-06-20 18:54:06 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-06-29 15:21:31 -0400 |
commit | 84fe925242157d4c934a02741d200c84f4a284ac (patch) | |
tree | 7e890171606e059cc987052e0892e72983164880 /src/opus_encoder.c | |
parent | ffa90359874e000c0eaf3c6fb1d224c114f5af62 (diff) | |
download | opus-84fe925242157d4c934a02741d200c84f4a284ac.tar.gz |
Taking loss rate into account in compute_equiv_rate()
Diffstat (limited to 'src/opus_encoder.c')
-rw-r--r-- | src/opus_encoder.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 5a6d158c..59db441f 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -993,9 +993,9 @@ static int compute_silk_rate_for_hybrid(int rate, int bandwidth, int frame20ms, /* Returns the equivalent bitrate corresponding to 20 ms frames, complexity 10 VBR operation. */ static opus_int32 compute_equiv_rate(opus_int32 bitrate, int channels, - int frame_rate, int vbr, int mode, int complexity) + int frame_rate, int vbr, int mode, int complexity, int loss) { - int equiv; + opus_int32 equiv; equiv = bitrate; /* Take into account overhead from smaller frames. */ equiv -= (40*channels+20)*(frame_rate - 50); @@ -1010,6 +1010,7 @@ static opus_int32 compute_equiv_rate(opus_int32 bitrate, int channels, costs about 20%. */ if (complexity<2) equiv = equiv*4/5; + equiv -= equiv*loss/(6*loss + 10); } else if (mode == MODE_CELT_ONLY) { /* CELT complexity 0-4 doesn't have the pitch filter, which costs about 10%. */ @@ -1017,6 +1018,8 @@ static opus_int32 compute_equiv_rate(opus_int32 bitrate, int channels, equiv = equiv*9/10; } else { /* Mode not known yet */ + /* Half the SILK loss*/ + equiv -= equiv*loss/(12*loss + 20); } return equiv; } @@ -1276,7 +1279,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* Equivalent 20-ms rate for mode/channel/bandwidth decisions */ equiv_rate = compute_equiv_rate(st->bitrate_bps, st->channels, st->Fs/frame_size, - st->use_vbr, 0, st->silk_mode.complexity); + st->use_vbr, 0, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); if (st->signal_type == OPUS_SIGNAL_VOICE) voice_est = 127; @@ -1319,7 +1322,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ } /* Update equivalent rate for channels decision. */ equiv_rate = compute_equiv_rate(st->bitrate_bps, st->stream_channels, st->Fs/frame_size, - st->use_vbr, 0, st->silk_mode.complexity); + st->use_vbr, 0, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); /* Mode selection depending on application and signal type */ if (st->application == OPUS_APPLICATION_RESTRICTED_LOWDELAY) @@ -1419,7 +1422,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* Update equivalent rate with mode decision. */ equiv_rate = compute_equiv_rate(st->bitrate_bps, st->stream_channels, st->Fs/frame_size, - st->use_vbr, st->mode, st->silk_mode.complexity); + st->use_vbr, st->mode, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); /* For the first frame at a new SILK bandwidth */ if (st->silk_bw_switch) |