From: averne <averne381@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 00/16] NVidia Tegra hardware decoding backend
Date: Thu, 30 May 2024 21:43:02 +0200
Message-ID: <cover.1717083799.git.averne381@gmail.com> (raw)
Hi all,
This patch series implements a hardware decoding backend for nvidia
Tegra devices, notably the Nintendo Switch. It was primarily written
for HorizonOS (Nintendo Switch OS), but also supports nvidia's
Linux4Tegra distro. As for hardware, all Tegras later than the X1
(T210) should be supported, although the patch does not implement
features that were added to subsequent revisions of multimedia
engines (eg. 12-bit HEVC). However, since I only own T210 devices
(Switch and jetson nano), I was not able to verify this.
The backend is essentially a userspace NVDEC driver, as due to the
OS design of the Switch, we cannot link to nvidia's system libraries.
It notably uses (sparse) hardware documentation released by nvidia
here: https://github.com/NVIDIA/open-gpu-doc/tree/master/classes/video.
It supports all codecs available in hardware (MPEG1/2/4, VC1, H264,
HEVC, VP8, VP9 and JPEG), with dynamic frequency scaling, and
hardware-accelerated frame transfer.
At the moment I'm submitting the series with some nvidia headers
pulled from various sources, but I do think they should rather be
put in nv-codec-headers, let me know.
The code was tested for memory bugs and leaks with valgrind and
asan on L4T. Some quick performance testing (decoding with -f null -)
showed results in line with official software, tested against the
nvv4l2 backend that was posted here a while ago:
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2020-June/263759.html.
Note that the numbers are skewed because frame transfer cannot be
disabled in nvidia's backend.
- HEVC Main 10 @ 4k (~80Mbps): nvtegra 79fps, nvv4l2 66fps
- HEVC Main 10 @ 1080p (~5Mbps): nvtegra 402fps, nvv4l2 229fps
- H264 @ 1080p (~3Mbps): nvtegra 286fps, nvv4l2 260fps
Several homebrew applications have been using this backend for some
time, with no bugs reported. As far as I'm aware, this is the
complete list of them:
- NXMP, a media player based on mpv: https://github.com/proconsule/nxmp
- WiliWili, a bilibili client: https://github.com/xfangfang/wiliwili
- Switchfin, a Jellyfin client: https://github.com/dragonflylee/switchfin
- Moonlight-Switch, a Moonlight client: https://github.com/XITRIX/Moonlight-Switch
- chiaki: https://git.sr.ht/~kkwong/chiaki/
- My own media player, unreleased at this time
Nintendo Switch support assumes a working devkitA64 homebrew
environment, instructions regarding setup can be found here:
https://devkitpro.org/wiki/devkitPro_pacman. The hwaccel can then be
configured by eg.:
```
source /opt/devkitpro/switchvars.sh && ./configure
--cross-prefix=aarch64-none-elf- --enable-cross-compile --arch=aarch64
--cpu=cortex-a57 --target-os=horizon --enable-pic --enable-gpl
--enable-nvtegra
```
It should probably be noted that NVDEC usage on discrete gpus is
very similar. As far as I know, the main difference is that the
interfacing is done through the GPFIFO block (same block that
manages the 3D engine), instead of host1x.
Thank you for your consideration.
averne (16):
avutil/buffer: add helper to allocate aligned memory
configure,avutil: add support for HorizonOS
avutil: add ioctl definitions for tegra devices
avutil: add hardware definitions for NVDEC, NVJPG and VIC
avutil: add common code for nvtegra
avutil: add nvtegra hwcontext
hwcontext_nvtegra: add dynamic frequency scaling routines
nvtegra: add common hardware decoding code
nvtegra: add mpeg1/2 hardware decoding
nvtegra: add mpeg4 hardware decoding
nvtegra: add vc1 hardware decoding
nvtegra: add h264 hardware decoding
nvtegra: add hevc hardware decoding
nvtegra: add vp8 hardware decoding
nvtegra: add vp9 hardware decoding
nvtegra: add mjpeg hardware decoding
configure | 30 +
libavcodec/Makefile | 11 +
libavcodec/h263dec.c | 6 +
libavcodec/h264_slice.c | 6 +-
libavcodec/h264dec.c | 3 +
libavcodec/hevcdec.c | 17 +-
libavcodec/hevcdec.h | 2 +
libavcodec/hwaccels.h | 10 +
libavcodec/hwconfig.h | 2 +
libavcodec/mjpegdec.c | 6 +
libavcodec/mpeg12dec.c | 12 +
libavcodec/mpeg4videodec.c | 3 +
libavcodec/nvtegra_decode.c | 517 +++++++++
libavcodec/nvtegra_decode.h | 94 ++
libavcodec/nvtegra_h264.c | 506 +++++++++
libavcodec/nvtegra_hevc.c | 633 +++++++++++
libavcodec/nvtegra_mjpeg.c | 336 ++++++
libavcodec/nvtegra_mpeg12.c | 319 ++++++
libavcodec/nvtegra_mpeg4.c | 344 ++++++
libavcodec/nvtegra_vc1.c | 455 ++++++++
libavcodec/nvtegra_vp8.c | 334 ++++++
libavcodec/nvtegra_vp9.c | 665 ++++++++++++
libavcodec/vc1dec.c | 9 +
libavcodec/vp8.c | 6 +
libavcodec/vp9.c | 10 +-
libavutil/Makefile | 9 +
libavutil/buffer.c | 31 +
libavutil/buffer.h | 7 +
libavutil/clb0b6.h | 303 ++++++
libavutil/clc5b0.h | 436 ++++++++
libavutil/cle7d0.h | 129 +++
libavutil/cpu.c | 7 +
libavutil/hwcontext.c | 4 +
libavutil/hwcontext.h | 1 +
libavutil/hwcontext_internal.h | 1 +
libavutil/hwcontext_nvtegra.c | 1045 ++++++++++++++++++
libavutil/hwcontext_nvtegra.h | 92 ++
libavutil/nvdec_drv.h | 1858 ++++++++++++++++++++++++++++++++
libavutil/nvhost_ioctl.h | 511 +++++++++
libavutil/nvjpg_drv.h | 189 ++++
libavutil/nvmap_ioctl.h | 451 ++++++++
libavutil/nvtegra.c | 1035 ++++++++++++++++++
libavutil/nvtegra.h | 258 +++++
libavutil/nvtegra_host1x.h | 94 ++
libavutil/pixdesc.c | 4 +
libavutil/pixfmt.h | 8 +
libavutil/vic_drv.h | 279 +++++
47 files changed, 11085 insertions(+), 3 deletions(-)
create mode 100644 libavcodec/nvtegra_decode.c
create mode 100644 libavcodec/nvtegra_decode.h
create mode 100644 libavcodec/nvtegra_h264.c
create mode 100644 libavcodec/nvtegra_hevc.c
create mode 100644 libavcodec/nvtegra_mjpeg.c
create mode 100644 libavcodec/nvtegra_mpeg12.c
create mode 100644 libavcodec/nvtegra_mpeg4.c
create mode 100644 libavcodec/nvtegra_vc1.c
create mode 100644 libavcodec/nvtegra_vp8.c
create mode 100644 libavcodec/nvtegra_vp9.c
create mode 100644 libavutil/clb0b6.h
create mode 100644 libavutil/clc5b0.h
create mode 100644 libavutil/cle7d0.h
create mode 100644 libavutil/hwcontext_nvtegra.c
create mode 100644 libavutil/hwcontext_nvtegra.h
create mode 100644 libavutil/nvdec_drv.h
create mode 100644 libavutil/nvhost_ioctl.h
create mode 100644 libavutil/nvjpg_drv.h
create mode 100644 libavutil/nvmap_ioctl.h
create mode 100644 libavutil/nvtegra.c
create mode 100644 libavutil/nvtegra.h
create mode 100644 libavutil/nvtegra_host1x.h
create mode 100644 libavutil/vic_drv.h
--
2.45.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2024-05-30 19:43 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 19:43 averne [this message]
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 01/16] avutil/buffer: add helper to allocate aligned memory averne
2024-05-30 20:38 ` Rémi Denis-Courmont
2024-05-31 21:06 ` averne
2024-05-31 21:44 ` Michael Niedermayer
2024-06-02 18:37 ` averne
2024-06-01 6:59 ` Rémi Denis-Courmont
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 02/16] configure, avutil: add support for HorizonOS averne
2024-05-30 20:37 ` Rémi Denis-Courmont
2024-05-31 21:06 ` averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 03/16] avutil: add ioctl definitions for tegra devices averne
2024-05-30 20:42 ` Rémi Denis-Courmont
2024-05-31 21:06 ` averne
2024-05-31 21:16 ` Timo Rothenpieler
2024-06-02 18:37 ` averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 04/16] avutil: add hardware definitions for NVDEC, NVJPG and VIC averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 05/16] avutil: add common code for nvtegra averne
2024-05-31 8:32 ` Rémi Denis-Courmont
2024-05-31 21:06 ` averne
2024-06-01 7:29 ` Rémi Denis-Courmont
2024-06-05 20:29 ` Mark Thompson
2024-06-29 19:35 ` averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 06/16] avutil: add nvtegra hwcontext averne
2024-06-05 20:47 ` Mark Thompson
2024-06-29 19:35 ` averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 07/16] hwcontext_nvtegra: add dynamic frequency scaling routines averne
2024-06-05 20:50 ` Mark Thompson
2024-06-29 19:35 ` averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 08/16] nvtegra: add common hardware decoding code averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 09/16] nvtegra: add mpeg1/2 hardware decoding averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 10/16] nvtegra: add mpeg4 " averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 11/16] nvtegra: add vc1 " averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 12/16] nvtegra: add h264 " averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 13/16] nvtegra: add hevc " averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 14/16] nvtegra: add vp8 " averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 15/16] nvtegra: add vp9 " averne
2024-05-30 19:43 ` [FFmpeg-devel] [PATCH 16/16] nvtegra: add mjpeg " averne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1717083799.git.averne381@gmail.com \
--to=averne381@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git