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

Unified Diff: media/gpu/android_video_encode_accelerator.cc

Issue 2358683002: Android: enable/disable WebRTC HW H264 with a flag. (Closed)
Patch Set: loop codecs in fineHWEncoder() and other fixes. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: media/gpu/android_video_encode_accelerator.cc
diff --git a/media/gpu/android_video_encode_accelerator.cc b/media/gpu/android_video_encode_accelerator.cc
index 023d2351a1ee4047b0b008d784b114ce887b9d07..2608c991a299badec462b0e8f1797e79f211f55b 100644
--- a/media/gpu/android_video_encode_accelerator.cc
+++ b/media/gpu/android_video_encode_accelerator.cc
@@ -108,8 +108,7 @@ AndroidVideoEncodeAccelerator::GetSupportedProfiles() {
const VideoCodec codec;
const VideoCodecProfile profile;
} kSupportedCodecs[] = {{kCodecVP8, VP8PROFILE_ANY},
- {kCodecH264, H264PROFILE_BASELINE},
- {kCodecH264, H264PROFILE_MAIN}};
+ {kCodecH264, H264PROFILE_BASELINE}};
for (const auto& supported_codec : kSupportedCodecs) {
if (supported_codec.codec == kCodecVP8 &&
@@ -117,6 +116,11 @@ AndroidVideoEncodeAccelerator::GetSupportedProfiles() {
continue;
}
+ if (supported_codec.codec == kCodecH264 &&
+ !MediaCodecUtil::IsH264EncoderAvailable()) {
+ continue;
+ }
+
if (VideoCodecBridge::IsKnownUnaccelerated(supported_codec.codec,
MEDIA_CODEC_ENCODER)) {
continue;
@@ -161,15 +165,18 @@ bool AndroidVideoEncodeAccelerator::Initialize(
// encoder before being returned any output frames, since the encoder may
// need to hold onto some subset of inputs as reference pictures.
uint32_t frame_input_count;
+ uint32_t i_frame_interval;
if (output_profile == VP8PROFILE_ANY) {
codec = kCodecVP8;
mime_type = "video/x-vnd.on2.vp8";
frame_input_count = 1;
+ i_frame_interval = IFRAME_INTERVAL_VPX;
} else if (output_profile == H264PROFILE_BASELINE ||
output_profile == H264PROFILE_MAIN) {
codec = kCodecH264;
mime_type = "video/avc";
frame_input_count = 30;
+ i_frame_interval = IFRAME_INTERVAL_H264;
} else {
return false;
}
@@ -190,7 +197,7 @@ bool AndroidVideoEncodeAccelerator::Initialize(
}
media_codec_.reset(VideoCodecBridge::CreateEncoder(
codec, input_visible_size, initial_bitrate, INITIAL_FRAMERATE,
- IFRAME_INTERVAL, pixel_format));
+ i_frame_interval, pixel_format));
if (!media_codec_) {
DLOG(ERROR) << "Failed to create/start the codec: "
@@ -347,9 +354,10 @@ void AndroidVideoEncodeAccelerator::QueueInput() {
frame->coded_size().height());
RETURN_ON_FAILURE(converted, "Failed to I420ToNV12!", kPlatformFailureError);
- fake_input_timestamp_ += base::TimeDelta::FromMicroseconds(1);
+ input_timestamp_ += base::TimeDelta::FromMicroseconds(
+ base::Time::kMicrosecondsPerSecond / INITIAL_FRAMERATE);
status = media_codec_->QueueInputBuffer(input_buf_index, nullptr, queued_size,
- fake_input_timestamp_);
+ input_timestamp_);
UMA_HISTOGRAM_TIMES("Media.AVDA.InputQueueTime",
base::Time::Now() - std::get<2>(input));
RETURN_ON_FAILURE(status == MEDIA_CODEC_OK,
@@ -383,10 +391,10 @@ void AndroidVideoEncodeAccelerator::DequeueOutput() {
return;
case MEDIA_CODEC_OUTPUT_FORMAT_CHANGED:
- break;
+ return;
watk 2016/10/01 01:06:54 Did you mean to change these? You don't want to tr
braveyao 2016/10/03 23:50:15 Done removing do-while. Yes I incline to return i
case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED:
- break;
+ return;
case MEDIA_CODEC_OK:
DCHECK_GE(buf_index, 0);
« media/gpu/android_video_encode_accelerator.h ('K') | « media/gpu/android_video_encode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698