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

Unified Diff: media/base/audio_buffer.cc

Issue 156783003: Enhance AudioSplicer to crossfade marked splice frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More tests. Created 6 years, 10 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/base/audio_splicer.h » ('j') | media/base/audio_splicer.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_buffer.cc
diff --git a/media/base/audio_buffer.cc b/media/base/audio_buffer.cc
index 0bf37209b2b66489ff568547e5a4b9f363415c76..f21772ad6729501f7a651894824b5d420e5f584c 100644
--- a/media/base/audio_buffer.cc
+++ b/media/base/audio_buffer.cc
@@ -4,6 +4,8 @@
#include "media/base/audio_buffer.h"
+#include <cmath>
+
#include "base/logging.h"
#include "media/base/audio_bus.h"
#include "media/base/buffers.h"
@@ -220,10 +222,9 @@ void AudioBuffer::TrimStart(int frames_to_trim) {
CHECK_LE(frames_to_trim, adjusted_frame_count_);
// Adjust timestamp_ and duration_ to reflect the smaller number of frames.
- double offset = static_cast<double>(duration_.InMicroseconds()) *
- frames_to_trim / adjusted_frame_count_;
- base::TimeDelta offset_as_time =
- base::TimeDelta::FromMicroseconds(static_cast<int64>(offset));
+ const base::TimeDelta offset_as_time = base::TimeDelta::FromMicroseconds(
+ floor(static_cast<double>(duration_.InMicroseconds()) * frames_to_trim /
acolwell GONE FROM CHROMIUM 2014/02/24 21:46:11 nit: Why can't you use (duration_ * frames_to_trim
DaleCurtis 2014/02/26 02:38:45 Removed in favor of using the AudioTimestampHelper
+ adjusted_frame_count_));
timestamp_ += offset_as_time;
duration_ -= offset_as_time;
@@ -238,11 +239,9 @@ void AudioBuffer::TrimEnd(int frames_to_trim) {
CHECK_LE(frames_to_trim, adjusted_frame_count_);
// Adjust duration_ only to reflect the smaller number of frames.
- double offset = static_cast<double>(duration_.InMicroseconds()) *
- frames_to_trim / adjusted_frame_count_;
- base::TimeDelta offset_as_time =
- base::TimeDelta::FromMicroseconds(static_cast<int64>(offset));
- duration_ -= offset_as_time;
+ duration_ -= base::TimeDelta::FromMicroseconds(
acolwell GONE FROM CHROMIUM 2014/02/24 21:46:11 Why does this computation differ from the one abov
DaleCurtis 2014/02/26 02:38:45 Ditto.
+ ceil(static_cast<double>(duration_.InMicroseconds()) * frames_to_trim /
+ adjusted_frame_count_));
// Finally adjust the number of frames in this buffer.
adjusted_frame_count_ -= frames_to_trim;
« no previous file with comments | « no previous file | media/base/audio_splicer.h » ('j') | media/base/audio_splicer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698