Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 6772473

Browse files
author
Butkovits Atila
committed
Backed out 4 changesets (bug 1660336) for causing build bustage on libmozavcodec.so. CLOSED TREE
Backed out changeset 13936ff79b4c (bug 1660336) Backed out changeset 7315e7b327f7 (bug 1660336) Backed out changeset b6ca98c5a3cc (bug 1660336) Backed out changeset fb8fee4471de (bug 1660336)
1 parent c05b5c6 commit 6772473

28 files changed

Lines changed: 80 additions & 3331 deletions

dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#include "mozilla/Types.h"
1212
#include "PlatformDecoderModule.h"
1313
#include "prlink.h"
14-
#ifdef MOZ_WAYLAND
15-
# include "mozilla/widget/DMABufLibWrapper.h"
16-
# include "mozilla/StaticPrefs_media.h"
17-
#endif
1814

1915
#define AV_LOG_DEBUG 48
2016
#define AV_LOG_INFO 32
@@ -257,46 +253,6 @@ void FFmpegLibWrapper::Unlink() {
257253
PodZero(this);
258254
}
259255

260-
#ifdef MOZ_WAYLAND
261-
void FFmpegLibWrapper::LinkVAAPILibs() {
262-
if (widget::GetDMABufDevice()->IsDMABufVAAPIEnabled()) {
263-
PRLibSpec lspec;
264-
lspec.type = PR_LibSpec_Pathname;
265-
const char* libDrm = "libva-drm.so.2";
266-
lspec.value.pathname = libDrm;
267-
mVALibDrm = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
268-
if (!mVALibDrm) {
269-
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libDrm);
270-
}
271-
272-
if (!StaticPrefs::media_ffmpeg_vaapi_drm_display_enabled()) {
273-
const char* libWayland = "libva-wayland.so.2";
274-
lspec.value.pathname = libWayland;
275-
mVALibWayland = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
276-
if (!mVALibWayland) {
277-
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libWayland);
278-
}
279-
}
280-
281-
if (mVALibWayland || mVALibDrm) {
282-
const char* lib = "libva.so.2";
283-
lspec.value.pathname = lib;
284-
mVALib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
285-
// Don't use libva when it's missing vaExportSurfaceHandle.
286-
if (mVALib && !PR_FindSymbol(mVALib, "vaExportSurfaceHandle")) {
287-
PR_UnloadLibrary(mVALib);
288-
mVALib = nullptr;
289-
}
290-
if (!mVALib) {
291-
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", lib);
292-
}
293-
}
294-
} else {
295-
FFMPEG_LOG("VA-API FFmpeg is disabled by platform");
296-
}
297-
}
298-
#endif
299-
300256
#ifdef MOZ_WAYLAND
301257
bool FFmpegLibWrapper::IsVAAPIAvailable() {
302258
# define VA_FUNC_LOADED(func) (func != nullptr)

dom/media/platforms/ffmpeg/FFmpegLibWrapper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FFmpegLibWrapper {
5656
#ifdef MOZ_WAYLAND
5757
// Check if mVALib are available and we can use HW decode.
5858
bool IsVAAPIAvailable();
59-
void LinkVAAPILibs();
6059
#endif
6160

6261
// indicate the version of libavcodec linked to.

dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include "mozilla/ArrayUtils.h"
1010
#include "FFmpegLog.h"
1111
#include "prlink.h"
12+
#ifdef MOZ_WAYLAND
13+
# include "mozilla/widget/DMABufLibWrapper.h"
14+
# include "mozilla/StaticPrefs_media.h"
15+
#endif
1216

1317
namespace mozilla {
1418

@@ -54,7 +58,43 @@ bool FFmpegRuntimeLinker::Init() {
5458
}
5559

5660
#ifdef MOZ_WAYLAND
57-
sLibAV.LinkVAAPILibs();
61+
if (widget::GetDMABufDevice()->IsDMABufVAAPIEnabled()) {
62+
PRLibSpec lspec;
63+
lspec.type = PR_LibSpec_Pathname;
64+
const char* libDrm = "libva-drm.so.2";
65+
lspec.value.pathname = libDrm;
66+
sLibAV.mVALibDrm = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
67+
if (!sLibAV.mVALibDrm) {
68+
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libDrm);
69+
}
70+
71+
if (!StaticPrefs::media_ffmpeg_vaapi_drm_display_enabled()) {
72+
const char* libWayland = "libva-wayland.so.2";
73+
lspec.value.pathname = libWayland;
74+
sLibAV.mVALibWayland =
75+
PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
76+
if (!sLibAV.mVALibWayland) {
77+
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libWayland);
78+
}
79+
}
80+
81+
if (sLibAV.mVALibWayland || sLibAV.mVALibDrm) {
82+
const char* lib = "libva.so.2";
83+
lspec.value.pathname = lib;
84+
sLibAV.mVALib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
85+
// Don't use libva when it's missing vaExportSurfaceHandle.
86+
if (sLibAV.mVALib &&
87+
!PR_FindSymbol(sLibAV.mVALib, "vaExportSurfaceHandle")) {
88+
PR_UnloadLibrary(sLibAV.mVALib);
89+
sLibAV.mVALib = nullptr;
90+
}
91+
if (!sLibAV.mVALib) {
92+
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", lib);
93+
}
94+
}
95+
} else {
96+
FFMPEG_LOG("VA-API FFmpeg is disabled by platform");
97+
}
5898
#endif
5999

60100
// While going through all possible libs, this status will be updated with a

dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ static AVPixelFormat ChooseVAAPIPixelFormat(AVCodecContext* aCodecContext,
126126
return AV_PIX_FMT_NONE;
127127
}
128128

129-
DMABufSurfaceWrapper<LIBAV_VER>::DMABufSurfaceWrapper(DMABufSurface* aSurface,
130-
FFmpegLibWrapper* aLib)
129+
DMABufSurfaceWrapper::DMABufSurfaceWrapper(DMABufSurface* aSurface,
130+
FFmpegLibWrapper* aLib)
131131
: mSurface(aSurface),
132132
mLib(aLib),
133133
mAVHWFramesContext(nullptr),
@@ -140,8 +140,8 @@ DMABufSurfaceWrapper<LIBAV_VER>::DMABufSurfaceWrapper(DMABufSurface* aSurface,
140140
mSurface->GetUID());
141141
}
142142

143-
void DMABufSurfaceWrapper<LIBAV_VER>::LockVAAPIData(
144-
AVCodecContext* aAVCodecContext, AVFrame* aAVFrame) {
143+
void DMABufSurfaceWrapper::LockVAAPIData(AVCodecContext* aAVCodecContext,
144+
AVFrame* aAVFrame) {
145145
FFMPEG_LOG("DMABufSurfaceWrapper: VAAPI locking dmabuf surface UID = %d",
146146
mSurface->GetUID());
147147
if (aAVCodecContext && aAVFrame) {
@@ -150,7 +150,7 @@ void DMABufSurfaceWrapper<LIBAV_VER>::LockVAAPIData(
150150
}
151151
}
152152

153-
void DMABufSurfaceWrapper<LIBAV_VER>::ReleaseVAAPIData() {
153+
void DMABufSurfaceWrapper::ReleaseVAAPIData() {
154154
FFMPEG_LOG("DMABufSurfaceWrapper: VAAPI releasing dmabuf surface UID = %d",
155155
mSurface->GetUID());
156156
if (mHWAVBuffer && mAVHWFramesContext) {
@@ -160,7 +160,7 @@ void DMABufSurfaceWrapper<LIBAV_VER>::ReleaseVAAPIData() {
160160
mSurface->ReleaseSurface();
161161
}
162162

163-
DMABufSurfaceWrapper<LIBAV_VER>::~DMABufSurfaceWrapper() {
163+
DMABufSurfaceWrapper::~DMABufSurfaceWrapper() {
164164
FFMPEG_LOG("DMABufSurfaceWrapper: deleting dmabuf surface UID = %d",
165165
mSurface->GetUID());
166166
ReleaseVAAPIData();
@@ -183,14 +183,7 @@ AVCodec* FFmpegVideoDecoder<LIBAV_VER>::FindVAAPICodec() {
183183
return nullptr;
184184
}
185185

186-
template <int V>
187-
class VAAPIDisplayHolder {};
188-
189-
template <>
190-
class VAAPIDisplayHolder<LIBAV_VER>;
191-
192-
template <>
193-
class VAAPIDisplayHolder<LIBAV_VER> {
186+
class VAAPIDisplayHolder {
194187
public:
195188
VAAPIDisplayHolder(FFmpegLibWrapper* aLib, VADisplay aDisplay)
196189
: mLib(aLib), mDisplay(aDisplay){};
@@ -202,8 +195,7 @@ class VAAPIDisplayHolder<LIBAV_VER> {
202195
};
203196

204197
static void VAAPIDisplayReleaseCallback(struct AVHWDeviceContext* hwctx) {
205-
auto displayHolder =
206-
static_cast<VAAPIDisplayHolder<LIBAV_VER>*>(hwctx->user_opaque);
198+
auto displayHolder = static_cast<VAAPIDisplayHolder*>(hwctx->user_opaque);
207199
delete displayHolder;
208200
}
209201

@@ -239,7 +231,7 @@ bool FFmpegVideoDecoder<LIBAV_VER>::CreateVAAPIDeviceContext() {
239231
}
240232
}
241233

242-
hwctx->user_opaque = new VAAPIDisplayHolder<LIBAV_VER>(mLib, mDisplay);
234+
hwctx->user_opaque = new VAAPIDisplayHolder(mLib, mDisplay);
243235
hwctx->free = VAAPIDisplayReleaseCallback;
244236

245237
int major, minor;
@@ -713,7 +705,7 @@ void FFmpegVideoDecoder<LIBAV_VER>::ReleaseUnusedVAAPIFrames() {
713705
}
714706
}
715707

716-
DMABufSurfaceWrapper<LIBAV_VER>*
708+
DMABufSurfaceWrapper*
717709
FFmpegVideoDecoder<LIBAV_VER>::GetUnusedDMABufSurfaceWrapper() {
718710
int len = mDMABufSurfaces.Length();
719711
for (int i = 0; i < len; i++) {
@@ -779,8 +771,7 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER>::CreateImageDMABuf(
779771

780772
RefPtr<DMABufSurfaceYUV> surface;
781773

782-
DMABufSurfaceWrapper<LIBAV_VER>* surfaceWrapper =
783-
GetUnusedDMABufSurfaceWrapper();
774+
DMABufSurfaceWrapper* surfaceWrapper = GetUnusedDMABufSurfaceWrapper();
784775
if (!surfaceWrapper) {
785776
if (mVAAPIDeviceContext) {
786777
surface = DMABufSurfaceYUV::CreateYUVSurface(vaDesc);

dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@ namespace mozilla {
5555
// We own the DMABufSurface underlying GPU data and we use it for
5656
// repeated rendering of video frames.
5757
//
58-
template <int V>
59-
class DMABufSurfaceWrapper {};
60-
61-
template <>
62-
class DMABufSurfaceWrapper<LIBAV_VER>;
63-
64-
template <>
65-
class DMABufSurfaceWrapper<LIBAV_VER> final {
58+
class DMABufSurfaceWrapper final {
6659
public:
6760
DMABufSurfaceWrapper(DMABufSurface* aSurface, FFmpegLibWrapper* aLib);
6861
~DMABufSurfaceWrapper();
@@ -169,7 +162,7 @@ class FFmpegVideoDecoder<LIBAV_VER>
169162
MediaDataDecoder::DecodedData& aResults);
170163

171164
void ReleaseUnusedVAAPIFrames();
172-
DMABufSurfaceWrapper<LIBAV_VER>* GetUnusedDMABufSurfaceWrapper();
165+
DMABufSurfaceWrapper* GetUnusedDMABufSurfaceWrapper();
173166
void ReleaseDMABufSurfaces();
174167
#endif
175168

@@ -187,7 +180,7 @@ class FFmpegVideoDecoder<LIBAV_VER>
187180
const bool mDisableHardwareDecoding;
188181
VADisplay mDisplay;
189182
bool mUseDMABufSurfaces;
190-
nsTArray<DMABufSurfaceWrapper<LIBAV_VER>> mDMABufSurfaces;
183+
nsTArray<DMABufSurfaceWrapper> mDMABufSurfaces;
191184
#endif
192185
RefPtr<KnowsCompositor> mImageAllocator;
193186
RefPtr<ImageContainer> mImageContainer;

dom/media/platforms/ffmpeg/ffmpeg58/moz.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ if CONFIG['CC_TYPE'] == 'gcc':
2727
]
2828
if CONFIG['MOZ_WAYLAND']:
2929
CXXFLAGS += CONFIG['TK_CFLAGS']
30+
CXXFLAGS += CONFIG['MOZ_WAYLAND_CFLAGS']
3031
DEFINES['MOZ_WAYLAND_USE_VAAPI'] = 1
32+
include('/ipc/chromium/chromium-config.mozbuild')
3133

3234
FINAL_LIBRARY = 'xul'

dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ bool FFVPXRuntimeLinker::Init() {
6464
MOZ_ASSERT(NS_IsMainThread());
6565
sLinkStatus = LinkStatus_FAILED;
6666

67-
#ifdef MOZ_WAYLAND
68-
sFFVPXLib.LinkVAAPILibs();
69-
#endif
70-
7167
// We retrieve the path of the lgpllibs library as this is where mozavcodec
7268
// and mozavutil libs are located.
7369
PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs");

dom/media/platforms/ffmpeg/ffvpx/moz.build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,4 @@ if CONFIG["CC_TYPE"] == "gcc":
3636
DEFINES["FFVPX_VERSION"] = 46465650
3737
DEFINES["USING_MOZFFVPX"] = True
3838

39-
if CONFIG["MOZ_WAYLAND"]:
40-
CXXFLAGS += CONFIG["TK_CFLAGS"]
41-
DEFINES["MOZ_WAYLAND_USE_VAAPI"] = 1
42-
4339
FINAL_LIBRARY = "xul"

gfx/layers/DMABUFSurfaceImage.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
66

77
#include "DMABUFSurfaceImage.h"
8-
#include "mozilla/widget/DMABufSurface.h"
8+
#include "gfxPlatform.h"
99
#include "mozilla/layers/CompositableClient.h"
1010
#include "mozilla/layers/CompositableForwarder.h"
1111
#include "mozilla/layers/DMABUFTextureClientOGL.h"
1212
#include "mozilla/layers/TextureForwarder.h"
13+
#include "mozilla/UniquePtr.h"
1314

1415
using namespace mozilla;
1516
using namespace mozilla::layers;
1617
using namespace mozilla::gfx;
1718

18-
DMABUFSurfaceImage::DMABUFSurfaceImage(DMABufSurface* aSurface)
19-
: Image(nullptr, ImageFormat::DMABUF), mSurface(aSurface) {
20-
mSurface->GlobalRefAdd();
21-
}
22-
23-
DMABUFSurfaceImage::~DMABUFSurfaceImage() { mSurface->GlobalRefRelease(); }
24-
2519
TextureClient* DMABUFSurfaceImage::GetTextureClient(
2620
KnowsCompositor* aKnowsCompositor) {
2721
if (!mTextureClient) {
@@ -32,7 +26,3 @@ TextureClient* DMABUFSurfaceImage::GetTextureClient(
3226
}
3327
return mTextureClient;
3428
}
35-
36-
gfx::IntSize DMABUFSurfaceImage::GetSize() const {
37-
return gfx::IntSize::Truncate(mSurface->GetWidth(), mSurface->GetHeight());
38-
}

gfx/layers/DMABUFSurfaceImage.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,32 @@
88
#define SURFACE_DMABUF_H
99

1010
#include "ImageContainer.h"
11-
12-
class DMABufSurface;
11+
#include "mozilla/widget/DMABufSurface.h"
12+
#include "mozilla/gfx/Point.h"
13+
#include "mozilla/layers/TextureClient.h"
1314

1415
namespace mozilla {
1516
namespace layers {
1617

17-
class TextureClient;
18-
1918
class DMABUFSurfaceImage : public Image {
2019
public:
21-
explicit DMABUFSurfaceImage(DMABufSurface* aSurface);
22-
~DMABUFSurfaceImage();
20+
explicit DMABUFSurfaceImage(DMABufSurface* aSurface)
21+
: Image(nullptr, ImageFormat::DMABUF), mSurface(aSurface) {
22+
mSurface->GlobalRefAdd();
23+
}
24+
25+
~DMABUFSurfaceImage() { mSurface->GlobalRefRelease(); }
2326

2427
DMABufSurface* GetSurface() { return mSurface; }
25-
gfx::IntSize GetSize() const override;
28+
29+
gfx::IntSize GetSize() const override {
30+
return gfx::IntSize::Truncate(mSurface->GetWidth(), mSurface->GetHeight());
31+
}
32+
2633
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override {
2734
return nullptr;
2835
}
36+
2937
TextureClient* GetTextureClient(KnowsCompositor* aKnowsCompositor) override;
3038

3139
private:

0 commit comments

Comments
 (0)