| 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 26 matching lines...) Expand all Loading... |
| 37 // Yet another reason for having two threads :) | 37 // Yet another reason for having two threads :) |
| 38 static const int kDecodeThreads = 2; | 38 static const int kDecodeThreads = 2; |
| 39 static const int kMaxDecodeThreads = 16; | 39 static const int kMaxDecodeThreads = 16; |
| 40 | 40 |
| 41 // Returns the number of threads given the FFmpeg CodecID. Also inspects the | 41 // Returns the number of threads given the FFmpeg CodecID. Also inspects the |
| 42 // command line for a valid --video-threads flag. | 42 // command line for a valid --video-threads flag. |
| 43 static int GetThreadCount(AVCodecID codec_id) { | 43 static int GetThreadCount(AVCodecID codec_id) { |
| 44 // Refer to http://crbug.com/93932 for tsan suppressions on decoding. | 44 // Refer to http://crbug.com/93932 for tsan suppressions on decoding. |
| 45 int decode_threads = kDecodeThreads; | 45 int decode_threads = kDecodeThreads; |
| 46 | 46 |
| 47 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 47 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 48 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); | 48 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); |
| 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 static int GetVideoBufferImpl(struct AVCodecContext* s, | 57 static int GetVideoBufferImpl(struct AVCodecContext* s, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 345 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 346 ReleaseFFmpegResources(); | 346 ReleaseFFmpegResources(); |
| 347 return false; | 347 return false; |
| 348 } | 348 } |
| 349 | 349 |
| 350 av_frame_.reset(av_frame_alloc()); | 350 av_frame_.reset(av_frame_alloc()); |
| 351 return true; | 351 return true; |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace media | 354 } // namespace media |
| OLD | NEW |