0

Don't allow video codecs to be used during demuxing.

We've never allowed them on Android and things work fine, so
don't allow them everywhere to reduce memory usage during
demuxing. Guarded by AllowOnlyAudioCodecsDuringDemuxing
base::Feature in case anything explodes.

Removing audio codecs explodes a lot of tests, so those need
to be kept enabled it seems.

2abf8a0b1b..0c408ec7db

$ git log 2abf8a0b1..0c408ec7d --date=short --no-merges --format='%ad %ae %s'
2024-07-29 dalecurtis Check codec_whitelist before reinitializing AVCtx.priv_data.

Created with:
  roll-dep src/third_party/ffmpeg

Bug: 355485812, 348538294
Change-Id: I09a53c688bc0b14eddb76df4c646d919ea4eb6f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5745750
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1334421}
This commit is contained in:
Dale Curtis
2024-07-29 20:18:48 +00:00
committed by Chromium LUCI CQ
parent 66b8753cf0
commit 06cffc3fea
3 changed files with 15 additions and 7 deletions
DEPS
media/filters
third_party

2
DEPS

@ -498,7 +498,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling ffmpeg
# and whatever else without interference from each other.
'ffmpeg_revision': '2abf8a0b1bd189435762588c52794c11e1ddaa20',
'ffmpeg_revision': '0c408ec7dbc7052dc32b306588642b886c8b8a36',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling beto-core
# and whatever else without interference from each other.

@ -17,6 +17,11 @@
namespace media {
// Kill switch in case things explode. Remove after M132.
BASE_FEATURE(kAllowOnlyAudioCodecsDuringDemuxing,
"AllowOnlyAudioCodecsDuringDemuxing",
base::FEATURE_ENABLED_BY_DEFAULT);
// Internal buffer size used by AVIO for reading.
// TODO(dalecurtis): Experiment with this buffer size and measure impact on
// performance. Currently we want to use 32kb to preserve existing behavior
@ -123,6 +128,13 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol) {
// deprecations and when an external ffmpeg is used this adds extra
// security.
static const base::NoDestructor<std::string> kCombinedCodecList([]() {
if (base::FeatureList::IsEnabled(kAllowOnlyAudioCodecsDuringDemuxing)) {
// We also don't allow ffmpeg to use any video decoders during demuxing
// since it's unnecessary for the codecs we use and just increases
// memory usage.
return std::string(GetAllowedAudioDecoders());
}
return base::JoinString(
{GetAllowedAudioDecoders(), GetAllowedVideoDecoders()}, ",");
}());
@ -151,12 +163,8 @@ const char* FFmpegGlue::GetAllowedAudioDecoders() {
// static
const char* FFmpegGlue::GetAllowedVideoDecoders() {
// This should match the configured lists in //third_party/ffmpeg.
//
// Note: We don't check IsBuiltInVideoCodec(VideoCodec::kH264) here since
// unfortunately ffmpeg will refuse to extract metadata for H264 when the H264
// decoder is compiled in if we disable it here.
#if BUILDFLAG(USE_PROPRIETARY_CODECS) && BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
return "h264";
return IsBuiltInVideoCodec(VideoCodec::kH264) ? "h264" : "";
#else
return "";
#endif