| 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/limits.h" | 5 #include "media/base/limits.h" |
| 6 #include "media/base/video_frame_impl.h" | 6 #include "media/base/video_frame_impl.h" |
| 7 #include "media/filters/ffmpeg_common.h" | 7 #include "media/filters/ffmpeg_common.h" |
| 8 #include "media/filters/ffmpeg_demuxer.h" | 8 #include "media/filters/ffmpeg_demuxer.h" |
| 9 #include "media/filters/ffmpeg_video_decoder.h" | 9 #include "media/filters/ffmpeg_video_decoder.h" |
| 10 | 10 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (state_ == kFlushCodec) { | 188 if (state_ == kFlushCodec) { |
| 189 state_ = kDecodeFinished; | 189 state_ = kDecodeFinished; |
| 190 EnqueueEmptyFrame(); | 190 EnqueueEmptyFrame(); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 bool FFmpegVideoDecoder::EnqueueVideoFrame(VideoSurface::Format surface_format, | 195 bool FFmpegVideoDecoder::EnqueueVideoFrame(VideoSurface::Format surface_format, |
| 196 const TimeTuple& time, | 196 const TimeTuple& time, |
| 197 const AVFrame* frame) { | 197 const AVFrame* frame) { |
| 198 // TODO(fbarchard): Work around for FFmpeg http://crbug.com/27675 |
| 199 // The decoder is in a bad state and not decoding correctly. |
| 200 // Checking for NULL avoids a crash in CopyPlane(). |
| 201 if (!frame->data[VideoSurface::kYPlane] || |
| 202 !frame->data[VideoSurface::kUPlane] || |
| 203 !frame->data[VideoSurface::kVPlane]) { |
| 204 return true; |
| 205 } |
| 206 |
| 198 scoped_refptr<VideoFrame> video_frame; | 207 scoped_refptr<VideoFrame> video_frame; |
| 199 VideoFrameImpl::CreateFrame(surface_format, width_, height_, | 208 VideoFrameImpl::CreateFrame(surface_format, width_, height_, |
| 200 time.timestamp, time.duration, &video_frame); | 209 time.timestamp, time.duration, &video_frame); |
| 201 if (!video_frame) { | 210 if (!video_frame) { |
| 202 return false; | 211 return false; |
| 203 } | 212 } |
| 204 | 213 |
| 205 // Copy the frame data since FFmpeg reuses internal buffers for AVFrame | 214 // Copy the frame data since FFmpeg reuses internal buffers for AVFrame |
| 206 // output, meaning the data is only valid until the next | 215 // output, meaning the data is only valid until the next |
| 207 // avcodec_decode_video() call. | 216 // avcodec_decode_video() call. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // static | 361 // static |
| 353 bool FFmpegVideoDecoder::PtsHeapOrdering::operator()( | 362 bool FFmpegVideoDecoder::PtsHeapOrdering::operator()( |
| 354 const base::TimeDelta& lhs, | 363 const base::TimeDelta& lhs, |
| 355 const base::TimeDelta& rhs) const { | 364 const base::TimeDelta& rhs) const { |
| 356 // std::priority_queue is a max-heap. We want lower timestamps to show up | 365 // std::priority_queue is a max-heap. We want lower timestamps to show up |
| 357 // first so reverse the natural less-than comparison. | 366 // first so reverse the natural less-than comparison. |
| 358 return rhs < lhs; | 367 return rhs < lhs; |
| 359 } | 368 } |
| 360 | 369 |
| 361 } // namespace | 370 } // namespace |
| OLD | NEW |