Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 2693653003: Merge M57: "Make setOutputSurface, encrypted capabilities. Blacklist hi6210sft." (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/android/media_codec_util.cc ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
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/renderers/gpu_video_accelerator_factories.h" 32 #include "media/renderers/gpu_video_accelerator_factories.h"
33 #include "third_party/skia/include/core/SkBitmap.h" 33 #include "third_party/skia/include/core/SkBitmap.h"
34 34
35 #if defined(USE_PROPRIETARY_CODECS) 35 #if defined(USE_PROPRIETARY_CODECS)
36 #include "media/formats/mp4/box_definitions.h" 36 #include "media/formats/mp4/box_definitions.h"
37 #endif 37 #endif
38 38
39 #if defined(OS_ANDROID)
40 #include "base/android/build_info.h"
41 #endif
42
43 namespace media { 39 namespace media {
44 namespace { 40 namespace {
45 41
46 // Size of shared-memory segments we allocate. Since we reuse them we let them 42 // Size of shared-memory segments we allocate. Since we reuse them we let them
47 // be on the beefy side. 43 // be on the beefy side.
48 static const size_t kSharedMemorySegmentBytes = 100 << 10; 44 static const size_t kSharedMemorySegmentBytes = 100 << 10;
49 45
50 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) 46 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS)
51 // Extract the SPS and PPS lists from |extra_data|. Each SPS and PPS is prefixed 47 // 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 48 // with 0x0001, the Annex B framing bytes. The out parameters are not modified
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 const InitCB& init_cb, 207 const InitCB& init_cb,
212 const OutputCB& output_cb) { 208 const OutputCB& output_cb) {
213 DVLOG(3) << "Initialize()"; 209 DVLOG(3) << "Initialize()";
214 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 210 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
215 DCHECK(config.IsValidConfig()); 211 DCHECK(config.IsValidConfig());
216 212
217 InitCB bound_init_cb = 213 InitCB bound_init_cb =
218 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, 214 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB,
219 BindToCurrentLoop(init_cb), media_log_); 215 BindToCurrentLoop(init_cb), media_log_);
220 216
221 bool requires_restart_for_external_output_surface = false;
222 #if !defined(OS_ANDROID)
223 if (config.is_encrypted()) {
224 DVLOG(1) << "Encrypted stream not supported.";
225 bound_init_cb.Run(false);
226 return;
227 }
228 #else
229 requires_restart_for_external_output_surface =
230 base::android::BuildInfo::GetInstance()->sdk_int() < 23;
231 #endif
232
233 bool previously_initialized = config_.IsValidConfig(); 217 bool previously_initialized = config_.IsValidConfig();
234 DVLOG(1) << (previously_initialized ? "Reinitializing" : "Initializing") 218 DVLOG(1) << (previously_initialized ? "Reinitializing" : "Initializing")
235 << " GVD with config: " << config.AsHumanReadableString(); 219 << " GVD with config: " << config.AsHumanReadableString();
236 220
237 // Disallow codec changes between configuration changes. 221 // Disallow codec changes between configuration changes.
238 if (previously_initialized && config_.codec() != config.codec()) { 222 if (previously_initialized && config_.codec() != config.codec()) {
239 DVLOG(1) << "Codec changed, cannot reinitialize."; 223 DVLOG(1) << "Codec changed, cannot reinitialize.";
240 bound_init_cb.Run(false); 224 bound_init_cb.Run(false);
241 return; 225 return;
242 } 226 }
243 227
244 // TODO(sandersd): This should be moved to capabilities if we ever have a 228 // TODO(sandersd): This should be moved to capabilities if we ever have a
245 // hardware decoder which supports alpha formats. 229 // hardware decoder which supports alpha formats.
246 if (config.format() == PIXEL_FORMAT_YV12A) { 230 if (config.format() == PIXEL_FORMAT_YV12A) {
247 DVLOG(1) << "Alpha transparency formats are not supported."; 231 DVLOG(1) << "Alpha transparency formats are not supported.";
248 bound_init_cb.Run(false); 232 bound_init_cb.Run(false);
249 return; 233 return;
250 } 234 }
251 235
252 VideoDecodeAccelerator::Capabilities capabilities = 236 VideoDecodeAccelerator::Capabilities capabilities =
253 factories_->GetVideoDecodeAcceleratorCapabilities(); 237 factories_->GetVideoDecodeAcceleratorCapabilities();
238 if (config.is_encrypted() &&
239 !(capabilities.flags &
240 VideoDecodeAccelerator::Capabilities::SUPPORTS_ENCRYPTED_STREAMS)) {
241 DVLOG(1) << "Encrypted stream not supported.";
242 bound_init_cb.Run(false);
243 return;
244 }
245
254 if (!IsProfileSupported(capabilities, config.profile(), config.coded_size(), 246 if (!IsProfileSupported(capabilities, config.profile(), config.coded_size(),
255 config.is_encrypted())) { 247 config.is_encrypted())) {
256 DVLOG(1) << "Unsupported profile " << GetProfileName(config.profile()) 248 DVLOG(1) << "Unsupported profile " << GetProfileName(config.profile())
257 << ", unsupported coded size " << config.coded_size().ToString() 249 << ", unsupported coded size " << config.coded_size().ToString()
258 << ", or accelerator should only be used for encrypted content. " 250 << ", or accelerator should only be used for encrypted content. "
259 << " is_encrypted: " << (config.is_encrypted() ? "yes." : "no."); 251 << " is_encrypted: " << (config.is_encrypted() ? "yes." : "no.");
260 bound_init_cb.Run(false); 252 bound_init_cb.Run(false);
261 return; 253 return;
262 } 254 }
263 255
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // No need to store |cdm_context| since it's not needed in reinitialization. 296 // No need to store |cdm_context| since it's not needed in reinitialization.
305 if (cdm_id_ == CdmContext::kInvalidCdmId) { 297 if (cdm_id_ == CdmContext::kInvalidCdmId) {
306 DVLOG(1) << "CDM ID not available."; 298 DVLOG(1) << "CDM ID not available.";
307 bound_init_cb.Run(false); 299 bound_init_cb.Run(false);
308 return; 300 return;
309 } 301 }
310 } 302 }
311 303
312 init_cb_ = bound_init_cb; 304 init_cb_ = bound_init_cb;
313 305
314 const bool supports_external_output_surface = 306 const bool supports_external_output_surface = !!(
315 (capabilities.flags & VideoDecodeAccelerator::Capabilities:: 307 capabilities.flags &
316 SUPPORTS_EXTERNAL_OUTPUT_SURFACE) != 0; 308 VideoDecodeAccelerator::Capabilities::SUPPORTS_EXTERNAL_OUTPUT_SURFACE);
317 if (supports_external_output_surface && !request_surface_cb_.is_null()) { 309 if (supports_external_output_surface && !request_surface_cb_.is_null()) {
310 const bool requires_restart_for_external_output_surface =
311 !(capabilities.flags & VideoDecodeAccelerator::Capabilities::
312 SUPPORTS_SET_EXTERNAL_OUTPUT_SURFACE);
313
318 // If we have a surface request callback we should call it and complete 314 // If we have a surface request callback we should call it and complete
319 // initialization with the returned surface. 315 // initialization with the returned surface.
320 request_surface_cb_.Run( 316 request_surface_cb_.Run(
321 requires_restart_for_external_output_surface, 317 requires_restart_for_external_output_surface,
322 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::OnSurfaceAvailable, 318 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::OnSurfaceAvailable,
323 weak_factory_.GetWeakPtr()))); 319 weak_factory_.GetWeakPtr())));
324 return; 320 return;
325 } 321 }
326 322
327 // If external surfaces are not supported we can complete initialization now. 323 // If external surfaces are not supported we can complete initialization now.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 } 907 }
912 return false; 908 return false;
913 } 909 }
914 910
915 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 911 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
916 const { 912 const {
917 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 913 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
918 } 914 }
919 915
920 } // namespace media 916 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_util.cc ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698