| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ffmpeg_video_decoder.h" | 5 #include "media/filters/ffmpeg_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (threads.empty() || !base::StringToInt(threads, &decode_threads)) | 49 if (threads.empty() || !base::StringToInt(threads, &decode_threads)) |
| 50 return decode_threads; | 50 return decode_threads; |
| 51 | 51 |
| 52 decode_threads = std::max(decode_threads, 0); | 52 decode_threads = std::max(decode_threads, 0); |
| 53 decode_threads = std::min(decode_threads, kMaxDecodeThreads); | 53 decode_threads = std::min(decode_threads, kMaxDecodeThreads); |
| 54 return decode_threads; | 54 return decode_threads; |
| 55 } | 55 } |
| 56 | 56 |
| 57 FFmpegVideoDecoder::FFmpegVideoDecoder( | 57 FFmpegVideoDecoder::FFmpegVideoDecoder( |
| 58 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 58 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
| 59 : task_runner_(task_runner), | 59 : task_runner_(task_runner), state_(kUninitialized), weak_factory_(this) {} |
| 60 weak_factory_(this), | |
| 61 state_(kUninitialized) { | |
| 62 } | |
| 63 | 60 |
| 64 int FFmpegVideoDecoder::GetVideoBuffer(AVCodecContext* codec_context, | 61 int FFmpegVideoDecoder::GetVideoBuffer(AVCodecContext* codec_context, |
| 65 AVFrame* frame) { | 62 AVFrame* frame) { |
| 66 // Don't use |codec_context_| here! With threaded decoding, | 63 // Don't use |codec_context_| here! With threaded decoding, |
| 67 // it will contain unsynchronized width/height/pix_fmt values, | 64 // it will contain unsynchronized width/height/pix_fmt values, |
| 68 // whereas |codec_context| contains the current threads's | 65 // whereas |codec_context| contains the current threads's |
| 69 // updated width/height/pix_fmt, which can change for adaptive | 66 // updated width/height/pix_fmt, which can change for adaptive |
| 70 // content. | 67 // content. |
| 71 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); | 68 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); |
| 72 if (format == VideoFrame::UNKNOWN) | 69 if (format == VideoFrame::UNKNOWN) |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 375 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 379 ReleaseFFmpegResources(); | 376 ReleaseFFmpegResources(); |
| 380 return false; | 377 return false; |
| 381 } | 378 } |
| 382 | 379 |
| 383 av_frame_.reset(av_frame_alloc()); | 380 av_frame_.reset(av_frame_alloc()); |
| 384 return true; | 381 return true; |
| 385 } | 382 } |
| 386 | 383 |
| 387 } // namespace media | 384 } // namespace media |
| OLD | NEW |