OLD | NEW |
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 <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 DVLOG(1) << "Truncating buffer which overlaps append window start." | 381 DVLOG(1) << "Truncating buffer which overlaps append window start." |
382 << " presentation_timestamp " << buffer->timestamp().InSecondsF() | 382 << " presentation_timestamp " << buffer->timestamp().InSecondsF() |
383 << " frame_end_timestamp " << frame_end_timestamp.InSecondsF() | 383 << " frame_end_timestamp " << frame_end_timestamp.InSecondsF() |
384 << " append_window_start " << append_window_start.InSecondsF(); | 384 << " append_window_start " << append_window_start.InSecondsF(); |
385 | 385 |
386 // Mark the overlapping portion of the buffer for discard. | 386 // Mark the overlapping portion of the buffer for discard. |
387 buffer->set_discard_padding(std::make_pair( | 387 buffer->set_discard_padding(std::make_pair( |
388 append_window_start - buffer->timestamp(), base::TimeDelta())); | 388 append_window_start - buffer->timestamp(), base::TimeDelta())); |
389 | 389 |
390 // Adjust the timestamp of this buffer forward to |append_window_start| and | 390 // Adjust the timestamp of this buffer forward to |append_window_start| and |
391 // decrease the duration to compensate. | 391 // decrease the duration to compensate. Adjust DTS by the same delta as PTS |
| 392 // to help prevent spurious discontinuities when DTS > PTS. |
| 393 base::TimeDelta pts_delta = append_window_start - buffer->timestamp(); |
392 buffer->set_timestamp(append_window_start); | 394 buffer->set_timestamp(append_window_start); |
393 buffer->SetDecodeTimestamp( | 395 buffer->SetDecodeTimestamp(buffer->GetDecodeTimestamp() + pts_delta); |
394 DecodeTimestamp::FromPresentationTime(append_window_start)); | |
395 buffer->set_duration(frame_end_timestamp - append_window_start); | 396 buffer->set_duration(frame_end_timestamp - append_window_start); |
396 processed_buffer = true; | 397 processed_buffer = true; |
397 } | 398 } |
398 | 399 |
399 // See if a partial discard can be done around |append_window_end|. | 400 // See if a partial discard can be done around |append_window_end|. |
400 if (frame_end_timestamp > append_window_end) { | 401 if (frame_end_timestamp > append_window_end) { |
401 DVLOG(1) << "Truncating buffer which overlaps append window end." | 402 DVLOG(1) << "Truncating buffer which overlaps append window end." |
402 << " presentation_timestamp " << buffer->timestamp().InSecondsF() | 403 << " presentation_timestamp " << buffer->timestamp().InSecondsF() |
403 << " frame_end_timestamp " << frame_end_timestamp.InSecondsF() | 404 << " frame_end_timestamp " << frame_end_timestamp.InSecondsF() |
404 << " append_window_end " << append_window_end.InSecondsF(); | 405 << " append_window_end " << append_window_end.InSecondsF(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 DCHECK(group_end_timestamp_ >= base::TimeDelta()); | 696 DCHECK(group_end_timestamp_ >= base::TimeDelta()); |
696 | 697 |
697 return true; | 698 return true; |
698 } | 699 } |
699 | 700 |
700 NOTREACHED(); | 701 NOTREACHED(); |
701 return false; | 702 return false; |
702 } | 703 } |
703 | 704 |
704 } // namespace media | 705 } // namespace media |
OLD | NEW |