|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
From 4739b0c97b3378bdaf737171777fe9a71a53eff1 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From 1f48740db0dda8d6ec1b97a7f4a794e381a65636 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Neal Gompa <ngompa@fedoraproject.org>
|
|
|
|
|
Date: Wed, 12 Oct 2022 09:41:27 -0400
|
|
|
|
|
Subject: [PATCH] avcodec/openh264: Add the ability to dlopen() OpenH264
|
|
|
|
@ -14,12 +14,12 @@ Signed-off-by: Neal Gompa <ngompa@fedoraproject.org>
|
|
|
|
|
---
|
|
|
|
|
configure | 3 +
|
|
|
|
|
libavcodec/Makefile | 1 +
|
|
|
|
|
libavcodec/libopenh264.c | 18 +++-
|
|
|
|
|
libavcodec/libopenh264.c | 5 ++
|
|
|
|
|
libavcodec/libopenh264_dlopen.c | 147 ++++++++++++++++++++++++++++++++
|
|
|
|
|
libavcodec/libopenh264_dlopen.h | 58 +++++++++++++
|
|
|
|
|
libavcodec/libopenh264dec.c | 10 +++
|
|
|
|
|
libavcodec/libopenh264enc.c | 10 +++
|
|
|
|
|
7 files changed, 245 insertions(+), 2 deletions(-)
|
|
|
|
|
7 files changed, 234 insertions(+)
|
|
|
|
|
create mode 100644 libavcodec/libopenh264_dlopen.c
|
|
|
|
|
create mode 100644 libavcodec/libopenh264_dlopen.h
|
|
|
|
|
|
|
|
|
@ -64,7 +64,7 @@ index 457ec58377..08a26fba5f 100644
|
|
|
|
|
OBJS-$(CONFIG_LIBOPENH264_ENCODER) += libopenh264enc.o libopenh264.o
|
|
|
|
|
OBJS-$(CONFIG_LIBOPENJPEG_DECODER) += libopenjpegdec.o
|
|
|
|
|
diff --git a/libavcodec/libopenh264.c b/libavcodec/libopenh264.c
|
|
|
|
|
index 0f6d28ed88..a124c3fa1e 100644
|
|
|
|
|
index c80c85ea8b..128c3d9846 100644
|
|
|
|
|
--- a/libavcodec/libopenh264.c
|
|
|
|
|
+++ b/libavcodec/libopenh264.c
|
|
|
|
|
@@ -20,8 +20,13 @@
|
|
|
|
@ -81,26 +81,6 @@ index 0f6d28ed88..a124c3fa1e 100644
|
|
|
|
|
|
|
|
|
|
#include "libavutil/error.h"
|
|
|
|
|
#include "libavutil/log.h"
|
|
|
|
|
@@ -52,8 +57,17 @@ int ff_libopenh264_check_version(void *logctx)
|
|
|
|
|
// Mingw GCC < 4.7 on x86_32 uses an incorrect/buggy ABI for the WelsGetCodecVersion
|
|
|
|
|
// function (for functions returning larger structs), thus skip the check in those
|
|
|
|
|
// configurations.
|
|
|
|
|
-#if !defined(_WIN32) || !defined(__GNUC__) || !ARCH_X86_32 || AV_GCC_VERSION_AT_LEAST(4, 7)
|
|
|
|
|
- OpenH264Version libver = WelsGetCodecVersion();
|
|
|
|
|
+ // Also, for dlopened OpenH264, we should not do the version check. It's too punitive.
|
|
|
|
|
+#if !defined(_WIN32) || !defined(__GNUC__) || !ARCH_X86_32 || AV_GCC_VERSION_AT_LEAST(4, 7) || !defined(CONFIG_LIBOPENH264_DLOPEN)
|
|
|
|
|
+ OpenH264Version libver;
|
|
|
|
|
+
|
|
|
|
|
+#ifdef CONFIG_LIBOPENH264_DLOPEN
|
|
|
|
|
+ if (loadLibOpenH264(logctx)) {
|
|
|
|
|
+ return AVERROR_EXTERNAL;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+ libver = WelsGetCodecVersion();
|
|
|
|
|
if (memcmp(&libver, &g_stCodecVersion, sizeof(libver))) {
|
|
|
|
|
av_log(logctx, AV_LOG_ERROR, "Incorrect library version loaded\n");
|
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
|
diff --git a/libavcodec/libopenh264_dlopen.c b/libavcodec/libopenh264_dlopen.c
|
|
|
|
|
new file mode 100644
|
|
|
|
|
index 0000000000..49ea8ff44f
|
|
|
|
@ -319,7 +299,7 @@ index 0000000000..d7d8bb7cad
|
|
|
|
|
+
|
|
|
|
|
+#endif /* HAVE_LIBOPENH264_DLOPEN_H */
|
|
|
|
|
diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
|
|
|
|
|
index 007f86b619..57aa3bc1d1 100644
|
|
|
|
|
index 7e14d4dd7d..a805598446 100644
|
|
|
|
|
--- a/libavcodec/libopenh264dec.c
|
|
|
|
|
+++ b/libavcodec/libopenh264dec.c
|
|
|
|
|
@@ -19,8 +19,12 @@
|
|
|
|
@ -335,7 +315,7 @@ index 007f86b619..57aa3bc1d1 100644
|
|
|
|
|
|
|
|
|
|
#include "libavutil/common.h"
|
|
|
|
|
#include "libavutil/fifo.h"
|
|
|
|
|
@@ -56,6 +60,12 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
|
|
|
|
|
@@ -55,6 +59,12 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
|
|
|
|
|
int log_level;
|
|
|
|
|
WelsTraceCallback callback_function;
|
|
|
|
|
|
|
|
|
@ -345,11 +325,11 @@ index 007f86b619..57aa3bc1d1 100644
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
if ((err = ff_libopenh264_check_version(avctx)) < 0)
|
|
|
|
|
return AVERROR_DECODER_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
if (WelsCreateDecoder(&s->decoder)) {
|
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Unable to create decoder\n");
|
|
|
|
|
return AVERROR_UNKNOWN;
|
|
|
|
|
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
|
|
|
|
|
index db252aace1..75289678da 100644
|
|
|
|
|
index 5257906567..80481f3d0a 100644
|
|
|
|
|
--- a/libavcodec/libopenh264enc.c
|
|
|
|
|
+++ b/libavcodec/libopenh264enc.c
|
|
|
|
|
@@ -19,8 +19,12 @@
|
|
|
|
@ -365,7 +345,7 @@ index db252aace1..75289678da 100644
|
|
|
|
|
|
|
|
|
|
#include "libavutil/attributes.h"
|
|
|
|
|
#include "libavutil/common.h"
|
|
|
|
|
@@ -137,6 +141,12 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
|
|
|
|
|
@@ -114,6 +118,12 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
|
|
|
|
|
WelsTraceCallback callback_function;
|
|
|
|
|
AVCPBProperties *props;
|
|
|
|
|
|
|
|
|
@ -375,9 +355,9 @@ index db252aace1..75289678da 100644
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
if ((err = ff_libopenh264_check_version(avctx)) < 0)
|
|
|
|
|
return AVERROR_ENCODER_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
if (WelsCreateSVCEncoder(&s->encoder)) {
|
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
|
|
|
|
|
return AVERROR_UNKNOWN;
|
|
|
|
|
--
|
|
|
|
|
2.36.1
|
|
|
|
|
|
|
|
|
|