Bug 955981 - Make function InterleaveTrackData public and static. r=roc
authorShelly Lin <slin@mozilla.com>
Tue, 07 Jan 2014 18:05:05 +0800
changeset 162537 7d434e24be3b990be881554e992710e1ceead673
parent 162536 065cf8a7264576f28c0d949bc6e58ebb251f50b4
child 162538 acdb2a60fdaa75d058f63e0ccc2abb695e71eaa8
push id25958
push userryanvm@gmail.com
push dateWed, 08 Jan 2014 20:22:21 +0000
treeherdermozilla-central@8988416e489d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs955981
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 955981 - Make function InterleaveTrackData public and static. r=roc
content/media/encoder/OpusTrackEncoder.cpp
content/media/encoder/TrackEncoder.cpp
content/media/encoder/TrackEncoder.h
--- a/content/media/encoder/OpusTrackEncoder.cpp
+++ b/content/media/encoder/OpusTrackEncoder.cpp
@@ -282,18 +282,18 @@ OpusTrackEncoder::GetEncodedTrack(Encode
     // Chunk to the required frame size.
     int frameToCopy = chunk.GetDuration();
     if (frameCopied + frameToCopy > GetPacketDuration()) {
       frameToCopy = GetPacketDuration() - frameCopied;
     }
 
     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));
     }
 
     frameCopied += frameToCopy;
     iter.Next();
   }
--- a/content/media/encoder/TrackEncoder.cpp
+++ b/content/media/encoder/TrackEncoder.cpp
@@ -101,34 +101,35 @@ AudioTrackEncoder::AppendAudioSegment(co
   }
 
   return NS_OK;
 }
 
 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,
                                        uint32_t aOutputChannels,
                                        AudioDataValue* aOutput)
 {
   if (aChunk.mChannelData.Length() < aOutputChannels) {
     // Up-mix. This might make the mChannelData have more than aChannels.
     AudioChannelsUpMix(&aChunk.mChannelData, aOutputChannels, gZeroChannel);
   }
 
   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);
   }
 }
 
 void
 VideoTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
                                             TrackID aID,
                                             TrackRate aTrackRate,
                                             TrackTicks aTrackOffset,
--- a/content/media/encoder/TrackEncoder.h
+++ b/content/media/encoder/TrackEncoder.h
@@ -143,16 +143,26 @@ public:
   {}
 
   void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
                                 TrackRate aTrackRate,
                                 TrackTicks aTrackOffset,
                                 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
    * frame size required by audio encoder, and mReentrantMonitor will be
    * notified when at least this much data has been added to mRawSegment.
    */
   virtual int GetPacketDuration() { return 0; }
 
@@ -175,25 +185,16 @@ protected:
 
   /**
    * Notifies the audio encoder that we have reached the end of source stream,
    * and wakes up mReentrantMonitor if encoder is waiting for more track data.
    */
   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
    * the channels in the chunk, downmix PCM stream can be performed.
    * This value also be used to initialize the audio encoder.
    */
   int mChannels;
 
   /**