haikuwebkit/LayoutTests/media/vp-codec-parameters.html

136 lines
8.5 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<script src="video-test.js"></script>
<script>
function VPCodecConfigurationRecordToString(set) {
try {
return `{ ${set.codecName}, ${set.profile}, ${set.level}, ${set.bitDepth}, ${set.chromaSubsampling}, ${set.colorPrimaries}, ${set.transferCharacteristics}, ${set.matrixCoefficients}, ${set.videoFullRangeFlag}}`;
} catch(e) {
return `{ ${set} }`;
}
}
function isEqualVPCodecConfigurationRecord(setA, setB) {
try {
return setA.profile == setB.profile &&
setA.level == setB.level &&
setA.bitDepth == setB.bitDepth &&
setA.chromaSubsampling == setB.chromaSubsampling &&
setA.videoFullRangeFlag == setB.videoFullRangeFlag &&
setA.colorPrimaries == setB.colorPrimaries &&
setA.transferCharacteristics == setB.transferCharacteristics &&
setA.matrixCoefficients == setB.matrixCoefficients;
} catch(e) {
return false;
}
}
function makeVPCodecConfigurationRecord(codecName, profile, level, bitDepth, chromaSubsampling, colorPrimaries, transferCharacteristics, matrixCoefficients, videoFullRangeFlag)
{
return {
codecName: codecName,
profile: profile,
level: level,
bitDepth: bitDepth,
chromaSubsampling: chromaSubsampling,
videoFullRangeFlag: videoFullRangeFlag,
colorPrimaries: colorPrimaries,
transferCharacteristics: transferCharacteristics,
matrixCoefficients: matrixCoefficients
};
}
function testExpectedVPCodecConfigurationRecord(testFuncString, expected)
{
let observed = eval(testFuncString);
let success = isEqualVPCodecConfigurationRecord(observed, expected);
reportExpected(success, testFuncString, '===', VPCodecConfigurationRecordToString(expected), VPCodecConfigurationRecordToString(observed));
}
window.addEventListener('load', event => {
testExpected('internals.parseVPCodecParameters("bad-parameter")', null);
consoleWrite('');
consoleWrite('Test invalid number of required parameters:')
testExpected('internals.parseVPCodecParameters("vp09")', null);
testExpected('internals.parseVPCodecParameters("vp09.00")', null);
testExpected('internals.parseVPCodecParameters("vp09.00.41")', null);
consoleWrite('');
consoleWrite('Test valid default optional parameters:')
testExpectedVPCodecConfigurationRecord('internals.parseVPCodecParameters("vp09.00.41.08")', makeVPCodecConfigurationRecord('vp09', 0, 41, 8, 1, 1, 1, 1, 0));
consoleWrite('');
consoleWrite('Test invalid number of optional parameters:')
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01")', null);
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09")', null);
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09.16")', null);
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.09")', null);
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.09.01.00")', null);
consoleWrite('');
consoleWrite('Test valid required and optional parameters:')
testExpectedVPCodecConfigurationRecord('internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.09.01")', makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 1, 9, 16, 9, 1));
consoleWrite('');
consoleWrite('Test invalid codec type');
testExpected('internals.parseVPCodecParameters("vp10.00.41.08")', null);
consoleWrite('');
consoleWrite('Test invalid combination of matrixCoefficients and chromaSubsampling');
testExpected('internals.parseVPCodecParameters("vp09.00.41.08.01.01.01.00.00")', null);
consoleWrite('');
consoleWrite('Test valid profiles:');
for (let profile of [0, 1, 2, 3])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.${profile.toString().padStart(2, '0')}.41.08")`, makeVPCodecConfigurationRecord('vp09', profile, 41, 8, 1, 1, 1, 1, 0));
consoleWrite('');
consoleWrite('Test invalid profile:');
testExpected('internals.parseVPCodecParameters("vp09.04.41.08")', null);
consoleWrite('');
consoleWrite('Test valid levels:');
for (let level of [10, 11, 20, 21, 30, 31, 40, 41, 50, 51, 52, 60, 61, 62])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.00.${level.toString().padStart(2, '0')}.08")`, makeVPCodecConfigurationRecord('vp09', 0, level, 8, 1, 1, 1, 1, 0));
consoleWrite('');
consoleWrite('Test invalid level:');
testExpected('internals.parseVPCodecParameters("vp09.00.12.08")', null);
consoleWrite('');
consoleWrite('Test valid bitDepths:');
for (let bitDepth of [8, 10, 12])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.00.41.${bitDepth.toString().padStart(2, '0')}")`, makeVPCodecConfigurationRecord('vp09', 0, 41, bitDepth, 1, 1, 1, 1, 0));
consoleWrite('');
consoleWrite('Test invalid bitDepth:');
testExpected('internals.parseVPCodecParameters("vp09.00.41.09")', null);
consoleWrite('');
consoleWrite('Test valid chromaSubsampling:');
for (let chromaSubsampling of [0, 1, 2, 3])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.${chromaSubsampling.toString().padStart(2, '0')}.09.16.09.01")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, chromaSubsampling, 9, 16, 9, 1));
consoleWrite('');
consoleWrite('Test invalid chromaSubsampling:');
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.04.09.16.09.01")', null);
consoleWrite('');
consoleWrite('Test valid colorPrimaries:');
for (let colorPrimaries of [1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.01.${colorPrimaries.toString().padStart(2, '0')}.16.09.01")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 1, colorPrimaries, 16, 9, 1));
consoleWrite('');
consoleWrite('Test invalid colorPrimaries:');
[Cocoa] Add experimental MSE WebM parser https://bugs.webkit.org/show_bug.cgi?id=214529 Source/ThirdParty/libwebrtc: <rdar://problem/65782467> Reviewed by Eric Carlson. Add the vp9_header_parser from libwebrtc to the project, and add its symbols to the list of exported symbols. Because this header wants to be installed to a "common/vp9_header_parser.h" path, split up the default CopyHeadersInstallPhase into two separate CopyFiles build phases that put headers into different locations. * Configurations/libwebm.xcconfig: * Configurations/libwebrtc.iOS.exp: * Configurations/libwebrtc.iOSsim.exp: * Configurations/libwebrtc.mac.exp: * Source/third_party/libwebm/common/vp9_header_parser.h: (vp9_parser::Vp9HeaderParser::color_range const): (vp9_parser::Vp9HeaderParser::subsampling_x const): (vp9_parser::Vp9HeaderParser::subsampling_y const): * libwebrtc.xcodeproj/project.pbxproj: Source/WebCore: Reviewed by Eric Carlson. Test: media/media-source/media-source-webm.html Add an experimental MSE WebM parser to SourceBufferPrivateAVFObjC. This will require extensive refactoring of SourceBufferPrivateAVFObjC, to extract out the parser into a new, virtualized class. This new parser can take advantage of new C++>11 features such as lambdas to clean up some problematic existing code. The new virtualized SourceBufferParser class uses passed-in Function objects, rather than pure-virtual Client classes to notify it's parent object when the parser encounters initialization- or media-data. Because SourceBufferPrivateAVFObjC will now have to deal with AudioTrackPrivate and VideoTrackPrivate objects that are not necessarily Audio- and VideoTrackPrivateMediaSourceAVFObjC subclasses, move those classes notification features up into Audio- and VideoTrackPrivate, again using a Function object rather than a client class. Add a new SourceBufferParserWebM and associated AudioTrackPrivateWebM and VideoTrackPrivateWebM classes, which use libwebm via libwebrtc to parse appended buffers. SourceBufferParserWebM feeds passed-in data into a libwebm-provided parser of its own. It then builds up tracks and samples based on callbacks from that same parser, constructing CMSampleBuffers and VideoTrackPrivate objects out of the underlying libwebm primitives. Because WebM uses a UUID as its track identifier, the representation of a "trackID" inside WebCore must be increased from an int to a uint64_t, or trackIDs will be truncated or zeroed when passed between classes and when converted to and from AtomStrings. This early implementation is not yet able to pass the WebM WPT media-source/ tests, as we only have a VP9 decoder available, and those tests use both VP8 and Vorbis. * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebMParserEnabled): (WebCore::RuntimeEnabledFeatures::webMParserEnabled const): * platform/graphics/AudioTrackPrivate.h: (WebCore::AudioTrackPrivate::setEnabled): (WebCore::AudioTrackPrivate::setEnabledChangedCallback): * platform/graphics/VP9Utilities.cpp: (WebCore::isValidVPColorPrimaries): (WebCore::isValidVPTransferCharacteristics): (WebCore::isValidVPMatrixCoefficients): (WebCore::parseVPCodecParameters): * platform/graphics/VP9Utilities.h: * platform/graphics/VideoTrackPrivate.h: (WebCore::VideoTrackPrivate::setSelected): (WebCore::VideoTrackPrivate::setSelectedChangedCallback): * platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp: (WebCore::AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC): (WebCore::AudioTrackPrivateMediaSourceAVFObjC::setEnabled): * platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h: * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm: (WebCore::CDMSessionAVContentKeySession::update): * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm: (WebCore::CDMSessionAVStreamSession::update): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: (WebCore::MediaSampleAVFObjC::create): (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC): * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm: (WebCore::MediaSourcePrivateAVFObjC::addSourceBuffer): * platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.h: Added. (isType): * platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm: Added. (-[WebAVStreamDataParserListener initWithParser:parent:]): (-[WebAVStreamDataParserListener dealloc]): (-[WebAVStreamDataParserListener invalidate]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParserWillProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (WebCore::SourceBufferParserAVFObjC::isContentTypeSupported): (WebCore::SourceBufferParserAVFObjC::SourceBufferParserAVFObjC): (WebCore::SourceBufferParserAVFObjC::~SourceBufferParserAVFObjC): (WebCore::SourceBufferParserAVFObjC::appendData): (WebCore::SourceBufferParserAVFObjC::flushPendingMediaData): (WebCore::SourceBufferParserAVFObjC::setShouldProvideMediaDataForTrackID): (WebCore::SourceBufferParserAVFObjC::shouldProvideMediadataForTrackID): (WebCore::SourceBufferParserAVFObjC::resetParserState): (WebCore::SourceBufferParserAVFObjC::didParseStreamDataAsAsset): (WebCore::SourceBufferParserAVFObjC::didFailToParseStreamDataWithError): (WebCore::SourceBufferParserAVFObjC::didProvideMediaDataForTrackID): (WebCore::SourceBufferParserAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID): (WebCore::SourceBufferParserAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::create): (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::didEncounterErrorDuringParsing): (WebCore::SourceBufferPrivateAVFObjC::didProvideMediaDataForTrackID): (WebCore::SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID): (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): (WebCore::SourceBufferPrivateAVFObjC::append): (WebCore::SourceBufferPrivateAVFObjC::appendCompleted): (WebCore::SourceBufferPrivateAVFObjC::abort): (WebCore::SourceBufferPrivateAVFObjC::resetParserState): (WebCore::SourceBufferPrivateAVFObjC::destroyParser): (WebCore::SourceBufferPrivateAVFObjC::clearTracks): (WebCore::SourceBufferPrivateAVFObjC::hasSelectedVideo const): (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeSelected): (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): (WebCore::SourceBufferPrivateAVFObjC::parser const): (WebCore::SourceBufferPrivateAVFObjC::attemptToDecrypt): (WebCore::SourceBufferPrivateAVFObjC::flush): (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): (WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples): (WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): (WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): (WebCore::SourceBufferPrivateAVFObjC::canSetMinimumUpcomingPresentationTime const): * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h: * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm: (WebCore::VideoTrackPrivateMediaSourceAVFObjC::VideoTrackPrivateMediaSourceAVFObjC): * platform/graphics/cocoa/AudioTrackPrivateWebM.cpp: Copied from Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h. (WebCore::AudioTrackPrivateWebM::create): (WebCore::AudioTrackPrivateWebM::AudioTrackPrivateWebM): (WebCore::AudioTrackPrivateWebM::id const): (WebCore::AudioTrackPrivateWebM::label const): (WebCore::AudioTrackPrivateWebM::language const): (WebCore::AudioTrackPrivateWebM::trackIndex const): * platform/graphics/cocoa/AudioTrackPrivateWebM.h: Copied from Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h. * platform/graphics/cocoa/SourceBufferParser.cpp: Copied from Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h. (WebCore::SourceBufferParser::isContentTypeSupported): (WebCore::SourceBufferParser::create): * platform/graphics/cocoa/SourceBufferParser.h: Added. (WebCore::SourceBufferParser::setDidParseInitializationDataCallback): (WebCore::SourceBufferParser::setDidEncounterErrorDuringParsingCallback): (WebCore::SourceBufferParser::setDidProvideMediaDataCallback): (WebCore::SourceBufferParser::setWillProvideContentKeyRequestInitializationDataForTrackIDCallback): (WebCore::SourceBufferParser::setDidProvideContentKeyRequestInitializationDataForTrackIDCallback): * platform/graphics/cocoa/SourceBufferParserWebM.cpp: Added. (WebCore::isWebmParserAvailable): (WebCore::SourceBufferParserWebM::isContentTypeSupported): (WebCore::SourceBufferParserWebM::SourceBufferParserWebM): (WebCore::SourceBufferParserWebM::appendData): (WebCore::SourceBufferParserWebM::flushPendingMediaData): (WebCore::SourceBufferParserWebM::setShouldProvideMediaDataForTrackID): (WebCore::SourceBufferParserWebM::shouldProvideMediadataForTrackID): (WebCore::SourceBufferParserWebM::resetParserState): (WebCore::SourceBufferParserWebM::trackDataForTrackNumber): (WebCore::SourceBufferParserWebM::OnElementBegin): (WebCore::SourceBufferParserWebM::OnEbml): (WebCore::SourceBufferParserWebM::OnSegmentBegin): (WebCore::SourceBufferParserWebM::OnInfo): (WebCore::SourceBufferParserWebM::OnClusterBegin): (WebCore::SourceBufferParserWebM::OnTrackEntry): (WebCore::SourceBufferParserWebM::OnBlockBegin): (WebCore::SourceBufferParserWebM::OnBlockEnd): (WebCore::SourceBufferParserWebM::OnSimpleBlockBegin): (WebCore::SourceBufferParserWebM::OnSimpleBlockEnd): (WebCore::SourceBufferParserWebM::OnBlockGroupBegin): (WebCore::SourceBufferParserWebM::OnBlockGroupEnd): (WebCore::convertToColorPrimaries): (WebCore::convertToTransferCharacteristics): (WebCore::convertToMatrixCoefficients): (WebCore::convertSubsamplingXYToChromaSubsampling): (WebCore::createFormatDescriptionFromVP9HeaderParser): (WebCore::SourceBufferParserWebM::OnFrame): * platform/graphics/cocoa/SourceBufferParserWebM.h: Added. (WebCore::SourceBufferParserWebM::status const): (WebCore::SourceBufferParserWebM::type const): (isType): * platform/graphics/cocoa/VP9UtilitiesCocoa.h: * platform/graphics/cocoa/VP9UtilitiesCocoa.mm: (WebCore::isVP9DecoderAvailable): (WebCore::validateVPParameters): * platform/graphics/cocoa/VideoTrackPrivateWebM.cpp: (WebCore::VideoTrackPrivateWebM::create): (WebCore::VideoTrackPrivateWebM::VideoTrackPrivateWebM): (WebCore::VideoTrackPrivateWebM::id const): (WebCore::VideoTrackPrivateWebM::label const): (WebCore::VideoTrackPrivateWebM::language const): (WebCore::VideoTrackPrivateWebM::trackIndex const): * platform/graphics/cocoa/VideoTrackPrivateWebM.h: Source/WebKit: <rdar://problem/65782467> Reviewed by Eric Carlson. Add an Experimental setting to enable the MSE WebM parser (off by default). * Shared/WebPreferences.yaml: LayoutTests: <rdar://problem/65782467> Reviewed by Eric Carlson. * media/media-source/content/test-vp9-manifest.json: Added. * media/media-source/content/test-vp9.webm: Added. * media/media-source/media-source-webm-expected.txt: Added. * media/media-source/media-source-webm.html: Added. Canonical link: https://commits.webkit.org/227430@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-22 00:25:09 +00:00
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.03.16.09.01")', null);
consoleWrite('');
consoleWrite('Test valid transferCharacteristics:');
for (let transferCharacteristics of [1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.01.09.${transferCharacteristics.toString().padStart(2, '0')}.09.01")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 1, 9, transferCharacteristics, 9, 1));
consoleWrite('');
consoleWrite('Test invalid transferCharacteristics:');
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09.03.09.01")', null);
consoleWrite('');
consoleWrite('Test valid matrixCoefficients:');
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.03.09.16.00.01")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 3, 9, 16, 0, 1));
for (let matrixCoefficients of [1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.${matrixCoefficients.toString().padStart(2, '0')}.01")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 1, 9, 16, matrixCoefficients, 1));
consoleWrite('');
consoleWrite('Test invalid matrixCoefficients:');
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.09.03")', null);
consoleWrite('');
consoleWrite('Test valid videoFullRangeFlag:');
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.01.00")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 1, 9, 16, 1, 0));
testExpectedVPCodecConfigurationRecord(`internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.01.01")`, makeVPCodecConfigurationRecord('vp09', 2, 10, 10, 1, 9, 16, 1, 1));
consoleWrite('');
consoleWrite('Test invalid videoFullRangeFlag:');
testExpected('internals.parseVPCodecParameters("vp09.02.10.10.01.09.16.01.02")', null);
endTest();
}, { once: true });
</script>
</head>
<body>
</body>
</html>