content/media/AudioChannelFormat.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef MOZILLA_AUDIOCHANNELFORMAT_H_
     7 #define MOZILLA_AUDIOCHANNELFORMAT_H_
     9 #include <stdint.h>
    11 #include "nsTArrayForwardDeclare.h"
    13 namespace mozilla {
    15 /*
    16  * This file provides utilities for upmixing and downmixing channels.
    17  *
    18  * The channel layouts, upmixing and downmixing are consistent with the
    19  * Web Audio spec.
    20  *
    21  * Channel layouts for up to 6 channels:
    22  *   mono   { M }
    23  *   stereo { L, R }
    24  *          { L, R, C }
    25  *   quad   { L, R, SL, SR }
    26  *          { L, R, C, SL, SR }
    27  *   5.1    { L, R, C, LFE, SL, SR }
    28  *
    29  * Only 1, 2, 4 and 6 are currently defined in Web Audio.
    30  */
    32 /**
    33  * Return a channel count whose channel layout includes all the channels from
    34  * aChannels1 and aChannels2.
    35  */
    36 uint32_t
    37 GetAudioChannelsSuperset(uint32_t aChannels1, uint32_t aChannels2);
    39 /**
    40  * Given an array of input channel data, and an output channel count,
    41  * replaces the array with an array of upmixed channels.
    42  * This shuffles the array and may set some channel buffers to aZeroChannel.
    43  * Don't call this with input count >= output count.
    44  * This may return *more* channels than requested. In that case, downmixing
    45  * is required to to get to aOutputChannelCount. (This is how we handle
    46  * odd cases like 3 -> 4 upmixing.)
    47  * If aChannelArray.Length() was the input to one of a series of
    48  * GetAudioChannelsSuperset calls resulting in aOutputChannelCount,
    49  * no downmixing will be required.
    50  */
    51 void
    52 AudioChannelsUpMix(nsTArray<const void*>* aChannelArray,
    53                    uint32_t aOutputChannelCount,
    54                    const void* aZeroChannel);
    56 /**
    57  * Given an array of input channels (which must be float format!),
    58  * downmix to aOutputChannelCount, and copy the results to the
    59  * channel buffers in aOutputChannels.
    60  * Don't call this with input count <= output count.
    61  */
    62 void
    63 AudioChannelsDownMix(const nsTArray<const void*>& aChannelArray,
    64                      float** aOutputChannels,
    65                      uint32_t aOutputChannelCount,
    66                      uint32_t aDuration);
    68 // A version of AudioChannelsDownMix that downmixes int16_ts may be required.
    70 } // namespace mozilla
    72 #endif /* MOZILLA_AUDIOCHANNELFORMAT_H_ */

mercurial