Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3179e3b3 authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian Committed by Abhishek Arya
Browse files

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
(cherry picked from commit 08e82275)
parent e4ac35fa
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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<class T>
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;