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::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
@ -694,17 +701,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

@ -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
}
@ -83,7 +102,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.
@ -112,49 +131,46 @@ declare_args() {
enable_platform_hevc = true
}
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,
"proprietary_codecs required for enable_platform_mpeg_h_audio")
assert(
!enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
"proprietary_codecs required for enable_mse_mpeg2ts_stream_parser")
assert(
!enable_platform_dolby_vision || proprietary_codecs,
"proprietary_codecs required for enable_platform_dolby_vision")
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,
"proprietary_codecs required for enable_platform_mpeg_h_audio")
assert(!enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
"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(
!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,
"proprietary_codecs required for enable_platform_dts_audio")
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,
"enable_mse_mpeg2ts_stream_parser required for enable_hls_sample_aes")
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,
"enable_mse_mpeg2ts_stream_parser required for enable_hls_demuxer")
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,
"enable_platform_hevc required for enable_hevc_parser_and_hw_decoder")
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,
"enable_platform_hevc required for enable_platform_dolby_vision")
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|.
declare_args() {
@ -169,7 +185,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
@ -309,11 +325,11 @@ declare_args() {
declare_args() {
# Currently it is available on Win, Mac, Linux and ChromeOS since it requires
# the audio service to run in a separate process.
# ChromeOS(http://crbug/1407588):
# ChromeOS(http://crbug/1407588):
# On CromeOS we are experimenting with the same set of systems CRAS runs on
# ie. is_chromeos_device.
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
@ -336,10 +352,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

@ -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
// found in the LICENSE file.
@ -57,8 +57,9 @@ SkBitmap GetWidgetBitmap(const gfx::Size& size,
case BG_RENDER_NONE:
break;
}
if (render_frame)
if (render_frame) {
gtk_render_frame(context, cr, 0, 0, size.width(), size.height());
}
bitmap.setImmutable();
return bitmap;
}
@ -173,19 +174,8 @@ void NativeThemeGtk::OnThemeChanged(GtkSettings* settings,
GtkParamSpec* param) {
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 =
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
// 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;
}
};
if (GtkCheckVersion(3, 20)) {
auto context = GetStyleContextFromCss(
StrCat({GtkCssMenu(), " GtkSeparator#separator.horizontal"}));
int min_height = 1;
auto margin = GtkStyleContextGetMargin(context);
auto border = GtkStyleContextGetBorder(context);
auto padding = GtkStyleContextGetPadding(context);
if (GtkCheckVersion(4))
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);
auto context = GetStyleContextFromCss(
StrCat({GtkCssMenu(), " GtkSeparator#separator.horizontal"}));
int min_height = 1;
auto margin = GtkStyleContextGetMargin(context);
auto border = GtkStyleContextGetBorder(context);
auto padding = GtkStyleContextGetPadding(context);
if (GtkCheckVersion(4)) {
min_height = GetSeparatorSize(true).height();
} else {
auto context = GetStyleContextFromCss(
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);
}
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);
}
void NativeThemeGtk::PaintFrameTopArea(