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