From 08e8227514f5ab99822dfae8b4d39414646ff59d Mon Sep 17 00:00:00 2001 From: Vignesh Venkatasubramanian Date: Thu, 11 Jun 2015 11:15:00 -0700 Subject: SoftOpus: Fix output buffer capacity. The output buffer size as per opus project's sample decoder [1] is 960*6*channel_count. Whereas in SoftOpus, we use 960*6 (without the channel count multiplier. Fixing it to include maximum number of channels possible as the multiplier. [1] http://git.xiph.org/?p=opus-tools.git;a=blob;f=src/opusdec.c;h=d085f04eacdfd49759ffdb73db805562ba396720;hb=f2a2e88b47f6f24083a37be476f140f677fe7160#l571 BUG=20721050 Change-Id: I323891a1b11491782bc093477b09e7757b885674 --- media/libstagefright/codecs/opus/dec/SoftOpus.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'media/libstagefright/codecs/opus/dec/SoftOpus.cpp') diff --git a/media/libstagefright/codecs/opus/dec/SoftOpus.cpp b/media/libstagefright/codecs/opus/dec/SoftOpus.cpp index 7ff9ee7..cb10bce 100644 --- a/media/libstagefright/codecs/opus/dec/SoftOpus.cpp +++ b/media/libstagefright/codecs/opus/dec/SoftOpus.cpp @@ -34,6 +34,12 @@ namespace android { static const int kRate = 48000; +// Opus uses Vorbis channel mapping, and Vorbis channel mapping specifies +// mappings for up to 8 channels. This information is part of the Vorbis I +// Specification: +// http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html +static const int kMaxChannels = 8; + template static void InitOMXParams(T *params) { params->nSize = sizeof(T); @@ -101,7 +107,7 @@ void SoftOpus::initPorts() { def.eDir = OMX_DirOutput; def.nBufferCountMin = kNumBuffers; def.nBufferCountActual = def.nBufferCountMin; - def.nBufferSize = kMaxNumSamplesPerBuffer * sizeof(int16_t); + def.nBufferSize = kMaxNumSamplesPerBuffer * sizeof(int16_t) * kMaxChannels; def.bEnabled = OMX_TRUE; def.bPopulated = OMX_FALSE; def.eDomain = OMX_PortDomainAudio; @@ -225,12 +231,6 @@ static uint16_t ReadLE16(const uint8_t *data, size_t data_size, return val; } -// Opus uses Vorbis channel mapping, and Vorbis channel mapping specifies -// mappings for up to 8 channels. This information is part of the Vorbis I -// Specification: -// http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html -static const int kMaxChannels = 8; - // Maximum packet size used in Xiph's opusdec. static const int kMaxOpusOutputPacketSizeSamples = 960 * 6; -- cgit v1.1