This commit is contained in:
Alexander Frick 2023-04-28 07:00:54 -05:00
parent 52d84880fe
commit ce3de7ff92
6 changed files with 95 additions and 57 deletions

View file

@ -186,6 +186,7 @@ bool IsAudioCodecProprietary(AudioCodec codec) {
case AudioCodec::kMpegHAudio:
case AudioCodec::kDTS:
case AudioCodec::kDTSXP2:
case AudioCodec::kDTSE:
return true;
case AudioCodec::kFLAC:
@ -356,6 +357,7 @@ bool IsDefaultSupportedAudioType(const AudioType& type) {
return false;
case AudioCodec::kDTS:
case AudioCodec::kDTSXP2:
case AudioCodec::kDTSE:
#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
return true;
#else

View file

@ -15,6 +15,7 @@
#include "media/base/encryption_scheme.h"
#include "media/base/media_util.h"
#include "media/base/video_aspect_ratio.h"
#include "media/base/video_color_space.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_util.h"
#include "media/formats/mp4/box_definitions.h"
@ -45,6 +46,12 @@ VideoDecoderConfig::AlphaMode GetAlphaMode(const AVStream* stream) {
: VideoDecoderConfig::AlphaMode::kIsOpaque;
}
VideoColorSpace GetGuessedColorSpace(const VideoColorSpace& color_space) {
return VideoColorSpace::FromGfxColorSpace(
// convert to gfx color space and make a guess.
color_space.ToGfxColorSpace());
}
} // namespace
// Alignment requirement by FFmpeg for input and output buffers. This need to
@ -690,17 +697,18 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
// because GBR is reasonable for 4:4:4 content. See crbug.com/1067377.
color_space = VideoColorSpace::REC709();
} else if (codec_context->codec_id == AV_CODEC_ID_HEVC &&
color_space.primaries == VideoColorSpace::PrimaryID::INVALID &&
color_space.transfer == VideoColorSpace::TransferID::BT709 &&
color_space.matrix == VideoColorSpace::MatrixID::UNSPECIFIED &&
color_space.range == gfx::ColorSpace::RangeID::LIMITED &&
(color_space.primaries == VideoColorSpace::PrimaryID::INVALID ||
color_space.transfer == VideoColorSpace::TransferID::INVALID ||
color_space.matrix == VideoColorSpace::MatrixID::INVALID) &&
AVPixelFormatToVideoPixelFormat(codec_context->pix_fmt) ==
PIXEL_FORMAT_I420) {
// Some HEVC SDR content encoded by the Adobe Premiere HW HEVC encoder has
// invalid primaries but valid transfer and matrix, this will cause
// IsHevcProfileSupported return "false" and fail to playback.
// See crbug.com/1374270.
color_space = VideoColorSpace::REC709();
// invalid primaries but valid transfer and matrix, and some HEVC SDR
// content encoded by web camera has invalid primaries and transfer, this
// will cause IsHevcProfileSupported return "false" and fail to playback.
// make a guess can at least make these videos able to play. See
// crbug.com/1374270.
color_space = GetGuessedColorSpace(color_space);
}
// AVCodecContext occasionally has invalid extra data. See

View file

@ -1,4 +1,4 @@
# Copyright 2023 The Chromium Authors and Alex313031
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -16,6 +16,25 @@ import("//third_party/libgav1/options.gni")
# This flag sets defaults for the current generation of cast devices.
is_cast_media_device = is_castos || is_cast_android
# Out-of-process video decoding is a feature specific to Linux and ChromeOS
# which makes the interaction with platform drivers (for the purposes of
# hardware accelerated video decoding) happen on utility processes for stability
# and security purposes. When |allow_oop_video_decoder| is true, code to
# use this feature is compiled. Note that even if |allow_oop_video_decoder| is
# true, the feature may be disabled by a runtime flag.
#
# When |allow_hosting_oop_video_decoder| is true, code to host the video decoder
# utility processes is compiled. Note that even if
# |allow_hosting_oop_video_decoder| is true, the hosting of these utility
# processes may be disabled by a runtime flag.
#
# TODO(b/195769334): finish replacing usages of (is_linux || is_chromeos) with
# allow_oop_video_decoder where appropriate. Also, finish replacing usages of
# (is_linux || is_chromeos_ash) with allow_hosting_oop_video_decoder where
# appropriate.
allow_oop_video_decoder = is_linux || is_chromeos
allow_hosting_oop_video_decoder = is_linux || is_chromeos_ash
declare_args() {
# Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
# using dlopen. This helps with automated detection of ABI mismatches and
@ -31,8 +50,8 @@ declare_args() {
# decoding of VP9 and VP8A type content.
media_use_libvpx = true
# iOS doesn't use ffmpeg, libvpx.
if (is_ios) {
# non-blink builds doesn't use ffmpeg, libvpx.
if (!use_blink) {
media_use_ffmpeg = false
media_use_libvpx = false
}
@ -86,7 +105,7 @@ declare_args() {
# When enabled on Fuchsia, these are logged as VLOGs.
enable_logging_override = is_cast_media_device
enable_dav1d_decoder = !is_ios
enable_dav1d_decoder = use_blink
# Enable browser managed persistent metadata storage for EME persistent
# session and persistent usage record session.
@ -98,7 +117,10 @@ declare_args() {
# Enable inclusion of the HEVC/H265 parser and also enable HEVC/H265 decoding
# with hardware acceleration assist. Enabled by default for fuzzer builds,
# ChromeOS builds with protected content support, Windows, Mac, and Android.
enable_hevc_parser_and_hw_decoder = true
enable_hevc_parser_and_hw_decoder =
proprietary_codecs &&
(use_fuzzing_engine || use_chromeos_protected_media || is_win || is_mac ||
is_android || is_linux)
}
# Use another declare_args() to allow dependence on args defined above.
@ -112,51 +134,50 @@ declare_args() {
# TODO(b/194429120): Enable this for Lacros builds.
# TODO(crbug.com/1336055): Revisit the default value for this setting as it
# applies to video-capable devices.
enable_platform_hevc = true
enable_platform_hevc =
proprietary_codecs &&
(enable_hevc_parser_and_hw_decoder || is_cast_media_device)
}
assert(
!enable_platform_ac3_eac3_audio || proprietary_codecs,
declare_args() {
platform_has_optional_hevc_support =
enable_platform_hevc &&
(is_win || is_chromeos || is_linux || is_mac || is_android)
}
assert(!enable_platform_ac3_eac3_audio || proprietary_codecs,
"proprietary_codecs required for enable_platform_ac3_eac3_audio")
assert(
!enable_platform_mpeg_h_audio || proprietary_codecs,
assert(!enable_platform_mpeg_h_audio || proprietary_codecs,
"proprietary_codecs required for enable_platform_mpeg_h_audio")
assert(
!enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
assert(!enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
"proprietary_codecs required for enable_mse_mpeg2ts_stream_parser")
assert(
!enable_platform_dolby_vision || proprietary_codecs,
assert(!enable_platform_dolby_vision || proprietary_codecs,
"proprietary_codecs required for enable_platform_dolby_vision")
assert(
!enable_platform_encrypted_dolby_vision || enable_platform_dolby_vision,
"enable_platform_dolby_vision required for enable_platform_encrypted_dolby_vision")
assert(!enable_hls_sample_aes || proprietary_codecs,
"proprietary_codecs required for enable_hls_sample_aes")
assert(
!enable_platform_dts_audio || proprietary_codecs,
assert(!enable_platform_dts_audio || proprietary_codecs,
"proprietary_codecs required for enable_platform_dts_audio")
assert(
!enable_hls_sample_aes || enable_mse_mpeg2ts_stream_parser,
assert(!enable_hls_sample_aes || enable_mse_mpeg2ts_stream_parser,
"enable_mse_mpeg2ts_stream_parser required for enable_hls_sample_aes")
assert(
!enable_hls_demuxer || enable_mse_mpeg2ts_stream_parser,
assert(!enable_hls_demuxer || enable_mse_mpeg2ts_stream_parser,
"enable_mse_mpeg2ts_stream_parser required for enable_hls_demuxer")
assert(!enable_platform_hevc || proprietary_codecs,
"proprietary_codecs required for enable_platform_hevc")
assert(
!enable_hevc_parser_and_hw_decoder || enable_platform_hevc,
assert(!enable_hevc_parser_and_hw_decoder || enable_platform_hevc,
"enable_platform_hevc required for enable_hevc_parser_and_hw_decoder")
# Most DolbyVision profiles (4, 5, 7, 8, not 9) require HEVC support. It's very
# unlikely that we support DolbyVision on a new platform without requiring HEVC
# support. See for details:
# https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile
assert(
!enable_platform_dolby_vision || enable_platform_hevc,
assert(!enable_platform_dolby_vision || enable_platform_hevc,
"enable_platform_hevc required for enable_platform_dolby_vision")
# Use another declare_args() to pick up possible overrides of |use_cras|.
@ -172,7 +193,7 @@ declare_args() {
#
# TODO(crbug.com/1336055): Remove legacy target_cpu hack used for targeting
# desktop Chromecast builds.
if (is_posix && !is_android && !is_mac &&
if (is_posix && !is_android && !is_apple &&
(!is_castos || (target_cpu == "x86" || target_cpu == "x64") ||
is_cast_audio_only)) {
use_alsa = true
@ -340,10 +361,7 @@ media_subcomponent_deps = [
]
if (is_fuchsia) {
media_subcomponent_deps += [
"//media/fuchsia/cdm",
"//media/fuchsia/common",
]
media_subcomponent_deps += [ "//media/fuchsia/common" ]
}
if (media_use_ffmpeg) {

View file

@ -186,6 +186,7 @@ bool IsAudioCodecProprietary(AudioCodec codec) {
case AudioCodec::kMpegHAudio:
case AudioCodec::kDTS:
case AudioCodec::kDTSXP2:
case AudioCodec::kDTSE:
return true;
case AudioCodec::kFLAC:
@ -356,6 +357,7 @@ bool IsDefaultSupportedAudioType(const AudioType& type) {
return false;
case AudioCodec::kDTS:
case AudioCodec::kDTSXP2:
case AudioCodec::kDTSE:
#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
return true;
#else

View file

@ -15,6 +15,7 @@
#include "media/base/encryption_scheme.h"
#include "media/base/media_util.h"
#include "media/base/video_aspect_ratio.h"
#include "media/base/video_color_space.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_util.h"
#include "media/formats/mp4/box_definitions.h"
@ -45,6 +46,12 @@ VideoDecoderConfig::AlphaMode GetAlphaMode(const AVStream* stream) {
: VideoDecoderConfig::AlphaMode::kIsOpaque;
}
VideoColorSpace GetGuessedColorSpace(const VideoColorSpace& color_space) {
return VideoColorSpace::FromGfxColorSpace(
// convert to gfx color space and make a guess.
color_space.ToGfxColorSpace());
}
} // namespace
// Alignment requirement by FFmpeg for input and output buffers. This need to
@ -690,17 +697,18 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
// because GBR is reasonable for 4:4:4 content. See crbug.com/1067377.
color_space = VideoColorSpace::REC709();
} else if (codec_context->codec_id == AV_CODEC_ID_HEVC &&
color_space.primaries == VideoColorSpace::PrimaryID::INVALID &&
color_space.transfer == VideoColorSpace::TransferID::BT709 &&
color_space.matrix == VideoColorSpace::MatrixID::UNSPECIFIED &&
color_space.range == gfx::ColorSpace::RangeID::LIMITED &&
(color_space.primaries == VideoColorSpace::PrimaryID::INVALID ||
color_space.transfer == VideoColorSpace::TransferID::INVALID ||
color_space.matrix == VideoColorSpace::MatrixID::INVALID) &&
AVPixelFormatToVideoPixelFormat(codec_context->pix_fmt) ==
PIXEL_FORMAT_I420) {
// Some HEVC SDR content encoded by the Adobe Premiere HW HEVC encoder has
// invalid primaries but valid transfer and matrix, this will cause
// IsHevcProfileSupported return "false" and fail to playback.
// See crbug.com/1374270.
color_space = VideoColorSpace::REC709();
// invalid primaries but valid transfer and matrix, and some HEVC SDR
// content encoded by web camera has invalid primaries and transfer, this
// will cause IsHevcProfileSupported return "false" and fail to playback.
// make a guess can at least make these videos able to play. See
// crbug.com/1374270.
color_space = GetGuessedColorSpace(color_space);
}
// AVCodecContext occasionally has invalid extra data. See