Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2b04af10a098c18c19cc2bc578ec6539c0087f26
      
https://github.com/WebKit/WebKit/commit/2b04af10a098c18c19cc2bc578ec6539c0087f26
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2024-12-11 (Wed, 11 Dec 2024)

  Changed paths:
    M Source/WebCore/platform/audio/cocoa/AudioDecoderCocoa.cpp
    M Source/WebCore/platform/audio/cocoa/AudioSampleBufferConverter.h
    M Source/WebCore/platform/audio/cocoa/AudioSampleBufferConverter.mm
    M Source/WebCore/platform/graphics/cocoa/CMUtilities.h
    M Source/WebCore/platform/graphics/cocoa/CMUtilities.mm
    M Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp
    M Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h
    M Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm

  Log Message:
  -----------
  AudioDecoderCocoa should trim start of decoded samples in accordance with 
preSkip information
https://bugs.webkit.org/show_bug.cgi?id=284354
rdar://141202697

Reviewed by Youenn Fablet.

Opus provides out of band information related to the encoder delay (a.k.a 
preSkip)
available in the AudioConfig's description.
Other codecs do no, so we could have assumed as AudioToolbox does, default 
preSkip
values (2112 for AAC, 536 for Lame MP4, 0 for Flac and an entire packet for 
vorbis).
However doing so, while technically more accurate, would cause WPT's test 
failures
as some existing mp3 and aac frames make strong assumptions on how many decoded 
frames
we return.

We use the preSkip, when available and set the AudioSampleBufferConverter to 
trim those frames.

- We also store the AudioSampleBufferConverter's Config object rather than 
individual values
as this configuration object will need to be extensively amended to support the 
future AudioEncoder object.
- Fly by: Return error if we failed to create and configure the AudioConverter.

Following this changes, we provide more accurate Opus decoding. There's no 
change in the result
of existing AudioDecoder's tests, but incoming AudioEncoder ones do rely on the 
files to be correctly
trimmed.

* Source/WebCore/platform/audio/cocoa/AudioDecoderCocoa.cpp:
(WebCore::InternalAudioDecoderCocoa::initialize): Fly-by: Do not incorrectly 
reject Opus stereo content.
* Source/WebCore/platform/audio/cocoa/AudioSampleBufferConverter.h:
(WebCore::AudioSampleBufferConverter::preSkip const):
* Source/WebCore/platform/audio/cocoa/AudioSampleBufferConverter.mm:
(WebCore::m_options):
(WebCore::AudioSampleBufferConverter::initAudioConverterForSourceFormatDescription):
 Return error code when failing.
Change fallback rate from 44.1kHz to 48kHz. 48kHz is a more logical choice, 
it's supported by all hardware and is the default
for a codec (44.1kHz would have required to upsample to 48kHz first).
(WebCore::AudioSampleBufferConverter::attachPrimingTrimsIfNeeded):
(WebCore::AudioSampleBufferConverter::provideSourceDataNumOutputPackets):
(WebCore::AudioSampleBufferConverter::processSampleBuffers):
(WebCore::AudioSampleBufferConverter::bitRate const):
(WebCore::m_generateTimestamp): Deleted.
* Source/WebCore/platform/graphics/cocoa/CMUtilities.h:
* Source/WebCore/platform/graphics/cocoa/CMUtilities.mm:
(WebCore::PacketDurationParser::framesInPacket):
* Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::WebMParser::AudioTrackData::consumeFrameData):
* Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.h: Have 
parseOpusPrivateData take a span instead of a SharedBuffer
and return optional<OpusCookieContent> instead of using an out parameter.
* Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:
(WebCore::parseOpusTOCData):
(WebCore::parseOpusPrivateData):
(WebCore::createOpusPrivateData):

Canonical link: https://commits.webkit.org/287708@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to