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

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.cc

Issue 1282083003: Add support for H264 and VP9 to AndroidVDA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hide vp9/h264 behind ifdef Created 5 years, 4 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 | « no previous file | media/base/video_decoder_config.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "content/common/gpu/gpu_channel.h" 11 #include "content/common/gpu/gpu_channel.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
13 #include "media/base/bitstream_buffer.h" 13 #include "media/base/bitstream_buffer.h"
14 #include "media/base/limits.h" 14 #include "media/base/limits.h"
15 #include "media/base/video_decoder_config.h"
15 #include "media/video/picture.h" 16 #include "media/video/picture.h"
16 #include "ui/gl/android/scoped_java_surface.h" 17 #include "ui/gl/android/scoped_java_surface.h"
17 #include "ui/gl/android/surface_texture.h" 18 #include "ui/gl/android/surface_texture.h"
18 #include "ui/gl/gl_bindings.h" 19 #include "ui/gl/gl_bindings.h"
19 20
20 namespace content { 21 namespace content {
21 22
22 // Helper macros for dealing with failure. If |result| evaluates false, emit 23 // Helper macros for dealing with failure. If |result| evaluates false, emit
23 // |log| to ERROR, register |error| with the decoder, and return. 24 // |log| to ERROR, register |error| with the decoder, and return.
24 #define RETURN_ON_FAILURE(result, log, error) \ 25 #define RETURN_ON_FAILURE(result, log, error) \
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() { 82 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
82 DCHECK(thread_checker_.CalledOnValidThread()); 83 DCHECK(thread_checker_.CalledOnValidThread());
83 } 84 }
84 85
85 bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, 86 bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
86 Client* client) { 87 Client* client) {
87 DCHECK(!media_codec_); 88 DCHECK(!media_codec_);
88 DCHECK(thread_checker_.CalledOnValidThread()); 89 DCHECK(thread_checker_.CalledOnValidThread());
89 90
90 client_ = client; 91 client_ = client;
92 codec_ = VideoCodecProfileToVideoCodec(profile);
91 93
92 if (profile == media::VP8PROFILE_ANY) { 94 bool profile_supported = codec_ == media::kCodecVP8;
93 codec_ = media::kCodecVP8; 95 #if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
94 } else { 96 profile_supported |=
95 // TODO(dwkang): enable H264 once b/8125974 is fixed. 97 (codec_ == media::kCodecVP9 || codec_ == media::kCodecH264);
98 #endif
99
100 if (!profile_supported) {
96 LOG(ERROR) << "Unsupported profile: " << profile; 101 LOG(ERROR) << "Unsupported profile: " << profile;
97 return false; 102 return false;
98 } 103 }
99 104
100 // Only consider using MediaCodec if it's likely backed by hardware. 105 // Only use MediaCodec for VP8/9 if it's likely backed by hardware.
101 if (media::VideoCodecBridge::IsKnownUnaccelerated( 106 if ((codec_ == media::kCodecVP8 || codec_ == media::kCodecVP9) &&
107 media::VideoCodecBridge::IsKnownUnaccelerated(
102 codec_, media::MEDIA_CODEC_DECODER)) { 108 codec_, media::MEDIA_CODEC_DECODER)) {
109 DVLOG(1) << "Initialization failed: "
110 << (codec_ == media::kCodecVP8 ? "vp8" : "vp9")
111 << " is not hardware accelerated";
103 return false; 112 return false;
104 } 113 }
105 114
106 if (!make_context_current_.Run()) { 115 if (!make_context_current_.Run()) {
107 LOG(ERROR) << "Failed to make this decoder's GL context current."; 116 LOG(ERROR) << "Failed to make this decoder's GL context current.";
108 return false; 117 return false;
109 } 118 }
110 119
111 if (!gl_decoder_) { 120 if (!gl_decoder_) {
112 LOG(ERROR) << "Failed to get gles2 decoder instance."; 121 LOG(ERROR) << "Failed to get gles2 decoder instance.";
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 560
552 void AndroidVideoDecodeAccelerator::NotifyError( 561 void AndroidVideoDecodeAccelerator::NotifyError(
553 media::VideoDecodeAccelerator::Error error) { 562 media::VideoDecodeAccelerator::Error error) {
554 client_->NotifyError(error); 563 client_->NotifyError(error);
555 } 564 }
556 565
557 // static 566 // static
558 media::VideoDecodeAccelerator::SupportedProfiles 567 media::VideoDecodeAccelerator::SupportedProfiles
559 AndroidVideoDecodeAccelerator::GetSupportedProfiles() { 568 AndroidVideoDecodeAccelerator::GetSupportedProfiles() {
560 SupportedProfiles profiles; 569 SupportedProfiles profiles;
561 if (media::VideoCodecBridge::IsKnownUnaccelerated( 570
571 if (!media::VideoCodecBridge::IsKnownUnaccelerated(
562 media::kCodecVP8, media::MEDIA_CODEC_DECODER)) { 572 media::kCodecVP8, media::MEDIA_CODEC_DECODER)) {
563 return profiles; 573 SupportedProfile profile;
574 profile.profile = media::VP8PROFILE_ANY;
575 profile.min_resolution.SetSize(0, 0);
576 profile.max_resolution.SetSize(1920, 1088);
577 profiles.push_back(profile);
564 } 578 }
579
580 #if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
581 if (!media::VideoCodecBridge::IsKnownUnaccelerated(
582 media::kCodecVP9, media::MEDIA_CODEC_DECODER)) {
583 SupportedProfile profile;
584 profile.profile = media::VP9PROFILE_ANY;
585 profile.min_resolution.SetSize(0, 0);
586 profile.max_resolution.SetSize(1920, 1088);
587 profiles.push_back(profile);
588 }
589
565 SupportedProfile profile; 590 SupportedProfile profile;
566 profile.profile = media::VP8PROFILE_ANY; 591 // MediaCodec is only guaranteed to support the baseline profile.
567 profile.min_resolution.SetSize(16, 16); 592 profile.profile = media::H264PROFILE_BASELINE;
DaleCurtis 2015/08/11 19:15:46 As discussed offline we should go ahead and includ
watk 2015/08/11 20:07:47 Done.
568 profile.max_resolution.SetSize(1920, 1088); 593 profile.min_resolution.SetSize(0, 0);
594 // MediaCodec resolution support is likely device dependent, but it's
595 // expected that consumers won't have software fallback for h264 on Android,
596 // so it's ok to overpromise and fail to decode later.
597 profile.max_resolution.SetSize(3840, 2160);
569 profiles.push_back(profile); 598 profiles.push_back(profile);
599 #endif
600
570 return profiles; 601 return profiles;
571 } 602 }
572 603
573 } // namespace content 604 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/base/video_decoder_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698