Add VA-API decode path to bundled ffvpx
Categories
(Core :: Audio/Video: Playback, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox85 | --- | fixed |
People
(Reporter: pmenzel+bugzilla.mozilla.org, Assigned: stransky)
References
(Blocks 1 open bug)
Details
Attachments
(6 files, 1 obsolete file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0
Steps to reproduce:
Try to use hardware accelerated WebRTC VP8 decode.
Actual results:
The fan started spinning (bug #1660195).
Expected results:
It’d be great if libvpx shipped by Firefox supported VA-API decode path.
From Martin’s article:
Mozilla binaries perform VP8/VP9 decoding by bundled libvpx library which is missing VA-API decode path. If your hardware supports it and you want to use VA-API for VP8/VP9 decoding, you need to disable bundled libvpx and force external ffmpeg. Go to about:config and set
media.ffvpx.enabled
tofalse
. Fedora sets that by default when VA-API is enabled.
Comment 1•4 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Updated•4 years ago
|
Comment 2•4 years ago
|
||
AFAI understand libvpx is a pure software decoder and it doesn't make sense to "add VA-API" to it. What we actually want is for Firefox to try the external FFmpeg's hardware decoding first, then the internal libvpx (if enabled) and then the external FFmpeg's software decoding.
Comment 3•4 years ago
|
||
(In reply to Jan Alexander Steffens [:heftig] from comment #2)
AFAI understand libvpx is a pure software decoder and it doesn't make sense to "add VA-API" to it. What we actually want is for Firefox to try the external FFmpeg's hardware decoding first, then the internal libvpx (if enabled) and then the external FFmpeg's software decoding.
Only how it's used for video playback.
We have multiple copies unfortunately (one for webrtc, one for video playback (unused) and one for webp).
The one shipping with webrtc is used for encoding.
We're trying to remove the need for libvpx altogether
In any case, I will close this as won't fix.
With webrtc today, libvpx is used for encoding, ffvp8 is used for decoding and it can already be hardware decoded.
Comment 4•4 years ago
|
||
I think the confusion may come from the original blog entry that incorrectly refers to libvpx.
It's incorrect, we use ffvpx.
I do see an interest in shipping VA-API aware code with our own version of ffvpx on linux.
Assignee | ||
Comment 5•4 years ago
|
||
- Update in-tree ffvpx library with VP8/VP9 VAAPI HW decode code from FFmpeg 4.2.
- Enable VP8/VP9 VAAPI HW decode on MOZ_WAYLAND target.
Updated•4 years ago
|
Assignee | ||
Comment 6•4 years ago
|
||
Implemented DMABufSurfaceWrapper and VAAPIDisplayHolder as a versioned class templates
as they are going to be used by both system ffmpeg and bundled ffvpx decoders.
Depends on D90554
Assignee | ||
Comment 7•4 years ago
|
||
Depends on D90555
Assignee | ||
Comment 8•4 years ago
|
||
Depends on D90556
Assignee | ||
Comment 9•4 years ago
|
||
- Ship libva headers to allow build ffvpx with VA-API support
- Link libva runtime by library wrapper
Assignee | ||
Comment 10•4 years ago
|
||
Updated the patches with libva headers and run-time libva linker. It allows to build/run on systems without system libva library.
I know about the gfxPlatformGtk::GetPlaform() / RDD issue and I'd like to address that in a separate patch for both ffmpeg/ffvpx.
Thanks.
Assignee | ||
Comment 12•4 years ago
|
||
When https://phabricator.services.mozilla.com/D94650 is checked in we can remove runtime va* functions loading from FFmpegLibWrapper which may also help to address an issue with gfxPlatform in RDD process.
Updated•4 years ago
|
Comment 13•4 years ago
|
||
Comment 14•4 years ago
|
||
Backed out for causing build bustages in vaapi
Backout link: https://hg.mozilla.org/integration/autoland/rev/6af9cd7b395cde46d062ccf76713b74e8cf08038
Failure log: https://treeherder.mozilla.org/logviewer?job_id=320800064&repo=autoland&lineNumber=26061
"WARNING - /builds/worker/checkouts/gecko/media/ffvpx/config_unix64.h:235:9: warning: 'HAVE_VALGRIND_VALGRIND_H' macro redefined [-Wmacro-redefined]
[task 2020-11-05T08:13:40.759Z] 08:13:40 INFO - #define HAVE_VALGRIND_VALGRIND_H 0
[task 2020-11-05T08:13:40.759Z] 08:13:40 INFO - ^
[task 2020-11-05T08:13:40.759Z] 08:13:40 INFO - /builds/worker/workspace/obj-build/mozilla-config.h:106:9: note: previous definition is here
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - #define HAVE_VALGRIND_VALGRIND_H 1
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - ^
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - In file included from /builds/worker/checkouts/gecko/media/ffvpx/libavutil/hwcontext_vaapi.c:49:
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - /builds/worker/checkouts/gecko/media/ffvpx/libavutil/hwcontext_vaapi.h:22:10: fatal error: 'va/va.h' file not found
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - #include <va/va.h>
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - ^~~~~~~~~
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - 2 warnings and 1 error generated.
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - /builds/worker/checkouts/gecko/config/rules.mk:596: recipe for target 'hwcontext_vaapi.o' failed
[task 2020-11-05T08:13:40.760Z] 08:13:40 ERROR - make[4]: *** [hwcontext_vaapi.o] Error 1
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - make[4]: Leaving directory '/builds/worker/workspace/obj-build/media/ffvpx/libavutil'
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - make[4]: *** Waiting for unfinished jobs....
[task 2020-11-05T08:13:40.760Z] 08:13:40 INFO - make[4]: Entering directory '/builds/worker/workspace/obj-build/modules/libmar/tool'"
Assignee | ||
Comment 15•4 years ago
|
||
Thanks. We need libva 2.0 headers in build roots. Re-opened Bug 1665639 for it.
Comment 16•4 years ago
|
||
Comment 17•4 years ago
|
||
Comment 18•4 years ago
|
||
Comment 19•4 years ago
|
||
Backed out for bustages on hwcontext_vaapi.h.
Backout link: https://hg.mozilla.org/integration/autoland/rev/76ded4b3a6e09566992f314d430af03031ce0953
Failure log: https://treeherder.mozilla.org/logviewer?job_id=320928723&repo=autoland&lineNumber=25438
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 20•4 years ago
|
||
Assignee | ||
Comment 22•4 years ago
|
||
Assignee | ||
Comment 23•4 years ago
|
||
Comment 24•4 years ago
|
||
Wouldn't it be easier to swap order in which ffvpx- and ffmpeg-based decoders are registered? That will make Firefox prefer OS-provided ffmpeg for everything, including VP9.
Assignee | ||
Comment 25•4 years ago
|
||
(In reply to Rinat from comment #24)
Wouldn't it be easier to swap order in which ffvpx- and ffmpeg-based decoders are registered? That will make Firefox prefer OS-provided ffmpeg for everything, including VP9.
We still want to have bundled ffvpx with va-api support, especially for webrtc and distros without default system ffmpeg (fedora/suse...).
Comment 26•4 years ago
|
||
Comment 27•4 years ago
|
||
Backed out for media related failures
backout: https://hg.mozilla.org/integration/autoland/rev/0ecc51ff0cddf5ba357038b51d2cce52c2267972
push:
- https://treeherder.mozilla.org/jobs?repo=autoland&group_state=expanded&revision=1aa6c9d65403b441c567ebda260f6b528060b492&selectedTaskRun=GxHjooWqRWyVocuTAFDCkw.0
- due to the failures only appearing on ^ after backfills, they were firstly spotted on https://treeherder.mozilla.org/jobs?repo=autoland&group_state=expanded&resultStatus=testfailed%2Cbusted%2Cexception%2Cretry%2Cusercancel%2Crunnable&revision=66841ce77403a398abccad8698b2ed352ffc3694
failure logs:
- TEST-UNEXPECTED-TIMEOUT | /webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-routing.html | MediaStreamAudioSourceNode captures the right track. - Test timed out
- TEST-UNEXPECTED-FAIL | dom/media/webaudio/test/test_audioContextParams_sampleRate.html | Error executing test: Error: Audio analysis timed out waitForAnalysisSuccess@http://mochi.test:8888/tests/dom/media/webaudio/test/head.js:203:26 ... @http://mochi.test:8888/tests/dom/media/webaudio/test/test_audioContextParams_sampleRate.html:32:20 ... runTestWhenReady/<@http://mochi.test:8888/tests/dom/media/webaudio/test/head.js:473:30 ...
- etc
Assignee | ||
Comment 28•4 years ago
|
||
Interesting. I did local builds on Ubuntu 18.04 and I don't see such errors there...will look at it.
Comment 29•4 years ago
|
||
Comment 30•4 years ago
|
||
Comment 31•4 years ago
|
||
Backed out for perma failures.
Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception&revision=3fe77cc9a39c046c0040a70b4f40f54295e44c01&failure_classification_id=2
Logs:
https://treeherder.mozilla.org/logviewer?job_id=322944552&repo=autoland&lineNumber=3655
https://treeherder.mozilla.org/logviewer?job_id=322944594&repo=autoland&lineNumber=27294
https://treeherder.mozilla.org/logviewer?job_id=322944616&repo=autoland&lineNumber=2047
https://treeherder.mozilla.org/logviewer?job_id=322944576&repo=autoland&lineNumber=19802
https://treeherder.mozilla.org/logviewer?job_id=322943165&repo=autoland&lineNumber=3376
https://treeherder.mozilla.org/logviewer?job_id=322944737&repo=autoland&lineNumber=3074
https://treeherder.mozilla.org/logviewer?job_id=322944746&repo=autoland&lineNumber=4410
https://treeherder.mozilla.org/logviewer?job_id=322944648&repo=autoland&lineNumber=2542
https://treeherder.mozilla.org/logviewer?job_id=322943385&repo=autoland&lineNumber=23888
Backout: https://hg.mozilla.org/integration/autoland/rev/c92eaf9c3f4692378e4782eb9a909715d50582b2
Comment 32•4 years ago
|
||
I was checking why some recent landings of patches broke try-comm-central task job, and saw this post by chance.
I have been using the following patch to avoid the macro redefinition error in my local build of C-C TB
for the last few years.
# HG changeset patch
# User ISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
# Parent 270e38bde0892e4b8eff0afc3ffe07ed96a7a72f
Avoid conflict of HAVE_VALGRIND_VALGRIND_H definition with upper-level definition.
diff --git a/media/ffvpx/config_unix64.h b/media/ffvpx/config_unix64.h
--- a/media/ffvpx/config_unix64.h
+++ b/media/ffvpx/config_unix64.h
@@ -237,17 +237,17 @@
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_SOUNDCARD_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_SYS_VIDEOIO_H 0
#define HAVE_TERMIOS_H 1
#define HAVE_UDPLITE_H 0
#define HAVE_UNISTD_H 1
-#define HAVE_VALGRIND_VALGRIND_H 0
+// avoid conflict: #define HAVE_VALGRIND_VALGRIND_H 0
#define HAVE_WINDOWS_H 0
#define HAVE_WINSOCK2_H 0
#define HAVE_INTRINSICS_NEON 0
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1
#define HAVE_CBRT 1
#define HAVE_CBRTF 1
#define HAVE_COPYSIGN 1
(I enforce the "treat warning as errors" for local build and hit upon the redefinition error some years ago.)
Just FYI.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 33•4 years ago
|
||
Comment 34•4 years ago
|
||
Comment 35•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/708c5d069936
https://hg.mozilla.org/mozilla-central/rev/9d4893cc2f99
Assignee | ||
Comment 36•4 years ago
|
||
Reopened as three patches are missing:
D90554 Bug 1660336 Add VP8/VP9 VAAPI HW decode code to bundled ffvpx and build it with MOZ_WAYLAND target
D90556 Bug 1660336 Implement FFmpegLibWrapper::LinkVAAPILibs() to link VAAPI libraries
D90557 Bug 1660336 Build ffvpx FFmpegVideoDecoder module with VAAPI support, r?jya
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Comment 37•4 years ago
|
||
Patches failed to land with message:
"Revisions: D90554 diff 373469 ← D90555 diff 372311 ← D90556 diff 372312 ← D90557 diff 373470
Details: We're sorry, Lando could not rebase your commits for you automatically. Please manually rebase your commits and try again.
hg error in cmd: hg import --no-commit -s 95 /tmp/tmpagy1zcb1: applying /tmp/tmpagy1zcb1
patching file media/ffvpx/libavutil/moz.build
Hunk #2 FAILED at 62
1 out of 2 hunks FAILED -- saving rejects to file media/ffvpx/libavutil/moz.build.rej
patching file media/ffvpx/config_common.h
Hunk #1 FAILED at 18
1 out of 1 hunks FAILED -- saving rejects to file media/ffvpx/config_common.h.rej
abort: patch failed to apply"
Comment 38•4 years ago
|
||
Martin, please re-add the check-in needed tag after rebase.
Comment 40•4 years ago
|
||
Comment 41•4 years ago
|
||
Backed out for causing build bustage on libmozavcodec.so
Backout link: https://hg.mozilla.org/integration/autoland/rev/ce9943ea7091d45f1cd835e8710dac2f437d1b7e
Failure log: https://treeherder.mozilla.org/logviewer?job_id=323553211&repo=autoland&lineNumber=80850
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 42•4 years ago
|
||
Hm, the error is on opt/debug Linux x64 build-linux64-base-toolchains-clang Bbc (seems to be clang 5?) which I'm not able to reproduce. The error is:
/builds/worker/fetches/clang/bin/ld.lld: error: can't create dynamic relocation R_X86_64_PC32 against symbol: ff_cos_32 in readonly segment
[task 2020-12-05T21:52:13.384Z] 21:52:13 INFO - >>> defined in fft_float.o
[task 2020-12-05T21:52:13.384Z] 21:52:13 INFO - >>> referenced by fft.asm:394 (/builds/worker/checkouts/gecko/media/ffvpx/libavcodec/x86/fft.asm:394)
Mike, can you help me understand what's going on and how I can reproduce it? Which distro is that? Can I reproduce it locally somehow?
Thanks.
Assignee | ||
Comment 43•4 years ago
|
||
My try also shows that bug
although I don't understand how is that related to this bug.
Assignee | ||
Comment 44•4 years ago
|
||
Looks like it's caused by c++/c code linking together, when I move mozva.cpp to mozva.c the test passes.
Assignee | ||
Comment 45•4 years ago
|
||
Assignee | ||
Comment 46•4 years ago
|
||
Depends on D90555
Comment 47•4 years ago
|
||
Comment 48•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/321cbfd8cbb8
https://hg.mozilla.org/mozilla-central/rev/84ea73688876
https://hg.mozilla.org/mozilla-central/rev/c5097975c9c6
https://hg.mozilla.org/mozilla-central/rev/adbd3858fa50
Updated•4 years ago
|
Updated•4 years ago
|
Comment 49•4 years ago
|
||
Hi,
Does that fix also fixes VAAPI HW decode for Flatpak Firefox ?
Thanks
Assignee | ||
Comment 50•4 years ago
|
||
(In reply to antistress from comment #49)
Hi,
Does that fix also fixes VAAPI HW decode for Flatpak Firefox ?
Thanks
It may fix VP8/9 VA-API playback in Flatpak if you have libva and other libraries (intel/amd drivers) installed.
Comment 51•4 years ago
|
||
(In reply to Martin Stránský [:stransky] from comment #50)
Thanks !
Updated•3 years ago
|
Updated•3 years ago
|
Description
•