Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1226)

Unified Diff: media/filters/audio_renderer_algorithm_ola.h

Issue 151120: OLA Algorithm and test shell. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/audio_renderer_algorithm_ola.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_renderer_algorithm_ola.h
===================================================================
--- media/filters/audio_renderer_algorithm_ola.h (revision 0)
+++ media/filters/audio_renderer_algorithm_ola.h (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// AudioRendererAlgorithmOLA [ARAO] is the pitch-preservation implementation of
+// AudioRendererAlgorithmBase [ARAB]. For speeds greater than 1.0f, FillBuffer()
+// consumes more input data than output data requested and crossfades
+// samples to fill |buffer_out|. For speeds less than 1.0f, FillBuffer()
+// consumers less input data than output data requested and draws overlapping
+// samples from the input data to fill |buffer_out|. As ARAB is thread-unsafe,
+// so is ARAO.
+
+#ifndef MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_OLA_H_
+#define MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_OLA_H_
+
+#include "media/filters/audio_renderer_algorithm_base.h"
+
+namespace media {
+
+class DataBuffer;
+
+class AudioRendererAlgorithmOLA : public AudioRendererAlgorithmBase {
+ public:
+ AudioRendererAlgorithmOLA();
+ virtual ~AudioRendererAlgorithmOLA();
+
+ // AudioRendererAlgorithmBase implementation
+ virtual size_t FillBuffer(DataBuffer* buffer_out);
+
+ virtual void FlushBuffers();
+
+ virtual void set_playback_rate(float new_rate);
+
+ private:
+ // Advances our input position by |bytes| bytes.
+ void AdvanceInput(size_t bytes);
+
+ // Aligns |value| to a channel and sample boundary.
+ void AlignToSampleBoundary(size_t* value);
+
+ // Copies |length| bytes from our buffers to |dest|. Returns how many bytes
+ // of data were copied.
+ size_t CopyInput(uint8* dest, size_t length);
+
+ // Crossfades |samples| samples of |dest| with the data in |src|. Assumes
+ // there is room in |dest| and enough data in |src|. Type is the datatype
+ // of a data point in the waveform (i.e. uint8, int16, int32, etc). Also,
+ // sizeof(one sample) == sizeof(Type) * channels.
+ template <class Type>
+ void Crossfade(int samples, const Type* src, Type* dest);
+
+ // Returns true if |saved_buf_| is NULL and the queue is empty.
+ bool IsInputFinished();
+
+ // Stores the front element of the queue so we can peek at the second one.
+ scoped_refptr<Buffer> saved_buf_;
+
+ // Remembers the amount of remaining audio data for our |saved_buf_|.
+ size_t data_offset_;
+
+ // Members for ease of calculation in FillBuffer(). These members are
+ // based on |playback_rate_|, but are stored seperately so they don't
+ // have to be recalculated on every call to FillBuffer().
+ size_t input_step_;
+ size_t output_step_;
+
+ // Length for crossfade in bytes.
+ size_t crossfade_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioRendererAlgorithmOLA);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_OLA_H_
Property changes on: media\filters\audio_renderer_algorithm_ola.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | media/filters/audio_renderer_algorithm_ola.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698