Skip to content

Commit

Permalink
Introduce a WebCodecs HEVC feature flag
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259057
rdar://112016320

Reviewed by Eric Carlson.

We introduce the HEVC feature flag and use it in WebCodecsVideoDecoder/Encoder to stop early if the flag is off.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/Modules/webcodecs/WebCodecsVideoDecoder.cpp:
(WebCore::isValidDecoderConfig):
* Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoder.cpp:
(WebCore::isValidEncoderConfig):

Canonical link: https://commits.webkit.org/265908@main
  • Loading branch information
youennf committed Jul 10, 2023
1 parent 4a4b325 commit 4805993
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7325,6 +7325,21 @@ WebCodecsEnabled:
"USE(GSTREAMER)": true
default: false

WebCodecsHEVCEnabled:
type: bool
status: preview
category: media
humanReadableName: "WebCodecs HEVC codec"
humanReadableDescription: "Enable WebCodecs HEVC codec"
condition: ENABLE(WEB_CODECS)
defaultValue:
WebKitLegacy:
default: false
WebKit:
default: false
WebCore:
default: false

WebCryptoSafeCurvesEnabled:
type: bool
status: stable
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Modules/webcodecs/WebCodecsVideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ WebCodecsVideoDecoder::~WebCodecsVideoDecoder()
static bool isValidDecoderConfig(const WebCodecsVideoDecoderConfig& config, const Settings::Values& settings)
{
// FIXME: Check codec more accurately.
if (!config.codec.startsWith("vp8"_s) && !config.codec.startsWith("vp09."_s) && !config.codec.startsWith("avc1."_s) && (!config.codec.startsWith("av01."_s) || !settings.webCodecsAV1Enabled))
if (!config.codec.startsWith("vp8"_s) && !config.codec.startsWith("vp09."_s) && !config.codec.startsWith("avc1."_s) && !(config.codec.startsWith("hev1."_s) && settings.webCodecsHEVCEnabled) && !(config.codec.startsWith("hvc1."_s) && settings.webCodecsHEVCEnabled) && !(config.codec.startsWith("av01."_s) && settings.webCodecsAV1Enabled))
return false;

if (!!config.codedWidth != !!config.codedHeight)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ WebCodecsVideoEncoder::~WebCodecsVideoEncoder()
static bool isValidEncoderConfig(const WebCodecsVideoEncoderConfig& config, const Settings::Values& settings)
{
// FIXME: Check codec more accurately.
if (!config.codec.startsWith("vp8"_s) && !config.codec.startsWith("vp09."_s) && !config.codec.startsWith("avc1."_s) && !config.codec.startsWith("hev1."_s) && (!config.codec.startsWith("av01."_s) || !settings.webCodecsAV1Enabled))
if (!config.codec.startsWith("vp8"_s) && !config.codec.startsWith("vp09."_s) && !config.codec.startsWith("avc1."_s) && !(config.codec.startsWith("hev1."_s) && settings.webCodecsHEVCEnabled) && !(config.codec.startsWith("hvc1."_s) && settings.webCodecsHEVCEnabled) && !(config.codec.startsWith("av01."_s) && settings.webCodecsAV1Enabled))
return false;

if (!config.width || !config.height)
Expand Down

0 comments on commit 4805993

Please sign in to comment.