decoder/OpusHead: return pre-skip
This commit is contained in:
parent
472881cb95
commit
a99b4abae8
@ -136,8 +136,8 @@ MPDOpusDecoder::OnOggBeginning(const ogg_packet &packet)
|
||||
if (opus_decoder != nullptr || !IsOpusHead(packet))
|
||||
throw std::runtime_error("BOS packet must be OpusHead");
|
||||
|
||||
unsigned channels;
|
||||
if (!ScanOpusHeader(packet.packet, packet.bytes, channels) ||
|
||||
unsigned channels, pre_skip;
|
||||
if (!ScanOpusHeader(packet.packet, packet.bytes, channels, pre_skip) ||
|
||||
!audio_valid_channel_count(channels))
|
||||
throw std::runtime_error("Malformed BOS packet");
|
||||
|
||||
@ -305,10 +305,12 @@ ReadAndParseOpusHead(OggSyncState &sync, OggStreamState &stream,
|
||||
unsigned &channels)
|
||||
{
|
||||
ogg_packet packet;
|
||||
unsigned pre_skip;
|
||||
|
||||
return OggReadPacket(sync, stream, packet) && packet.b_o_s &&
|
||||
IsOpusHead(packet) &&
|
||||
ScanOpusHeader(packet.packet, packet.bytes, channels) &&
|
||||
ScanOpusHeader(packet.packet, packet.bytes, channels,
|
||||
pre_skip) &&
|
||||
audio_valid_channel_count(channels);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "OpusHead.hxx"
|
||||
#include "util/ByteOrder.hxx"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -31,12 +32,14 @@ struct OpusHead {
|
||||
};
|
||||
|
||||
bool
|
||||
ScanOpusHeader(const void *data, size_t size, unsigned &channels_r)
|
||||
ScanOpusHeader(const void *data, size_t size, unsigned &channels_r,
|
||||
unsigned &pre_skip_r)
|
||||
{
|
||||
const OpusHead *h = (const OpusHead *)data;
|
||||
if (size < 19 || (h->version & 0xf0) != 0)
|
||||
return false;
|
||||
|
||||
channels_r = h->channels;
|
||||
pre_skip_r = FromLE16(h->pre_skip);
|
||||
return true;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
bool
|
||||
ScanOpusHeader(const void *data, size_t size, unsigned &channels_r);
|
||||
ScanOpusHeader(const void *data, size_t size, unsigned &channels_r,
|
||||
unsigned &pre_skip_r);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user