Fix video playback

This adds support to

- VideoPlayer
- VideoStreamWebm
- VideoStreamTheora
This commit is contained in:
Matt Hughes
2017-09-14 15:45:02 -05:00
committed by Hiroshi Ogawa
parent e8f8359b2e
commit 3edd3cd377
32 changed files with 873 additions and 331 deletions

View File

@ -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;

View File

@ -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: