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

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

Issue 294393002: MSE: Allow fully discarding frames with resulting timestamps below 0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix PS4 nit (FullDiscard -> P) Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/frame_processor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/filters/frame_processor.h" 5 #include "media/filters/frame_processor.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 #include "media/base/stream_parser_buffer.h" 9 #include "media/base/stream_parser_buffer.h"
10 10
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // 7.2. - 7.5.: 231 // 7.2. - 7.5.:
232 Reset(); 232 Reset();
233 233
234 // 7.6. Jump to the Loop Top step above to restart processing of the 234 // 7.6. Jump to the Loop Top step above to restart processing of the
235 // current coded frame. 235 // current coded frame.
236 DVLOG(3) << __FUNCTION__ << ": Discontinuity: reprocessing frame"; 236 DVLOG(3) << __FUNCTION__ << ": Discontinuity: reprocessing frame";
237 continue; 237 continue;
238 } 238 }
239 } 239 }
240 240
241 // 8. If the presentation timestamp or decode timestamp is less than the
242 // presentation start time, then run the end of stream algorithm with the
243 // error parameter set to "decode", and abort these steps.
244 if (presentation_timestamp < base::TimeDelta() ||
245 decode_timestamp < base::TimeDelta()) {
246 DVLOG(2) << __FUNCTION__
247 << ": frame PTS=" << presentation_timestamp.InSecondsF()
248 << " or DTS=" << decode_timestamp.InSecondsF()
249 << " negative after applying timestampOffset and handling any "
250 << " discontinuity";
251 return false;
252 }
253
254 // 9. Let frame end timestamp equal the sum of presentation timestamp and 241 // 9. Let frame end timestamp equal the sum of presentation timestamp and
255 // frame duration. 242 // frame duration.
256 const base::TimeDelta frame_end_timestamp = 243 const base::TimeDelta frame_end_timestamp =
257 presentation_timestamp + frame_duration; 244 presentation_timestamp + frame_duration;
258 245
259 // 10. If presentation timestamp is less than appendWindowStart, then set 246 // 10. If presentation timestamp is less than appendWindowStart, then set
260 // the need random access point flag to true, drop the coded frame, and 247 // the need random access point flag to true, drop the coded frame, and
261 // jump to the top of the loop to start processing the next coded 248 // jump to the top of the loop to start processing the next coded
262 // frame. 249 // frame.
263 // Note: We keep the result of partial discard of a buffer that overlaps 250 // Note: We keep the result of partial discard of a buffer that overlaps
(...skipping 29 matching lines...) Expand all
293 if (!sequence_mode_) { 280 if (!sequence_mode_) {
294 // This also triggers a discontinuity so we need to treat the next 281 // This also triggers a discontinuity so we need to treat the next
295 // frames appended within the append window as if they were the 282 // frames appended within the append window as if they were the
296 // beginning of a new segment. 283 // beginning of a new segment.
297 *new_media_segment = true; 284 *new_media_segment = true;
298 } 285 }
299 286
300 return true; 287 return true;
301 } 288 }
302 289
290 // Note: This step is relocated, versus April 1 spec, to allow append window
291 // processing to first filter coded frames shifted by |timestamp_offset_| in
292 // such a way that their PTS is negative.
293 // 8. If the presentation timestamp or decode timestamp is less than the
294 // presentation start time, then run the end of stream algorithm with the
295 // error parameter set to "decode", and abort these steps.
296 DCHECK(presentation_timestamp >= base::TimeDelta());
297 if (decode_timestamp < base::TimeDelta()) {
298 // B-frames may still result in negative DTS here after being shifted by
299 // |timestamp_offset_|.
300 DVLOG(2) << __FUNCTION__
301 << ": frame PTS=" << presentation_timestamp.InSecondsF()
302 << " has negative DTS=" << decode_timestamp.InSecondsF()
303 << " after applying timestampOffset, handling any discontinuity,"
304 << " and filtering against append window";
305 return false;
306 }
307
303 // 12. If the need random access point flag on track buffer equals true, 308 // 12. If the need random access point flag on track buffer equals true,
304 // then run the following steps: 309 // then run the following steps:
305 if (track_buffer->needs_random_access_point()) { 310 if (track_buffer->needs_random_access_point()) {
306 // 12.1. If the coded frame is not a random access point, then drop the 311 // 12.1. If the coded frame is not a random access point, then drop the
307 // coded frame and jump to the top of the loop to start processing 312 // coded frame and jump to the top of the loop to start processing
308 // the next coded frame. 313 // the next coded frame.
309 if (!frame->IsKeyframe()) { 314 if (!frame->IsKeyframe()) {
310 DVLOG(3) << __FUNCTION__ 315 DVLOG(3) << __FUNCTION__
311 << ": Dropping frame that is not a random access point"; 316 << ": Dropping frame that is not a random access point";
312 return true; 317 return true;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 349
345 // 21. If highest presentation timestamp for track buffer is unset or frame 350 // 21. If highest presentation timestamp for track buffer is unset or frame
346 // end timestamp is greater than highest presentation timestamp, then 351 // end timestamp is greater than highest presentation timestamp, then
347 // set highest presentation timestamp for track buffer to frame end 352 // set highest presentation timestamp for track buffer to frame end
348 // timestamp. 353 // timestamp.
349 track_buffer->SetHighestPresentationTimestampIfIncreased( 354 track_buffer->SetHighestPresentationTimestampIfIncreased(
350 frame_end_timestamp); 355 frame_end_timestamp);
351 356
352 // 22. If frame end timestamp is greater than group end timestamp, then set 357 // 22. If frame end timestamp is greater than group end timestamp, then set
353 // group end timestamp equal to frame end timestamp. 358 // group end timestamp equal to frame end timestamp.
354 DCHECK(group_end_timestamp_ >= base::TimeDelta());
355 if (frame_end_timestamp > group_end_timestamp_) 359 if (frame_end_timestamp > group_end_timestamp_)
356 group_end_timestamp_ = frame_end_timestamp; 360 group_end_timestamp_ = frame_end_timestamp;
361 DCHECK(group_end_timestamp_ >= base::TimeDelta());
357 362
358 return true; 363 return true;
359 } 364 }
360 365
361 NOTREACHED(); 366 NOTREACHED();
362 return false; 367 return false;
363 } 368 }
364 369
365 void FrameProcessor::SetAllTrackBuffersNeedRandomAccessPoint() { 370 void FrameProcessor::SetAllTrackBuffersNeedRandomAccessPoint() {
366 for (TrackBufferMap::iterator itr = track_buffers_.begin(); 371 for (TrackBufferMap::iterator itr = track_buffers_.begin();
367 itr != track_buffers_.end(); ++itr) { 372 itr != track_buffers_.end(); ++itr) {
368 itr->second->set_needs_random_access_point(true); 373 itr->second->set_needs_random_access_point(true);
369 } 374 }
370 } 375 }
371 376
372 } // namespace media 377 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/frame_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698