| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/video_frame_impl.h" | 5 #include "media/base/video_frame_impl.h" |
| 6 #include "media/filters/ffmpeg_common.h" | 6 #include "media/filters/ffmpeg_common.h" |
| 7 #include "media/filters/ffmpeg_demuxer.h" | 7 #include "media/filters/ffmpeg_demuxer.h" |
| 8 #include "media/filters/ffmpeg_video_decoder.h" | 8 #include "media/filters/ffmpeg_video_decoder.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if (frame && | 299 if (frame && |
| 300 (frame->pts != static_cast<int64_t>(AV_NOPTS_VALUE)) && | 300 (frame->pts != static_cast<int64_t>(AV_NOPTS_VALUE)) && |
| 301 (frame->pts != 0)) { | 301 (frame->pts != 0)) { |
| 302 pts.timestamp = ConvertTimestamp(time_base, frame->pts); | 302 pts.timestamp = ConvertTimestamp(time_base, frame->pts); |
| 303 repeat_pict = frame->repeat_pict; | 303 repeat_pict = frame->repeat_pict; |
| 304 } else if (!pts_queue.empty()) { | 304 } else if (!pts_queue.empty()) { |
| 305 // If the frame did not have pts, try to get the pts from the | 305 // If the frame did not have pts, try to get the pts from the |
| 306 // |pts_queue_|. | 306 // |pts_queue_|. |
| 307 pts.timestamp = pts_queue.top(); | 307 pts.timestamp = pts_queue.top(); |
| 308 } else { | 308 } else { |
| 309 DCHECK(last_pts.timestamp != StreamSample::kInvalidTimestamp); |
| 310 DCHECK(last_pts.duration != StreamSample::kInvalidTimestamp); |
| 309 // Unable to read the pts from anywhere. Time to guess. | 311 // Unable to read the pts from anywhere. Time to guess. |
| 310 pts.timestamp = last_pts.timestamp + last_pts.duration; | 312 pts.timestamp = last_pts.timestamp + last_pts.duration; |
| 311 } | 313 } |
| 312 | 314 |
| 313 // Fill in the duration while accounting for repeated frames. | 315 // Fill in the duration while accounting for repeated frames. |
| 314 // | 316 // |
| 315 // TODO(ajwong): Make sure this formula is correct. | 317 // TODO(ajwong): Make sure this formula is correct. |
| 316 pts.duration = ConvertTimestamp(time_base, 1 + repeat_pict); | 318 pts.duration = ConvertTimestamp(time_base, 1 + repeat_pict); |
| 317 | 319 |
| 318 return pts; | 320 return pts; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 346 // static | 348 // static |
| 347 bool FFmpegVideoDecoder::PtsHeapOrdering::operator()( | 349 bool FFmpegVideoDecoder::PtsHeapOrdering::operator()( |
| 348 const base::TimeDelta& lhs, | 350 const base::TimeDelta& lhs, |
| 349 const base::TimeDelta& rhs) const { | 351 const base::TimeDelta& rhs) const { |
| 350 // std::priority_queue is a max-heap. We want lower timestamps to show up | 352 // std::priority_queue is a max-heap. We want lower timestamps to show up |
| 351 // first so reverse the natural less-than comparison. | 353 // first so reverse the natural less-than comparison. |
| 352 return rhs < lhs; | 354 return rhs < lhs; |
| 353 } | 355 } |
| 354 | 356 |
| 355 } // namespace | 357 } // namespace |
| OLD | NEW |