From ae843b40ff7edc20e140b11bbe2d609773198780 Mon Sep 17 00:00:00 2001 From: Bo-Rong Chen Date: Fri, 8 Nov 2024 10:59:46 -0800 Subject: [PATCH] [media] Support DecoderBufferAllocator (#4348) This is to avoid OOM on low-end devices. The current design is the same as Cobalt C25, and will be revisited once Cobalt is rebased to m126+. b/374822966 --- media/base/decoder_buffer.cc | 44 ++++++++++++++++ media/base/decoder_buffer.h | 52 +++++++++++++++++++ media/base/media_client.h | 10 ++++ media/formats/mp4/mp4_stream_parser.cc | 6 +++ media/starboard/BUILD.gn | 14 +++-- .../bidirectional_fit_reuse_allocator.cc | 17 +++--- .../bidirectional_fit_reuse_allocator.h | 41 +++++++-------- .../bidirectional_fit_reuse_allocator_test.cc | 3 +- media/starboard/decoder_buffer_allocator.cc | 17 +++--- media/starboard/decoder_buffer_allocator.h | 22 ++++---- media/starboard/decoder_buffer_memory_info.h | 8 ++- media/starboard/starboard_memory_allocator.h | 8 ++- media/starboard/starboard_utils.cc | 4 -- 13 files changed, 179 insertions(+), 67 deletions(-) diff --git a/media/base/decoder_buffer.cc b/media/base/decoder_buffer.cc index e3622277bccfd..fdc205bb8a4a6 100644 --- a/media/base/decoder_buffer.cc +++ b/media/base/decoder_buffer.cc @@ -11,6 +11,23 @@ namespace media { +#if BUILDFLAG(USE_STARBOARD_MEDIA) +namespace { +DecoderBuffer::Allocator* s_allocator = nullptr; +} // namespace + +// static +DecoderBuffer::Allocator* DecoderBuffer::Allocator::GetInstance() { + DCHECK(s_allocator); + return s_allocator; +} + +// static +void DecoderBuffer::Allocator::Set(Allocator* allocator) { + s_allocator = allocator; +} +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) + DecoderBuffer::TimeInfo::TimeInfo() = default; DecoderBuffer::TimeInfo::~TimeInfo() = default; DecoderBuffer::TimeInfo::TimeInfo(const TimeInfo&) = default; @@ -35,7 +52,11 @@ DecoderBuffer::DecoderBuffer(const uint8_t* data, Initialize(); +#if BUILDFLAG(USE_STARBOARD_MEDIA) + memcpy(data_, data, size_); +#else // BUILDFLAG(USE_STARBOARD_MEDIA) memcpy(data_.get(), data, size_); +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) if (!side_data) { CHECK_EQ(side_data_size, 0u); @@ -47,7 +68,13 @@ DecoderBuffer::DecoderBuffer(const uint8_t* data, } DecoderBuffer::DecoderBuffer(std::unique_ptr data, size_t size) +#if BUILDFLAG(USE_STARBOARD_MEDIA) + : size_(size) { + // TODO(b/378106931): revisit DecoderBufferAllocator once rebase to m126+ + } +#else // BUILDFLAG(USE_STARBOARD_MEDIA) : data_(std::move(data)), size_(size) {} +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) DecoderBuffer::DecoderBuffer(base::ReadOnlySharedMemoryMapping mapping, size_t size) @@ -62,12 +89,29 @@ DecoderBuffer::DecoderBuffer(std::unique_ptr external_memory) external_memory_(std::move(external_memory)) {} DecoderBuffer::~DecoderBuffer() { +#if BUILDFLAG(USE_STARBOARD_MEDIA) + DCHECK(s_allocator); + s_allocator->Free(data_, allocated_size_); +#else // BUILDFLAG(USE_STARBOARD_MEDIA) data_.reset(); +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) side_data_.reset(); } void DecoderBuffer::Initialize() { +#if BUILDFLAG(USE_STARBOARD_MEDIA) + DCHECK(s_allocator); + DCHECK(!data_); + + int alignment = s_allocator->GetBufferAlignment(); + int padding = s_allocator->GetBufferPadding(); + allocated_size_ = size_ + padding; + data_ = static_cast(s_allocator->Allocate(allocated_size_, + alignment)); + memset(data_ + size_, 0, padding); +#else // BUILDFLAG(USE_STARBOARD_MEDIA) data_.reset(new uint8_t[size_]); +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) if (side_data_size_ > 0) side_data_.reset(new uint8_t[side_data_size_]); } diff --git a/media/base/decoder_buffer.h b/media/base/decoder_buffer.h index e8c8cfeb766d6..27a87eb204e50 100644 --- a/media/base/decoder_buffer.h +++ b/media/base/decoder_buffer.h @@ -25,6 +25,10 @@ #include "media/base/media_export.h" #include "media/base/timestamp_constants.h" +#if BUILDFLAG(USE_STARBOARD_MEDIA) +#include "starboard/media.h" +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) + namespace media { // A specialized buffer for interfacing with audio / video decoders. @@ -73,6 +77,36 @@ class MEDIA_EXPORT DecoderBuffer DiscardPadding discard_padding; }; +#if BUILDFLAG(USE_STARBOARD_MEDIA) + class Allocator { + public: + static Allocator* GetInstance(); + + // The function should never return nullptr. It may terminate the app on + // allocation failure. + virtual void* Allocate(size_t size, size_t alignment) = 0; + virtual void Free(void* p, size_t size) = 0; + + virtual int GetAudioBufferBudget() const = 0; + virtual int GetBufferAlignment() const = 0; + virtual int GetBufferPadding() const = 0; + virtual base::TimeDelta GetBufferGarbageCollectionDurationThreshold() const = 0; + virtual int GetProgressiveBufferBudget(SbMediaVideoCodec codec, + int resolution_width, + int resolution_height, + int bits_per_pixel) const = 0; + virtual int GetVideoBufferBudget(SbMediaVideoCodec codec, + int resolution_width, + int resolution_height, + int bits_per_pixel) const = 0; + + protected: + ~Allocator() {} + + static void Set(Allocator* allocator); + }; +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) + // Allocates buffer with |size| >= 0. |is_key_frame_| will default to false. explicit DecoderBuffer(size_t size); @@ -166,6 +200,9 @@ class MEDIA_EXPORT DecoderBuffer const uint8_t* data() const { DCHECK(!end_of_stream()); +#if BUILDFLAG(USE_STARBOARD_MEDIA) + return data_; +#else // BUILDFLAG(USE_STARBOARD_MEDIA) if (read_only_mapping_.IsValid()) return read_only_mapping_.GetMemoryAs(); if (writable_mapping_.IsValid()) @@ -173,15 +210,20 @@ class MEDIA_EXPORT DecoderBuffer if (external_memory_) return external_memory_->span().data(); return data_.get(); +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) } // TODO(sandersd): Remove writable_data(). https://crbug.com/834088 uint8_t* writable_data() const { +#if BUILDFLAG(USE_STARBOARD_MEDIA) + return data_; +#else // BUILDFLAG(USE_STARBOARD_MEDIA) DCHECK(!end_of_stream()); DCHECK(!read_only_mapping_.IsValid()); DCHECK(!writable_mapping_.IsValid()); DCHECK(!external_memory_); return data_.get(); +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) } size_t data_size() const { @@ -222,10 +264,14 @@ class MEDIA_EXPORT DecoderBuffer } // If there's no data in this buffer, it represents end of stream. +#if BUILDFLAG(USE_STARBOARD_MEDIA) + bool end_of_stream() const { return !data_; } +#else // BUILDFLAG(USE_STARBOARD_MEDIA) bool end_of_stream() const { return !read_only_mapping_.IsValid() && !writable_mapping_.IsValid() && !external_memory_ && !data_; } +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) bool is_key_frame() const { DCHECK(!end_of_stream()); @@ -271,8 +317,14 @@ class MEDIA_EXPORT DecoderBuffer virtual ~DecoderBuffer(); +#if BUILDFLAG(USE_STARBOARD_MEDIA) + // Encoded data, allocated from DecoderBuffer::Allocator. + uint8_t* data_ = nullptr; + size_t allocated_size_ = 0; +#else // BUILDFLAG(USE_STARBOARD_MEDIA) // Encoded data, if it is stored on the heap. std::unique_ptr data_; +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) private: TimeInfo time_info_; diff --git a/media/base/media_client.h b/media/base/media_client.h index fd22d95e89c76..7f6c9704cb068 100644 --- a/media/base/media_client.h +++ b/media/base/media_client.h @@ -19,6 +19,10 @@ #include "ui/gfx/color_space.h" #include "url/gurl.h" +#if BUILDFLAG(USE_STARBOARD_MEDIA) +#include "media/starboard/decoder_buffer_allocator.h" +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) + namespace media { class MediaClient; @@ -56,6 +60,12 @@ class MEDIA_EXPORT MediaClient { // Optionally returns audio renderer algorithm parameters. virtual absl::optional<::media::AudioRendererAlgorithmParameters> GetAudioRendererAlgorithmParameters(AudioParameters audio_parameters) = 0; + +#if BUILDFLAG(USE_STARBOARD_MEDIA) + private: + // TODO(b/326497953): Support Suspend() and Resume(). + DecoderBufferAllocator decoder_buffer_allocator_; +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) }; } // namespace media diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc index 3bd040b95a835..0fd7ece7f43f3 100644 --- a/media/formats/mp4/mp4_stream_parser.cc +++ b/media/formats/mp4/mp4_stream_parser.cc @@ -1011,9 +1011,15 @@ ParseResult MP4StreamParser::EnqueueSample(BufferQueueMap* buffers) { StreamParserBuffer::Type buffer_type = audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; +#if BUILDFLAG(USE_STARBOARD_MEDIA) + scoped_refptr stream_buf = + StreamParserBuffer::CopyFrom(&frame_buf[0], frame_buf.size(), is_keyframe, + buffer_type, runs_->track_id()); +#else // BUILDFLAG(USE_STARBOARD_MEDIA) auto stream_buf = StreamParserBuffer::FromExternalMemory( std::make_unique(std::move(frame_buf)), is_keyframe, buffer_type, runs_->track_id()); +#endif // BUILDFLAG(USE_STARBOARD_MEDIA) if (decrypt_config) stream_buf->set_decrypt_config(std::move(decrypt_config)); diff --git a/media/starboard/BUILD.gn b/media/starboard/BUILD.gn index 8f0cfdf94fcc2..c4be5d83006a7 100644 --- a/media/starboard/BUILD.gn +++ b/media/starboard/BUILD.gn @@ -25,9 +25,6 @@ source_set("starboard") { # TODO(b/375069564): Revisit CValStats "COBALT_MEDIA_ENABLE_CVAL=0", - # TODO(b/374822966): Revisit DecoderBuffer budget - "COBALT_MEDIA_ENABLE_DECODE_BUFFER_BUDGET=0", - # TODO(b/375070492): Revisit decode-to-texture "COBALT_MEDIA_ENABLE_DECODE_TARGET_PROVIDER=0", @@ -57,12 +54,18 @@ source_set("starboard") { ] sources = [ + "bidirectional_fit_reuse_allocator.cc", + "bidirectional_fit_reuse_allocator.h", + "decoder_buffer_allocator.cc", + "decoder_buffer_allocator.h", + "decoder_buffer_memory_info.h", "sbplayer_bridge.cc", "sbplayer_bridge.h", "sbplayer_interface.cc", "sbplayer_interface.h", "sbplayer_set_bounds_helper.cc", "sbplayer_set_bounds_helper.h", + "starboard_memory_allocator.h", "starboard_renderer.cc", "starboard_renderer.h", "starboard_utils.cc", @@ -82,7 +85,10 @@ source_set("starboard") { source_set("unit_tests") { testonly = true - sources = [ "starboard_utils_test.cc" ] + sources = [ + "bidirectional_fit_reuse_allocator_test.cc", + "starboard_utils_test.cc", + ] configs += [ "//media:media_config" ] deps = [ "//base", diff --git a/media/starboard/bidirectional_fit_reuse_allocator.cc b/media/starboard/bidirectional_fit_reuse_allocator.cc index cfb9a13775e8a..ba90a6287c3b2 100644 --- a/media/starboard/bidirectional_fit_reuse_allocator.cc +++ b/media/starboard/bidirectional_fit_reuse_allocator.cc @@ -12,24 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "cobalt/media/bidirectional_fit_reuse_allocator.h" +#include "media/starboard/bidirectional_fit_reuse_allocator.h" #include +#include "base/check.h" #include "base/logging.h" #include "starboard/common/pointer_arithmetic.h" #include "starboard/types.h" -namespace cobalt { namespace media { BidirectionalFitReuseAllocator::BidirectionalFitReuseAllocator( - Allocator* fallback_allocator, std::size_t initial_capacity, + Allocator* fallback_allocator, + std::size_t initial_capacity, std::size_t small_allocation_threshold, - std::size_t allocation_increment /*= 0*/, std::size_t max_capacity /* =0 */ + std::size_t allocation_increment /*= 0*/, + std::size_t max_capacity /* =0 */ ) - : ReuseAllocatorBase(fallback_allocator, initial_capacity, - allocation_increment, max_capacity), + : ReuseAllocatorBase(fallback_allocator, + initial_capacity, + allocation_increment, + max_capacity), small_allocation_threshold_(small_allocation_threshold) {} starboard::common::ReuseAllocatorBase::FreeBlockSet::iterator @@ -64,4 +68,3 @@ BidirectionalFitReuseAllocator::FindFreeBlock(std::size_t size, } } // namespace media -} // namespace cobalt diff --git a/media/starboard/bidirectional_fit_reuse_allocator.h b/media/starboard/bidirectional_fit_reuse_allocator.h index 907d27cc9d457..8078758823594 100644 --- a/media/starboard/bidirectional_fit_reuse_allocator.h +++ b/media/starboard/bidirectional_fit_reuse_allocator.h @@ -1,26 +1,23 @@ -/* - * Copyright 2017 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef COBALT_MEDIA_BIDIRECTIONAL_FIT_REUSE_ALLOCATOR_H_ -#define COBALT_MEDIA_BIDIRECTIONAL_FIT_REUSE_ALLOCATOR_H_ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef MEDIA_STARBOARD_BIDIRECTIONAL_FIT_REUSE_ALLOCATOR_H_ +#define MEDIA_STARBOARD_BIDIRECTIONAL_FIT_REUSE_ALLOCATOR_H_ #include "starboard/common/reuse_allocator_base.h" #include "starboard/configuration.h" -namespace cobalt { namespace media { // This class uses first-fit allocation strategy to allocate memory block whose @@ -41,7 +38,8 @@ class BidirectionalFitReuseAllocator std::size_t allocation_increment = 0, std::size_t max_capacity = 0); - FreeBlockSet::iterator FindFreeBlock(std::size_t size, std::size_t alignment, + FreeBlockSet::iterator FindFreeBlock(std::size_t size, + std::size_t alignment, FreeBlockSet::iterator begin, FreeBlockSet::iterator end, bool* allocate_from_front) override; @@ -51,6 +49,5 @@ class BidirectionalFitReuseAllocator }; } // namespace media -} // namespace cobalt -#endif // COBALT_MEDIA_BIDIRECTIONAL_FIT_REUSE_ALLOCATOR_H_ +#endif // MEDIA_STARBOARD_BIDIRECTIONAL_FIT_REUSE_ALLOCATOR_H_ diff --git a/media/starboard/bidirectional_fit_reuse_allocator_test.cc b/media/starboard/bidirectional_fit_reuse_allocator_test.cc index cdf46a8e49349..c6809ea4866aa 100644 --- a/media/starboard/bidirectional_fit_reuse_allocator_test.cc +++ b/media/starboard/bidirectional_fit_reuse_allocator_test.cc @@ -14,13 +14,14 @@ * limitations under the License. */ -#include "cobalt/media/bidirectional_fit_reuse_allocator.h" +#include "media/starboard/bidirectional_fit_reuse_allocator.h" #include #include "starboard/common/fixed_no_free_allocator.h" #include "starboard/common/pointer_arithmetic.h" #include "starboard/configuration.h" +#include "starboard/memory.h" #include "starboard/types.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/media/starboard/decoder_buffer_allocator.cc b/media/starboard/decoder_buffer_allocator.cc index 021cf728e9129..2dc77690401e7 100644 --- a/media/starboard/decoder_buffer_allocator.cc +++ b/media/starboard/decoder_buffer_allocator.cc @@ -12,19 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "cobalt/media/decoder_buffer_allocator.h" +#include "media/starboard/decoder_buffer_allocator.h" #include #include #include "base/logging.h" -#include "cobalt/math/size.h" -#include "media/base/starboard_utils.h" +#include "media/starboard/starboard_utils.h" #include "starboard/common/allocator.h" #include "starboard/configuration.h" #include "starboard/media.h" -namespace cobalt { namespace media { namespace { @@ -126,7 +124,9 @@ int DecoderBufferAllocator::GetAudioBufferBudget() const { return SbMediaGetAudioBufferBudget(); } -int DecoderBufferAllocator::GetBufferAlignment() const { return sizeof(void*); } +int DecoderBufferAllocator::GetBufferAlignment() const { + return sizeof(void*); +} int DecoderBufferAllocator::GetBufferPadding() const { return SbMediaGetBufferPadding(); @@ -134,12 +134,14 @@ int DecoderBufferAllocator::GetBufferPadding() const { base::TimeDelta DecoderBufferAllocator::GetBufferGarbageCollectionDurationThreshold() const { - return base::TimeDelta::FromMicroseconds( + return base::Microseconds( SbMediaGetBufferGarbageCollectionDurationThreshold()); } int DecoderBufferAllocator::GetProgressiveBufferBudget( - SbMediaVideoCodec codec, int resolution_width, int resolution_height, + SbMediaVideoCodec codec, + int resolution_width, + int resolution_height, int bits_per_pixel) const { return SbMediaGetProgressiveBufferBudget(codec, resolution_width, resolution_height, bits_per_pixel); @@ -186,4 +188,3 @@ void DecoderBufferAllocator::EnsureReuseAllocatorIsCreated() { } } // namespace media -} // namespace cobalt diff --git a/media/starboard/decoder_buffer_allocator.h b/media/starboard/decoder_buffer_allocator.h index da9877cce5adb..b3d9ad35677f7 100644 --- a/media/starboard/decoder_buffer_allocator.h +++ b/media/starboard/decoder_buffer_allocator.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_ -#define COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_ +#ifndef MEDIA_STARBOARD_DECODER_BUFFER_ALLOCATOR_H_ +#define MEDIA_STARBOARD_DECODER_BUFFER_ALLOCATOR_H_ #include #include @@ -21,17 +21,16 @@ #include "base/compiler_specific.h" #include "base/synchronization/lock.h" #include "base/time/time.h" -#include "cobalt/media/bidirectional_fit_reuse_allocator.h" -#include "cobalt/media/decoder_buffer_memory_info.h" -#include "cobalt/media/starboard_memory_allocator.h" #include "media/base/decoder_buffer.h" #include "media/base/video_decoder_config.h" +#include "media/starboard/bidirectional_fit_reuse_allocator.h" +#include "media/starboard/decoder_buffer_memory_info.h" +#include "media/starboard/starboard_memory_allocator.h" #include "starboard/media.h" -namespace cobalt { namespace media { -class DecoderBufferAllocator : public ::media::DecoderBuffer::Allocator, +class DecoderBufferAllocator : public DecoderBuffer::Allocator, public DecoderBufferMemoryInfo { public: DecoderBufferAllocator(); @@ -48,10 +47,12 @@ class DecoderBufferAllocator : public ::media::DecoderBuffer::Allocator, int GetBufferAlignment() const override; int GetBufferPadding() const override; base::TimeDelta GetBufferGarbageCollectionDurationThreshold() const override; - int GetProgressiveBufferBudget(SbMediaVideoCodec codec, int resolution_width, + int GetProgressiveBufferBudget(SbMediaVideoCodec codec, + int resolution_width, int resolution_height, int bits_per_pixel) const override; - int GetVideoBufferBudget(SbMediaVideoCodec codec, int resolution_width, + int GetVideoBufferBudget(SbMediaVideoCodec codec, + int resolution_width, int resolution_height, int bits_per_pixel) const override; @@ -75,6 +76,5 @@ class DecoderBufferAllocator : public ::media::DecoderBuffer::Allocator, }; } // namespace media -} // namespace cobalt -#endif // COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_ +#endif // MEDIA_STARBOARD_DECODER_BUFFER_ALLOCATOR_H_ diff --git a/media/starboard/decoder_buffer_memory_info.h b/media/starboard/decoder_buffer_memory_info.h index 730b3030996af..58782b31f3645 100644 --- a/media/starboard/decoder_buffer_memory_info.h +++ b/media/starboard/decoder_buffer_memory_info.h @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COBALT_MEDIA_DECODER_BUFFER_MEMORY_INFO_H_ -#define COBALT_MEDIA_DECODER_BUFFER_MEMORY_INFO_H_ +#ifndef MEDIA_STARBOARD_DECODER_BUFFER_MEMORY_INFO_H_ +#define MEDIA_STARBOARD_DECODER_BUFFER_MEMORY_INFO_H_ #include "starboard/media.h" #include "starboard/types.h" -namespace cobalt { namespace media { class DecoderBufferMemoryInfo { @@ -40,6 +39,5 @@ class StubDecoderBufferMemoryInfo : public DecoderBufferMemoryInfo { }; } // namespace media -} // namespace cobalt -#endif // COBALT_MEDIA_DECODER_BUFFER_MEMORY_INFO_H_ +#endif // MEDIA_STARBOARD_DECODER_BUFFER_MEMORY_INFO_H_ diff --git a/media/starboard/starboard_memory_allocator.h b/media/starboard/starboard_memory_allocator.h index 4494bf489d930..6298e4f2273ba 100644 --- a/media/starboard/starboard_memory_allocator.h +++ b/media/starboard/starboard_memory_allocator.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef COBALT_MEDIA_STARBOARD_MEMORY_ALLOCATOR_H_ -#define COBALT_MEDIA_STARBOARD_MEMORY_ALLOCATOR_H_ +#ifndef MEDIA_STARBOARD_STARBOARD_MEMORY_ALLOCATOR_H_ +#define MEDIA_STARBOARD_STARBOARD_MEMORY_ALLOCATOR_H_ #include @@ -22,7 +22,6 @@ #include "starboard/common/allocator.h" #include "starboard/configuration.h" -namespace cobalt { namespace media { // StarboardMemoryAllocator is an allocator that allocates and frees memory @@ -54,6 +53,5 @@ class StarboardMemoryAllocator : public starboard::common::Allocator { }; } // namespace media -} // namespace cobalt -#endif // COBALT_MEDIA_STARBOARD_MEMORY_ALLOCATOR_H_ +#endif // MEDIA_STARBOARD_STARBOARD_MEMORY_ALLOCATOR_H_ diff --git a/media/starboard/starboard_utils.cc b/media/starboard/starboard_utils.cc index 5dceed49ea574..f287fbdf16866 100644 --- a/media/starboard/starboard_utils.cc +++ b/media/starboard/starboard_utils.cc @@ -363,7 +363,6 @@ SbMediaColorMetadata MediaToSbMediaColorMetadata( } int GetSbMediaVideoBufferBudget(const VideoDecoderConfig* video_config, const std::string& mime_type) { -#if COBALT_MEDIA_ENABLE_DECODE_BUFFER_BUDGET if (!video_config) { return DecoderBuffer::Allocator::GetInstance()->GetVideoBufferBudget( kSbMediaVideoCodecH264, 1920, 1080, 8); @@ -375,9 +374,6 @@ int GetSbMediaVideoBufferBudget(const VideoDecoderConfig* video_config, auto codec = MediaVideoCodecToSbMediaVideoCodec(video_config->codec()); return DecoderBuffer::Allocator::GetInstance()->GetVideoBufferBudget( codec, width, height, bits_per_pixel); -#else // COBALT_MEDIA_ENABLE_DECODE_BUFFER_BUDGET - return 100 * 1024 * 1024; -#endif // COBALT_MEDIA_ENABLE_DECODE_BUFFER_BUDGET } std::string ExtractCodecs(const std::string& mime_type) {