OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/video/ffmpeg_video_decode_engine.h" | 5 #include "media/video/ffmpeg_video_decode_engine.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 // Enable motion vector search (potentially slow), strong deblocking filter | 79 // Enable motion vector search (potentially slow), strong deblocking filter |
80 // for damaged macroblocks, and set our error detection sensitivity. | 80 // for damaged macroblocks, and set our error detection sensitivity. |
81 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; | 81 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; |
82 codec_context_->error_recognition = FF_ER_CAREFUL; | 82 codec_context_->error_recognition = FF_ER_CAREFUL; |
83 | 83 |
84 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); | 84 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); |
85 | 85 |
86 // TODO(fbarchard): Improve thread logic based on size / codec. | 86 // TODO(fbarchard): Improve thread logic based on size / codec. |
87 // TODO(fbarchard): Fix bug affecting video-cookie.html | 87 // TODO(fbarchard): Fix bug affecting video-cookie.html |
88 int decode_threads = (codec_context_->codec_id == CODEC_ID_THEORA) ? | 88 int decode_threads = (codec_context_->codec_id == CODEC_ID_THEORA) ? |
89 1 : kDecodeThreads; | 89 1 : kDecodeThreads; |
fbarchard
2011/06/29 22:21:06
Can you test if this is still necessary?
ilja
2011/06/30 01:28:58
I tried and it seems it is not. But we leave this
| |
90 | 90 |
91 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 91 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
92 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); | 92 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); |
93 if ((!threads.empty() && | 93 if ((!threads.empty() && |
94 !base::StringToInt(threads, &decode_threads)) || | 94 !base::StringToInt(threads, &decode_threads)) || |
95 decode_threads < 0 || decode_threads > kMaxDecodeThreads) { | 95 decode_threads < 0 || decode_threads > kMaxDecodeThreads) { |
96 decode_threads = kDecodeThreads; | 96 decode_threads = kDecodeThreads; |
97 } | 97 } |
98 | 98 |
99 // We don't allocate AVFrame on the stack since different versions of FFmpeg | 99 // We don't allocate AVFrame on the stack since different versions of FFmpeg |
(...skipping 20 matching lines...) Expand all Loading... | |
120 config.height(), | 120 config.height(), |
121 kNoTimestamp, | 121 kNoTimestamp, |
122 kNoTimestamp, | 122 kNoTimestamp, |
123 &video_frame); | 123 &video_frame); |
124 if (!video_frame.get()) { | 124 if (!video_frame.get()) { |
125 buffer_allocated = false; | 125 buffer_allocated = false; |
126 break; | 126 break; |
127 } | 127 } |
128 frame_queue_available_.push_back(video_frame); | 128 frame_queue_available_.push_back(video_frame); |
129 } | 129 } |
130 | 130 codec_context_->thread_count = decode_threads; |
131 if (codec && | 131 if (codec && |
132 avcodec_thread_init(codec_context_, decode_threads) >= 0 && | |
133 avcodec_open(codec_context_, codec) >= 0 && | 132 avcodec_open(codec_context_, codec) >= 0 && |
134 av_frame_.get() && | 133 av_frame_.get() && |
135 buffer_allocated) { | 134 buffer_allocated) { |
136 info.success = true; | 135 info.success = true; |
137 } | 136 } |
138 event_handler_ = event_handler; | 137 event_handler_ = event_handler; |
139 event_handler_->OnInitializeComplete(info); | 138 event_handler_->OnInitializeComplete(info); |
140 } | 139 } |
141 | 140 |
142 // TODO(scherkus): Move this function to a utility class and unit test. | 141 // TODO(scherkus): Move this function to a utility class and unit test. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 break; | 356 break; |
358 } | 357 } |
359 return VideoFrame::INVALID; | 358 return VideoFrame::INVALID; |
360 } | 359 } |
361 | 360 |
362 } // namespace media | 361 } // namespace media |
363 | 362 |
364 // Disable refcounting for this object because this object only lives | 363 // Disable refcounting for this object because this object only lives |
365 // on the video decoder thread and there's no need to refcount it. | 364 // on the video decoder thread and there's no need to refcount it. |
366 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::FFmpegVideoDecodeEngine); | 365 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::FFmpegVideoDecodeEngine); |
OLD | NEW |