From 75b4ffef6507a82e58cdd0cc844561e08b0d188b Mon Sep 17 00:00:00 2001 From: Shelly Lin Date: Tue, 7 Jan 2014 18:05:05 +0800 Subject: [PATCH] Bug 955981 - Make function InterleaveTrackData public and static. r=roc --- content/media/encoder/OpusTrackEncoder.cpp | 4 ++-- content/media/encoder/TrackEncoder.cpp | 5 +++-- content/media/encoder/TrackEncoder.h | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/content/media/encoder/OpusTrackEncoder.cpp b/content/media/encoder/OpusTrackEncoder.cpp index 8ddedc170ab8..e1ce627feac5 100644 --- a/content/media/encoder/OpusTrackEncoder.cpp +++ b/content/media/encoder/OpusTrackEncoder.cpp @@ -287,8 +287,8 @@ OpusTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData) if (!chunk.IsNull()) { // Append the interleaved data to the end of pcm buffer. - InterleaveTrackData(chunk, frameToCopy, mChannels, - pcm.Elements() + frameCopied * mChannels); + AudioTrackEncoder::InterleaveTrackData(chunk, frameToCopy, mChannels, + pcm.Elements() + frameCopied * mChannels); } else { memset(pcm.Elements() + frameCopied * mChannels, 0, frameToCopy * mChannels * sizeof(AudioDataValue)); diff --git a/content/media/encoder/TrackEncoder.cpp b/content/media/encoder/TrackEncoder.cpp index fdecba8eeb8c..42df784445ee 100644 --- a/content/media/encoder/TrackEncoder.cpp +++ b/content/media/encoder/TrackEncoder.cpp @@ -106,6 +106,7 @@ AudioTrackEncoder::AppendAudioSegment(const AudioSegment& aSegment) 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*/ void AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk, int32_t aDuration, @@ -119,11 +120,11 @@ AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk, if (aChunk.mChannelData.Length() > aOutputChannels) { DownmixAndInterleave(aChunk.mChannelData, aChunk.mBufferFormat, aDuration, - aChunk.mVolume, mChannels, aOutput); + aChunk.mVolume, aOutputChannels, aOutput); } else { InterleaveAndConvertBuffer(aChunk.mChannelData.Elements(), aChunk.mBufferFormat, aDuration, aChunk.mVolume, - mChannels, aOutput); + aOutputChannels, aOutput); } } diff --git a/content/media/encoder/TrackEncoder.h b/content/media/encoder/TrackEncoder.h index 3602d09744ab..f322fc93126f 100644 --- a/content/media/encoder/TrackEncoder.h +++ b/content/media/encoder/TrackEncoder.h @@ -148,6 +148,16 @@ public: uint32_t aTrackEvents, 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: /** * 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; - /** - * 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. * This value comes from the first valid audio chunk. If encoder can't support