decoder/opus: Implement bitrate calculation
This commit is contained in:
parent
407fa2720a
commit
3a3f605a56
2
NEWS
2
NEWS
|
@ -4,6 +4,8 @@ ver 0.24 (not yet released)
|
||||||
- filter "prio" (for "playlistfind"/"playlistsearch")
|
- filter "prio" (for "playlistfind"/"playlistsearch")
|
||||||
* archive
|
* archive
|
||||||
- add option to disable archive plugins in mpd.conf
|
- add option to disable archive plugins in mpd.conf
|
||||||
|
* decoder
|
||||||
|
- opus: implement bitrate calculation
|
||||||
* player
|
* player
|
||||||
- add option "mixramp_analyzer" to scan MixRamp tags on-the-fly
|
- add option "mixramp_analyzer" to scan MixRamp tags on-the-fly
|
||||||
* tags
|
* tags
|
||||||
|
|
|
@ -327,6 +327,13 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Formula for calculation of bitrate of the current opus packet:
|
||||||
|
bits_sent_into_decoder = packet.bytes * 8
|
||||||
|
1/seconds_decoded = opus_sample_rate / nframes
|
||||||
|
kbits = bits_sent_into_decoder * 1/seconds_decoded / 1000
|
||||||
|
*/
|
||||||
|
uint16_t kbits = (unsigned int)packet.bytes*8 * opus_sample_rate / nframes / 1000;
|
||||||
|
|
||||||
/* apply the "skip" value */
|
/* apply the "skip" value */
|
||||||
if (skip >= (unsigned)nframes) {
|
if (skip >= (unsigned)nframes) {
|
||||||
skip -= nframes;
|
skip -= nframes;
|
||||||
|
@ -361,7 +368,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
|
||||||
const size_t nbytes = nframes * frame_size;
|
const size_t nbytes = nframes * frame_size;
|
||||||
auto cmd = client.SubmitData(input_stream,
|
auto cmd = client.SubmitData(input_stream,
|
||||||
data, nbytes,
|
data, nbytes,
|
||||||
0);
|
kbits);
|
||||||
if (cmd != DecoderCommand::NONE)
|
if (cmd != DecoderCommand::NONE)
|
||||||
throw cmd;
|
throw cmd;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue