| 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/vpx_video_decoder.h" | 5 #include "media/filters/vpx_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 static const int kMaxDecodeThreads = 16; | 46 static const int kMaxDecodeThreads = 16; |
| 47 | 47 |
| 48 // Returns the number of threads. | 48 // Returns the number of threads. |
| 49 static int GetThreadCount(const VideoDecoderConfig& config) { | 49 static int GetThreadCount(const VideoDecoderConfig& config) { |
| 50 // Refer to http://crbug.com/93932 for tsan suppressions on decoding. | 50 // Refer to http://crbug.com/93932 for tsan suppressions on decoding. |
| 51 int decode_threads = kDecodeThreads; | 51 int decode_threads = kDecodeThreads; |
| 52 | 52 |
| 53 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 53 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 54 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); | 54 std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads)); |
| 55 if (threads.empty() || !base::StringToInt(threads, &decode_threads)) { | 55 if (threads.empty() || !base::StringToInt(threads, &decode_threads)) { |
| 56 if (config.codec() == kCodecVP9) { | 56 // if (config.codec() == kCodecVP9) { |
| 57 // For VP9 decode when using the default thread count, increase the number | 57 // // For VP9 decode when using the default thread count, increase the num
ber |
| 58 // of decode threads to equal the maximum number of tiles possible for | 58 // // of decode threads to equal the maximum number of tiles possible for |
| 59 // higher resolution streams. | 59 // // higher resolution streams. |
| 60 if (config.coded_size().width() >= 2048) | 60 // if (config.coded_size().width() >= 2048) |
| 61 decode_threads = 8; | 61 // decode_threads = 8; |
| 62 else if (config.coded_size().width() >= 1024) | 62 // else if (config.coded_size().width() >= 1024) |
| 63 decode_threads = 4; | 63 // decode_threads = 4; |
| 64 } | 64 // } |
| 65 | 65 |
| 66 return decode_threads; | 66 return decode_threads; |
| 67 } | 67 } |
| 68 | 68 |
| 69 decode_threads = std::max(decode_threads, 0); | 69 decode_threads = std::max(decode_threads, 0); |
| 70 decode_threads = std::min(decode_threads, kMaxDecodeThreads); | 70 decode_threads = std::min(decode_threads, kMaxDecodeThreads); |
| 71 return decode_threads; | 71 return decode_threads; |
| 72 } | 72 } |
| 73 | 73 |
| 74 class VpxVideoDecoder::MemoryPool | 74 class VpxVideoDecoder::MemoryPool |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 0); | 243 0); |
| 244 if (status != VPX_CODEC_OK) { | 244 if (status != VPX_CODEC_OK) { |
| 245 LOG(ERROR) << "vpx_codec_dec_init failed, status=" << status; | 245 LOG(ERROR) << "vpx_codec_dec_init failed, status=" << status; |
| 246 delete context; | 246 delete context; |
| 247 return NULL; | 247 return NULL; |
| 248 } | 248 } |
| 249 return context; | 249 return context; |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool VpxVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config) { | 252 bool VpxVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config) { |
| 253 if (config.codec() != kCodecVP8 && config.codec() != kCodecVP9) | 253 if (config.codec() != kCodecVP8) |
| 254 return false; | 254 return false; |
| 255 | 255 |
| 256 // In VP8 videos, only those with alpha are handled by VpxVideoDecoder. All | 256 // In VP8 videos, only those with alpha are handled by VpxVideoDecoder. All |
| 257 // other VP8 videos go to FFmpegVideoDecoder. | 257 // other VP8 videos go to FFmpegVideoDecoder. |
| 258 if (config.codec() == kCodecVP8 && config.format() != VideoFrame::YV12A) | 258 if (config.codec() == kCodecVP8 && config.format() != VideoFrame::YV12A) |
| 259 return false; | 259 return false; |
| 260 | 260 |
| 261 CloseDecoder(); | 261 CloseDecoder(); |
| 262 | 262 |
| 263 vpx_codec_ = InitializeVpxContext(vpx_codec_, config); | 263 vpx_codec_ = InitializeVpxContext(vpx_codec_, config); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 276 return false; | 276 return false; |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 if (config.format() == VideoFrame::YV12A) { | 280 if (config.format() == VideoFrame::YV12A) { |
| 281 vpx_codec_alpha_ = InitializeVpxContext(vpx_codec_alpha_, config); | 281 vpx_codec_alpha_ = InitializeVpxContext(vpx_codec_alpha_, config); |
| 282 if (!vpx_codec_alpha_) | 282 if (!vpx_codec_alpha_) |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 | 285 |
| 286 LOG(ERROR) << "Using libvpx..."; |
| 286 return true; | 287 return true; |
| 287 } | 288 } |
| 288 | 289 |
| 289 void VpxVideoDecoder::CloseDecoder() { | 290 void VpxVideoDecoder::CloseDecoder() { |
| 290 if (vpx_codec_) { | 291 if (vpx_codec_) { |
| 291 vpx_codec_destroy(vpx_codec_); | 292 vpx_codec_destroy(vpx_codec_); |
| 292 delete vpx_codec_; | 293 delete vpx_codec_; |
| 293 vpx_codec_ = NULL; | 294 vpx_codec_ = NULL; |
| 294 memory_pool_ = NULL; | 295 memory_pool_ = NULL; |
| 295 } | 296 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); | 495 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); |
| 495 return; | 496 return; |
| 496 } | 497 } |
| 497 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 498 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
| 498 vpx_image->stride[VPX_PLANE_Y], | 499 vpx_image->stride[VPX_PLANE_Y], |
| 499 vpx_image->d_h, | 500 vpx_image->d_h, |
| 500 video_frame->get()); | 501 video_frame->get()); |
| 501 } | 502 } |
| 502 | 503 |
| 503 } // namespace media | 504 } // namespace media |
| OLD | NEW |