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

Side by Side Diff: media/filters/audio_renderer_algorithm.cc

Issue 205093002: Remove muting for extreme playbackRates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/audio_renderer_algorithm.h" 5 #include "media/filters/audio_renderer_algorithm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 28 matching lines...) Expand all
39 // 39 //
40 // 5) Overlap-and-add |optimal_block_| to the |wsola_output_|. 40 // 5) Overlap-and-add |optimal_block_| to the |wsola_output_|.
41 // 41 //
42 // 6) Update: 42 // 6) Update:
43 // |target_block_| = |optimal_index| + |ola_window_size_| / 2. 43 // |target_block_| = |optimal_index| + |ola_window_size_| / 2.
44 // |output_index_| = |output_index_| + |ola_window_size_| / 2, 44 // |output_index_| = |output_index_| + |ola_window_size_| / 2,
45 // |search_block_center_offset_| = |output_index_| * |playback_rate_|, and 45 // |search_block_center_offset_| = |output_index_| * |playback_rate_|, and
46 // |search_block_index_| = |search_block_center_offset_| - 46 // |search_block_index_| = |search_block_center_offset_| -
47 // |search_block_center_offset_|. 47 // |search_block_center_offset_|.
48 48
49 // Max/min supported playback rates for fast/slow audio. Audio outside of these
50 // ranges are muted.
51 // Audio at these speeds would sound better under a frequency domain algorithm.
scherkus (not reviewing) 2014/03/19 19:44:27 FYI I don't believe this comment is necessarily tr
52 static const float kMinPlaybackRate = 0.5f;
53 static const float kMaxPlaybackRate = 4.0f;
54
55 // Overlap-and-add window size in milliseconds. 49 // Overlap-and-add window size in milliseconds.
56 static const int kOlaWindowSizeMs = 20; 50 static const int kOlaWindowSizeMs = 20;
57 51
58 // Size of search interval in milliseconds. The search interval is 52 // Size of search interval in milliseconds. The search interval is
59 // [-delta delta] around |output_index_| * |playback_rate_|. So the search 53 // [-delta delta] around |output_index_| * |playback_rate_|. So the search
60 // interval is 2 * delta. 54 // interval is 2 * delta.
61 static const int kWsolaSearchIntervalMs = 30; 55 static const int kWsolaSearchIntervalMs = 30;
62 56
63 // The maximum size in seconds for the |audio_buffer_|. Arbitrarily determined. 57 // The maximum size in seconds for the |audio_buffer_|. Arbitrarily determined.
64 static const int kMaxCapacityInSeconds = 3; 58 static const int kMaxCapacityInSeconds = 3;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 do { 187 do {
194 rendered_frames += WriteCompletedFramesTo( 188 rendered_frames += WriteCompletedFramesTo(
195 requested_frames - rendered_frames, rendered_frames, dest); 189 requested_frames - rendered_frames, rendered_frames, dest);
196 } while (rendered_frames < requested_frames && RunOneWsolaIteration()); 190 } while (rendered_frames < requested_frames && RunOneWsolaIteration());
197 return rendered_frames; 191 return rendered_frames;
198 } 192 }
199 193
200 void AudioRendererAlgorithm::SetPlaybackRate(float new_rate) { 194 void AudioRendererAlgorithm::SetPlaybackRate(float new_rate) {
201 DCHECK_GE(new_rate, 0); 195 DCHECK_GE(new_rate, 0);
202 playback_rate_ = new_rate; 196 playback_rate_ = new_rate;
203 muted_ = 197 muted_ = new_rate == 0.0f;
scherkus (not reviewing) 2014/03/19 19:44:27 dalecurtis: can we rip out all the |muted_| relate
204 playback_rate_ < kMinPlaybackRate || playback_rate_ > kMaxPlaybackRate;
205 } 198 }
206 199
207 void AudioRendererAlgorithm::FlushBuffers() { 200 void AudioRendererAlgorithm::FlushBuffers() {
208 // Clear the queue of decoded packets (releasing the buffers). 201 // Clear the queue of decoded packets (releasing the buffers).
209 audio_buffer_.Clear(); 202 audio_buffer_.Clear();
210 output_time_ = 0.0; 203 output_time_ = 0.0;
211 search_block_index_ = 0; 204 search_block_index_ = 0;
212 target_block_index_ = 0; 205 target_block_index_ = 0;
213 wsola_output_->Zero(); 206 wsola_output_->Zero();
214 num_complete_frames_ = 0; 207 num_complete_frames_ = 0;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 read_offset_frames = 0; 380 read_offset_frames = 0;
388 num_frames_to_read -= num_zero_frames_appended; 381 num_frames_to_read -= num_zero_frames_appended;
389 write_offset = num_zero_frames_appended; 382 write_offset = num_zero_frames_appended;
390 dest->ZeroFrames(num_zero_frames_appended); 383 dest->ZeroFrames(num_zero_frames_appended);
391 } 384 }
392 audio_buffer_.PeekFrames(num_frames_to_read, read_offset_frames, 385 audio_buffer_.PeekFrames(num_frames_to_read, read_offset_frames,
393 write_offset, dest); 386 write_offset, dest);
394 } 387 }
395 388
396 } // namespace media 389 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698