+// Copyright 2019 Samsung Electronics Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/demuxer_memory_limit.h"
+#include "media/base/video_decoder_config.h"
+
+namespace media {
+
+size_t UpdateDemuxerStreamVideoMemoryLimit(
+ const VideoDecoderConfig* video_config) {
+ static size_t demuxer_stream_video_memory_limit =
+ internal::kDemuxerStreamVideoMemoryLimitTvDefault;
+
+ if (!video_config)
+ return demuxer_stream_video_memory_limit;
+
+ const int kFHDWidth = 1920;
+ const int kFHDHeight = 1080;
+ bool isUHDResolution = video_config->coded_size().width() > kFHDWidth ||
+ video_config->coded_size().height() > kFHDHeight;
+ if (isUHDResolution) {
+ demuxer_stream_video_memory_limit =
+ internal::kDemuxerStreamVideoMemoryLimitTvUHD;
+ }
+
+ return demuxer_stream_video_memory_limit;
+}
+
+size_t GetDemuxerStreamVideoMemoryLimit(
+ Demuxer::DemuxerTypes /*demuxer_type*/,
+ const VideoDecoderConfig* video_config) {
+ return UpdateDemuxerStreamVideoMemoryLimit(video_config);
+}
+
+size_t GetDemuxerStreamAudioMemoryLimit(
+ const AudioDecoderConfig* /*audio_config*/) {
+ return internal::kDemuxerStreamAudioMemoryLimitTvDefault;
+}
+
+size_t GetDemuxerMemoryLimit(Demuxer::DemuxerTypes demuxer_type) {
+ return GetDemuxerStreamAudioMemoryLimit(nullptr) +
+ GetDemuxerStreamVideoMemoryLimit(demuxer_type, nullptr);
+}
+
+} // namespace media