M112 part 6

This commit is contained in:
Alexander Frick 2023-04-28 06:42:30 -05:00
parent df3b227598
commit 52d84880fe
4 changed files with 87 additions and 98 deletions

View file

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

View file

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

View file

@ -16,6 +16,25 @@ import("//third_party/libgav1/options.gni")
# This flag sets defaults for the current generation of cast devices. # This flag sets defaults for the current generation of cast devices.
is_cast_media_device = is_castos || is_cast_android 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() { declare_args() {
# Allows distributions to link pulseaudio directly (DT_NEEDED) instead of # Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
# using dlopen. This helps with automated detection of ABI mismatches and # using dlopen. This helps with automated detection of ABI mismatches and
@ -31,8 +50,8 @@ declare_args() {
# decoding of VP9 and VP8A type content. # decoding of VP9 and VP8A type content.
media_use_libvpx = true media_use_libvpx = true
# iOS doesn't use ffmpeg, libvpx. # non-blink builds doesn't use ffmpeg, libvpx.
if (is_ios) { if (!use_blink) {
media_use_ffmpeg = false media_use_ffmpeg = false
media_use_libvpx = false media_use_libvpx = false
} }
@ -83,7 +102,7 @@ declare_args() {
# When enabled on Fuchsia, these are logged as VLOGs. # When enabled on Fuchsia, these are logged as VLOGs.
enable_logging_override = is_cast_media_device 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 # Enable browser managed persistent metadata storage for EME persistent
# session and persistent usage record session. # session and persistent usage record session.
@ -112,49 +131,46 @@ declare_args() {
enable_platform_hevc = true enable_platform_hevc = true
} }
assert( declare_args() {
!enable_platform_ac3_eac3_audio || proprietary_codecs, platform_has_optional_hevc_support =
"proprietary_codecs required for enable_platform_ac3_eac3_audio") enable_platform_hevc &&
assert( (is_win || is_chromeos || is_linux || is_mac || is_android)
!enable_platform_mpeg_h_audio || proprietary_codecs, }
"proprietary_codecs required for enable_platform_mpeg_h_audio")
assert( assert(!enable_platform_ac3_eac3_audio || proprietary_codecs,
!enable_mse_mpeg2ts_stream_parser || proprietary_codecs, "proprietary_codecs required for enable_platform_ac3_eac3_audio")
"proprietary_codecs required for enable_mse_mpeg2ts_stream_parser") assert(!enable_platform_mpeg_h_audio || proprietary_codecs,
assert( "proprietary_codecs required for enable_platform_mpeg_h_audio")
!enable_platform_dolby_vision || proprietary_codecs, assert(!enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
"proprietary_codecs required for enable_platform_dolby_vision") "proprietary_codecs required for enable_mse_mpeg2ts_stream_parser")
assert(!enable_platform_dolby_vision || proprietary_codecs,
"proprietary_codecs required for enable_platform_dolby_vision")
assert( assert(
!enable_platform_encrypted_dolby_vision || enable_platform_dolby_vision, !enable_platform_encrypted_dolby_vision || enable_platform_dolby_vision,
"enable_platform_dolby_vision required for enable_platform_encrypted_dolby_vision") "enable_platform_dolby_vision required for enable_platform_encrypted_dolby_vision")
assert(!enable_hls_sample_aes || proprietary_codecs, assert(!enable_hls_sample_aes || proprietary_codecs,
"proprietary_codecs required for enable_hls_sample_aes") "proprietary_codecs required for enable_hls_sample_aes")
assert( assert(!enable_platform_dts_audio || proprietary_codecs,
!enable_platform_dts_audio || proprietary_codecs, "proprietary_codecs required for enable_platform_dts_audio")
"proprietary_codecs required for enable_platform_dts_audio")
assert( assert(!enable_hls_sample_aes || enable_mse_mpeg2ts_stream_parser,
!enable_hls_sample_aes || enable_mse_mpeg2ts_stream_parser, "enable_mse_mpeg2ts_stream_parser required for enable_hls_sample_aes")
"enable_mse_mpeg2ts_stream_parser required for enable_hls_sample_aes")
assert( assert(!enable_hls_demuxer || enable_mse_mpeg2ts_stream_parser,
!enable_hls_demuxer || enable_mse_mpeg2ts_stream_parser, "enable_mse_mpeg2ts_stream_parser required for enable_hls_demuxer")
"enable_mse_mpeg2ts_stream_parser required for enable_hls_demuxer")
assert(!enable_platform_hevc || proprietary_codecs, assert(!enable_platform_hevc || proprietary_codecs,
"proprietary_codecs required for enable_platform_hevc") "proprietary_codecs required for enable_platform_hevc")
assert( assert(!enable_hevc_parser_and_hw_decoder || enable_platform_hevc,
!enable_hevc_parser_and_hw_decoder || enable_platform_hevc, "enable_platform_hevc required for enable_hevc_parser_and_hw_decoder")
"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 # 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 # unlikely that we support DolbyVision on a new platform without requiring HEVC
# support. See for details: # support. See for details:
# https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile # https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile
assert( assert(!enable_platform_dolby_vision || enable_platform_hevc,
!enable_platform_dolby_vision || enable_platform_hevc, "enable_platform_hevc required for enable_platform_dolby_vision")
"enable_platform_hevc required for enable_platform_dolby_vision")
# Use another declare_args() to pick up possible overrides of |use_cras|. # Use another declare_args() to pick up possible overrides of |use_cras|.
declare_args() { declare_args() {
@ -169,7 +185,7 @@ declare_args() {
# #
# TODO(crbug.com/1336055): Remove legacy target_cpu hack used for targeting # TODO(crbug.com/1336055): Remove legacy target_cpu hack used for targeting
# desktop Chromecast builds. # 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_castos || (target_cpu == "x86" || target_cpu == "x64") ||
is_cast_audio_only)) { is_cast_audio_only)) {
use_alsa = true use_alsa = true
@ -313,7 +329,7 @@ declare_args() {
# On CromeOS we are experimenting with the same set of systems CRAS runs on # On CromeOS we are experimenting with the same set of systems CRAS runs on
# ie. is_chromeos_device. # ie. is_chromeos_device.
chrome_wide_echo_cancellation_supported = chrome_wide_echo_cancellation_supported =
is_win || is_mac || is_linux || is_chromeos_device is_win || is_mac || is_linux || is_chromeos_device
} }
# Do not expand this list without double-checking with OWNERS, this is a list of # Do not expand this list without double-checking with OWNERS, this is a list of
@ -336,10 +352,7 @@ media_subcomponent_deps = [
] ]
if (is_fuchsia) { if (is_fuchsia) {
media_subcomponent_deps += [ media_subcomponent_deps += [ "//media/fuchsia/common" ]
"//media/fuchsia/cdm",
"//media/fuchsia/common",
]
} }
if (media_use_ffmpeg) { if (media_use_ffmpeg) {

View file

@ -1,4 +1,4 @@
// Copyright 2023 The Chromium Authors, Alex313031, qcasey and icepie. // Copyright 2023 The Chromium Authors, Alex313031, qcasey and icepie
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
@ -57,8 +57,9 @@ SkBitmap GetWidgetBitmap(const gfx::Size& size,
case BG_RENDER_NONE: case BG_RENDER_NONE:
break; break;
} }
if (render_frame) if (render_frame) {
gtk_render_frame(context, cr, 0, 0, size.width(), size.height()); gtk_render_frame(context, cr, 0, 0, size.width(), size.height());
}
bitmap.setImmutable(); bitmap.setImmutable();
return bitmap; return bitmap;
} }
@ -173,19 +174,8 @@ void NativeThemeGtk::OnThemeChanged(GtkSettings* settings,
GtkParamSpec* param) { GtkParamSpec* param) {
SetThemeCssOverride(ScopedCssProvider()); SetThemeCssOverride(ScopedCssProvider());
// Hack to workaround a bug on GNOME standard themes which would
// cause black patches to be rendered on GtkFileChooser dialogs.
std::string theme_name = std::string theme_name =
GetGtkSettingsStringProperty(settings, "gtk-theme-name"); GetGtkSettingsStringProperty(settings, "gtk-theme-name");
if (!GtkCheckVersion(3, 14)) {
if (theme_name == "Adwaita") {
SetThemeCssOverride(GetCssProvider(
"GtkFileChooser GtkPaned { background-color: @theme_bg_color; }"));
} else if (theme_name == "HighContrast") {
SetThemeCssOverride(GetCssProvider(
"GtkFileChooser GtkPaned { background-color: @theme_base_color; }"));
}
}
// GTK has a dark mode setting called "gtk-application-prefer-dark-theme", but // GTK has a dark mode setting called "gtk-application-prefer-dark-theme", but
// this is really only used for themes that have a dark or light variant that // this is really only used for themes that have a dark or light variant that
@ -278,48 +268,24 @@ void NativeThemeGtk::PaintMenuSeparator(
return (rect.height() - separator_thickness) / 2; return (rect.height() - separator_thickness) / 2;
} }
}; };
if (GtkCheckVersion(3, 20)) { auto context = GetStyleContextFromCss(
auto context = GetStyleContextFromCss( StrCat({GtkCssMenu(), " GtkSeparator#separator.horizontal"}));
StrCat({GtkCssMenu(), " GtkSeparator#separator.horizontal"})); int min_height = 1;
int min_height = 1; auto margin = GtkStyleContextGetMargin(context);
auto margin = GtkStyleContextGetMargin(context); auto border = GtkStyleContextGetBorder(context);
auto border = GtkStyleContextGetBorder(context); auto padding = GtkStyleContextGetPadding(context);
auto padding = GtkStyleContextGetPadding(context); if (GtkCheckVersion(4)) {
if (GtkCheckVersion(4)) min_height = GetSeparatorSize(true).height();
min_height = GetSeparatorSize(true).height();
else
GtkStyleContextGet(context, "min-height", &min_height, nullptr);
int w = rect.width() - margin.left() - margin.right();
int h = std::max(min_height + padding.top() + padding.bottom() +
border.top() + border.bottom(),
1);
int x = margin.left();
int y = separator_offset(h);
PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NORMAL, true);
} else { } else {
auto context = GetStyleContextFromCss( GtkStyleContextGet(context, "min-height", &min_height, nullptr);
StrCat({GtkCssMenu(), " ", GtkCssMenuItem(), ".separator.horizontal"}));
gboolean wide_separators = false;
gint separator_height = 0;
GtkStyleContextGetStyle(context, "wide-separators", &wide_separators,
"separator-height", &separator_height, nullptr);
// This code was adapted from gtk/gtkmenuitem.c. For some reason,
// padding is used as the margin.
auto padding = GtkStyleContextGetPadding(context);
int w = rect.width() - padding.left() - padding.right();
int x = rect.x() + padding.left();
int h = wide_separators ? separator_height : 1;
int y = rect.y() + separator_offset(h);
if (wide_separators) {
PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NONE, true);
} else {
cc::PaintFlags flags;
flags.setColor(GtkStyleContextGetColor(context));
flags.setAntiAlias(true);
flags.setStrokeWidth(1);
canvas->drawLine(x + 0.5f, y + 0.5f, x + w + 0.5f, y + 0.5f, flags);
}
} }
int w = rect.width() - margin.left() - margin.right();
int h = std::max(min_height + padding.top() + padding.bottom() +
border.top() + border.bottom(),
1);
int x = margin.left();
int y = separator_offset(h);
PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NORMAL, true);
} }
void NativeThemeGtk::PaintFrameTopArea( void NativeThemeGtk::PaintFrameTopArea(