Skip to content

Commit

Permalink
Cherry pick PR #787: [XB] Workaround to fix memory issue for Xbox One…
Browse files Browse the repository at this point in the history
… X (#957)

"Refer to the original PR: #787"

Co-authored-by: iuriionishchenko <[email protected]>
  • Loading branch information
1 parent 0f1aa3b commit 5c4daaa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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

0 comments on commit 5c4daaa

Please sign in to comment.