ffmpeg: update v4l2-drmprime patch

Patch created using revisions ea3d24b..807bf8d
from branch v4l2-drmprime-n6.0 of https://github.com/jernejsk/FFmpeg
This commit is contained in:
Matthias Reichl 2023-04-01 17:46:48 +02:00
parent e21b529685
commit 458fb14ab2

View File

@ -1,7 +1,7 @@
From c4be609d822229be09cd9dd6f64cad716b0a48ce Mon Sep 17 00:00:00 2001
From d08054c6eb2bb041e554b9fa24013d521f7ff024 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Tue, 24 Apr 2018 23:00:23 -0700
Subject: [PATCH 1/9] libavcodec: v4l2m2m: output AVDRMFrameDescriptor
Subject: [PATCH 1/8] libavcodec: v4l2m2m: output AVDRMFrameDescriptor
This allows for a zero-copy output by exporting the v4l2 buffer then wrapping that buffer
in the AVDRMFrameDescriptor like it is done in rkmpp.
@ -282,7 +282,7 @@ index 3d2ff1b9a5..b82c990dcc 100644
* of how many context-refs we are holding. */
AVBufferRef *context_ref;
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index e891649f92..4de23e687c 100644
index a40be94690..5bbab77c1e 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -441,22 +441,54 @@ static int v4l2_release_buffers(V4L2Context* ctx)
@ -345,7 +345,7 @@ index e891649f92..4de23e687c 100644
static inline int v4l2_try_raw_format(V4L2Context* ctx, enum AVPixelFormat pixfmt)
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index b67b216331..0fbd19a013 100644
index 04d86d7b92..4251efcb86 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -66,6 +66,9 @@ typedef struct V4L2m2mContext {
@ -359,7 +359,7 @@ index b67b216331..0fbd19a013 100644
typedef struct V4L2m2mPriv {
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 8a51dec3fa..d916a3b726 100644
index 4944d08511..9a2b922fb1 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -23,6 +23,9 @@
@ -410,10 +410,10 @@ index 8a51dec3fa..d916a3b726 100644
#define M2MDEC_CLASS(NAME) \
static const AVClass v4l2_m2m_ ## NAME ## _dec_class = { \
.class_name = #NAME "_v4l2m2m_decoder", \
@@ -253,6 +273,9 @@ static const AVOption options[] = {
.bsfs = bsf_name, \
@@ -254,6 +274,9 @@ static const AVOption options[] = {
.p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
+ .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \
+ AV_PIX_FMT_NONE}, \
+ .hw_configs = v4l2_m2m_hw_configs, \
@ -421,10 +421,10 @@ index 8a51dec3fa..d916a3b726 100644
}
From bb47b0e2ce4dda5ddeb4568d2b0260ec950d68cd Mon Sep 17 00:00:00 2001
From bb9db9b85e0f1c99a4b6cd9bea2d86ce64af05b5 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Thu, 16 Aug 2018 21:09:40 -0700
Subject: [PATCH 2/9] libavcodec: v4l2m2m: depends on libdrm
Subject: [PATCH 2/8] libavcodec: v4l2m2m: depends on libdrm
---
configure | 1 +
@ -432,10 +432,10 @@ Subject: [PATCH 2/9] libavcodec: v4l2m2m: depends on libdrm
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index ba5793b2ff..1872046e0e 100755
index b6616f00b6..09a824a579 100755
--- a/configure
+++ b/configure
@@ -3539,6 +3539,7 @@ sndio_indev_deps="sndio"
@@ -3549,6 +3549,7 @@ sndio_indev_deps="sndio"
sndio_outdev_deps="sndio"
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
v4l2_indev_suggest="libv4l2"
@ -457,10 +457,10 @@ index 07662b5fc3..d41558527c 100644
#include <sys/ioctl.h>
#include <sys/mman.h>
From a362c4ec155e5e38c7a1ed3d3c57054ba09d9945 Mon Sep 17 00:00:00 2001
From 22928b7f1ae1054f303a50c60f9fc5f5d0c7c08b Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Thu, 16 Aug 2018 21:10:13 -0700
Subject: [PATCH 3/9] libavcodec: v4l2m2m: set format_modifier to
Subject: [PATCH 3/8] libavcodec: v4l2m2m: set format_modifier to
DRM_FORMAT_MOD_LINEAR
---
@ -485,10 +485,10 @@ index d41558527c..95c8a1e409 100644
}
From d4c8398a40baae35c79c1baf7e99306edda53e1a Mon Sep 17 00:00:00 2001
From 87182c63602793c3310b207400bf77c8f2d0d1d8 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Thu, 16 Aug 2018 21:10:53 -0700
Subject: [PATCH 4/9] libavcodec: v4l2m2m: only mmap the buffer when it is
Subject: [PATCH 4/8] libavcodec: v4l2m2m: only mmap the buffer when it is
output type and drm prime is used
---
@ -529,17 +529,17 @@ index 95c8a1e409..0a65f32cb2 100644
if (avbuf->plane_info[i].mm_addr == MAP_FAILED)
From 5c468fefad99503d2fe53e5a83ef29a409f0abaa Mon Sep 17 00:00:00 2001
From edc89c1d0214e9fbc3c33ea26efe9a86456931c4 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Thu, 16 Aug 2018 21:11:38 -0700
Subject: [PATCH 5/9] libavcodec: v4l2m2m: allow using software pixel formats
Subject: [PATCH 5/8] libavcodec: v4l2m2m: allow using software pixel formats
---
libavcodec/v4l2_m2m_dec.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index d916a3b726..7787a2c185 100644
index 9a2b922fb1..11b893cc65 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -217,8 +217,16 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
@ -560,19 +560,19 @@ index d916a3b726..7787a2c185 100644
s->avctx = avctx;
ret = ff_v4l2_m2m_codec_init(priv);
@@ -274,6 +282,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = {
.p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
@@ -275,6 +283,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = {
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
.p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \
+ AV_PIX_FMT_NV12, \
AV_PIX_FMT_NONE}, \
.hw_configs = v4l2_m2m_hw_configs, \
.p.wrapper_name = "v4l2m2m", \
From dd923e56e054df2f1bb275cef039b82e94fcbcb6 Mon Sep 17 00:00:00 2001
From 180e12f23b20ff358956fd6cb24db665535cad04 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Mon, 24 Sep 2018 13:39:31 -0700
Subject: [PATCH 6/9] libavcodec: v4l2m2m: implement hwcontext
Subject: [PATCH 6/8] libavcodec: v4l2m2m: implement hwcontext
---
libavcodec/v4l2_buffers.c | 22 ++++++++++++++++++++++
@ -635,7 +635,7 @@ index 6f7460c89a..02fbb6eec3 100644
/**
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index 0fbd19a013..adf5997bb5 100644
index 4251efcb86..1082b9dad2 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -67,6 +67,8 @@ typedef struct V4L2m2mContext {
@ -648,7 +648,7 @@ index 0fbd19a013..adf5997bb5 100644
int output_drm;
} V4L2m2mContext;
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 7787a2c185..9aca68e48c 100644
index 11b893cc65..6f67aabcbd 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -35,6 +35,7 @@
@ -677,51 +677,10 @@ index 7787a2c185..9aca68e48c 100644
ret = ff_v4l2_m2m_codec_init(priv);
if (ret) {
From 32ca7163c62887aa4b4032bbd5858a03bf3e145e Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Mon, 4 May 2020 13:01:29 -0700
Subject: [PATCH 7/9] libavcodec: v4l2m2m: allow lower minimum buffer values
There is no reason to enforce a high minimum. In the context
of streaming only a few output buffers and capture buffers
are even needed for continuous playback. This also helps
alleviate memory pressure when decoding 4K media.
---
libavcodec/v4l2_m2m.h | 2 +-
libavcodec/v4l2_m2m_dec.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index adf5997bb5..1082b9dad2 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -38,7 +38,7 @@
#define V4L_M2M_DEFAULT_OPTS \
{ "num_output_buffers", "Number of buffers in the output context",\
- OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 6, INT_MAX, FLAGS }
+ OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 2, INT_MAX, FLAGS }
typedef struct V4L2m2mContext {
char devname[PATH_MAX];
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 9aca68e48c..7afc81180d 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -260,7 +260,7 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx)
static const AVOption options[] = {
V4L_M2M_DEFAULT_OPTS,
{ "num_capture_buffers", "Number of buffers in the capture context",
- OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 20, INT_MAX, FLAGS },
+ OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 2, INT_MAX, FLAGS },
{ NULL},
};
From 199d87bed11be1665913b88d7cae9417f48afa37 Mon Sep 17 00:00:00 2001
From 8c64981ace0a08bdc7eb445125a70f691ed829cb Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Wed, 6 May 2020 11:12:58 -0700
Subject: [PATCH 8/9] libavcodec: v4l2m2m: add option to specify pixel format
Subject: [PATCH 7/8] libavcodec: v4l2m2m: add option to specify pixel format
used by the decoder
---
@ -731,7 +690,7 @@ Subject: [PATCH 8/9] libavcodec: v4l2m2m: add option to specify pixel format
3 files changed, 12 insertions(+)
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 4de23e687c..49ef4a684f 100644
index 5bbab77c1e..3bd1f37c75 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -517,6 +517,8 @@ static inline int v4l2_try_raw_format(V4L2Context* ctx, enum AVPixelFormat pixfm
@ -778,7 +737,7 @@ index 1082b9dad2..943a8923c4 100644
/**
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 7afc81180d..de89d0ff18 100644
index 6f67aabcbd..279f26cbe6 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -261,6 +261,7 @@ static const AVOption options[] = {
@ -790,17 +749,17 @@ index 7afc81180d..de89d0ff18 100644
};
From 38c65aab679c04e4dd5a58f889844e68e34c80ab Mon Sep 17 00:00:00 2001
From 807bf8da5fa9f28443b5eee9429fb2478171e8f7 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Mon, 24 Sep 2018 13:39:56 -0700
Subject: [PATCH 9/9] libavcodec: v4l2m2m: implement flush
Subject: [PATCH 8/8] libavcodec: v4l2m2m: implement flush
---
libavcodec/v4l2_m2m_dec.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index de89d0ff18..3278627553 100644
index 279f26cbe6..8f1dd4a886 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -254,6 +254,41 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx)
@ -852,4 +811,4 @@ index de89d0ff18..3278627553 100644
+ .flush = v4l2_decode_flush, \
.bsfs = bsf_name, \
.p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \