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

Unified Diff: media/gpu/media_foundation_video_encode_accelerator_win.cc

Issue 2615513003: Add optional max supported resolution on MediaFoundationVideoEncodeAccelerator (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « media/gpu/media_foundation_video_encode_accelerator_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/media_foundation_video_encode_accelerator_win.cc
diff --git a/media/gpu/media_foundation_video_encode_accelerator_win.cc b/media/gpu/media_foundation_video_encode_accelerator_win.cc
index a43e2ad236bcecd15efa45ec2c10755c7a98cf53..17ba2b25463aa96b032482ba0226767d1bf4b956 100644
--- a/media/gpu/media_foundation_video_encode_accelerator_win.cc
+++ b/media/gpu/media_foundation_video_encode_accelerator_win.cc
@@ -34,8 +34,8 @@ namespace {
const int32_t kDefaultTargetBitrate = 5000000;
const size_t kMaxFrameRateNumerator = 30;
const size_t kMaxFrameRateDenominator = 1;
-const size_t kMaxResolutionWidth = 3840;
-const size_t kMaxResolutionHeight = 2176;
+const size_t kMaxResolutionWidth = 1920;
+const size_t kMaxResolutionHeight = 1088;
const size_t kNumInputBuffers = 3;
// Media Foundation uses 100 nanosecond units for time, see
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms697282(v=vs.85).aspx
@@ -46,6 +46,9 @@ constexpr const wchar_t* const kMediaFoundationVideoEncoderDLLs[] = {
L"mf.dll", L"mfplat.dll",
};
+// Resolutions that some platforms support, should be listed in ascending order.
+constexpr const gfx::Size kOptionalMaxResolutions[] = {gfx::Size(3840, 2176)};
+
} // namespace
class MediaFoundationVideoEncodeAccelerator::EncodeOutput {
@@ -101,7 +104,6 @@ MediaFoundationVideoEncodeAccelerator::GetSupportedProfiles() {
DCHECK(main_client_task_runner_->BelongsToCurrentThread());
SupportedProfiles profiles;
-
target_bitrate_ = kDefaultTargetBitrate;
frame_rate_ = kMaxFrameRateNumerator / kMaxFrameRateDenominator;
input_visible_size_ = gfx::Size(kMaxResolutionWidth, kMaxResolutionHeight);
@@ -112,6 +114,14 @@ MediaFoundationVideoEncodeAccelerator::GetSupportedProfiles() {
<< "Hardware encode acceleration is not available on this platform.";
return profiles;
}
+
+ gfx::Size highest_supported_resolution = input_visible_size_;
+ for (const auto& resolution : kOptionalMaxResolutions) {
+ DCHECK_GT(resolution.GetArea(), highest_supported_resolution.GetArea());
+ if (!IsResolutionSupported(resolution))
+ break;
+ highest_supported_resolution = resolution;
+ }
ReleaseEncoderResources();
SupportedProfile profile;
@@ -120,7 +130,7 @@ MediaFoundationVideoEncodeAccelerator::GetSupportedProfiles() {
profile.profile = H264PROFILE_BASELINE;
profile.max_framerate_numerator = kMaxFrameRateNumerator;
profile.max_framerate_denominator = kMaxFrameRateDenominator;
- profile.max_resolution = gfx::Size(kMaxResolutionWidth, kMaxResolutionHeight);
+ profile.max_resolution = highest_supported_resolution;
profiles.push_back(profile);
return profiles;
}
@@ -449,6 +459,28 @@ bool MediaFoundationVideoEncodeAccelerator::SetEncoderModes() {
return SUCCEEDED(hr);
}
+bool MediaFoundationVideoEncodeAccelerator::IsResolutionSupported(
+ const gfx::Size& resolution) {
+ DCHECK(main_client_task_runner_->BelongsToCurrentThread());
+ DCHECK(encoder_);
+
+ HRESULT hr =
+ MFSetAttributeSize(imf_output_media_type_.get(), MF_MT_FRAME_SIZE,
+ resolution.width(), resolution.height());
+ RETURN_ON_HR_FAILURE(hr, "Couldn't set frame size", false);
+ hr = encoder_->SetOutputType(output_stream_id_, imf_output_media_type_.get(),
+ 0);
+ RETURN_ON_HR_FAILURE(hr, "Couldn't set output media type", false);
+
+ hr = MFSetAttributeSize(imf_input_media_type_.get(), MF_MT_FRAME_SIZE,
+ resolution.width(), resolution.height());
+ RETURN_ON_HR_FAILURE(hr, "Couldn't set frame size", false);
+ hr = encoder_->SetInputType(input_stream_id_, imf_input_media_type_.get(), 0);
+ RETURN_ON_HR_FAILURE(hr, "Couldn't set input media type", false);
+
+ return true;
+}
+
void MediaFoundationVideoEncodeAccelerator::NotifyError(
VideoEncodeAccelerator::Error error) {
DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread());
« no previous file with comments | « media/gpu/media_foundation_video_encode_accelerator_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698