Bug 955981 - Make function InterleaveTrackData public and static. r=roc

This commit is contained in:
Shelly Lin 2014-01-07 18:05:05 +08:00
parent 5f3ba55496
commit 75b4ffef65
3 changed files with 15 additions and 13 deletions

View File

@ -287,8 +287,8 @@ OpusTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
if (!chunk.IsNull()) { if (!chunk.IsNull()) {
// Append the interleaved data to the end of pcm buffer. // Append the interleaved data to the end of pcm buffer.
InterleaveTrackData(chunk, frameToCopy, mChannels, AudioTrackEncoder::InterleaveTrackData(chunk, frameToCopy, mChannels,
pcm.Elements() + frameCopied * mChannels); pcm.Elements() + frameCopied * mChannels);
} else { } else {
memset(pcm.Elements() + frameCopied * mChannels, 0, memset(pcm.Elements() + frameCopied * mChannels, 0,
frameToCopy * mChannels * sizeof(AudioDataValue)); frameToCopy * mChannels * sizeof(AudioDataValue));

View File

@ -106,6 +106,7 @@ AudioTrackEncoder::AppendAudioSegment(const AudioSegment& aSegment)
static const int AUDIO_PROCESSING_FRAMES = 640; /* > 10ms of 48KHz audio */ static const int AUDIO_PROCESSING_FRAMES = 640; /* > 10ms of 48KHz audio */
static const uint8_t gZeroChannel[MAX_AUDIO_SAMPLE_SIZE*AUDIO_PROCESSING_FRAMES] = {0}; static const uint8_t gZeroChannel[MAX_AUDIO_SAMPLE_SIZE*AUDIO_PROCESSING_FRAMES] = {0};
/*static*/
void void
AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk, AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk,
int32_t aDuration, int32_t aDuration,
@ -119,11 +120,11 @@ AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk,
if (aChunk.mChannelData.Length() > aOutputChannels) { if (aChunk.mChannelData.Length() > aOutputChannels) {
DownmixAndInterleave(aChunk.mChannelData, aChunk.mBufferFormat, aDuration, DownmixAndInterleave(aChunk.mChannelData, aChunk.mBufferFormat, aDuration,
aChunk.mVolume, mChannels, aOutput); aChunk.mVolume, aOutputChannels, aOutput);
} else { } else {
InterleaveAndConvertBuffer(aChunk.mChannelData.Elements(), InterleaveAndConvertBuffer(aChunk.mChannelData.Elements(),
aChunk.mBufferFormat, aDuration, aChunk.mVolume, aChunk.mBufferFormat, aDuration, aChunk.mVolume,
mChannels, aOutput); aOutputChannels, aOutput);
} }
} }

View File

@ -148,6 +148,16 @@ public:
uint32_t aTrackEvents, uint32_t aTrackEvents,
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE; const MediaSegment& aQueuedMedia) MOZ_OVERRIDE;
/**
* Interleaves the track data and stores the result into aOutput. Might need
* to up-mix or down-mix the channel data if the channels number of this chunk
* is different from aOutputChannels. The channel data from aChunk might be
* modified by up-mixing.
*/
static void InterleaveTrackData(AudioChunk& aChunk, int32_t aDuration,
uint32_t aOutputChannels,
AudioDataValue* aOutput);
protected: protected:
/** /**
* Number of samples per channel in a pcm buffer. This is also the value of * Number of samples per channel in a pcm buffer. This is also the value of
@ -179,15 +189,6 @@ protected:
*/ */
virtual void NotifyEndOfStream() MOZ_OVERRIDE; virtual void NotifyEndOfStream() MOZ_OVERRIDE;
/**
* Interleaves the track data and stores the result into aOutput. Might need
* to up-mix or down-mix the channel data if the channels number of this chunk
* is different from mChannels. The channel data from aChunk might be modified
* by up-mixing.
*/
void InterleaveTrackData(AudioChunk& aChunk, int32_t aDuration,
uint32_t aOutputChannels, AudioDataValue* aOutput);
/** /**
* The number of channels are used for processing PCM data in the audio encoder. * The number of channels are used for processing PCM data in the audio encoder.
* This value comes from the first valid audio chunk. If encoder can't support * This value comes from the first valid audio chunk. If encoder can't support