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