ffmpeg: update v4l2-drmprime patch

Patch created using revisions b08d796..0e747a2
from branch v4l2-drmprime-n7.1 of https://github.com/jernejsk/FFmpeg
This commit is contained in:
Alex Bee 2024-12-15 12:35:05 +01:00 committed by Matthias Reichl
parent e102b88ad0
commit dbbb3cb45a

View File

@ -1,4 +1,4 @@
From d08054c6eb2bb041e554b9fa24013d521f7ff024 Mon Sep 17 00:00:00 2001
From cf29d984c17f56df0e41f33fb28fe72160cc7869 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/8] libavcodec: v4l2m2m: output AVDRMFrameDescriptor
@ -42,7 +42,7 @@ V5:
5 files changed, 213 insertions(+), 12 deletions(-)
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 3f5471067a..07662b5fc3 100644
index 23474ee143..0013f54caa 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -21,6 +21,7 @@
@ -53,15 +53,15 @@ index 3f5471067a..07662b5fc3 100644
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -29,6 +30,7 @@
@@ -28,6 +29,7 @@
#include <fcntl.h>
#include <poll.h>
#include "libavcodec/avcodec.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/hwcontext.h"
#include "libavutil/pixdesc.h"
#include "refstruct.h"
#include "v4l2_context.h"
#include "v4l2_buffers.h"
#include "v4l2_m2m.h"
@@ -209,7 +211,79 @@ static enum AVColorTransferCharacteristic v4l2_get_color_trc(V4L2Buffer *buf)
@@ -210,7 +212,79 @@ static enum AVColorTransferCharacteristic v4l2_get_color_trc(V4L2Buffer *buf)
return AVCOL_TRC_UNSPECIFIED;
}
@ -142,7 +142,7 @@ index 3f5471067a..07662b5fc3 100644
{
V4L2Buffer* avbuf = opaque;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
@@ -233,6 +307,36 @@ static void v4l2_free_buffer(void *opaque, uint8_t *unused)
@@ -234,6 +308,36 @@ static void v4l2_free_buffer(void *opaque, uint8_t *unused)
}
}
@ -179,7 +179,7 @@ index 3f5471067a..07662b5fc3 100644
static int v4l2_buf_increase_ref(V4L2Buffer *in)
{
V4L2m2mContext *s = buf_to_m2mctx(in);
@@ -253,6 +357,24 @@ static int v4l2_buf_increase_ref(V4L2Buffer *in)
@@ -252,6 +356,24 @@ static int v4l2_buf_increase_ref(V4L2Buffer *in)
return 0;
}
@ -204,7 +204,7 @@ index 3f5471067a..07662b5fc3 100644
static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, AVBufferRef **buf)
{
int ret;
@@ -302,13 +424,24 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf)
@@ -301,13 +423,24 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf)
frame->format = avbuf->context->av_pix_fmt;
@ -260,18 +260,18 @@ index 3f5471067a..07662b5fc3 100644
}
diff --git a/libavcodec/v4l2_buffers.h b/libavcodec/v4l2_buffers.h
index 3d2ff1b9a5..b82c990dcc 100644
index e35b161309..b83f22152c 100644
--- a/libavcodec/v4l2_buffers.h
+++ b/libavcodec/v4l2_buffers.h
@@ -30,6 +30,7 @@
@@ -29,6 +29,7 @@
#include <linux/videodev2.h>
#include "libavutil/buffer.h"
#include "libavutil/frame.h"
+#include "libavutil/hwcontext_drm.h"
#include "packet.h"
enum V4L2Buffer_status {
@@ -45,6 +46,9 @@ typedef struct V4L2Buffer {
@@ -44,6 +45,9 @@ typedef struct V4L2Buffer {
/* each buffer needs to have a reference to its context */
struct V4L2Context *context;
@ -279,13 +279,13 @@ index 3d2ff1b9a5..b82c990dcc 100644
+ AVDRMFrameDescriptor drm_frame;
+
/* This object is refcounted per-plane, so we need to keep track
* of how many context-refs we are holding. */
AVBufferRef *context_ref;
* of how many context-refs we are holding.
* This pointer is a RefStruct reference. */
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index a40be94690..5bbab77c1e 100644
index be1df3785b..4673d025c5 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -441,22 +441,54 @@ static int v4l2_release_buffers(V4L2Context* ctx)
@@ -446,22 +446,54 @@ static int v4l2_release_buffers(V4L2Context* ctx)
struct v4l2_requestbuffers req = {
.memory = V4L2_MEMORY_MMAP,
.type = ctx->type,
@ -345,7 +345,7 @@ index a40be94690..5bbab77c1e 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 04d86d7b92..4251efcb86 100644
index 4ba33dc335..76ddbf1a26 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -66,6 +66,9 @@ typedef struct V4L2m2mContext {
@ -359,7 +359,7 @@ index 04d86d7b92..4251efcb86 100644
typedef struct V4L2m2mPriv {
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 4944d08511..9a2b922fb1 100644
index aa2d759e1e..b8dc4eb81f 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -23,6 +23,9 @@
@ -410,18 +410,18 @@ index 4944d08511..9a2b922fb1 100644
#define M2MDEC_CLASS(NAME) \
static const AVClass v4l2_m2m_ ## NAME ## _dec_class = { \
.class_name = #NAME "_v4l2m2m_decoder", \
@@ -254,6 +274,9 @@ static const AVOption options[] = {
.p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
@@ -255,6 +275,9 @@ static const AVOption options[] = {
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
FF_CODEC_CAP_INIT_CLEANUP, \
.p.wrapper_name = "v4l2m2m", \
+ .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \
+ AV_PIX_FMT_NONE}, \
+ .hw_configs = v4l2_m2m_hw_configs, \
.p.wrapper_name = "v4l2m2m", \
}
M2MDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb");
From bb9db9b85e0f1c99a4b6cd9bea2d86ce64af05b5 Mon Sep 17 00:00:00 2001
From b1c53282fe4a9357f5a74feebd5a4c01954930b3 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/8] libavcodec: v4l2m2m: depends on libdrm
@ -432,10 +432,10 @@ Subject: [PATCH 2/8] libavcodec: v4l2m2m: depends on libdrm
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index b6616f00b6..09a824a579 100755
index d77a55b653..9db1921b99 100755
--- a/configure
+++ b/configure
@@ -3549,6 +3549,7 @@ sndio_indev_deps="sndio"
@@ -3746,6 +3746,7 @@ sndio_indev_deps="sndio"
sndio_outdev_deps="sndio"
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
v4l2_indev_suggest="libv4l2"
@ -444,7 +444,7 @@ index b6616f00b6..09a824a579 100755
v4l2_outdev_suggest="libv4l2"
vfwcap_indev_deps="vfw32 vfwcap_defines"
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 07662b5fc3..d41558527c 100644
index 0013f54caa..9069520556 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -21,7 +21,7 @@
@ -457,7 +457,7 @@ index 07662b5fc3..d41558527c 100644
#include <sys/ioctl.h>
#include <sys/mman.h>
From 22928b7f1ae1054f303a50c60f9fc5f5d0c7c08b Mon Sep 17 00:00:00 2001
From 659318a5f802b42be23eb95cebb01cfd46cfac21 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/8] libavcodec: v4l2m2m: set format_modifier to
@ -468,10 +468,10 @@ Subject: [PATCH 3/8] libavcodec: v4l2m2m: set format_modifier to
1 file changed, 2 insertions(+)
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index d41558527c..95c8a1e409 100644
index 9069520556..066bf5b8c3 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -327,10 +327,12 @@ static int v4l2_buffer_export_drm(V4L2Buffer* avbuf)
@@ -328,10 +328,12 @@ static int v4l2_buffer_export_drm(V4L2Buffer* avbuf)
/* drm frame */
avbuf->drm_frame.objects[i].size = avbuf->buf.m.planes[i].length;
avbuf->drm_frame.objects[i].fd = expbuf.fd;
@ -485,7 +485,7 @@ index d41558527c..95c8a1e409 100644
}
From 87182c63602793c3310b207400bf77c8f2d0d1d8 Mon Sep 17 00:00:00 2001
From f84379aca3bff34205648e85e0c79fd544a20e39 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/8] libavcodec: v4l2m2m: only mmap the buffer when it is
@ -496,7 +496,7 @@ Subject: [PATCH 4/8] libavcodec: v4l2m2m: only mmap the buffer when it is
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 95c8a1e409..0a65f32cb2 100644
index 066bf5b8c3..3a65ced497 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -661,14 +661,22 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index)
@ -529,7 +529,7 @@ index 95c8a1e409..0a65f32cb2 100644
if (avbuf->plane_info[i].mm_addr == MAP_FAILED)
From edc89c1d0214e9fbc3c33ea26efe9a86456931c4 Mon Sep 17 00:00:00 2001
From 6c02dc58f69365fd1f3c5502b481e0fae6987ff7 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/8] libavcodec: v4l2m2m: allow using software pixel formats
@ -539,7 +539,7 @@ Subject: [PATCH 5/8] libavcodec: v4l2m2m: allow using software pixel formats
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 9a2b922fb1..11b893cc65 100644
index b8dc4eb81f..28b29c4522 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,16 +560,16 @@ index 9a2b922fb1..11b893cc65 100644
s->avctx = avctx;
ret = ff_v4l2_m2m_codec_init(priv);
@@ -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, \
@@ -276,6 +284,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = {
FF_CODEC_CAP_INIT_CLEANUP, \
.p.wrapper_name = "v4l2m2m", \
.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 180e12f23b20ff358956fd6cb24db665535cad04 Mon Sep 17 00:00:00 2001
From 45cab2ebdbd00ce6eb683dd838956049e7fe9a3f 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/8] libavcodec: v4l2m2m: implement hwcontext
@ -582,10 +582,10 @@ Subject: [PATCH 6/8] libavcodec: v4l2m2m: implement hwcontext
4 files changed, 37 insertions(+)
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 0a65f32cb2..a040d418d9 100644
index 3a65ced497..7285705857 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -434,6 +434,7 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf)
@@ -433,6 +433,7 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf)
frame->data[0] = (uint8_t *) v4l2_get_drm_frame(avbuf);
frame->format = AV_PIX_FMT_DRM_PRIME;
@ -635,7 +635,7 @@ index 6f7460c89a..02fbb6eec3 100644
/**
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index 4251efcb86..1082b9dad2 100644
index 76ddbf1a26..47dfe0905f 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -67,6 +67,8 @@ typedef struct V4L2m2mContext {
@ -648,7 +648,7 @@ index 4251efcb86..1082b9dad2 100644
int output_drm;
} V4L2m2mContext;
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 11b893cc65..6f67aabcbd 100644
index 28b29c4522..a5dc926232 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -35,6 +35,7 @@
@ -677,7 +677,7 @@ index 11b893cc65..6f67aabcbd 100644
ret = ff_v4l2_m2m_codec_init(priv);
if (ret) {
From 8c64981ace0a08bdc7eb445125a70f691ed829cb Mon Sep 17 00:00:00 2001
From 221ed816ded7c3a2b265a7c3e8c06e320ba791fb Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Wed, 6 May 2020 11:12:58 -0700
Subject: [PATCH 7/8] libavcodec: v4l2m2m: add option to specify pixel format
@ -690,10 +690,10 @@ Subject: [PATCH 7/8] 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 5bbab77c1e..3bd1f37c75 100644
index 4673d025c5..1f1fd6d982 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
@@ -522,6 +522,8 @@ static inline int v4l2_try_raw_format(V4L2Context* ctx, enum AVPixelFormat pixfm
static int v4l2_get_raw_format(V4L2Context* ctx, enum AVPixelFormat *p)
{
@ -702,7 +702,7 @@ index 5bbab77c1e..3bd1f37c75 100644
enum AVPixelFormat pixfmt = ctx->av_pix_fmt;
struct v4l2_fmtdesc fdesc;
int ret;
@@ -535,6 +537,13 @@ static int v4l2_get_raw_format(V4L2Context* ctx, enum AVPixelFormat *p)
@@ -540,6 +542,13 @@ static int v4l2_get_raw_format(V4L2Context* ctx, enum AVPixelFormat *p)
if (ret)
return AVERROR(EINVAL);
@ -717,7 +717,7 @@ index 5bbab77c1e..3bd1f37c75 100644
ret = v4l2_try_raw_format(ctx, pixfmt);
if (ret){
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index 1082b9dad2..943a8923c4 100644
index 47dfe0905f..7b020e2373 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -30,6 +30,7 @@
@ -728,7 +728,7 @@ index 1082b9dad2..943a8923c4 100644
#include "v4l2_context.h"
#define container_of(ptr, type, member) ({ \
@@ -81,6 +82,7 @@ typedef struct V4L2m2mPriv {
@@ -80,6 +81,7 @@ typedef struct V4L2m2mPriv {
int num_output_buffers;
int num_capture_buffers;
@ -737,7 +737,7 @@ index 1082b9dad2..943a8923c4 100644
/**
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 6f67aabcbd..279f26cbe6 100644
index a5dc926232..a8f707ba4e 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -261,6 +261,7 @@ static const AVOption options[] = {
@ -749,7 +749,7 @@ index 6f67aabcbd..279f26cbe6 100644
};
From 807bf8da5fa9f28443b5eee9429fb2478171e8f7 Mon Sep 17 00:00:00 2001
From 0e747a21c508567cd6ea615dba1a0dd85d38c076 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Mon, 24 Sep 2018 13:39:56 -0700
Subject: [PATCH 8/8] libavcodec: v4l2m2m: implement flush
@ -759,7 +759,7 @@ Subject: [PATCH 8/8] libavcodec: v4l2m2m: implement flush
1 file changed, 36 insertions(+)
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index 279f26cbe6..8f1dd4a886 100644
index a8f707ba4e..5f992f0e7f 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)