diff options
Diffstat (limited to 'chromium/media/gpu/android')
13 files changed, 51 insertions, 47 deletions
diff --git a/chromium/media/gpu/android/android_video_encode_accelerator.cc b/chromium/media/gpu/android/android_video_encode_accelerator.cc index c5270706bc6..a2e21c0273d 100644 --- a/chromium/media/gpu/android/android_video_encode_accelerator.cc +++ b/chromium/media/gpu/android/android_video_encode_accelerator.cc @@ -147,8 +147,7 @@ bool AndroidVideoEncodeAccelerator::Initialize(const Config& config, client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); - if (!(MediaCodecUtil::SupportsSetParameters() && - config.input_format == PIXEL_FORMAT_I420)) { + if (config.input_format != PIXEL_FORMAT_I420) { DLOG(ERROR) << "Unexpected combo: " << config.input_format << ", " << GetProfileName(config.output_profile); return false; diff --git a/chromium/media/gpu/android/codec_allocator.cc b/chromium/media/gpu/android/codec_allocator.cc index 0f80ad4fec6..6e2547d96b4 100644 --- a/chromium/media/gpu/android/codec_allocator.cc +++ b/chromium/media/gpu/android/codec_allocator.cc @@ -9,6 +9,7 @@ #include <algorithm> #include <memory> +#include "base/android/build_info.h" #include "base/callback_helpers.h" #include "base/logging.h" #include "base/task/post_task.h" @@ -54,6 +55,9 @@ scoped_refptr<base::SequencedTaskRunner> CreateCodecTaskRunner() { } // namespace // static +constexpr gfx::Size CodecAllocator::kMinHardwareResolution; + +// static CodecAllocator* CodecAllocator::GetInstance( scoped_refptr<base::SequencedTaskRunner> task_runner) { static base::NoDestructor<CodecAllocator> allocator( @@ -97,7 +101,11 @@ void CodecAllocator::CreateMediaCodecAsync( // If we're still allowed to pick any type we want, then limit to software for // low resolution. https://crbug.com/1166833 - if (codec_config->codec_type == CodecType::kAny && + // Software decoders on Lollipop refuse to decode media that played + // everywhere else, so let's not force it. https://crbug.com/1175322 + bool lollipop = base::android::BuildInfo::GetInstance()->sdk_int() < + base::android::SDK_VERSION_MARSHMALLOW; + if (!lollipop && codec_config->codec_type == CodecType::kAny && (codec_config->initial_expected_coded_size.width() < kMinHardwareResolution.width() || codec_config->initial_expected_coded_size.height() < diff --git a/chromium/media/gpu/android/codec_allocator_unittest.cc b/chromium/media/gpu/android/codec_allocator_unittest.cc index 7b08de5e192..09a02a325c1 100644 --- a/chromium/media/gpu/android/codec_allocator_unittest.cc +++ b/chromium/media/gpu/android/codec_allocator_unittest.cc @@ -8,6 +8,7 @@ #include <memory> +#include "base/android/build_info.h" #include "base/bind.h" #include "base/callback_helpers.h" #include "base/check.h" @@ -392,7 +393,13 @@ TEST_F(CodecAllocatorTest, LowResolutionGetsSoftware) { base::Unretained(this), run_loop.QuitClosure()), std::move(config)); - EXPECT_CALL(*this, OnCodecCreated(CodecType::kSoftware)); + bool lollipop = base::android::BuildInfo::GetInstance()->sdk_int() < + base::android::SDK_VERSION_MARSHMALLOW; + if (lollipop) + EXPECT_CALL(*this, OnCodecCreated(CodecType::kAny)); + else + EXPECT_CALL(*this, OnCodecCreated(CodecType::kSoftware)); + run_loop.Run(); } diff --git a/chromium/media/gpu/android/codec_image_unittest.cc b/chromium/media/gpu/android/codec_image_unittest.cc index bc0b5e4c27f..29a09b3989d 100644 --- a/chromium/media/gpu/android/codec_image_unittest.cc +++ b/chromium/media/gpu/android/codec_image_unittest.cc @@ -49,7 +49,7 @@ class CodecImageTest : public testing::Test { .WillByDefault(Return(MEDIA_CODEC_OK)); gl::init::InitializeStaticGLBindingsImplementation( - gl::kGLImplementationEGLGLES2, false); + gl::GLImplementationParts(gl::kGLImplementationEGLGLES2), false); gl::init::InitializeGLOneOffPlatformImplementation(false, false, false); surface_ = new gl::PbufferGLSurfaceEGL(gfx::Size(320, 240)); diff --git a/chromium/media/gpu/android/codec_output_buffer_renderer.cc b/chromium/media/gpu/android/codec_output_buffer_renderer.cc index 9beaf756533..b327de7c161 100644 --- a/chromium/media/gpu/android/codec_output_buffer_renderer.cc +++ b/chromium/media/gpu/android/codec_output_buffer_renderer.cc @@ -109,9 +109,19 @@ bool CodecOutputBufferRenderer::RenderToTextureOwnerFrontBuffer( if (phase_ == Phase::kInvalidated) return false; - std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current = - MakeCurrentIfNeeded( - codec_buffer_wait_coordinator_->texture_owner().get()); + std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; + + // If the texture_owner() binds the texture while doing the texture update + // (UpdateTexImage), like in SurfaceTexture case, then only make the context + // current. For AImageReader, since we only acquire the latest image from it + // during the texture update process, there is no need to make it's context + // current. + if (codec_buffer_wait_coordinator_->texture_owner() + ->binds_texture_on_update()) { + scoped_make_current = MakeCurrentIfNeeded( + codec_buffer_wait_coordinator_->texture_owner().get()); + } + // If updating the image will implicitly update the texture bindings then // restore if requested or the update needed a context switch. base::Optional<ScopedRestoreTextureBinding> scoped_restore_texture; diff --git a/chromium/media/gpu/android/codec_wrapper.cc b/chromium/media/gpu/android/codec_wrapper.cc index 128ebadb96c..be7a5ddd7a4 100644 --- a/chromium/media/gpu/android/codec_wrapper.cc +++ b/chromium/media/gpu/android/codec_wrapper.cc @@ -38,7 +38,6 @@ class CodecWrapperImpl : public base::RefCountedThreadSafe<CodecWrapperImpl> { bool IsFlushed() const; bool IsDraining() const; bool IsDrained() const; - bool SupportsFlush(DeviceInfo* device_info) const; bool Flush(); bool SetSurface(scoped_refptr<CodecSurfaceBundle> surface_bundle); scoped_refptr<CodecSurfaceBundle> SurfaceBundle(); @@ -189,12 +188,6 @@ void CodecWrapperImpl::DiscardOutputBuffers_Locked() { buffer_ids_.clear(); } -bool CodecWrapperImpl::SupportsFlush(DeviceInfo* device_info) const { - DVLOG(2) << __func__; - base::AutoLock l(lock_); - return !device_info->CodecNeedsFlushWorkaround(codec_.get()); -} - bool CodecWrapperImpl::Flush() { DVLOG(2) << __func__; base::AutoLock l(lock_); @@ -461,10 +454,6 @@ void CodecWrapper::DiscardOutputBuffers() { impl_->DiscardOutputBuffers(); } -bool CodecWrapper::SupportsFlush(DeviceInfo* device_info) const { - return impl_->SupportsFlush(device_info); -} - bool CodecWrapper::IsFlushed() const { return impl_->IsFlushed(); } diff --git a/chromium/media/gpu/android/codec_wrapper.h b/chromium/media/gpu/android/codec_wrapper.h index c49931981ba..df5acec0f69 100644 --- a/chromium/media/gpu/android/codec_wrapper.h +++ b/chromium/media/gpu/android/codec_wrapper.h @@ -123,9 +123,6 @@ class MEDIA_GPU_EXPORT CodecWrapper { // Releases all dequeued output buffers back to the codec without rendering. void DiscardOutputBuffers(); - // Whether the codec supports Flush(). - bool SupportsFlush(DeviceInfo* device_info) const; - // Flushes the codec and discards all output buffers. bool Flush(); diff --git a/chromium/media/gpu/android/device_info.cc b/chromium/media/gpu/android/device_info.cc index cdf0395dba8..5665664dce4 100644 --- a/chromium/media/gpu/android/device_info.cc +++ b/chromium/media/gpu/android/device_info.cc @@ -49,10 +49,6 @@ bool DeviceInfo::SupportsOverlaySurfaces() { return result; } -bool DeviceInfo::CodecNeedsFlushWorkaround(MediaCodecBridge* codec) { - return MediaCodecUtil::CodecNeedsFlushWorkaround(codec); -} - bool DeviceInfo::IsAsyncApiSupported() { // Technically the base setCallback() API is available in L, but we // need the version which accepts a Handler which is in M... but diff --git a/chromium/media/gpu/android/device_info.h b/chromium/media/gpu/android/device_info.h index ff98e98300a..17202796c8a 100644 --- a/chromium/media/gpu/android/device_info.h +++ b/chromium/media/gpu/android/device_info.h @@ -9,7 +9,6 @@ #include "media/gpu/media_gpu_export.h" namespace media { -class MediaCodecBridge; // Info about the current platform and device with caching of the results that // don't change. Virtual for testing. @@ -23,7 +22,6 @@ struct MEDIA_GPU_EXPORT DeviceInfo { virtual bool IsDecoderKnownUnaccelerated(VideoCodec codec); virtual bool IsSetOutputSurfaceSupported(); virtual bool SupportsOverlaySurfaces(); - virtual bool CodecNeedsFlushWorkaround(MediaCodecBridge* codec); virtual bool IsAsyncApiSupported(); virtual bool AddSupportedCodecProfileLevels( std::vector<CodecProfileLevel>* result); diff --git a/chromium/media/gpu/android/media_codec_video_decoder.cc b/chromium/media/gpu/android/media_codec_video_decoder.cc index 9069826e489..be37e450fbd 100644 --- a/chromium/media/gpu/android/media_codec_video_decoder.cc +++ b/chromium/media/gpu/android/media_codec_video_decoder.cc @@ -172,7 +172,19 @@ std::vector<SupportedVideoDecoderConfig> GetSupportedConfigsInternal( true, // allow_encrypted false); // require_encrypted #endif +#if BUILDFLAG(ENABLE_PLATFORM_DOLBY_VISION) + // Technically we should check which profiles are supported, but we can + // allow them all like we do with H264 codec. + supported_configs.emplace_back(DOLBYVISION_PROFILE4, DOLBYVISION_PROFILE9, + gfx::Size(0, 0), gfx::Size(3840, 2160), + true, // allow_encrypted + false); // require_encrypted + supported_configs.emplace_back(DOLBYVISION_PROFILE4, DOLBYVISION_PROFILE9, + gfx::Size(0, 0), gfx::Size(2160, 3840), + true, // allow_encrypted + false); // require_encrypted #endif +#endif // #if BUILDFLAG(USE_PROPRIETARY_CODECS) return supported_configs; } @@ -762,20 +774,9 @@ void MediaCodecVideoDecoder::FlushCodec() { if (!codec_ || codec_->IsFlushed()) return; - if (codec_->SupportsFlush(device_info_)) { - DVLOG(2) << "Flushing codec"; - if (!codec_->Flush()) - EnterTerminalState(State::kError, "Codec flush failed"); - } else { - DVLOG(2) << "flush() workaround: creating a new codec"; - // Release the codec and create a new one. - // Note: we may end up with two codecs attached to the same surface if the - // release hangs on one thread and create proceeds on another. This will - // result in an error, letting the user retry the playback. The alternative - // of waiting for the release risks hanging the playback forever. - ReleaseCodec(); - CreateCodec(); - } + DVLOG(2) << "Flushing codec"; + if (!codec_->Flush()) + EnterTerminalState(State::kError, "Codec flush failed"); } void MediaCodecVideoDecoder::PumpCodec(bool force_start_timer) { @@ -1155,10 +1156,6 @@ AndroidOverlayFactoryCB MediaCodecVideoDecoder::CreateOverlayFactoryCb() { return base::BindRepeating(overlay_factory_cb_, *overlay_info_.routing_token); } -std::string MediaCodecVideoDecoder::GetDisplayName() const { - return "MediaCodecVideoDecoder"; -} - VideoDecoderType MediaCodecVideoDecoder::GetDecoderType() const { return VideoDecoderType::kMediaCodec; } diff --git a/chromium/media/gpu/android/media_codec_video_decoder.h b/chromium/media/gpu/android/media_codec_video_decoder.h index d3e3f21057f..4b9d81a7821 100644 --- a/chromium/media/gpu/android/media_codec_video_decoder.h +++ b/chromium/media/gpu/android/media_codec_video_decoder.h @@ -79,7 +79,6 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder final : public VideoDecoder { std::unique_ptr<VideoFrameFactory> video_frame_factory); // VideoDecoder implementation: - std::string GetDisplayName() const override; VideoDecoderType GetDecoderType() const override; void Initialize(const VideoDecoderConfig& config, bool low_delay, diff --git a/chromium/media/gpu/android/media_codec_video_decoder_unittest.cc b/chromium/media/gpu/android/media_codec_video_decoder_unittest.cc index be0e415b85c..f8b383a76f7 100644 --- a/chromium/media/gpu/android/media_codec_video_decoder_unittest.cc +++ b/chromium/media/gpu/android/media_codec_video_decoder_unittest.cc @@ -1059,5 +1059,7 @@ INSTANTIATE_TEST_SUITE_P(MediaCodecVideoDecoderAV1Test, GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MediaCodecVideoDecoderVp9Test); // This test suite is empty on some OSes. GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MediaCodecVideoDecoderAV1Test); +// For builds without proprietary codecs +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MediaCodecVideoDecoderH264Test); } // namespace media diff --git a/chromium/media/gpu/android/mock_device_info.h b/chromium/media/gpu/android/mock_device_info.h index 756efed8b7f..bfd1fc1df98 100644 --- a/chromium/media/gpu/android/mock_device_info.h +++ b/chromium/media/gpu/android/mock_device_info.h @@ -11,6 +11,8 @@ namespace media { +class MediaCodecBridge; + // A mock DeviceInfo with reasonable defaults. class MockDeviceInfo : public DeviceInfo { public: |