summaryrefslogtreecommitdiff
path: root/thirdparty
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-13 19:57:18 +0100
committerGitHub <noreply@github.com>2017-11-13 19:57:18 +0100
commit03a080547dacdec0d8c181df700ef8dd1c092913 (patch)
tree8d7c100e1e12f9dbc3f106e817f758c9dbb40b3c /thirdparty
parent4c000a05f6275ae7b539927d4a2608cb54e34308 (diff)
parent3edd3cd377511b4cef27478be24f7562273d69ce (diff)
Merge pull request #12014 from hi-ogawa/fix-video-playback
Fix video playback
Diffstat (limited to 'thirdparty')
-rw-r--r--thirdparty/libsimplewebm/OpusVorbisDecoder.cpp37
-rw-r--r--thirdparty/libsimplewebm/OpusVorbisDecoder.hpp2
2 files changed, 38 insertions, 1 deletions
diff --git a/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp b/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp
index 06447aca57..c9e71eb733 100644
--- a/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp
+++ b/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp
@@ -122,6 +122,43 @@ bool OpusVorbisDecoder::getPCMS16(WebMFrame &frame, short *buffer, int &numOutSa
return false;
}
+bool OpusVorbisDecoder::getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples) {
+ if (m_vorbis) {
+ m_vorbis->op.packet = frame.buffer;
+ m_vorbis->op.bytes = frame.bufferSize;
+
+ if (vorbis_synthesis(&m_vorbis->block, &m_vorbis->op))
+ return false;
+ if (vorbis_synthesis_blockin(&m_vorbis->dspState, &m_vorbis->block))
+ return false;
+
+ const int maxSamples = getBufferSamples();
+ int samplesCount, count = 0;
+ float **pcm;
+ while ((samplesCount = vorbis_synthesis_pcmout(&m_vorbis->dspState, &pcm))) {
+ const int toConvert = samplesCount <= maxSamples ? samplesCount : maxSamples;
+ for (int c = 0; c < m_channels; ++c) {
+ float *samples = pcm[c];
+ for (int i = 0, j = c; i < toConvert; ++i, j += m_channels) {
+ buffer[count + j] = samples[i];
+ }
+ }
+ vorbis_synthesis_read(&m_vorbis->dspState, toConvert);
+ count += toConvert;
+ }
+
+ numOutSamples = count;
+ return true;
+ } else if (m_opus) {
+ const int samples = opus_decode_float(m_opus, frame.buffer, frame.bufferSize, buffer, m_numSamples, 0);
+ if (samples >= 0) {
+ numOutSamples = samples;
+ return true;
+ }
+ }
+ return false;
+}
+
bool OpusVorbisDecoder::openVorbis(const WebMDemuxer &demuxer)
{
size_t extradataSize = 0;
diff --git a/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp b/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp
index bcdca731ee..b7619d6a25 100644
--- a/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp
+++ b/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp
@@ -44,7 +44,7 @@ public:
{
return m_numSamples;
}
-
+ bool getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples);
bool getPCMS16(WebMFrame &frame, short *buffer, int &numOutSamples);
private: