Changeset 265095 in webkit


Ignore:
Timestamp:
Jul 30, 2020 2:28:38 PM (4 years ago)
Author:
jer.noble@apple.com
Message:

[Cocoa] Make DecoderTest run against .mp4 files; add rate-limiting.
https://bugs.webkit.org/show_bug.cgi?id=214807

Reviewed by Darin Adler.

PerformanceTests:

Look up the UTI type of the specified file, and create the appropriate SourceBufferParser
by passing in the ContentType (converted from UTI). Also, add a --rate-limit flag which
causes the decompression session to run at the same FPS as the underlying media.

  • DecoderTest/DecoderTest.xcodeproj/project.pbxproj:
  • DecoderTest/DecoderTest/main.mm:

(main):

Source/WebCore:

Export registerWebKitVP9Decoder() from VP9UtilitiesCocoa instead of LibWebRTCProvider to make it easier
for DecodeTest to import, as LibWebRTCProvider also pulls in a bunch of libwebrtc headers. Also, export
SourceBufferParser.h so DecoderTest can create parsers for fMP4 files.

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/cocoa/VP9UtilitiesCocoa.h:
  • platform/graphics/cocoa/VP9UtilitiesCocoa.mm:

(WebCore::registerWebKitVP9Decoder):

Source/WebKit:

  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::enableVP9Decoder):

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/ChangeLog

    r264839 r265095  
     12020-07-30  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Make DecoderTest run against .mp4 files; add rate-limiting.
     4        https://bugs.webkit.org/show_bug.cgi?id=214807
     5
     6        Reviewed by Darin Adler.
     7
     8        Look up the UTI type of the specified file, and create the appropriate SourceBufferParser
     9        by passing in the ContentType (converted from UTI). Also, add a --rate-limit flag which
     10        causes the decompression session to run at the same FPS as the underlying media.
     11
     12        * DecoderTest/DecoderTest.xcodeproj/project.pbxproj:
     13        * DecoderTest/DecoderTest/main.mm:
     14        (main):
     15
    1162020-07-24  Jer Noble  <jer.noble@apple.com>
    217
  • trunk/PerformanceTests/DecoderTest/DecoderTest.xcodeproj/project.pbxproj

    r264839 r265095  
    88
    99/* Begin PBXBuildFile section */
    10                 CD89724C24CA485100AF6621 /* libwebrtc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD89724B24CA485100AF6621 /* libwebrtc.dylib */; };
    11                 CDE0C9BF24CA247A00593A83 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDE0C9BE24CA247A00593A83 /* JavaScriptCore.framework */; };
    1210                CDE0C9C124CA249A00593A83 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDE0C9C024CA249A00593A83 /* WebKit.framework */; };
    1311                CDE0C9C424CA36CD00593A83 /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDE0C9C324CA36CD00593A83 /* CoreMedia.framework */; };
     12                CDEB7B2924CB558C0015249E /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDEB7B2824CB558C0015249E /* CoreServices.framework */; };
     13                CDEB7B2B24CB68E90015249E /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDEB7B2A24CB68E90015249E /* VideoToolbox.framework */; };
     14                CDED1C3E24CD350600934E12 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDE0C9BE24CA247A00593A83 /* JavaScriptCore.framework */; };
    1415                CDF1350124C9F99900432E1E /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDF1350024C9F99900432E1E /* main.mm */; };
    1516/* End PBXBuildFile section */
     
    2829
    2930/* Begin PBXFileReference section */
    30                 CD89724B24CA485100AF6621 /* libwebrtc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libwebrtc.dylib; path = ../../WebKitBuild/Release/libwebrtc.dylib; sourceTree = "<group>"; };
    3131                CDE0C9BE24CA247A00593A83 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
    3232                CDE0C9C024CA249A00593A83 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
    3333                CDE0C9C324CA36CD00593A83 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
    3434                CDEB7B2624CAC7420015249E /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
     35                CDEB7B2824CB558C0015249E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
     36                CDEB7B2A24CB68E90015249E /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; };
    3537                CDF134FD24C9F99900432E1E /* DecoderTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DecoderTest; sourceTree = BUILT_PRODUCTS_DIR; };
    3638                CDF1350024C9F99900432E1E /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
     
    4648                        files = (
    4749                                CDE0C9C424CA36CD00593A83 /* CoreMedia.framework in Frameworks */,
    48                                 CDE0C9BF24CA247A00593A83 /* JavaScriptCore.framework in Frameworks */,
    49                                 CD89724C24CA485100AF6621 /* libwebrtc.dylib in Frameworks */,
     50                                CDEB7B2924CB558C0015249E /* CoreServices.framework in Frameworks */,
     51                                CDED1C3E24CD350600934E12 /* JavaScriptCore.framework in Frameworks */,
     52                                CDEB7B2B24CB68E90015249E /* VideoToolbox.framework in Frameworks */,
    5053                                CDE0C9C124CA249A00593A83 /* WebKit.framework in Frameworks */,
    5154                        );
     
    5962                        children = (
    6063                                CDE0C9C324CA36CD00593A83 /* CoreMedia.framework */,
     64                                CDEB7B2824CB558C0015249E /* CoreServices.framework */,
    6165                                CDE0C9BE24CA247A00593A83 /* JavaScriptCore.framework */,
    62                                 CD89724B24CA485100AF6621 /* libwebrtc.dylib */,
     66                                CDEB7B2A24CB68E90015249E /* VideoToolbox.framework */,
    6367                                CDE0C9C024CA249A00593A83 /* WebKit.framework */,
    6468                        );
     
    8791                        isa = PBXGroup;
    8892                        children = (
     93                                CDEB7B2624CAC7420015249E /* config.h */,
    8994                                CDF1350024C9F99900432E1E /* main.mm */,
    90                                 CDEB7B2624CAC7420015249E /* config.h */,
    9195                        );
    9296                        path = DecoderTest;
  • trunk/PerformanceTests/DecoderTest/DecoderTest/main.mm

    r264839 r265095  
    2929#import <CoreMedia/CMFormatDescription.h>
    3030#import <CoreMedia/CMSampleBuffer.h>
     31#import <CoreServices/CoreServices.h>
    3132#import <Foundation/Foundation.h>
     33#import <WebCore/ContentType.h>
    3234#import <WebCore/MediaSample.h>
    3335#import <WebCore/RuntimeEnabledFeatures.h>
    3436#import <WebCore/SharedBuffer.h>
    3537#import <WebCore/SourceBufferParserWebM.h>
     38#import <WebCore/UTIUtilities.h>
    3639#import <WebCore/VP9UtilitiesCocoa.h>
    3740#import <WebCore/WebCoreDecompressionSession.h>
    3841#import <getopt.h>
    39 #import <webrtc/sdk/WebKit/WebKitVP9Decoder.h>
     42#import <pal/avfoundation/MediaTimeAVFoundation.h>
    4043#import <wtf/CPUTime.h>
    4144#import <wtf/MonotonicTime.h>
    4245#import <wtf/NeverDestroyed.h>
     46#import <wtf/URL.h>
    4347#import <wtf/WTFSemaphore.h>
    4448#import <wtf/cf/TypeCastsCF.h>
     
    5559{
    5660    int enableHardwareDecoder = true;
     61    int rateLimit = false;
    5762    static struct option longopts[] = {
    5863        { "hardware",    no_argument, &enableHardwareDecoder, 1 },
    5964        { "no-hardware", no_argument, &enableHardwareDecoder, 0 },
     65        { "rate-limit",  no_argument, &rateLimit, 1 },
    6066        { NULL,          0,           NULL, 0 }
    6167    };
     
    6571        fprintf(stderr, "\tOptions:\n"
    6672            "\t\t--[no-]hardware     # Enable or disable the hardware decoder\n"
     73            "\t\t--rate-limit        # Rate limit the decoder to decode samples at the natural frame rate\n"
    6774        );
    6875    };
     
    8996    @autoreleasepool {
    9097        WTF::initializeMainThread();
    91         webrtc::registerWebKitVP9Decoder();
     98        registerWebKitVP9Decoder();
    9299        registerSupplementalVP9Decoder();
    93100        RuntimeEnabledFeatures::sharedFeatures().setWebMParserEnabled(true);
     101
     102        auto mdItem = adoptCF(MDItemCreate(kCFAllocatorDefault, filename.createCFString().get()));
     103        auto mdContentType = adoptCF(checked_cf_cast<CFStringRef>(MDItemCopyAttribute(mdItem.get(), kMDItemContentType)));
     104        if (!mdContentType) {
     105            fprintf(stderr, "Could not discover file type of file \"%s\"\n", filename.utf8().data());
     106            return -1;
     107        }
     108
     109        auto mimeType = MIMETypeFromUTI(mdContentType.get());
     110        if (mimeType.isEmpty() && filename.endsWith(".webm"))
     111            mimeType = "video/webm";
     112
     113        if (mimeType.isEmpty()) {
     114            fprintf(stderr, "Could not discover file type of file \"%s\"\n", filename.utf8().data());
     115            return -1;
     116        }
    94117
    95118        auto buffer = SharedBuffer::createWithContentsOfFile(filename.utf8().data());
     
    101124        fprintf(stdout, "Parsing \"%s\"...\n", filename.utf8().data());
    102125
    103         SourceBufferParserWebM parser;
    104         parser.setDidEncounterErrorDuringParsingCallback([&] (uint64_t errorCode) {
     126        auto parser = SourceBufferParser::create(ContentType(mimeType));
     127        if (!buffer) {
     128            fprintf(stderr, "Could not create parser for file of type \"%s\"\n", mimeType.utf8().data());
     129            return -1;
     130        }
     131
     132        parser->setDidEncounterErrorDuringParsingCallback([&] (uint64_t errorCode) {
    105133            fprintf(stderr, "Parser encountered error %llu, exiting", errorCode);
    106134            exit(-1);
     
    125153
    126154            fprintf(stdout, "Decoded %llu samples in %g seconds (%g fps)\n", decodedSamples, duration.value(), fps);
    127             if (startCPUTime && endCPUTime)
    128                 fprintf(stdout, "CPU Usage: %g %%\n", endCPUTime->percentageCPUUsageSince(*startCPUTime));
     155            if (startCPUTime && endCPUTime) {
     156                auto percentage = endCPUTime->percentageCPUUsageSince(*startCPUTime);
     157                fprintf(stdout, "CPU Usage: %g %%, (%g %% per frame)\n", percentage, percentage / decodedSamples);
     158            }
    129159        };
    130160
    131161        struct sigaction action { };
    132162        action.sa_flags = SA_SIGINFO;
    133         action.sa_sigaction = [] (int, siginfo_t*, void*) {
     163        action.sa_sigaction = [] (int signal, siginfo_t*, void*) {
    134164            if (updateOutputFunction())
    135165                updateOutputFunction()();
     166            if (signal == SIGINT)
     167                exit(-1);
    136168        };
    137169        sigaction(SIGINFO, &action, nullptr);
     170        sigaction(SIGINT, &action, nullptr);
    138171
    139172        WTF::Semaphore sampleSemaphore { 0 };
    140         parser.setDidProvideMediaDataCallback([&] (Ref<MediaSample>&& sample, uint64_t, const String&) {
     173        parser->setDidProvideMediaDataCallback([&] (Ref<MediaSample>&& sample, uint64_t, const String&) {
    141174            auto platformSample = sample->platformSample();
    142175            if (platformSample.type != PlatformSample::CMSampleBufferType)
     
    153186                startTime = MonotonicTime::now();
    154187                startCPUTime = CPUTime::get();
     188
    155189                fprintf(stdout, "Size: %g x %g\n", size.width(), size.height());
    156190                firstSample = false;
     
    168202            bytes.resize(buffer->size());
    169203            memcpy(bytes.data(), buffer->data(), buffer->size());
    170             parser.appendData(WTFMove(bytes));
     204            parser->appendData(WTFMove(bytes));
    171205            dispatch_async(dispatch_get_main_queue(), [&] {
    172206                finishedParsingSemaphore.signal();
     
    174208        });
    175209
     210        auto decompressionSession = WebCoreDecompressionSession::createOpenGL();
    176211        Semaphore finishedDecodingSemaphore { 0 };
    177212        auto decoderQueue = dispatch_queue_create("decoder queue", DISPATCH_QUEUE_CONCURRENT);
    178213        dispatch_async(decoderQueue, [&] {
    179             auto decompressionSession = WebCoreDecompressionSession::createOpenGL();
    180214            decompressionSession->setHardwareDecoderEnabled(enableHardwareDecoder);
    181215
     
    188222
    189223                auto sample = adoptCF((CMSampleBufferRef)(const_cast<void*>(CMBufferQueueDequeueAndRetain(bufferQueue))));
     224                auto decodeStartTime = MonotonicTime::now();
     225                auto duration = PAL::toMediaTime(CMSampleBufferGetOutputDuration(sample.get()));
    190226                decompressionSession->decodeSampleSync(sample.get());
     227                auto decodeEndTime = MonotonicTime::now();
     228                auto remainingTime = Seconds(duration.toDouble()) - (decodeEndTime - decodeStartTime);
     229
     230                if (rateLimit && remainingTime > Seconds(0))
     231                    sleep(remainingTime);
    191232                ++decodedSamples;
    192233            } while (true);
  • trunk/Source/WebCore/ChangeLog

    r265092 r265095  
     12020-07-30  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Make DecoderTest run against .mp4 files; add rate-limiting.
     4        https://bugs.webkit.org/show_bug.cgi?id=214807
     5
     6        Reviewed by Darin Adler.
     7
     8        Export registerWebKitVP9Decoder() from VP9UtilitiesCocoa instead of LibWebRTCProvider to make it easier
     9        for DecodeTest to import, as LibWebRTCProvider also pulls in a bunch of libwebrtc headers. Also, export
     10        SourceBufferParser.h so DecoderTest can create parsers for fMP4 files.
     11
     12        * SourcesCocoa.txt:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * platform/graphics/cocoa/VP9UtilitiesCocoa.h:
     15        * platform/graphics/cocoa/VP9UtilitiesCocoa.mm:
     16        (WebCore::registerWebKitVP9Decoder):
     17
    1182020-07-30  Ryosuke Niwa  <rniwa@webkit.org>
    219
  • trunk/Source/WebCore/SourcesCocoa.txt

    r265079 r265095  
    359359platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
    360360platform/graphics/cocoa/TextTrackRepresentationCocoa.mm
    361 platform/graphics/cocoa/VP9UtilitiesCocoa.mm
     361platform/graphics/cocoa/VP9UtilitiesCocoa.mm @no-unify
    362362platform/graphics/cocoa/WebActionDisablingCALayerDelegate.mm
    363363platform/graphics/cocoa/WebCoreCALayerExtras.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r265079 r265095  
    42504250                CDECA89A1EDF447D00DCB08B /* AVAssetTrackUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDECA8981EDF447D00DCB08B /* AVAssetTrackUtilities.mm */; };
    42514251                CDECA89B1EDF447D00DCB08B /* AVAssetTrackUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CDECA8991EDF447D00DCB08B /* AVAssetTrackUtilities.h */; };
     4252                CDED1C3C24CD305700934E12 /* VP9UtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD6FE5B824BCE645009FCDA4 /* VP9UtilitiesCocoa.mm */; };
    42524253                CDEF4FD717E85C8F00AEE24B /* GridLength.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEF4FD617E85C8F00AEE24B /* GridLength.h */; settings = {ATTRIBUTES = (Private, ); }; };
    42534254                CDEFA2281E7669E8000AE99C /* PlatformAudioData.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE667A11E4BBA4D00E8154A /* PlatformAudioData.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    3504935050                                DECA803A1F9FED6A00E3B661 /* UnifiedSource249.cpp in Sources */,
    3505035051                                DECA803B1F9FED6A00E3B661 /* UnifiedSource250.cpp in Sources */,
     35052                                CDED1C3C24CD305700934E12 /* VP9UtilitiesCocoa.mm in Sources */,
    3505135053                                DECA803C1F9FED6A00E3B661 /* UnifiedSource251.cpp in Sources */,
    3505235054                                DECA803D1F9FED6A00E3B661 /* UnifiedSource252.cpp in Sources */,
  • trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParser.h

    r264685 r265095  
    3838class MediaSample;
    3939
    40 class SourceBufferParser : public ThreadSafeRefCounted<SourceBufferParser> {
     40class WEBCORE_EXPORT SourceBufferParser : public ThreadSafeRefCounted<SourceBufferParser> {
    4141public:
    4242    static MediaPlayerEnums::SupportsType isContentTypeSupported(const ContentType&);
  • trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h

    r264685 r265095  
    3939WEBCORE_EXPORT extern void resetOverrideVP9ScreenSizeAndScaleForTesting();
    4040
     41WEBCORE_EXPORT extern void registerWebKitVP9Decoder();
    4142WEBCORE_EXPORT extern void registerSupplementalVP9Decoder();
    4243extern bool isVP9DecoderAvailable();
  • trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm

    r264791 r265095  
    3030
    3131#import "FourCC.h"
     32#import "LibWebRTCProvider.h"
    3233#import "MediaCapabilitiesInfo.h"
    3334#import "PlatformScreen.h"
     
    9798}
    9899
     100void registerWebKitVP9Decoder()
     101{
     102    LibWebRTCProvider::registerWebKitVP9Decoder();
     103}
     104
    99105void registerSupplementalVP9Decoder()
    100106{
  • trunk/Source/WebKit/ChangeLog

    r265091 r265095  
     12020-07-30  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Make DecoderTest run against .mp4 files; add rate-limiting.
     4        https://bugs.webkit.org/show_bug.cgi?id=214807
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebProcess/WebProcess.cpp:
     9        (WebKit::WebProcess::enableVP9Decoder):
     10
    1112020-07-30  Tim Horton  <timothy_horton@apple.com>
    212
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r264664 r265095  
    19611961
    19621962    m_vp9DecoderEnabled = true;
    1963     LibWebRTCProvider::registerWebKitVP9Decoder();
    19641963
    19651964#if PLATFORM(COCOA)
     1965    WebCore::registerWebKitVP9Decoder();
    19661966    WebCore::registerSupplementalVP9Decoder();
    19671967#endif
Note: See TracChangeset for help on using the changeset viewer.