| 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/gpu_video_decoder.h" | 5 #include "media/filters/gpu_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <array> | 8 #include <array> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "gpu/command_buffer/common/mailbox_holder.h" | 23 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 24 #include "media/base/bind_to_current_loop.h" | 24 #include "media/base/bind_to_current_loop.h" |
| 25 #include "media/base/cdm_context.h" | 25 #include "media/base/cdm_context.h" |
| 26 #include "media/base/decoder_buffer.h" | 26 #include "media/base/decoder_buffer.h" |
| 27 #include "media/base/media_log.h" | 27 #include "media/base/media_log.h" |
| 28 #include "media/base/media_switches.h" | 28 #include "media/base/media_switches.h" |
| 29 #include "media/base/pipeline_status.h" | 29 #include "media/base/pipeline_status.h" |
| 30 #include "media/base/surface_manager.h" | 30 #include "media/base/surface_manager.h" |
| 31 #include "media/base/video_decoder_config.h" | 31 #include "media/base/video_decoder_config.h" |
| 32 #include "media/media_features.h" | |
| 33 #include "media/renderers/gpu_video_accelerator_factories.h" | 32 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 34 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
| 35 | 34 |
| 36 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 35 #if defined(USE_PROPRIETARY_CODECS) |
| 37 #include "media/formats/mp4/box_definitions.h" | 36 #include "media/formats/mp4/box_definitions.h" |
| 38 #endif | 37 #endif |
| 39 | 38 |
| 40 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 41 #include "base/android/build_info.h" | 40 #include "base/android/build_info.h" |
| 42 #endif | 41 #endif |
| 43 | 42 |
| 44 namespace media { | 43 namespace media { |
| 45 namespace { | 44 namespace { |
| 46 | 45 |
| 47 // Size of shared-memory segments we allocate. Since we reuse them we let them | 46 // Size of shared-memory segments we allocate. Since we reuse them we let them |
| 48 // be on the beefy side. | 47 // be on the beefy side. |
| 49 static const size_t kSharedMemorySegmentBytes = 100 << 10; | 48 static const size_t kSharedMemorySegmentBytes = 100 << 10; |
| 50 | 49 |
| 51 #if defined(OS_ANDROID) && BUILDFLAG(USE_PROPRIETARY_CODECS) | 50 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) |
| 52 // Extract the SPS and PPS lists from |extra_data|. Each SPS and PPS is prefixed | 51 // Extract the SPS and PPS lists from |extra_data|. Each SPS and PPS is prefixed |
| 53 // with 0x0001, the Annex B framing bytes. The out parameters are not modified | 52 // with 0x0001, the Annex B framing bytes. The out parameters are not modified |
| 54 // on failure. | 53 // on failure. |
| 55 void ExtractSpsAndPps(const std::vector<uint8_t>& extra_data, | 54 void ExtractSpsAndPps(const std::vector<uint8_t>& extra_data, |
| 56 std::vector<uint8_t>* sps_out, | 55 std::vector<uint8_t>* sps_out, |
| 57 std::vector<uint8_t>* pps_out) { | 56 std::vector<uint8_t>* pps_out) { |
| 58 if (extra_data.empty()) | 57 if (extra_data.empty()) |
| 59 return; | 58 return; |
| 60 | 59 |
| 61 mp4::AVCDecoderConfigurationRecord record; | 60 mp4::AVCDecoderConfigurationRecord record; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 DCHECK(!init_cb_.is_null()); | 355 DCHECK(!init_cb_.is_null()); |
| 357 | 356 |
| 358 VideoDecodeAccelerator::Config vda_config; | 357 VideoDecodeAccelerator::Config vda_config; |
| 359 vda_config.profile = config_.profile(); | 358 vda_config.profile = config_.profile(); |
| 360 vda_config.cdm_id = cdm_id_; | 359 vda_config.cdm_id = cdm_id_; |
| 361 vda_config.surface_id = surface_id; | 360 vda_config.surface_id = surface_id; |
| 362 vda_config.encryption_scheme = config_.encryption_scheme(); | 361 vda_config.encryption_scheme = config_.encryption_scheme(); |
| 363 vda_config.is_deferred_initialization_allowed = true; | 362 vda_config.is_deferred_initialization_allowed = true; |
| 364 vda_config.initial_expected_coded_size = config_.coded_size(); | 363 vda_config.initial_expected_coded_size = config_.coded_size(); |
| 365 | 364 |
| 366 #if defined(OS_ANDROID) && BUILDFLAG(USE_PROPRIETARY_CODECS) | 365 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) |
| 367 // We pass the SPS and PPS on Android because it lets us initialize | 366 // We pass the SPS and PPS on Android because it lets us initialize |
| 368 // MediaCodec more reliably (http://crbug.com/649185). | 367 // MediaCodec more reliably (http://crbug.com/649185). |
| 369 if (config_.codec() == kCodecH264) | 368 if (config_.codec() == kCodecH264) |
| 370 ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps); | 369 ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps); |
| 371 #endif | 370 #endif |
| 372 | 371 |
| 373 if (!vda_->Initialize(vda_config, this)) { | 372 if (!vda_->Initialize(vda_config, this)) { |
| 374 DVLOG(1) << "VDA::Initialize failed."; | 373 DVLOG(1) << "VDA::Initialize failed."; |
| 375 base::ResetAndReturn(&init_cb_).Run(false); | 374 base::ResetAndReturn(&init_cb_).Run(false); |
| 376 return; | 375 return; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 } | 901 } |
| 903 return false; | 902 return false; |
| 904 } | 903 } |
| 905 | 904 |
| 906 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 905 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 907 const { | 906 const { |
| 908 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 907 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 909 } | 908 } |
| 910 | 909 |
| 911 } // namespace media | 910 } // namespace media |
| OLD | NEW |