From 0a69bb92e7831eeaa3781057abd3d6409601608c Mon Sep 17 00:00:00 2001 From: iuriionishchenko <136322748+iuriionishchenko@users.noreply.github.com> Date: Tue, 18 Jul 2023 21:19:26 +0300 Subject: [PATCH] [XB] Workaround to fix memory issue for Xbox One X (#787) Number of the video decoder output buffers was decreased from 10 to 5 b/268591344 Change-Id: Icbbdab428196c119e606ef7653b3b17a8e9ec846 --- starboard/shared/win32/video_decoder.cc | 7 ++++--- starboard/xb1/shared/video_decoder_uwp.cc | 13 +++++++++++++ starboard/xb1/shared/video_decoder_uwp.h | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/starboard/shared/win32/video_decoder.cc b/starboard/shared/win32/video_decoder.cc index cf95a60bffba..b69cdaf5bb1c 100644 --- a/starboard/shared/win32/video_decoder.cc +++ b/starboard/shared/win32/video_decoder.cc @@ -476,8 +476,9 @@ void VideoDecoder::InitializeCodec() { ComPtr attributes = transform->GetAttributes(); SB_DCHECK(attributes); - CheckResult(attributes->SetUINT32(MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT, - kMaxOutputSamples)); + CheckResult( + attributes->SetUINT32(MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT, + static_cast(GetMaxNumberOfCachedFrames()))); UpdateVideoArea(transform->GetCurrentOutputType()); @@ -716,7 +717,7 @@ void VideoDecoder::DecoderThreadRun() { // MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT. thread_lock_.Acquire(); bool input_full = thread_events_.size() >= kMaxInputSamples; - bool output_full = thread_outputs_.size() >= kMaxOutputSamples; + bool output_full = thread_outputs_.size() >= GetMaxNumberOfCachedFrames(); thread_lock_.Release(); Status status = input_full ? kBufferFull : kNeedMoreInput; diff --git a/starboard/xb1/shared/video_decoder_uwp.cc b/starboard/xb1/shared/video_decoder_uwp.cc index 6a9a9e6c49ed..8e380636f28b 100644 --- a/starboard/xb1/shared/video_decoder_uwp.cc +++ b/starboard/xb1/shared/video_decoder_uwp.cc @@ -29,6 +29,8 @@ namespace starboard { namespace xb1 { namespace shared { +const int kXboxeOneXMaxOutputSamples = 5; + VideoDecoderUwp::~VideoDecoderUwp() { if (IsHdrSupported() && IsHdrAngleModeEnabled()) { SetHdrAngleModeEnabled(false); @@ -78,6 +80,17 @@ bool VideoDecoderUwp::TryUpdateOutputForHdrVideo( return true; } +size_t VideoDecoderUwp::GetPrerollFrameCount() { + return GetMaxNumberOfCachedFrames(); +} + +size_t VideoDecoderUwp::GetMaxNumberOfCachedFrames() { + return (::starboard::shared::uwp::kXboxOneX == + ::starboard::shared::uwp::GetXboxType()) + ? kXboxeOneXMaxOutputSamples + : ::starboard::shared::win32::VideoDecoder::GetPrerollFrameCount(); +} + } // namespace shared } // namespace xb1 } // namespace starboard diff --git a/starboard/xb1/shared/video_decoder_uwp.h b/starboard/xb1/shared/video_decoder_uwp.h index 6251c8821d25..a7eb58243c1b 100644 --- a/starboard/xb1/shared/video_decoder_uwp.h +++ b/starboard/xb1/shared/video_decoder_uwp.h @@ -17,6 +17,7 @@ #include "starboard/shared/starboard/media/media_util.h" #include "starboard/shared/uwp/application_uwp.h" +#include "starboard/shared/uwp/xb1_get_type.h" #include "starboard/shared/win32/video_decoder.h" namespace starboard { @@ -48,6 +49,9 @@ class VideoDecoderUwp : public ::starboard::shared::win32::VideoDecoder { bool TryUpdateOutputForHdrVideo(const VideoStreamInfo& stream_info) override; + size_t GetPrerollFrameCount() const override; + size_t GetMaxNumberOfCachedFrames() const override; + private: SbMediaColorMetadata current_color_metadata_ = {}; bool is_first_input_ = true;