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

Side by Side Diff: media/base/audio_discard_helper.cc

Issue 1260193005: Fix incorrect opus seek preroll and flaky pre-skip removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 5 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/base/audio_discard_helper.h" 5 #include "media/base/audio_discard_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/audio_buffer.h" 10 #include "media/base/audio_buffer.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (discard_frames_ > 0) { 97 if (discard_frames_ > 0) {
98 const size_t decoded_frames = decoded_buffer->frame_count(); 98 const size_t decoded_frames = decoded_buffer->frame_count();
99 const size_t frames_to_discard = std::min(discard_frames_, decoded_frames); 99 const size_t frames_to_discard = std::min(discard_frames_, decoded_frames);
100 discard_frames_ -= frames_to_discard; 100 discard_frames_ -= frames_to_discard;
101 101
102 DVLOG(1) << "Initial discard of " << frames_to_discard << " out of " 102 DVLOG(1) << "Initial discard of " << frames_to_discard << " out of "
103 << decoded_frames << " frames."; 103 << decoded_frames << " frames.";
104 104
105 // If everything would be discarded, indicate a new buffer is required. 105 // If everything would be discarded, indicate a new buffer is required.
106 if (frames_to_discard == decoded_frames) { 106 if (frames_to_discard == decoded_frames) {
107 // For simplicity disallow cases where a buffer with discard padding is 107 // For simplicity, we just drop any discard padding if |discard_frames_|
108 // present. Doing so allows us to avoid complexity around tracking 108 // consumes the entire buffer.
chcunningham 2015/07/31 19:48:44 What about the case where current_discard_padding
DaleCurtis 2015/08/03 22:49:53 That would still be correct, as the initial discar
109 // discards across buffers.
110 DCHECK(current_discard_padding.first == base::TimeDelta());
111 DCHECK(current_discard_padding.second == base::TimeDelta());
112 return false; 109 return false;
113 } 110 }
114 111
115 decoded_buffer->TrimStart(frames_to_discard); 112 decoded_buffer->TrimStart(frames_to_discard);
116 } 113 }
117 114
118 // Process any delayed end discard from the previous buffer. 115 // Process any delayed end discard from the previous buffer.
119 if (delayed_end_discard_ > 0) { 116 if (delayed_end_discard_ > 0) {
120 DCHECK_GT(decoder_delay_, 0u); 117 DCHECK_GT(decoder_delay_, 0u);
121 118
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 DCHECK(current_discard_padding.second == base::TimeDelta()); 229 DCHECK(current_discard_padding.second == base::TimeDelta());
233 } 230 }
234 231
235 // Assign timestamp to the buffer. 232 // Assign timestamp to the buffer.
236 decoded_buffer->set_timestamp(timestamp_helper_.GetTimestamp()); 233 decoded_buffer->set_timestamp(timestamp_helper_.GetTimestamp());
237 timestamp_helper_.AddFrames(decoded_buffer->frame_count()); 234 timestamp_helper_.AddFrames(decoded_buffer->frame_count());
238 return true; 235 return true;
239 } 236 }
240 237
241 } // namespace media 238 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698