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

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

mercurial