ffmpeg: update to 7.0.1

This commit is contained in:
Raven 2024-07-18 14:20:32 +06:00
parent 230eebe0b6
commit c76a4a0d8c
6 changed files with 231 additions and 403 deletions

View File

@ -1,4 +1,4 @@
From be059eaeefdc49e93066a8b618d5635e9a2c696a Mon Sep 17 00:00:00 2001
From 35bc2299c7eebb302b5db359fed1f01bc1beea73 Mon Sep 17 00:00:00 2001
From: Jing Sun <jing.a.sun@intel.com>
Date: Wed, 21 Nov 2018 11:33:04 +0800
Subject: [PATCH] lavc/svt_hevc: add libsvt hevc encoder wrapper
@ -14,15 +14,15 @@ Signed-off-by: Guo Jiansheng <jiansheng.guo@intel.com>
configure | 4 +
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 1 +
libavcodec/libsvt_hevc.c | 585 +++++++++++++++++++++++++++++++++++++++
4 files changed, 591 insertions(+)
libavcodec/libsvt_hevc.c | 586 +++++++++++++++++++++++++++++++++++++++
4 files changed, 592 insertions(+)
create mode 100644 libavcodec/libsvt_hevc.c
diff --git a/configure b/configure
index c8ae0a061d..9cc741d2a7 100755
index 2d46ef0b9c..cc6d5891ec 100755
--- a/configure
+++ b/configure
@@ -330,6 +330,7 @@ External library support:
@@ -333,6 +333,7 @@ External library support:
--enable-vapoursynth enable VapourSynth demuxer [no]
--disable-xlib disable xlib [autodetect]
--disable-zlib disable zlib [autodetect]
@ -30,7 +30,7 @@ index c8ae0a061d..9cc741d2a7 100755
The following libraries provide various hardware acceleration features:
--disable-amf disable AMF video encoding code [autodetect]
@@ -1898,6 +1899,7 @@ EXTERNAL_LIBRARY_LIST="
@@ -1953,6 +1954,7 @@ EXTERNAL_LIBRARY_LIST="
libsrt
libssh
libsvtav1
@ -38,7 +38,7 @@ index c8ae0a061d..9cc741d2a7 100755
libtensorflow
libtesseract
libtheora
@@ -3495,6 +3497,7 @@ vapoursynth_demuxer_deps="vapoursynth"
@@ -3552,6 +3554,7 @@ vapoursynth_demuxer_deps="vapoursynth"
videotoolbox_suggest="coreservices"
videotoolbox_deps="corefoundation coremedia corevideo"
videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames"
@ -46,7 +46,7 @@ index c8ae0a061d..9cc741d2a7 100755
# demuxers / muxers
ac3_demuxer_select="ac3_parser"
@@ -6868,6 +6871,7 @@ enabled libssh && require_pkg_config libssh "libssh >= 0.6.0" libssh/
@@ -6951,6 +6954,7 @@ enabled libssh && require_pkg_config libssh "libssh >= 0.6.0" libssh/
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
enabled libsvtav1 && require_pkg_config libsvtav1 "SvtAv1Enc >= 0.9.0" EbSvtAv1Enc.h svt_av1_enc_init_handle
@ -55,22 +55,22 @@ index c8ae0a061d..9cc741d2a7 100755
enabled libtesseract && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index bb42095165..08ebc58d7d 100644
index eef936944d..76c42fe35e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1143,6 +1143,7 @@
@@ -1154,6 +1154,7 @@ OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o libwebpenc_anim
OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o
+OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER) += libsvt_hevc.o
OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o
OBJS-$(CONFIG_LIBXAVS2_ENCODER) += libxavs2.o
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o
OBJS-$(CONFIG_LIBXEVD_DECODER) += libxevd.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 93ce8e3224..b709c7d551 100644
index 2386b450a6..5dad6ff74e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -829,6 +829,7 @@ extern const FFCodec ff_libxavs_encoder;
@@ -820,6 +820,7 @@ extern const FFCodec ff_libxavs_encoder;
extern const FFCodec ff_libxavs2_encoder;
extern const FFCodec ff_libxvid_encoder;
extern const FFCodec ff_libzvbi_teletext_decoder;
@ -80,10 +80,10 @@ index 93ce8e3224..b709c7d551 100644
extern const FFCodec ff_bintext_decoder;
diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
new file mode 100644
index 0000000000..80b53a2157
index 0000000000..cb7bc93472
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,585 @@
@@ -0,0 +1,586 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
@ -110,6 +110,7 @@ index 0000000000..80b53a2157
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+
+#include "codec_internal.h"
@ -670,5 +671,5 @@ index 0000000000..80b53a2157
+ .p.wrapper_name = "libsvt_hevc",
+};
--
2.43.0
2.44.0

View File

@ -1,8 +1,9 @@
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1020,6 +1020,10 @@ attribute_deprecated
int64_t av_stream_get_end_pts(const AVStream *st);
#endif
diff -Naur a/libavformat/avformat.h b/libavformat/avformat.h
--- a/libavformat/avformat.h 2024-04-05 05:23:00.000000000 +0600
+++ b/libavformat/avformat.h 2024-07-17 17:51:20.156314168 +0600
@@ -1170,6 +1170,10 @@
struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st);
@ -11,19 +12,20 @@
#define AV_PROGRAM_RUNNING 1
/**
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -56,6 +56,13 @@ int ff_unlock_avformat(void)
return ff_mutex_unlock(&avformat_mutex) ? -1 : 0;
}
diff -Naur a/libavformat/mux_utils.c b/libavformat/mux_utils.c
--- a/libavformat/mux_utils.c 2024-04-05 05:23:00.000000000 +0600
+++ b/libavformat/mux_utils.c 2024-07-17 17:52:26.337981552 +0600
@@ -30,6 +30,13 @@
#include "internal.h"
#include "mux.h"
+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st)
+{
+ return ffstream(st)->first_dts;
+ return cffstream(st)->first_dts;
+}
+// Chromium: We use the internal field first_dts ^^^
+
/* an arbitrarily chosen "sane" max packet size -- 50M */
#define SANE_CHUNK_SIZE (50000000)
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
int std_compliance)
{

View File

@ -1,14 +1,7 @@
From: Andreas Schneider <asn@cryptomilk.org>
fdk-aac-free-devel is GPL compatible
See https://bugzilla.redhat.com/show_bug.cgi?id=1501522#c112
Index: ffmpeg-5.0/configure
===================================================================
--- ffmpeg-5.0.orig/configure 2022-02-09 20:07:49.490888877 +0100
+++ ffmpeg-5.0/configure 2022-02-09 20:08:30.102854308 +0100
@@ -1783,7 +1783,6 @@ EXTERNAL_LIBRARY_GPL_LIST="
diff -Naur a/configure b/configure
--- a/configure 2024-04-05 05:22:59.000000000 +0600
+++ b/configure 2024-07-17 17:59:24.141881751 +0600
@@ -1872,7 +1872,6 @@
EXTERNAL_LIBRARY_NONFREE_LIST="
decklink
@ -16,10 +9,10 @@ Index: ffmpeg-5.0/configure
libtls
"
@@ -1822,6 +1821,7 @@ EXTERNAL_LIBRARY_LIST="
@@ -1912,6 +1911,7 @@
libcodec2
libdav1d
libdc1394
libdrm
+ libfdk_aac
libflite
libfontconfig

View File

@ -11,11 +11,11 @@ reduced codec selection list.
libavformat/matroskaenc.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
Index: ffmpeg-6.0/libavformat/matroskaenc.c
Index: ffmpeg-6.1.1/libavformat/matroskaenc.c
===================================================================
--- ffmpeg-6.0.orig/libavformat/matroskaenc.c
+++ ffmpeg-6.0/libavformat/matroskaenc.c
@@ -3321,16 +3321,25 @@ static int mkv_query_codec(enum AVCodecI
--- ffmpeg-6.1.1.orig/libavformat/matroskaenc.c
+++ ffmpeg-6.1.1/libavformat/matroskaenc.c
@@ -3538,16 +3538,25 @@ static int mkv_query_codec(enum AVCodecI
return 0;
}
@ -45,7 +45,7 @@ Index: ffmpeg-6.0/libavformat/matroskaenc.c
.init = mkv_init,
.deinit = mkv_deinit,
.write_header = mkv_write_header,
@@ -3388,8 +3397,7 @@ const FFOutputFormat ff_matroska_audio_m
@@ -3615,8 +3624,7 @@ const FFOutputFormat ff_matroska_audio_m
.p.mime_type = "audio/x-matroska",
.p.extensions = "mka",
.priv_data_size = sizeof(MatroskaMuxContext),

View File

@ -1,363 +1,195 @@
From 3daa49cae0bfc3de434dd28c3a23ae877f0639db Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@fedoraproject.org>
Date: Thu, 4 Jan 2024 10:21:17 -0500
Subject: [PATCH] lavc/openh264: Add the ability to dlopen() OpenH264
From: Ismail Dönmez <ismail@i10z.com>
Date: 2019-06-11 11:21:23
We can't directly depend on OpenH264, but we can weakly link to it
and gracefully expose the capability.
This is ffmpeg-4.1-dlopen-faac-mp3lame-opencore-x264-x265-xvid.patch
from OpenMandriva to optionally enable runtime enabling of
fdkaac/lame/x264/x265.
Co-authored-by: Andreas Schneider <asn@cryptomilk.org>
Co-authored-by: Neal Gompa <ngompa@fedoraproject.org>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Neal Gompa <ngompa@fedoraproject.org>
---
configure | 3 +
libavcodec/Makefile | 1 +
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, 234 insertions(+)
create mode 100644 libavcodec/libopenh264_dlopen.c
create mode 100644 libavcodec/libopenh264_dlopen.h
configure | 3 ++
libavcodec/dlopen.h | 12 ++++++++++
libavcodec/libfdk-aacdec.c | 53 +++++++++++++++++++++++++++++++++++++++++++++
libavcodec/libfdk-aacenc.c | 47 +++++++++++++++++++++++++++++++++++++++
4 files changed, 115 insertions(+)
diff --git a/configure b/configure
index 1f0b9497cb..97fa4a5d6a 100755
--- a/configure
+++ b/configure
@@ -249,6 +249,7 @@ External library support:
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
--enable-libopencv enable video filtering via libopencv [no]
--enable-libopenh264 enable H.264 encoding via OpenH264 [no]
+ --enable-libopenh264-dlopen enable H.264 encoding via dlopen()'ed OpenH264 [no]
--enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
--enable-libopenmpt enable decoding tracked files via libopenmpt [no]
--enable-libopenvino enable OpenVINO as a DNN module backend
@@ -1871,6 +1872,7 @@ EXTERNAL_LIBRARY_LIST="
libmysofa
libopencv
libopenh264
+ libopenh264_dlopen
libopenjpeg
libopenmpt
libopenvino
@@ -6765,6 +6767,7 @@ enabled libopencv && { check_headers opencv2/core/core_c.h &&
require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; }
enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion
+enabled libopenh264_dlopen && enable libopenh264 && add_cppflags "-I$(dirname `readlink -f $0`)/ffdlopenhdrs/include -DCONFIG_LIBOPENH264_DLOPEN=1"
enabled libopenjpeg && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version ||
{ require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } }
enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 580a8d6b54..c27d229f6d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1115,6 +1115,7 @@ OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER) += libopencore-amr.o
+OBJS-$(CONFIG_LIBOPENH264_DLOPEN) += libopenh264_dlopen.o
OBJS-$(CONFIG_LIBOPENH264_DECODER) += libopenh264dec.o libopenh264.o
OBJS-$(CONFIG_LIBOPENH264_ENCODER) += libopenh264enc.o libopenh264.o
OBJS-$(CONFIG_LIBOPENJPEG_ENCODER) += libopenjpegenc.o
diff --git a/libavcodec/libopenh264.c b/libavcodec/libopenh264.c
index c80c85ea8b..128c3d9846 100644
--- a/libavcodec/libopenh264.c
+++ b/libavcodec/libopenh264.c
@@ -20,8 +20,13 @@
*/
Index: ffmpeg-7.0/configure
===================================================================
--- ffmpeg-7.0.orig/configure
+++ ffmpeg-7.0/configure
@@ -230,6 +230,7 @@ External library support:
--enable-libdvdnav enable libdvdnav, needed for DVD demuxing [no]
--enable-libdvdread enable libdvdread, needed for DVD demuxing [no]
--enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]
+ --enable-libfdk-aac-dlopen enable AAC de/encoding via dlopen()'ed libfdk-aac [no]
--enable-libflite enable flite (voice synthesis) support via libflite [no]
--enable-libfontconfig enable libfontconfig, useful for drawtext filter [no]
--enable-libfreetype enable libfreetype, needed for drawtext filter [no]
@@ -1873,6 +1874,7 @@ EXTERNAL_LIBRARY_GPL_LIST="
EXTERNAL_LIBRARY_NONFREE_LIST="
decklink
libfdk_aac
+ libfdk_aac_dlopen
libtls
"
#include <string.h>
+
+#ifdef CONFIG_LIBOPENH264_DLOPEN
+#include "libopenh264_dlopen.h"
+#else
#include <wels/codec_api.h>
#include <wels/codec_ver.h>
+#endif
#include "libavutil/error.h"
#include "libavutil/log.h"
diff --git a/libavcodec/libopenh264_dlopen.c b/libavcodec/libopenh264_dlopen.c
new file mode 100644
index 0000000000..49ea8ff44f
@@ -6847,6 +6849,7 @@ enabled libdvdread && require_pkg
enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
warn "using libfdk without pkg-config"; } }
+enabled libfdk_aac_dlopen && enable libfdk_aac && add_cppflags "-I/usr/include/fdk-aac"
flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
enabled libflite && require libflite "flite/flite.h" flite_init $flite_extralibs
enabled fontconfig && enable libfontconfig
Index: ffmpeg-7.0/libavcodec/dlopen.h
===================================================================
--- /dev/null
+++ b/libavcodec/libopenh264_dlopen.c
@@ -0,0 +1,147 @@
+/*
+ * OpenH264 dlopen code
+ *
+ * Copyright (C) 2022 Andreas Schneider <asn@cryptomilk.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+++ ffmpeg-7.0/libavcodec/dlopen.h
@@ -0,0 +1,12 @@
+#ifndef LOCALINC_DLOPEN_H
+#define LOCALINC_DLOPEN_H
+#include <dlfcn.h>
+#define num2str(x) str(x)
+#define str(x) #x
+
+#include "libopenh264_dlopen.h"
+#define dl_sym(func, args, lib) \
+ dl_##func = args dlsym(lib, #func); \
+ if ((err = dlerror())) \
+ goto error;
+
+/*
+ * The symbol binding makes sure we do not run into strict aliasing issues which
+ * can lead into segfaults.
+ */
+typedef int (*__oh264_WelsCreateSVCEncoder)(ISVCEncoder **);
+typedef void (*__oh264_WelsDestroySVCEncoder)(ISVCEncoder *);
+typedef int (*__oh264_WelsGetDecoderCapability)(SDecoderCapability *);
+typedef long (*__oh264_WelsCreateDecoder)(ISVCDecoder **);
+typedef void (*__oh264_WelsDestroyDecoder)(ISVCDecoder *);
+typedef OpenH264Version (*__oh264_WelsGetCodecVersion)(void);
+typedef void (*__oh264_WelsGetCodecVersionEx)(OpenH264Version *);
+
+#define OH264_SYMBOL_ENTRY(i) \
+ union { \
+ __oh264_##i f; \
+ void *obj; \
+ } _oh264_##i
+
+struct oh264_symbols {
+ OH264_SYMBOL_ENTRY(WelsCreateSVCEncoder);
+ OH264_SYMBOL_ENTRY(WelsDestroySVCEncoder);
+ OH264_SYMBOL_ENTRY(WelsGetDecoderCapability);
+ OH264_SYMBOL_ENTRY(WelsCreateDecoder);
+ OH264_SYMBOL_ENTRY(WelsDestroyDecoder);
+ OH264_SYMBOL_ENTRY(WelsGetCodecVersion);
+ OH264_SYMBOL_ENTRY(WelsGetCodecVersionEx);
+};
+
+/* Symbols are bound by loadLibOpenH264() */
+static struct oh264_symbols openh264_symbols;
+
+int oh264_WelsCreateSVCEncoder(ISVCEncoder **ppEncoder) {
+ return openh264_symbols._oh264_WelsCreateSVCEncoder.f(ppEncoder);
+}
+
+void oh264_WelsDestroySVCEncoder(ISVCEncoder *pEncoder) {
+ return openh264_symbols._oh264_WelsDestroySVCEncoder.f(pEncoder);
+}
+
+int oh264_WelsGetDecoderCapability(SDecoderCapability *pDecCapability) {
+ return openh264_symbols._oh264_WelsGetDecoderCapability.f(pDecCapability);
+}
+
+long oh264_WelsCreateDecoder(ISVCDecoder **ppDecoder) {
+ return openh264_symbols._oh264_WelsCreateDecoder.f(ppDecoder);
+}
+
+void oh264_WelsDestroyDecoder(ISVCDecoder *pDecoder) {
+ return openh264_symbols._oh264_WelsDestroyDecoder.f(pDecoder);
+}
+
+OpenH264Version oh264_WelsGetCodecVersion(void) {
+ return openh264_symbols._oh264_WelsGetCodecVersion.f();
+}
+
+void oh264_WelsGetCodecVersionEx(OpenH264Version *pVersion) {
+ openh264_symbols._oh264_WelsGetCodecVersionEx.f(pVersion);
+}
+
+static void *_oh264_bind_symbol(AVCodecContext *avctx,
+ void *handle,
+ const char *sym_name) {
+ void *sym = NULL;
+
+ sym = dlsym(handle, sym_name);
+ if (sym == NULL) {
+ const char *err = dlerror();
+ av_log(avctx,
+ AV_LOG_WARNING,
+ "%s: Failed to bind %s\n",
+ err,
+ sym_name);
+ return NULL;
+ }
+
+ return sym;
+}
+
+#define oh264_bind_symbol(avctx, handle, sym_name) \
+ if (openh264_symbols._oh264_##sym_name.obj == NULL) { \
+ openh264_symbols._oh264_##sym_name.obj = _oh264_bind_symbol(avctx, handle, #sym_name); \
+ if (openh264_symbols._oh264_##sym_name.obj == NULL) { \
+ return 1; \
+ } \
+ }
+
+int loadLibOpenH264(AVCodecContext *avctx) {
+ static bool initialized = false;
+ void *libopenh264 = NULL;
+ const char *err = NULL;
+
+ if (initialized) {
+ return 0;
+ }
+
+#define OPENH264_LIB "libopenh264.so.7"
+ libopenh264 = dlopen(OPENH264_LIB, RTLD_LAZY);
+ err = dlerror();
+ if (err != NULL) {
+ av_log(avctx, AV_LOG_WARNING,
+ "%s: %s is missing, openh264 support will be disabled\n", err,
+ OPENH264_LIB);
+
+ if (libopenh264 != NULL) {
+ dlclose(libopenh264);
+ }
+ return 1;
+ }
+
+ oh264_bind_symbol(avctx, libopenh264, WelsCreateSVCEncoder);
+ oh264_bind_symbol(avctx, libopenh264, WelsDestroySVCEncoder);
+ oh264_bind_symbol(avctx, libopenh264, WelsGetDecoderCapability);
+ oh264_bind_symbol(avctx, libopenh264, WelsCreateDecoder);
+ oh264_bind_symbol(avctx, libopenh264, WelsDestroyDecoder);
+ oh264_bind_symbol(avctx, libopenh264, WelsGetCodecVersion);
+ oh264_bind_symbol(avctx, libopenh264, WelsGetCodecVersionEx);
+
+ initialized = true;
+
+ return 0;
+}
diff --git a/libavcodec/libopenh264_dlopen.h b/libavcodec/libopenh264_dlopen.h
new file mode 100644
index 0000000000..d7d8bb7cad
--- /dev/null
+++ b/libavcodec/libopenh264_dlopen.h
@@ -0,0 +1,58 @@
+/*
+ * OpenH264 dlopen code
+ *
+ * Copyright (C) 2022 Andreas Schneider <asn@cryptomilk.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef HAVE_LIBOPENH264_DLOPEN_H
+#define HAVE_LIBOPENH264_DLOPEN_H
+
+#ifdef CONFIG_LIBOPENH264_DLOPEN
+
+#include <wels/codec_api.h>
+#include <wels/codec_ver.h>
+
+#include "avcodec.h"
+
+int oh264_WelsCreateSVCEncoder(ISVCEncoder **ppEncoder);
+#define WelsCreateSVCEncoder oh264_WelsCreateSVCEncoder
+
+void oh264_WelsDestroySVCEncoder(ISVCEncoder *pEncoder);
+#define WelsDestroySVCEncoder oh264_WelsDestroySVCEncoder
+
+int oh264_WelsGetDecoderCapability(SDecoderCapability *pDecCapability);
+#define WelsGetDecoderCapability oh264_WelsGetDecoderCapability
+
+long oh264_WelsCreateDecoder(ISVCDecoder **ppDecoder);
+#define WelsCreateDecoder oh264_WelsCreateDecoder
+
+void oh264_WelsDestroyDecoder(ISVCDecoder *pDecoder);
+#define WelsDestroyDecoder oh264_WelsDestroyDecoder
+
+OpenH264Version oh264_WelsGetCodecVersion(void);
+#define WelsGetCodecVersion oh264_WelsGetCodecVersion
+
+void oh264_WelsGetCodecVersionEx(OpenH264Version *pVersion);
+#define WelsGetCodecVersionEx oh264_WelsGetCodecVersionEx
+
+int loadLibOpenH264(AVCodecContext *avctx);
+
+#endif /* CONFIG_LIBOPENH264_DLOPEN */
+
+#endif /* HAVE_LIBOPENH264_DLOPEN_H */
diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index b6a9bba2dc..e042189161 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -19,8 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifdef CONFIG_LIBOPENH264_DLOPEN
+#include "libopenh264_dlopen.h"
+#else
#include <wels/codec_api.h>
#include <wels/codec_ver.h>
+#endif
Index: ffmpeg-7.0/libavcodec/libfdk-aacdec.c
===================================================================
--- ffmpeg-7.0.orig/libavcodec/libfdk-aacdec.c
+++ ffmpeg-7.0/libavcodec/libfdk-aacdec.c
@@ -38,6 +38,54 @@
#define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS
#endif
#include "libavutil/common.h"
#include "libavutil/fifo.h"
@@ -55,6 +59,12 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
int log_level;
WelsTraceCallback callback_function;
+#ifdef CONFIG_LIBOPENH264_DLOPEN
+ if (loadLibOpenH264(avctx)) {
+ return AVERROR_DECODER_NOT_FOUND;
+ }
+#ifdef CONFIG_LIBFDK_AAC_DLOPEN
+#include "dlopen.h"
+AAC_DECODER_ERROR (*dl_aacDecoder_AncDataInit)(HANDLE_AACDECODER, UCHAR*, int);
+HANDLE_AACDECODER (*dl_aacDecoder_Open)(TRANSPORT_TYPE, UINT);
+AAC_DECODER_ERROR (*dl_aacDecoder_Fill)(HANDLE_AACDECODER, UCHAR**, const UINT*, UINT*);
+AAC_DECODER_ERROR (*dl_aacDecoder_ConfigRaw)(HANDLE_AACDECODER, UCHAR **, const UINT*);
+AAC_DECODER_ERROR (*dl_aacDecoder_SetParam)(const HANDLE_AACDECODER, const AACDEC_PARAM, const INT);
+AAC_DECODER_ERROR (*dl_aacDecoder_DecodeFrame)(HANDLE_AACDECODER, INT_PCM*, const INT, const UINT);
+CStreamInfo* (*dl_aacDecoder_GetStreamInfo)(HANDLE_AACDECODER);
+void (*dl_aacDecoder_Close)(HANDLE_AACDECODER);
+#define aacDecoder_AncDataInit dl_aacDecoder_AncDataInit
+#define aacDecoder_Open dl_aacDecoder_Open
+#define aacDecoder_Fill dl_aacDecoder_Fill
+#define aacDecoder_ConfigRaw dl_aacDecoder_ConfigRaw
+#define aacDecoder_SetParam dl_aacDecoder_SetParam
+#define aacDecoder_DecodeFrame dl_aacDecoder_DecodeFrame
+#define aacDecoder_GetStreamInfo dl_aacDecoder_GetStreamInfo
+#define aacDecoder_Close dl_aacDecoder_Close
+#define FDKAAC_LIB "libfdk-aac.so.2"
+static int loadLibFdkAac(AVCodecContext *avctx);
+static int loadLibFdkAac(AVCodecContext *avctx) {
+ void *libfdkaac = NULL;
+ const char *err = NULL;
+
+ libfdkaac = dlopen(FDKAAC_LIB, RTLD_LAZY);
+ if(err = dlerror()) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, libfdk-aac support will be disabled\n", err, FDKAAC_LIB);
+ if(libfdkaac)
+ dlclose(libfdkaac);
+ return 1;
+ }
+ dl_sym(aacDecoder_AncDataInit, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, UCHAR*, int)), libfdkaac);
+ dl_sym(aacDecoder_Open, (HANDLE_AACDECODER (*)(TRANSPORT_TYPE, UINT)), libfdkaac);
+ dl_sym(aacDecoder_Fill, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, UCHAR**, const UINT*, UINT*)), libfdkaac);
+ dl_sym(aacDecoder_ConfigRaw, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, UCHAR**, const UINT*)), libfdkaac);
+ dl_sym(aacDecoder_SetParam, (AAC_DECODER_ERROR (*)(const HANDLE_AACDECODER, const AACDEC_PARAM, const INT)), libfdkaac);
+ dl_sym(aacDecoder_DecodeFrame, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, INT_PCM*, const INT, const UINT)), libfdkaac);
+ dl_sym(aacDecoder_GetStreamInfo, (CStreamInfo* (*)(HANDLE_AACDECODER)), libfdkaac);
+ dl_sym(aacDecoder_Close, (void (*)(HANDLE_AACDECODER)), libfdkaac);
+ return 0;
+error:
+ av_log(avctx, AV_LOG_FATAL, "libfdk-aac: Missing symbols in %s: %s\n"
+ "libfdk-aac support disabled\n", FDKAAC_LIB, err);
+ dlclose(libfdkaac);
+ return 1;
+}
+#endif
+
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 6f231d22b2..3f0e990d80 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -19,8 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
enum ConcealMethod {
CONCEAL_METHOD_SPECTRAL_MUTING = 0,
CONCEAL_METHOD_NOISE_SUBSTITUTION = 1,
@@ -244,6 +292,11 @@ static av_cold int fdk_aac_decode_init(A
FDKAACDecContext *s = avctx->priv_data;
AAC_DECODER_ERROR err;
+#ifdef CONFIG_LIBOPENH264_DLOPEN
+#include "libopenh264_dlopen.h"
+#else
#include <wels/codec_api.h>
#include <wels/codec_ver.h>
+#endif
#include "libavutil/attributes.h"
#include "libavutil/common.h"
@@ -114,6 +118,12 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
WelsTraceCallback callback_function;
AVCPBProperties *props;
+#ifdef CONFIG_LIBOPENH264_DLOPEN
+ if (loadLibOpenH264(avctx)) {
+ return AVERROR_ENCODER_NOT_FOUND;
+ }
+#ifdef CONFIG_LIBFDK_AAC_DLOPEN
+ if (loadLibFdkAac(avctx))
+ return -1;
+#endif
+
if (WelsCreateSVCEncoder(&s->encoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
return AVERROR_UNKNOWN;
--
2.43.0
s->handle = aacDecoder_Open(avctx->extradata_size ? TT_MP4_RAW : TT_MP4_ADTS, 1);
if (!s->handle) {
av_log(avctx, AV_LOG_ERROR, "Error opening decoder\n");
Index: ffmpeg-7.0/libavcodec/libfdk-aacenc.c
===================================================================
--- ffmpeg-7.0.orig/libavcodec/libfdk-aacenc.c
+++ ffmpeg-7.0/libavcodec/libfdk-aacenc.c
@@ -37,6 +37,48 @@
#define FDKENC_VER_AT_LEAST(vl0, vl1) 0
#endif
+#ifdef CONFIG_LIBFDK_AAC_DLOPEN
+#include "dlopen.h"
+#include <fdk-aac/aacdecoder_lib.h>
+AACENC_ERROR (*dl_aacEncOpen)(HANDLE_AACENCODER*, const UINT, const UINT);
+AACENC_ERROR (*dl_aacEncoder_SetParam)(const HANDLE_AACENCODER, const AACENC_PARAM, const UINT);
+AACENC_ERROR (*dl_aacEncEncode)(const HANDLE_AACENCODER, const AACENC_BufDesc*, const AACENC_BufDesc*, const AACENC_InArgs*, AACENC_OutArgs*);
+AACENC_ERROR (*dl_aacEncInfo)(const HANDLE_AACENCODER, AACENC_InfoStruct*);
+AACENC_ERROR (*dl_aacEncClose)(HANDLE_AACENCODER*);
+
+#define aacEncOpen dl_aacEncOpen
+#define aacEncoder_SetParam dl_aacEncoder_SetParam
+#define aacEncEncode dl_aacEncEncode
+#define aacEncInfo dl_aacEncInfo
+#define aacEncClose dl_aacEncClose
+#define FDKAAC_LIB "libfdk-aac.so.2"
+
+static int loadLibFdkAac(AVCodecContext *avctx);
+static int loadLibFdkAac(AVCodecContext *avctx) {
+ void *libfdkaac = NULL;
+ const char *err = NULL;
+
+ libfdkaac = dlopen(FDKAAC_LIB, RTLD_LAZY);
+ if(err = dlerror()) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, libfdk-aac support will be disabled\n", err, FDKAAC_LIB);
+ if(libfdkaac)
+ dlclose(libfdkaac);
+ return 1;
+ }
+ dl_sym(aacEncOpen, (AACENC_ERROR (*)(HANDLE_AACENCODER*, const UINT, const UINT)), libfdkaac);
+ dl_sym(aacEncoder_SetParam, (AACENC_ERROR (*)(const HANDLE_AACENCODER, const AACENC_PARAM, const UINT)), libfdkaac);
+ dl_sym(aacEncEncode, (AACENC_ERROR (*)(const HANDLE_AACENCODER, const AACENC_BufDesc*, const AACENC_BufDesc*, const AACENC_InArgs*, AACENC_OutArgs*)), libfdkaac);
+ dl_sym(aacEncInfo, (AACENC_ERROR (*)(const HANDLE_AACENCODER, AACENC_InfoStruct*)), libfdkaac);
+ dl_sym(aacEncClose, (AACENC_ERROR (*)(HANDLE_AACENCODER*)), libfdkaac);
+ return 0;
+error:
+ av_log(avctx, AV_LOG_FATAL, "libfdk-aac: Missing symbols in %s: %s\n"
+ "libfdk-aac support disabled\n", FDKAAC_LIB, err);
+ dlclose(libfdkaac);
+ return 1;
+}
+#endif
+
typedef struct AACContext {
const AVClass *class;
HANDLE_AACENCODER handle;
@@ -182,6 +224,11 @@ static av_cold int aac_encode_init(AVCod
int aot = AV_PROFILE_AAC_LOW + 1;
int sce = 0, cpe = 0;
+#ifdef CONFIG_LIBFDK_AAC_DLOPEN
+ if (loadLibFdkAac(avctx))
+ return -1;
+#endif
+
if ((err = aacEncOpen(&s->handle, 0, avctx->ch_layout.nb_channels)) != AACENC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to open the encoder: %s\n",
aac_get_error(err));

View File

@ -124,8 +124,8 @@ ExclusiveArch: armv7hnl
Summary: Digital VCR and streaming server
Name: ffmpeg%{?flavor}
Version: 6.1.1
Release: 2%{?date:.%{?date}%{?date:git}%{?rel}}%{?dist}
Version: 7.0.1
Release: 1%{?date:.%{?date}%{?date:git}%{?rel}}%{?dist}
License: %{ffmpeg_license}
URL: https://ffmpeg.org/
%if 0%{?date}
@ -147,9 +147,7 @@ Patch3: 030-ffmpeg-add-svt-vp9.patch
Patch4: 040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch
# Fedora patches
Patch5: 0001-lavc-libopenh264-Drop-openh264-runtime-version-check.patch
Patch6: ffmpeg-allow-fdk-aac-free.patch
Patch7: ffmpeg-c99.patch
Patch8: ffmpeg-codec-choice.patch
%{!?_with_openh264:Patch9: ffmpeg-dlopen-openh264.patch}
@ -185,7 +183,6 @@ BuildRequires: lame-devel >= 3.98.3
%{?_with_caca:BuildRequires: libcaca-devel}
%{!?_without_cdio:BuildRequires: libcdio-paranoia-devel}
%{?_with_chromaprint:BuildRequires: libchromaprint-devel}
%{?_with_crystalhd:BuildRequires: libcrystalhd-devel}
%{!?_without_lensfun:BuildRequires: lensfun-devel}
%if 0%{?_with_ieee1394}
BuildRequires: libavc1394-devel
@ -252,8 +249,8 @@ BuildRequires: texinfo
%{?_with_vmaf:BuildRequires: libvmaf-devel >= 1.5.2}
%{?_with_vpl:BuildRequires: pkgconfig(vpl) >= 2.6}
%{?_with_wavpack:BuildRequires: wavpack-devel}
%{!?_without_vidstab:BuildRequires: vid.stab-devel}
%{!?_without_vulkan:BuildRequires: vulkan-loader-devel >= 1.3.255, pkgconfig(shaderc)}
%{!?_without_vidstab:BuildRequires: vid.stab-devel}
%{!?_without_vulkan:BuildRequires: vulkan-headers, vulkan-loader-devel >= 1.3.277, pkgconfig(shaderc)}
%{!?_without_x264:BuildRequires: x264-devel >= 0.0.0-0.31}
%{!?_without_x265:BuildRequires: x265-devel}
%{!?_without_xvid:BuildRequires: xvidcore-devel}
@ -277,6 +274,7 @@ Conflicts: libavutil-free
Conflicts: libpostproc-free
Conflicts: libswresample-free
Conflicts: libswscale-free
%{!?_without_vulkan:Requires: vulkan-headers >= 1.3.277}
%{?_with_vmaf:Recommends: vmaf-models}
%{!?_with_openh264:Recommends: openh264}
@ -342,7 +340,6 @@ Freeworld libavcodec to complement the distro counterparts
%{!?_without_amr:--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3} \\\
--enable-bzlib \\\
%{?_with_chromaprint:--enable-chromaprint} \\\
%{!?_with_crystalhd:--disable-crystalhd} \\\
--enable-fontconfig \\\
%{!?_without_frei0r:--enable-frei0r} \\\
--enable-gcrypt \\\
@ -566,6 +563,9 @@ strip %{buildroot}%{_libdir}/%{name}/libavcodec.so.*
%changelog
* Mon May 20 2024 Raven <raven@sysadmins.ws> - 7.0.1-1
- Update to 7.0.1 release
* Wed Mar 6 2024 Raven <raven@sysadmins.ws> - 6.1.1-2
- fix for chromium
- add openh264 support