⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268908 in webkit


Ignore:
Timestamp:
Oct 23, 2020, 1:25:22 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r268392 - [GStreamer] Crash in WebCore::GStreamerRegistryScanner::isAVC1CodecSupported
https://bugs.webkit.org/show_bug.cgi?id=217647

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

The registry scanner was assuming the avc1 codec field is always of the form
avc1.codecprofile, which is wrong.

Covered by test: media/media-can-play-mpeg4-video.html

  • platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:

(WebCore::GStreamerRegistryScanner::isAVC1CodecSupported const): Check for '.' presence and
fallback to unconstrained check if no profile or level information was extracted.

LayoutTests:

  • media/media-can-play-mpeg4-video-expected.txt:
  • media/media-can-play-mpeg4-video.html: Add test for "avc1" codec.
Location:
releases/WebKitGTK/webkit-2.30
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.30/LayoutTests/ChangeLog

    r266595 r268908  
     12020-10-13  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] Crash in WebCore::GStreamerRegistryScanner::isAVC1CodecSupported
     4        https://bugs.webkit.org/show_bug.cgi?id=217647
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        * media/media-can-play-mpeg4-video-expected.txt:
     9        * media/media-can-play-mpeg4-video.html: Add test for "avc1" codec.
     10
    1112020-08-28  Adrian Perez de Castro  <aperez@igalia.com>
    212
  • releases/WebKitGTK/webkit-2.30/LayoutTests/media/media-can-play-mpeg4-video-expected.txt

    r158743 r268908  
    66EXPECTED (video.canPlayType('video/x-m4v') == 'maybe') OK
    77EXPECTED (video.canPlayType('video/mp4') == 'maybe') OK
     8EXPECTED (video.canPlayType('video/mp4; Codecs="avc1"') == 'probably') OK
    89EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"') == 'probably') OK
    910EXPECTED (video.canPlayType(' Video/MP4 ; CODECS="mp4v.20.8, mp4a.40.2"') == 'probably') OK
  • releases/WebKitGTK/webkit-2.30/LayoutTests/media/media-can-play-mpeg4-video.html

    r115798 r268908  
    1010                testExpected("video.canPlayType('video/x-m4v')", "maybe");
    1111                testExpected("video.canPlayType('video/mp4')", "maybe");
     12                testExpected("video.canPlayType('video/mp4; Codecs=\"avc1\"')", "probably");
    1213                testExpected("video.canPlayType('video/mp4; Codecs=\"avc1.4D400C\"')", "probably");
    1314                testExpected("video.canPlayType('        Video/MP4 ; CODECS=\"mp4v.20.8, mp4a.40.2\"')", "probably");
  • releases/WebKitGTK/webkit-2.30/Source/WebCore/ChangeLog

    r268452 r268908  
     12020-10-13  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] Crash in WebCore::GStreamerRegistryScanner::isAVC1CodecSupported
     4        https://bugs.webkit.org/show_bug.cgi?id=217647
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        The registry scanner was assuming the avc1 codec field is always of the form
     9        avc1.codecprofile, which is wrong.
     10
     11        Covered by test: media/media-can-play-mpeg4-video.html
     12
     13        * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
     14        (WebCore::GStreamerRegistryScanner::isAVC1CodecSupported const): Check for '.' presence and
     15        fallback to unconstrained check if no profile or level information was extracted.
     16
    1172020-10-13  Adrian Perez de Castro  <aperez@igalia.com>
    218
  • releases/WebKitGTK/webkit-2.30/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp

    r264162 r268908  
    363363bool GStreamerRegistryScanner::isAVC1CodecSupported(const String& codec, bool shouldCheckForHardwareUse) const
    364364{
    365     auto components = codec.split('.');
    366     long int spsAsInteger = strtol(components[1].utf8().data(), nullptr, 16);
    367     uint8_t sps[3];
    368     sps[0] = spsAsInteger >> 16;
    369     sps[1] = spsAsInteger >> 8;
    370     sps[2] = spsAsInteger;
    371 
    372     const char* profile = gst_codec_utils_h264_get_profile(sps, 3);
    373     const char* level = gst_codec_utils_h264_get_level(sps, 3);
    374 
    375     // To avoid going through a class hierarchy for such a simple
    376     // string conversion, we use a little trick here: See
    377     // https://bugs.webkit.org/show_bug.cgi?id=201870.
    378     char levelAsStringFallback[2] = { '\0', '\0' };
    379     if (!level && sps[2] > 0 && sps[2] <= 5) {
    380         levelAsStringFallback[0] = static_cast<char>('0' + sps[2]);
    381         level = levelAsStringFallback;
    382     }
    383 
    384     if (!profile || !level) {
    385         GST_ERROR("H.264 profile / level was not recognised in codec %s", codec.utf8().data());
    386         return false;
    387     }
    388 
    389     GST_DEBUG("Codec %s translates to H.264 profile %s and level %s", codec.utf8().data(), profile, level);
    390 
    391365    auto checkH264Caps = [&](const char* capsString) {
    392366        bool supported = false;
     
    398372        return supported;
    399373    };
     374
     375    if (codec.find('.') == notFound) {
     376        GST_DEBUG("Codec has no profile/level, falling back to unconstrained caps");
     377        return checkH264Caps("video/x-h264");
     378    }
     379
     380    auto components = codec.split('.');
     381    long int spsAsInteger = strtol(components[1].utf8().data(), nullptr, 16);
     382    uint8_t sps[3];
     383    sps[0] = spsAsInteger >> 16;
     384    sps[1] = spsAsInteger >> 8;
     385    sps[2] = spsAsInteger;
     386
     387    const char* profile = gst_codec_utils_h264_get_profile(sps, 3);
     388    const char* level = gst_codec_utils_h264_get_level(sps, 3);
     389
     390    // To avoid going through a class hierarchy for such a simple
     391    // string conversion, we use a little trick here: See
     392    // https://bugs.webkit.org/show_bug.cgi?id=201870.
     393    char levelAsStringFallback[2] = { '\0', '\0' };
     394    if (!level && sps[2] > 0 && sps[2] <= 5) {
     395        levelAsStringFallback[0] = static_cast<char>('0' + sps[2]);
     396        level = levelAsStringFallback;
     397    }
     398
     399    if (!profile || !level) {
     400        GST_ERROR("H.264 profile / level was not recognised in codec %s", codec.utf8().data());
     401        return false;
     402    }
     403
     404    GST_DEBUG("Codec %s translates to H.264 profile %s and level %s", codec.utf8().data(), profile, level);
    400405
    401406    if (const char* maxVideoResolution = g_getenv("WEBKIT_GST_MAX_AVC1_RESOLUTION")) {
Note: See TracChangeset for help on using the changeset viewer.