tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit dd2ab66fbfaa9535e01dc0ede181c074b7e12136
parent 82ea5a2188f40840ab0d364b460fc0d5fdb0c2da
Author: Andrew Osmond <aosmond@gmail.com>
Date:   Mon,  5 Jan 2026 03:04:58 +0000

Bug 2008328 - Use const with FFmpegLibWrapper* consistently. r=media-playback-reviewers,karlt

Differential Revision: https://phabricator.services.mozilla.com/D277745

Diffstat:
Mdom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp | 2+-
Mdom/media/platforms/ffmpeg/FFmpegAudioDecoder.h | 2+-
Mdom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp | 7++++---
Mdom/media/platforms/ffmpeg/FFmpegDataDecoder.h | 9+++++----
Mdom/media/platforms/ffmpeg/FFmpegDecoderModule.h | 8++++----
Mdom/media/platforms/ffmpeg/FFmpegEncoderModule.cpp | 2+-
Mdom/media/platforms/ffmpeg/FFmpegEncoderModule.h | 6+++---
Mdom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp | 2+-
Mdom/media/platforms/ffmpeg/FFmpegLibWrapper.h | 2+-
Mdom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp | 10++++++----
Mdom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp | 5+++--
Mdom/media/platforms/ffmpeg/FFmpegVideoDecoder.h | 4++--
Mdom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp | 6+++---
Mdom/media/platforms/ffmpeg/FFmpegVideoFramePool.h | 6+++---
Mdom/media/platforms/ffmpeg/ffvpx/D3D11TextureWrapper.cpp | 2+-
Mdom/media/platforms/ffmpeg/ffvpx/D3D11TextureWrapper.h | 4++--
Mdom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp | 10++++++----
17 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp @@ -29,7 +29,7 @@ namespace mozilla { using TimeUnit = media::TimeUnit; FFmpegAudioDecoder<LIBAV_VER>::FFmpegAudioDecoder( - FFmpegLibWrapper* aLib, const CreateDecoderParams& aDecoderParams) + const FFmpegLibWrapper* aLib, const CreateDecoderParams& aDecoderParams) : FFmpegDataDecoder(aLib, GetCodecId(aDecoderParams.AudioConfig().mMimeType, aDecoderParams.AudioConfig()), diff --git a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h @@ -25,7 +25,7 @@ class FFmpegAudioDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>, public DecoderDoctorLifeLogger<FFmpegAudioDecoder<LIBAV_VER>> { public: - FFmpegAudioDecoder(FFmpegLibWrapper* aLib, + FFmpegAudioDecoder(const FFmpegLibWrapper* aLib, const CreateDecoderParams& aDecoderParams); virtual ~FFmpegAudioDecoder(); diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp @@ -29,7 +29,7 @@ namespace mozilla { StaticMutex FFmpegDataDecoder<LIBAV_VER>::sMutex; -FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(FFmpegLibWrapper* aLib, +FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(const FFmpegLibWrapper* aLib, AVCodecID aCodecID, PRemoteCDMActor* aCDM) : mLib(aLib), @@ -437,7 +437,7 @@ AVFrame* FFmpegDataDecoder<LIBAV_VER>::PrepareFrame() { } /* static */ AVCodec* FFmpegDataDecoder<LIBAV_VER>::FindSoftwareAVCodec( - FFmpegLibWrapper* aLib, AVCodecID aCodec) { + const FFmpegLibWrapper* aLib, AVCodecID aCodec) { MOZ_ASSERT(aLib); // We use this instead of MOZ_USE_HWDECODE because it is possible to disable @@ -504,7 +504,8 @@ AVFrame* FFmpegDataDecoder<LIBAV_VER>::PrepareFrame() { #ifdef MOZ_USE_HWDECODE /* static */ AVCodec* FFmpegDataDecoder<LIBAV_VER>::FindHardwareAVCodec( - FFmpegLibWrapper* aLib, AVCodecID aCodec, AVHWDeviceType aDeviceType) { + const FFmpegLibWrapper* aLib, AVCodecID aCodec, + AVHWDeviceType aDeviceType) { AVCodec* fallbackCodec = nullptr; void* opaque = nullptr; const bool ignoreDeviceType = aDeviceType == AV_HWDEVICE_TYPE_NONE; diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h @@ -34,7 +34,7 @@ class FFmpegDataDecoder<LIBAV_VER> public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FFmpegDataDecoder, final); - FFmpegDataDecoder(FFmpegLibWrapper* aLib, AVCodecID aCodecID, + FFmpegDataDecoder(const FFmpegLibWrapper* aLib, AVCodecID aCodecID, PRemoteCDMActor* aCDM); static bool Link(); @@ -45,10 +45,11 @@ class FFmpegDataDecoder<LIBAV_VER> RefPtr<FlushPromise> Flush() override; RefPtr<ShutdownPromise> Shutdown() override; - static AVCodec* FindSoftwareAVCodec(FFmpegLibWrapper* aLib, AVCodecID aCodec); + static AVCodec* FindSoftwareAVCodec(const FFmpegLibWrapper* aLib, + AVCodecID aCodec); #ifdef MOZ_USE_HWDECODE static AVCodec* FindHardwareAVCodec( - FFmpegLibWrapper* aLib, AVCodecID aCodec, + const FFmpegLibWrapper* aLib, AVCodecID aCodec, AVHWDeviceType aDeviceType = AV_HWDEVICE_TYPE_NONE); #endif @@ -73,7 +74,7 @@ class FFmpegDataDecoder<LIBAV_VER> void MaybeDetachCDM(); #endif - FFmpegLibWrapper* mLib; // set in constructor + const FFmpegLibWrapper* mLib; // set in constructor // mCodecContext is accessed on taskqueue only, no locking needed AVCodecContext* mCodecContext; diff --git a/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h b/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h @@ -36,7 +36,7 @@ class FFmpegDecoderModule : public PlatformDecoderModule { return "FFmpeg(OS library)"; #endif } - static void Init(FFmpegLibWrapper* aLib) { + static void Init(const FFmpegLibWrapper* aLib) { #if (defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \ defined(MOZ_WIDGET_ANDROID)) && \ defined(MOZ_USE_HWDECODE) && !defined(MOZ_FFVPX_AUDIOONLY) @@ -144,13 +144,13 @@ class FFmpegDecoderModule : public PlatformDecoderModule { } static already_AddRefed<PlatformDecoderModule> Create( - FFmpegLibWrapper* aLib) { + const FFmpegLibWrapper* aLib) { RefPtr<PlatformDecoderModule> pdm = new FFmpegDecoderModule(aLib); return pdm.forget(); } - explicit FFmpegDecoderModule(FFmpegLibWrapper* aLib) : mLib(aLib) {} + explicit FFmpegDecoderModule(const FFmpegLibWrapper* aLib) : mLib(aLib) {} virtual ~FFmpegDecoderModule() = default; already_AddRefed<MediaDataDecoder> CreateVideoDecoder( @@ -334,7 +334,7 @@ class FFmpegDecoderModule : public PlatformDecoderModule { } private: - FFmpegLibWrapper* mLib; + const FFmpegLibWrapper* mLib; MOZ_RUNINIT static inline StaticDataMutex<nsTArray<AVCodecID>> sSupportedHWCodecs{"sSupportedHWCodecs"}; }; diff --git a/dom/media/platforms/ffmpeg/FFmpegEncoderModule.cpp b/dom/media/platforms/ffmpeg/FFmpegEncoderModule.cpp @@ -29,7 +29,7 @@ using mozilla::media::EncodeSupportSet; namespace mozilla { template <int V> -/* static */ void FFmpegEncoderModule<V>::Init(FFmpegLibWrapper* aLib) { +/* static */ void FFmpegEncoderModule<V>::Init(const FFmpegLibWrapper* aLib) { #if (defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \ defined(MOZ_WIDGET_ANDROID)) && \ defined(MOZ_USE_HWDECODE) && !defined(MOZ_FFVPX_AUDIOONLY) && \ diff --git a/dom/media/platforms/ffmpeg/FFmpegEncoderModule.h b/dom/media/platforms/ffmpeg/FFmpegEncoderModule.h @@ -20,10 +20,10 @@ class FFmpegEncoderModule final : public PlatformEncoderModule { public: virtual ~FFmpegEncoderModule() = default; - static void Init(FFmpegLibWrapper* aLib); + static void Init(const FFmpegLibWrapper* aLib); static already_AddRefed<PlatformEncoderModule> Create( - FFmpegLibWrapper* aLib) { + const FFmpegLibWrapper* aLib) { RefPtr<PlatformEncoderModule> pem = new FFmpegEncoderModule(aLib); return pem.forget(); } @@ -41,7 +41,7 @@ class FFmpegEncoderModule final : public PlatformEncoderModule { const RefPtr<TaskQueue>& aTaskQueue) const override; protected: - explicit FFmpegEncoderModule(FFmpegLibWrapper* aLib) : mLib(aLib) { + explicit FFmpegEncoderModule(const FFmpegLibWrapper* aLib) : mLib(aLib) { MOZ_ASSERT(mLib); } diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp @@ -447,7 +447,7 @@ void FFmpegLibWrapper::UpdateLogLevel() { } #ifdef MOZ_WIDGET_GTK -bool FFmpegLibWrapper::IsVAAPIAvailable() { +bool FFmpegLibWrapper::IsVAAPIAvailable() const { # define VA_FUNC_LOADED(func) ((func) != nullptr) return VA_FUNC_LOADED(avcodec_get_hw_config) && VA_FUNC_LOADED(av_hwdevice_ctx_alloc) && diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h @@ -57,7 +57,7 @@ struct MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FFmpegLibWrapper { #ifdef MOZ_WIDGET_GTK // Check if libva and libva-drm are available and we can use HW decode. - bool IsVAAPIAvailable(); + bool IsVAAPIAvailable() const; #endif // Helpers for libavcodec/util logging to integrate with MOZ_LOG. diff --git a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp @@ -19,15 +19,17 @@ const char* FFmpegRuntimeLinker::sLinkStatusLibraryName = ""; template <int V> class FFmpegDecoderModule { public: - static void Init(FFmpegLibWrapper*); - static already_AddRefed<PlatformDecoderModule> Create(FFmpegLibWrapper*); + static void Init(const FFmpegLibWrapper*); + static already_AddRefed<PlatformDecoderModule> Create( + const FFmpegLibWrapper*); }; template <int V> class FFmpegEncoderModule { public: - static void Init(FFmpegLibWrapper*); - static already_AddRefed<PlatformEncoderModule> Create(FFmpegLibWrapper*); + static void Init(const FFmpegLibWrapper*); + static already_AddRefed<PlatformEncoderModule> Create( + const FFmpegLibWrapper*); }; static FFmpegLibWrapper sLibAV; diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -602,7 +602,7 @@ bool FFmpegVideoDecoder<LIBAV_VER>::UploadSWDecodeToDMABuf() const { #endif FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder( - FFmpegLibWrapper* aLib, const VideoInfo& aConfig, + const FFmpegLibWrapper* aLib, const VideoInfo& aConfig, KnowsCompositor* aAllocator, ImageContainer* aImageContainer, bool aLowLatency, bool aDisableHardwareDecoding, bool a8BitOutput, Maybe<TrackingId> aTrackingId, PRemoteCDMActor* aCDM) @@ -2604,7 +2604,8 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER>::CreateImageMediaCodec( #if MOZ_USE_HWDECODE /* static */ AVCodec* FFmpegVideoDecoder<LIBAV_VER>::FindVideoHardwareAVCodec( - FFmpegLibWrapper* aLib, AVCodecID aCodec, AVHWDeviceType aDeviceType) { + const FFmpegLibWrapper* aLib, AVCodecID aCodec, + AVHWDeviceType aDeviceType) { # ifdef MOZ_WIDGET_GTK if (aDeviceType == AV_HWDEVICE_TYPE_NONE) { switch (aCodec) { diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h @@ -66,7 +66,7 @@ class FFmpegVideoDecoder<LIBAV_VER> typedef mozilla::layers::KnowsCompositor KnowsCompositor; public: - FFmpegVideoDecoder(FFmpegLibWrapper* aLib, const VideoInfo& aConfig, + FFmpegVideoDecoder(const FFmpegLibWrapper* aLib, const VideoInfo& aConfig, KnowsCompositor* aAllocator, ImageContainer* aImageContainer, bool aLowLatency, bool aDisableHardwareDecoding, bool a8BitOutput, @@ -168,7 +168,7 @@ class FFmpegVideoDecoder<LIBAV_VER> #ifdef MOZ_USE_HWDECODE public: static AVCodec* FindVideoHardwareAVCodec( - FFmpegLibWrapper* aLib, AVCodecID aCodec, + const FFmpegLibWrapper* aLib, AVCodecID aCodec, AVHWDeviceType aDeviceType = AV_HWDEVICE_TYPE_NONE); private: diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp @@ -79,7 +79,7 @@ void VideoFrameSurface<LIBAV_VER>::DisableRecycle() { void VideoFrameSurface<LIBAV_VER>::LockVAAPIData( AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, - FFmpegLibWrapper* aLib) { + const FFmpegLibWrapper* aLib) { mLib = aLib; mHoldByFFmpeg = true; @@ -290,7 +290,7 @@ RefPtr<VideoFrameSurface<LIBAV_VER>> VideoFramePool<LIBAV_VER>::GetVideoFrameSurface( VADRMPRIMESurfaceDescriptor& aVaDesc, int aWidth, int aHeight, AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, - FFmpegLibWrapper* aLib) { + const FFmpegLibWrapper* aLib) { if (aVaDesc.fourcc != VA_FOURCC_NV12 && aVaDesc.fourcc != VA_FOURCC_YV12 && aVaDesc.fourcc != VA_FOURCC_P010 && aVaDesc.fourcc != VA_FOURCC_P016) { DMABUF_LOG("Unsupported VA-API surface format %d", aVaDesc.fourcc); @@ -494,7 +494,7 @@ VideoFramePool<LIBAV_VER>::GetVideoFrameSurface(AVDRMFrameDescriptor& aDesc, int aWidth, int aHeight, AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, - FFmpegLibWrapper* aLib) { + const FFmpegLibWrapper* aLib) { MOZ_ASSERT(aDesc.nb_layers > 0); auto layerDesc = FFmpegDescToVA(aDesc, aAVFrame); diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.h b/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.h @@ -102,7 +102,7 @@ class VideoFrameSurface<LIBAV_VER> { protected: // Lock VAAPI related data void LockVAAPIData(AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, - FFmpegLibWrapper* aLib); + const FFmpegLibWrapper* aLib); // Release VAAPI related data, DMABufSurface can be reused // for another frame. void ReleaseVAAPIData(bool aForFrameRecycle = true); @@ -135,11 +135,11 @@ class VideoFramePool<LIBAV_VER> { RefPtr<VideoFrameSurface<LIBAV_VER>> GetVideoFrameSurface( VADRMPRIMESurfaceDescriptor& aVaDesc, int aWidth, int aHeight, AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, - FFmpegLibWrapper* aLib); + const FFmpegLibWrapper* aLib); RefPtr<VideoFrameSurface<LIBAV_VER>> GetVideoFrameSurface( AVDRMFrameDescriptor& aDesc, int aWidth, int aHeight, AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, - FFmpegLibWrapper* aLib); + const FFmpegLibWrapper* aLib); RefPtr<VideoFrameSurface<LIBAV_VER>> GetVideoFrameSurface( const layers::PlanarYCbCrData& aData, AVCodecContext* aAVCodecContext); diff --git a/dom/media/platforms/ffmpeg/ffvpx/D3D11TextureWrapper.cpp b/dom/media/platforms/ffmpeg/ffvpx/D3D11TextureWrapper.cpp @@ -23,7 +23,7 @@ extern mozilla::LazyLogModule sFFmpegVideoLog; namespace mozilla { D3D11TextureWrapper::D3D11TextureWrapper(AVFrame* aAVFrame, - FFmpegLibWrapper* aLib, + const FFmpegLibWrapper* aLib, ID3D11Texture2D* aTexture, const gfx::SurfaceFormat aFormat, const unsigned int aArrayIdx, diff --git a/dom/media/platforms/ffmpeg/ffvpx/D3D11TextureWrapper.h b/dom/media/platforms/ffmpeg/ffvpx/D3D11TextureWrapper.h @@ -26,7 +26,7 @@ struct FFmpegLibWrapper; // which can help avoid significant playback stutter. class D3D11TextureWrapper final { public: - D3D11TextureWrapper(AVFrame* aAVFrame, FFmpegLibWrapper* aLib, + D3D11TextureWrapper(AVFrame* aAVFrame, const FFmpegLibWrapper* aLib, ID3D11Texture2D* aTexture, const gfx::SurfaceFormat aFormat, const unsigned int aArrayIdx, @@ -43,7 +43,7 @@ class D3D11TextureWrapper final { const std::function<void()> mReleaseMethod; private: - FFmpegLibWrapper* mLib; + const FFmpegLibWrapper* mLib; ID3D11Texture2D* mTexture; AVBufferRef* mHWAVBuffer; }; diff --git a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp @@ -19,15 +19,17 @@ namespace mozilla { template <int V> class FFmpegDecoderModule { public: - static void Init(FFmpegLibWrapper*); - static already_AddRefed<PlatformDecoderModule> Create(FFmpegLibWrapper*); + static void Init(const FFmpegLibWrapper*); + static already_AddRefed<PlatformDecoderModule> Create( + const FFmpegLibWrapper*); }; template <int V> class FFmpegEncoderModule { public: - static void Init(FFmpegLibWrapper*); - static already_AddRefed<PlatformEncoderModule> Create(FFmpegLibWrapper*); + static void Init(const FFmpegLibWrapper*); + static already_AddRefed<PlatformEncoderModule> Create( + const FFmpegLibWrapper*); }; static FFmpegLibWrapper sFFVPXLib;