Skip to content

Commit

Permalink
Lakka v5.x switch 6 (upstream of libretro#1926)
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinDarkglider authored and ToKe79 committed May 19, 2024
1 parent 96bc6f2 commit 00390d3
Show file tree
Hide file tree
Showing 54 changed files with 2,455 additions and 971 deletions.
2 changes: 0 additions & 2 deletions packages/multimedia/ffmpeg/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ case "${PROJECT}" in
PKG_PATCH_DIRS+=" rpi"
;;
L4T)
if [ ! "${DISTRO}" = "LibreELEC" ]; then
PKG_DEPENDS_TARGET+=" tegra-bsp:host"
PKG_PATCH_DIRS+=" L4T"
PKG_FFMPEG_NVV4L2="--enable-nvv4l2"
EXTRA_CFLAGS="-I${SYSROOT_PREFIX}/usr/src/jetson_multimedia_api/include"
fi
;;
*)
PKG_PATCH_DIRS+=" v4l2-request v4l2-drmprime"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
From ffa9de21d7415d53f2f02b674438a41daaeee209 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sat, 5 Mar 2022 03:30:44 +0000
Subject: [PATCH 02/39] fftools/libavformat: Enforce nvv4l2

This enforces NVV4L2 even if user requests another codec.
Additionally, it forces nvv4l2 to go through software codecs first to get context if needed.
---
fftools/ffplay.c | 25 +++++++++++++++++++++++++
libavformat/demux.c | 13 +++++++++++++
2 files changed, 38 insertions(+)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index d6479aef5f..86f8425a15 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2590,6 +2590,31 @@ static int stream_component_open(VideoState *is, int stream_index)
case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break;
case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break;
}
+
+#if CONFIG_NVV4L2
+ /* Reset requested decoder in order to enforce NVV4L2 if possible. */
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) {
+ if (strcmp(forced_codec_name, "h264") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "hevc") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg2video") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg4") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp8") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp9") == 0 &&
+ avctx->pix_fmt != AV_PIX_FMT_YUV420P10) {
+ forced_codec_name = NULL;
+ }
+ }
+
+ /* NVV4L2 does not support VP9 with YUV420P10. */
+ if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
+ forced_codec_name = "vp9";
+#endif
+
if (forced_codec_name)
codec = avcodec_find_decoder_by_name(forced_codec_name);
if (!codec) {
diff --git a/libavformat/demux.c b/libavformat/demux.c
index b19ab86d08..ae60a819d5 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -77,6 +77,19 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
if (codec_id == AV_CODEC_ID_H264)
return avcodec_find_decoder_by_name("h264");
#endif
+#if CONFIG_NVV4L2
+ /* NVV4L2 decoders depend on context init from base decoders */
+ if (codec_id == AV_CODEC_ID_HEVC)
+ return avcodec_find_decoder_by_name("hevc");
+ else if (codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ return avcodec_find_decoder_by_name("mpeg2video");
+ else if (codec_id == AV_CODEC_ID_MPEG4)
+ return avcodec_find_decoder_by_name("mpeg4");
+ else if (codec_id == AV_CODEC_ID_VP8)
+ return avcodec_find_decoder_by_name("vp8");
+ else if (codec_id == AV_CODEC_ID_VP9)
+ return avcodec_find_decoder_by_name("vp9");
+#endif

codec = ff_find_decoder(s, st, codec_id);
if (!codec)
--
2.25.1

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 87622041abb1387bc8580721d23ec79a03e5249c Mon Sep 17 00:00:00 2001
From c80256646ddae6d91a1ec9fe1a6cda53efaf923f Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 6 Mar 2022 04:26:06 +0000
Subject: [PATCH 04/22] codecs: nvv4l2: avoid probing
Subject: [PATCH 03/39] codecs: nvv4l2: avoid probing

NVV4L2 does not support probing for getting stream metadata.
So disallow that.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
From ecdbd9b4904b71bea7d3c373690d0e6283896730 Mon Sep 17 00:00:00 2001
From 81aa7501ce56cf7df7ee7be3bf6e7e37d1952dc8 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 6 Mar 2022 04:27:54 +0000
Subject: [PATCH 05/22] libavformat: remove nvv4l2 probing mitigation
Subject: [PATCH 04/39] libavformat: remove nvv4l2 probing mitigation

It was fixed properly with AV_CODEC_CAP_AVOID_PROBING flag.
---
libavformat/utils.c | 13 -------------
libavformat/demux.c | 13 -------------
1 file changed, 13 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index a960f8265d..1384b56771 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -211,19 +211,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
diff --git a/libavformat/demux.c b/libavformat/demux.c
index ae60a819d5..b19ab86d08 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -77,19 +77,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
if (codec_id == AV_CODEC_ID_H264)
return avcodec_find_decoder_by_name("h264");
#endif
Expand All @@ -25,12 +25,12 @@ index a960f8265d..1384b56771 100644
- else if (codec_id == AV_CODEC_ID_MPEG4)
- return avcodec_find_decoder_by_name("mpeg4");
- else if (codec_id == AV_CODEC_ID_VP8)
- return avcodec_find_decoder_by_name("vp8");
- return avcodec_find_decoder_by_name("vp8");
- else if (codec_id == AV_CODEC_ID_VP9)
- return avcodec_find_decoder_by_name("vp9");
-#endif

codec = find_decoder(s, st, codec_id);
codec = ff_find_decoder(s, st, codec_id);
if (!codec)
--
2.25.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 8e286f3ffc845709f6747d77982c60ad0ed0b37f Mon Sep 17 00:00:00 2001
From 135ad87310784e7dfd49c95ba6f7ed45e9444cd8 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:16:35 +0000
Subject: [PATCH 06/22] codecs: nvv4l2: do not use external headers
Subject: [PATCH 05/39] codecs: nvv4l2: do not use external headers

Make needed headers builtin as this will help to bring compatibility from r32.3.1 till r32.7.1 and newer with a single build.
---
Expand All @@ -11,19 +11,19 @@ Make needed headers builtin as this will help to bring compatibility from r32.3.
create mode 100644 libavcodec/nvv4l2_ext_utils.h

diff --git a/configure b/configure
index 29a6d96575..ea84db929c 100755
index 889b547071..ba28526b44 100755
--- a/configure
+++ b/configure
@@ -3053,7 +3053,7 @@ qsvenc_select="qsv"
@@ -3131,7 +3131,7 @@ qsvenc_select="qsv"
qsvvpp_select="qsv"
vaapi_encode_deps="vaapi"
v4l2_m2m_deps="linux_videodev2_h sem_timedwait"
-nvv4l2_deps="libv4l2 pthreads linux_videodev2_h nvbuf_utils_h v4l2_nv_extensions_h"
+nvv4l2_deps="libv4l2 pthreads linux_videodev2_h"
nvv4l2_extralibs="-lnvbuf_utils"

hwupload_cuda_filter_deps="ffnvcodec"
@@ -6798,11 +6798,8 @@ if enabled_any nvdec cuvid; then
bilateral_cuda_filter_deps="ffnvcodec"
@@ -7070,11 +7070,8 @@ if enabled_any nvdec cuvid; then
check_type "ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h" "CUVIDAV1PICPARAMS"
fi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From fd622ef8d15cf208810f82a6a843b4db94fb28be Mon Sep 17 00:00:00 2001
From 4896ff0afcdccbb5521dee948c233dccb6616d7a Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:20:48 +0000
Subject: [PATCH 07/22] codecs: nvv4l2: use atomics for pool
Subject: [PATCH 06/39] codecs: nvv4l2: use atomics for pool

Do not lock with mutexes until we need to do more in pools. Use atomics for now to lower latency.
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0fd5fb903861c42d40f84b0468496006966e1c5d Mon Sep 17 00:00:00 2001
From 607f6a8e40b495ecb887fc046bf8cf6030036c3a Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:23:33 +0000
Subject: [PATCH 08/22] codecs: nvv4l2: add new functions and update context as
Subject: [PATCH 07/39] codecs: nvv4l2: add new functions and update context as
prep

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 02d9583d32a9a8bd02dda9dd510519c04691d8d2 Mon Sep 17 00:00:00 2001
From 72f992d69e5462c2da170f4259032b5f9ff6b250 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:31:31 +0000
Subject: [PATCH 09/22] codecs: nvv4l2: support multiple L4T versions with
Subject: [PATCH 08/39] codecs: nvv4l2: support multiple L4T versions with
single build

Nvidia has the tendency to break compatibility on documented apis for no reason.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 280522f4f351a045ae7288ce7f5110ae099ea8b7 Mon Sep 17 00:00:00 2001
From ade9d9b54d172437be84797300b25a85c4164cd4 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:39:48 +0000
Subject: [PATCH 10/22] codecs: nvv4l2: align line width to 64B
Subject: [PATCH 09/39] codecs: nvv4l2: align line width to 64B

Transformations of formats to formats of simply Block linear to Pitch are done in HW.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 9d3282af10055fbbb81bd53654dd342682e2d09d Mon Sep 17 00:00:00 2001
From b7a72216ca1ed53f6428a3fca5949618d2059538 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:42:29 +0000
Subject: [PATCH 11/22] codecs: nvv4l2: add two-pass cbr mode support
Subject: [PATCH 10/39] codecs: nvv4l2: add two-pass cbr mode support

To enable, use `twopass=on` as encoder option.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 73aba81a154a3f25efb2326a6e59949660d6a5f5 Mon Sep 17 00:00:00 2001
From 124b4a1c85f24a11de5710b8515648dae91000cf Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:46:36 +0000
Subject: [PATCH 12/22] codecs: nvv4l2: various bugfixes
Subject: [PATCH 11/39] codecs: nvv4l2: various bugfixes

---
libavcodec/nvv4l2_dec.c | 105 ++++++++++++++++++++++------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From c0832ff40e14ff28c926e500525cdf839d58ff98 Mon Sep 17 00:00:00 2001
From d78e4bc70ec1d97e22c5f0365c027574e740923f Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:50:20 +0000
Subject: [PATCH 13/22] codecs: nvv4l2: fix hanging on event wait if no full
Subject: [PATCH 12/39] codecs: nvv4l2: fix hanging on event wait if no full
frame info

Sometimes the decoder can be opened with no packet sent or not many for a frame to be decoded.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From eceaecff30fc8a1ca622de7506470d486e34695a Mon Sep 17 00:00:00 2001
From ac123e70b68b22a99b483ba5b9406e60b35f1519 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:53:34 +0000
Subject: [PATCH 14/22] codecs: nvv4l2: use sessions for transformations
Subject: [PATCH 13/39] codecs: nvv4l2: use sessions for transformations

Some apps use different processes for init and decoding.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 1d0dbfb7243a12b2941a23584a2dbed7cfb7077f Mon Sep 17 00:00:00 2001
From 95ed6f305a76c588f8264406e69123e3775e6c36 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:57:58 +0000
Subject: [PATCH 15/22] codecs: nvv4l2: support all different timestamps
Subject: [PATCH 14/39] codecs: nvv4l2: support all different timestamps

Various packets and players have different timestamps defined.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 04008befad133d97b7f956a21632592aaaede7ca Mon Sep 17 00:00:00 2001
From 0cd74d94cdac5e3cd7ce3e014b3af2b276389074 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sat, 11 Jun 2022 17:14:49 +0000
Subject: [PATCH 16/22] codecs: nvv4l2: BSP 34.1.x remarks
Subject: [PATCH 15/39] codecs: nvv4l2: BSP 34.1.x remarks

NVIDIA changed the enum again in r34 and broke compatibility for no reason.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3674076e6287c62dd39c73585521504908f25fb9 Mon Sep 17 00:00:00 2001
From 628d01310250a97fc874f3acb9405460b57e679d Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Tue, 14 Jun 2022 19:21:20 +0000
Subject: [PATCH 17/22] codecs: nvv4l2: support BT709/BT2020 colorspaces
Subject: [PATCH 16/39] codecs: nvv4l2: support BT709/BT2020 colorspaces

---
libavcodec/nvv4l2_dec.c | 62 ++++++++++++++++++++++++-----------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 636c040931dff3d5febae00697a8502af396e01f Mon Sep 17 00:00:00 2001
From 9ad8d41a2aa4dcb6b552d77e04f9ce4dc26e999a Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Wed, 15 Jun 2022 13:33:10 +0000
Subject: [PATCH 18/22] codecs: nvv4l2: reorder capture buffer queueing
Subject: [PATCH 17/39] codecs: nvv4l2: reorder capture buffer queueing

Move capture buffer queueing after capture plane stream on.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 7b67a0996bb80c38a923b215566c67ffc130d161 Mon Sep 17 00:00:00 2001
From ef1bcd73fa1e37982dfc24f2319e83d5932848a8 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Tue, 28 Jun 2022 01:37:59 +0000
Subject: [PATCH 19/22] codecs: nvv4l2: align encoder plane width to 64B
Subject: [PATCH 18/39] codecs: nvv4l2: align encoder plane width to 64B

Transformations of Block linear formats to linear Pitch formats are done in HW.

Expand Down
Loading

0 comments on commit 00390d3

Please sign in to comment.