Skip to content

Commit

Permalink
OpusPacketDecoder: set decoder complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
nu774 committed Mar 22, 2024
1 parent 84f0640 commit 4770366
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions input/OpusPacketDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bool LibOpusModule::load(const std::wstring &path)
CHECK(multistream_decode_float = m_dl.fetch("opus_multistream_decode_float"));
CHECK(multistream_decoder_ctl = m_dl.fetch("opus_multistream_decoder_ctl"));
CHECK(multistream_decoder_destroy = m_dl.fetch("opus_multistream_decoder_destroy"));
CHECK(decoder_ctl = m_dl.fetch("opus_decoder_ctl"));
return true;
} catch (...) {
m_dl.reset();
Expand Down Expand Up @@ -95,6 +96,13 @@ void OpusPacketDecoder::setMagicCookie(const std::vector<uint8_t> &cookie)
OpusMSDecoder *decoder = m_module.multistream_decoder_create(48000,
channel_count, stream_count, coupled_count, mapping, &err);
if (err) throw std::runtime_error(m_module.strerror(err));
for (int i = 0; i < stream_count; ++i) {
OpusDecoder *dec = nullptr;
err = m_module.multistream_decoder_ctl(decoder, OPUS_MULTISTREAM_GET_DECODER_STATE(i, &dec));
if (err) throw std::runtime_error(m_module.strerror(err));
err = m_module.decoder_ctl(dec, OPUS_SET_COMPLEXITY(10));
if (err) throw std::runtime_error(m_module.strerror(err));
}
m_decoder = std::shared_ptr<OpusMSDecoder>(decoder, m_module.multistream_decoder_destroy);
m_iasbd.mFormatID = util::fourcc("opus");
m_iasbd.mSampleRate = 48000;
Expand Down
1 change: 1 addition & 0 deletions input/OpusPacketDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LibOpusModule {
int (*multistream_decode_float)(OpusMSDecoder *, const unsigned char *, opus_int32, float *, int, int);
int (*multistream_decoder_ctl)(OpusMSDecoder *, int, ...);
void (*multistream_decoder_destroy)(OpusMSDecoder *);
int (*decoder_ctl)(OpusDecoder *, int, ...);
};

class OpusPacketDecoder: public IPacketDecoder {
Expand Down

0 comments on commit 4770366

Please sign in to comment.