Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick PR #787: [XB] Workaround to fix memory issue for Xbox One X #957

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions starboard/shared/win32/video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,9 @@ void VideoDecoder::InitializeCodec() {

ComPtr<IMFAttributes> 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<UINT32>(GetMaxNumberOfCachedFrames())));

UpdateVideoArea(transform->GetCurrentOutputType());

Expand Down Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions starboard/xb1/shared/video_decoder_uwp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace starboard {
namespace xb1 {
namespace shared {

const int kXboxeOneXMaxOutputSamples = 5;

VideoDecoderUwp::~VideoDecoderUwp() {
if (IsHdrSupported() && IsHdrAngleModeEnabled()) {
SetHdrAngleModeEnabled(false);
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions starboard/xb1/shared/video_decoder_uwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down