diff options
author | Koen Vos <koenvos74@gmail.com> | 2015-08-20 16:38:32 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2015-08-20 16:46:31 +0300 |
commit | 56d850412a2fc40bedb162de5e4b506bda2a5f4e (patch) | |
tree | a30e6a5c791814dd6625c4322ebaf9e4dca0be50 | |
parent | 3499e78bd5a93edcef80f6cbd88e7fc1e1666d9b (diff) |
Fixes bitrate statistics for decode-only operation and inband FEC
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
-rw-r--r-- | src/opus_demo.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/opus_demo.c b/src/opus_demo.c index 9be3bf78..173ec517 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -834,28 +834,32 @@ int main(int argc, char *argv[]) } lost_prev = lost; - - /* count bits */ - bits += len[toggle]*8; - bits_max = ( len[toggle]*8 > bits_max ) ? len[toggle]*8 : bits_max; if( count >= use_inbandfec ) { - nrg = 0.0; + /* count bits */ + bits += len[toggle]*8; + bits_max = ( len[toggle]*8 > bits_max ) ? len[toggle]*8 : bits_max; + bits2 += len[toggle]*len[toggle]*64; if (!decode_only) { + nrg = 0.0; for ( k = 0; k < frame_size * channels; k++ ) { nrg += in[ k ] * (double)in[ k ]; } + nrg /= frame_size * channels; + if( nrg > 1e5 ) { + bits_act += len[toggle]*8; + count_act++; + } } - if ( ( nrg / ( frame_size * channels ) ) > 1e5 ) { - bits_act += len[toggle]*8; - count_act++; - } - /* Variance */ - bits2 += len[toggle]*len[toggle]*64; } count++; toggle = (toggle + use_inbandfec) & 1; } + + /* Print out bitrate statistics */ + if(decode_only) + frame_size = (int)(tot_samples / count); + count -= use_inbandfec; fprintf (stderr, "average bitrate: %7.3f kb/s\n", 1e-3*bits*sampling_rate/tot_samples); fprintf (stderr, "maximum bitrate: %7.3f kb/s\n", |