Changeset 181006 in webkit
- Timestamp:
- Mar 4, 2015 11:26:22 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r181005 r181006 1 2015-03-04 Jer Noble <jer.noble@apple.com> 2 3 [Mac] YouTube playback at 1.5x speed has audible distortion 4 https://bugs.webkit.org/show_bug.cgi?id=142280 5 6 Reviewed by Eric Carlson. 7 8 Use the high-quality AVAudioTimePitchAlgorithmSpectral algorithm for the 9 AVSampleBufferAudioRenderer rather than its default value of 10 AVAudioTimePitchAlgorithmTimeDomain. 11 12 Drive-by fix: 13 14 Might as well add support for MediaPlayer::setPreservesPitch() while we're 15 changing the audio pitch algorithm. If preservesPitch() is false use the 16 AVAudioTimePitchAlgorithmVarispeed algorithm in both AVFObjC-based media players 17 (MediaPlayerPrivateAVFoundationObjC & MediaPlayerPrivateMediaSourceAVFObjC). 18 19 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 20 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 21 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): 22 (WebCore::MediaPlayerPrivateAVFoundationObjC::setPreservesPitch): 23 (WebCore::MediaPlayerPrivateAVFoundationObjC::setRateDouble): Deleted. 24 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 25 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 26 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch): 27 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer): 28 1 29 2015-03-04 Jer Noble <jer.noble@apple.com> 2 30 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r180839 r181006 179 179 virtual void setRateDouble(double) override; 180 180 virtual double rate() const; 181 void setPreservesPitch(bool) override; 181 182 virtual void seekToTime(const MediaTime&, const MediaTime& negativeTolerance, const MediaTime& positiveTolerance); 182 183 virtual unsigned long long totalBytes() const; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r180839 r181006 183 183 SOFT_LINK_CLASS(CoreImage, CIImage) 184 184 185 SOFT_LINK_POINTER(AVFoundation, AVAudioTimePitchAlgorithmSpectral, NSString*) 186 SOFT_LINK_POINTER(AVFoundation, AVAudioTimePitchAlgorithmVarispeed, NSString*) 185 187 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicVisual, NSString *) 186 188 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicAudible, NSString *) … … 207 209 #define AVMetadataItem getAVMetadataItemClass() 208 210 211 #define AVAudioTimePitchAlgorithmSpectral getAVAudioTimePitchAlgorithmSpectral() 212 #define AVAudioTimePitchAlgorithmVarispeed getAVAudioTimePitchAlgorithmVarispeed() 209 213 #define AVMediaCharacteristicVisual getAVMediaCharacteristicVisual() 210 214 #define AVMediaCharacteristicAudible getAVMediaCharacteristicAudible() … … 963 967 [m_avPlayerItem.get() addObserver:m_objcObserver.get() forKeyPath:keyName options:options context:(void *)MediaPlayerAVFoundationObservationContextPlayerItem]; 964 968 969 [m_avPlayerItem setAudioTimePitchAlgorithm:(player()->preservesPitch() ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)]; 970 965 971 if (m_avPlayer) 966 972 setAVPlayerItem(m_avPlayerItem.get()); … … 970 976 if (player()->doesHaveAttribute("data-youtube-id", &value)) 971 977 [m_avPlayerItem.get() setDataYouTubeID: value]; 972 978 #endif 973 979 974 980 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) … … 1321 1327 1322 1328 void MediaPlayerPrivateAVFoundationObjC::setRateDouble(double rate) 1323 1324 1329 { 1325 1330 setDelayCallbacks(true); … … 1335 1340 1336 1341 return m_cachedRate; 1342 } 1343 1344 void MediaPlayerPrivateAVFoundationObjC::setPreservesPitch(bool preservesPitch) 1345 { 1346 if (m_avPlayerItem) 1347 [m_avPlayerItem setAudioTimePitchAlgorithm:(preservesPitch ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)]; 1337 1348 } 1338 1349 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r180839 r181006 132 132 virtual void setRateDouble(double) override; 133 133 134 void setPreservesPitch(bool) override; 135 134 136 virtual std::unique_ptr<PlatformTimeRanges> seekable() const override; 135 137 virtual MediaTime maxMediaTimeSeekable() const override; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r180839 r181006 63 63 SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVVideoPerformanceMetrics) 64 64 65 SOFT_LINK_CONSTANT(AVFoundation, AVAudioTimePitchAlgorithmSpectral, NSString*) 66 SOFT_LINK_CONSTANT(AVFoundation, AVAudioTimePitchAlgorithmVarispeed, NSString*) 65 67 SOFT_LINK_CONSTANT(CoreMedia, kCMTimebaseNotification_EffectiveRateChanged, CFStringRef) 68 69 #define AVAudioTimePitchAlgorithmSpectral getAVAudioTimePitchAlgorithmSpectral() 70 #define AVAudioTimePitchAlgorithmVarispeed getAVAudioTimePitchAlgorithmVarispeed() 66 71 #define kCMTimebaseNotification_EffectiveRateChanged getkCMTimebaseNotification_EffectiveRateChanged() 67 72 … … 92 97 - (void)setVolume:(float)volume; 93 98 - (void)setMuted:(BOOL)muted; 99 @property (nonatomic, copy) NSString *audioTimePitchAlgorithm; 94 100 @end 95 101 … … 471 477 } 472 478 479 void MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch(bool preservesPitch) 480 { 481 NSString *algorithm = preservesPitch ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed; 482 for (auto& renderer : m_sampleBufferAudioRenderers) 483 [renderer setAudioTimePitchAlgorithm:algorithm]; 484 } 485 473 486 MediaPlayer::NetworkState MediaPlayerPrivateMediaSourceAVFObjC::networkState() const 474 487 { … … 773 786 [audioRenderer setMuted:m_player->muted()]; 774 787 [audioRenderer setVolume:m_player->volume()]; 788 [audioRenderer setAudioTimePitchAlgorithm:(m_player->preservesPitch() ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)]; 775 789 776 790 [m_synchronizer addRenderer:audioRenderer];
Note: See TracChangeset
for help on using the changeset viewer.