本文整理汇总了C++中AudioBuffer::DeinterlaceFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::DeinterlaceFrom方法的具体用法?C++ AudioBuffer::DeinterlaceFrom怎么用?C++ AudioBuffer::DeinterlaceFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::DeinterlaceFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadCache
int FFmpegAudioDecoder::ReadCache(AudioBuffer<s16>& buffer, int count, int offset)
{
count = Math::Min((size_t)count, cacheLength / sizeof(AudioBuffer<s16>::AudioSample) / channels);
buffer.DeinterlaceFrom((AudioBuffer<s16>::AudioSample*)cache, count, offset);
cacheLength -= sizeof(AudioBuffer<s16>::AudioSample) * channels * count;
memmove(cache, (u8*)cache + sizeof(AudioBuffer<s16>::AudioSample) * channels * count, cacheLength);
return count;
}
示例2: Read
u32 FFmpegAudioDecoder::Read(AudioBuffer<s16>& buffer, u32 count, u32 boffset)
{
int offset = ReadCache(buffer, count, boffset);
count -= offset;
while (count > 0) {
AVPacket originalPacket;
if (!decoder->ReadPacket(&originalPacket, streamIndex))
break;
AVPacket packet = originalPacket;
cacheLength = 0;
while (packet.size > 0) {
int datasize = bufferSize;
int used = avcodec_decode_audio3(stream->codec, (s16*)this->buffer, &datasize, &packet);
if (used < 0)
break;
packet.size -= used;
packet.data += used;
if (datasize <= 0)
break;
int read = Math::Min((u32)datasize, count * 2 * channels);
int left = datasize - read;
if (read > 0) {
int samples = read / sizeof(AudioBuffer<s16>::AudioSample) / channels;
buffer.DeinterlaceFrom((AudioBuffer<s16>::AudioSample*)this->buffer, samples, boffset + offset);
offset += samples;
count -= samples;
}
if (left > 0) {
memcpy((u8*)cache + cacheLength, (u8*)this->buffer + read, left);
cacheLength += left;
}
}
decoder->FreePacket(&originalPacket);
}
AudioCodec<s16>::Read(buffer, offset);
return offset;
}