SHA256
1
0
forked from pool/ffmpeg-4

- Add ffmpeg-4.1-dlopen-faac-mp3lame-opencore-x264-x265-xvid.patch

from OpenMandriva to optionally enable runtime enabling of
  fdkaac/lame/x264/x265
- Enable runtime enabling for fdkaac via --enable-libfdk-aac-dlopen

OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/ffmpeg-4?expand=0&rev=70
This commit is contained in:
Ismail Dönmez 2019-06-11 11:21:23 +00:00 committed by Git OBS Bridge
parent c3028f2aad
commit 5478d2e6f2
7 changed files with 941 additions and 295 deletions

View File

@ -0,0 +1,865 @@
Index: ffmpeg-4.1.3/configure
===================================================================
--- ffmpeg-4.1.3.orig/configure
+++ ffmpeg-4.1.3/configure
@@ -231,6 +231,7 @@ External library support:
--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
and libraw1394 [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]
@@ -245,8 +246,11 @@ External library support:
--enable-liblensfun enable lensfun lens correction [no]
--enable-libmodplug enable ModPlug via libmodplug [no]
--enable-libmp3lame enable MP3 encoding via libmp3lame [no]
+ --enable-libmp3lame-dlopen enable MP3 encoding via dlopen()'ed libmp3lame [no]
--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
+ --enable-libopencore-amrnb-dlopen enable AMR-NB de/encoding via dlopen()'ed libopencore-amrnb [no]
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
+ --enable-libopencore-amrwb-dlopen enable AMR-WB decoding via dlopen()'ed libopencore-amrwb [no]
--enable-libopencv enable video filtering via libopencv [no]
--enable-libopenh264 enable H.264 encoding via OpenH264 [no]
--enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
@@ -280,7 +284,9 @@ External library support:
--enable-libwavpack enable wavpack encoding via libwavpack [no]
--enable-libwebp enable WebP encoding via libwebp [no]
--enable-libx264 enable H.264 encoding via x264 [no]
+ --enable-libx264-dlopen enable H.264 encoding via dlopen()'ed x264 [no]
--enable-libx265 enable HEVC encoding via x265 [no]
+ --enable-libx265-dlopen enable HEVC encoding via dlopen()'ed x265 [no]
--enable-libxavs enable AVS encoding via xavs [no]
--enable-libxavs2 enable AVS2 encoding via xavs2 [no]
--enable-libxcb enable X11 grabbing using XCB [autodetect]
@@ -289,6 +295,7 @@ External library support:
--enable-libxcb-shape enable X11 grabbing shape rendering [autodetect]
--enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
+ --enable-libxvid-dlopen enable Xvid encoding via dlopen()'ed xvidcore [no]
--enable-libxml2 enable XML parsing using the C library libxml2, needed
for dash demuxing support [no]
--enable-libzimg enable z.lib, needed for zscale filter [no]
@@ -1667,16 +1674,20 @@ EXTERNAL_LIBRARY_GPL_LIST="
librubberband
libvidstab
libx264
+ libx264_dlopen
libx265
+ libx265_dlopen
libxavs
libxavs2
libxvid
+ libxvid_dlopen
"
EXTERNAL_LIBRARY_NONFREE_LIST="
decklink
libndi_newtek
libfdk_aac
+ libfdk_aac_dlopen
openssl
libtls
"
@@ -1685,7 +1696,9 @@ EXTERNAL_LIBRARY_VERSION3_LIST="
gmp
liblensfun
libopencore_amrnb
+ libopencore_amrnb_dlopen
libopencore_amrwb
+ libopencore_amrwb_dlopen
libvmaf
libvo_amrwbenc
mbedtls
@@ -1729,6 +1742,7 @@ EXTERNAL_LIBRARY_LIST="
libkvazaar
libmodplug
libmp3lame
+ libmp3lame_dlopen
libmysofa
libopencv
libopenh264
@@ -6079,6 +6093,7 @@ enabled libdrm && 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$(dirname `readlink -f $0`)/localinc"
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
@@ -6104,13 +6119,16 @@ enabled libmfx && { check_pkg
{ require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs
+enabled libmp3lame_dlopen && enable libmp3lame && add_cppflags "-I$(dirname `readlink -f $0`)/localinc"
enabled libmysofa && { check_pkg_config libmysofa libmysofa mysofa.h mysofa_load ||
require libmysofa mysofa.h mysofa_load -lmysofa $zlib_extralibs; }
enabled libnpp && { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc -lnppidei ||
check_lib libnpp npp.h nppGetLibVersion -lnppi -lnppc -lnppidei ||
die "ERROR: libnpp not found"; }
enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
+enabled libopencore_amrnb_dlopen && enable libopencore_amrnb && add_cppflags "-I$(dirname `readlink -f $0`)/localinc"
enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
+enabled libopencore_amrwb_dlopen && enable libopencore_amrwb && add_cppflags "-I$(dirname `readlink -f $0`)/localinc"
enabled libopencv && { check_headers opencv2/core/core_c.h &&
{ check_pkg_config libopencv opencv opencv2/core/core_c.h cvCreateImageHeader ||
require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
@@ -6186,11 +6204,14 @@ enabled libx264 && { check_pkg
warn "using libx264 without pkg-config"; } } &&
require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
check_cpp_condition libx262 x264.h "X264_MPEG2"
+enabled libx264_dlopen && enable libx264 && add_cppflags "-I$(dirname `readlink -f $0`)/localinc"
enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get &&
require_cpp_condition libx265 x265.h "X265_BUILD >= 68"
+enabled libx265_dlopen && enable libx265 && add_cppflags "-I$(dirname `readlink -f $0`)/localinc"
enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.2.77" "stdint.h xavs2.h" xavs2_api_get
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
+enabled libxvid_dlopen && enable libxvid && add_cppflags "-I$(dirname `readlink -f $0`)/localinc"
enabled libzimg && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h zimg_get_api_version
enabled libzmq && require_pkg_config libzmq libzmq zmq.h zmq_ctx_new
enabled libzvbi && require_pkg_config libzvbi zvbi-0.2 libzvbi.h vbi_decoder_new &&
Index: ffmpeg-4.1.3/libavcodec/dlopen.h
===================================================================
--- /dev/null
+++ ffmpeg-4.1.3/libavcodec/dlopen.h
@@ -0,0 +1,13 @@
+#ifndef LOCALINC_DLOPEN_H
+#define LOCALINC_DLOPEN_H
+#include <dlfcn.h>
+#define num2str(x) str(x)
+#define str(x) #x
+
+#define dl_sym(func, args, lib) \
+ fprintf(stderr, "dlsym " #func "\n"); \
+ dl_##func = args dlsym(lib, #func); \
+ if ((err = dlerror())) \
+ goto error;
+
+#endif
Index: ffmpeg-4.1.3/libavcodec/libfdk-aacdec.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libfdk-aacdec.c
+++ ffmpeg-4.1.3/libavcodec/libfdk-aacdec.c
@@ -37,6 +37,54 @@
#define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS
#endif
+#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.1"
+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
+
enum ConcealMethod {
CONCEAL_METHOD_SPECTRAL_MUTING = 0,
CONCEAL_METHOD_NOISE_SUBSTITUTION = 1,
@@ -224,6 +272,11 @@ static av_cold int fdk_aac_decode_init(A
FDKAACDecContext *s = avctx->priv_data;
AAC_DECODER_ERROR err;
+#ifdef CONFIG_LIBFDK_AAC_DLOPEN
+ if (loadLibFdkAac(avctx))
+ return -1;
+#endif
+
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-4.1.3/libavcodec/libfdk-aacenc.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libfdk-aacenc.c
+++ ffmpeg-4.1.3/libavcodec/libfdk-aacenc.c
@@ -34,6 +34,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.1"
+
+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;
@@ -126,6 +168,11 @@ static av_cold int aac_encode_init(AVCod
int aot = FF_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->channels)) != AACENC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to open the encoder: %s\n",
aac_get_error(err));
Index: ffmpeg-4.1.3/libavcodec/libmp3lame.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libmp3lame.c
+++ ffmpeg-4.1.3/libavcodec/libmp3lame.c
@@ -38,6 +38,145 @@
#include "mpegaudio.h"
#include "mpegaudiodecheader.h"
+#ifdef CONFIG_LIBMP3LAME_DLOPEN
+#include "dlopen.h"
+
+static lame_global_flags* (*dl_lame_init) (void);
+
+static int (*dl_lame_close) (lame_global_flags *);
+
+static int (*dl_lame_encode_flush) (lame_global_flags * gfp, unsigned char* mp3buf, int size);
+
+static int (*dl_lame_encode_buffer) (lame_global_flags* gfp, const short int buffer_l [], const short int buffer_r [], const int nsamples, unsigned char* mp3buf, const int mp3buf_size );
+
+static int (*dl_lame_encode_buffer_interleaved) (lame_global_flags* gfp, short int pcm[], int num_samples, unsigned char* mp3buf, int mp3buf_size );
+
+static int (*dl_lame_encode_buffer_int) (lame_global_flags* gfp, const int buffer_l [], const int buffer_r [], const int nsamples, unsigned char* mp3buf, const int mp3buf_size );
+
+static int (*dl_lame_encode_buffer_float) (lame_global_flags* gfp, const float buffer_l [], const float buffer_r [], const int nsamples, unsigned char* mp3buf, const int mp3buf_size );
+
+static int (*dl_lame_get_encoder_delay) (lame_global_flags* gfp );
+
+static int (*dl_lame_set_in_samplerate) (lame_global_flags *, int);
+
+static int (*dl_lame_set_num_channels) (lame_global_flags *, int);
+
+static int (*dl_lame_set_quality) (lame_global_flags *, int);
+static int (*dl_lame_set_mode) (lame_global_flags *, MPEG_mode);
+
+static int (*dl_lame_set_out_samplerate) (lame_global_flags *, int);
+
+static int (*dl_lame_set_brate) (lame_global_flags *, int);
+
+static int (*dl_lame_set_VBR) (lame_global_flags *, vbr_mode);
+
+static int (*dl_lame_set_VBR_quality) (lame_global_flags *, float);
+
+static int (*dl_lame_set_VBR_mean_bitrate_kbps) (lame_global_flags *, int);
+
+static int (*dl_lame_set_bWriteVbrTag) (lame_global_flags *, int);
+
+static int (*dl_lame_set_disable_reservoir) (lame_global_flags *, int);
+
+static int (*dl_lame_init_params) (lame_global_flags *);
+
+static int (*dl_lame_get_framesize) (const lame_global_flags *);
+
+static int (*dl_lame_set_lowpassfreq) (lame_global_flags *, int);
+
+#define lame_init dl_lame_init
+#define lame_close dl_lame_close
+#define lame_encode_flush dl_lame_encode_flush
+#define lame_encode_buffer dl_lame_encode_buffer
+#define lame_encode_buffer_interleaved dl_lame_encode_buffer_interleaved
+#define lame_encode_buffer_int dl_lame_encode_buffer_int
+#define lame_encode_buffer_float dl_lame_encode_buffer_float
+#define lame_get_encoder_delay dl_lame_get_encoder_delay
+#define lame_set_in_samplerate dl_lame_set_in_samplerate
+#define lame_set_num_channels dl_lame_set_num_channels
+#define lame_set_quality dl_lame_set_quality
+#define lame_set_mode dl_lame_set_mode
+#define lame_set_out_samplerate dl_lame_set_out_samplerate
+#define lame_set_brate dl_lame_set_brate
+#define lame_set_VBR dl_lame_set_VBR
+#define lame_set_VBR_quality dl_lame_set_VBR_quality
+#define lame_set_VBR_mean_bitrate_kbps dl_lame_set_VBR_mean_bitrate_kbps
+#define lame_set_bWriteVbrTag dl_lame_set_bWriteVbrTag
+#define lame_set_disable_reservoir dl_lame_set_disable_reservoir
+#define lame_init_params dl_lame_init_params
+#define lame_get_framesize dl_lame_get_framesize
+#define lame_set_lowpassfreq dl_lame_set_lowpassfreq
+#define MP3LAME_LIB "libmp3lame.so.0"
+
+static int loadLibMp3Lame(AVCodecContext *avctx);
+static int loadLibMp3Lame(AVCodecContext *avctx) {
+ void *libmp3lame = NULL;
+ const char *err = NULL;
+
+
+ libmp3lame = dlopen(MP3LAME_LIB, RTLD_LAZY);
+ if ((err = dlerror())) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, libmp3lame support disabled\n", err, MP3LAME_LIB);
+ if (libmp3lame)
+ dlclose(libmp3lame);
+ return 1;
+ }
+
+ dl_sym(lame_init, (lame_global_flags* (*) (void)), libmp3lame);
+
+ dl_sym(lame_close, (int (*) (lame_global_flags*)), libmp3lame);
+
+ dl_sym(lame_encode_flush, (int (*) (lame_global_flags* gfp, unsigned char* mp3buf, int size)), libmp3lame);
+
+ dl_sym(lame_encode_buffer, (int (*) (lame_global_flags* gfp, const short int buffer_l [], const short int buffer_r [], const int nsamples, unsigned char* mp3buf, const int mp3buf_size)), libmp3lame);
+
+ dl_sym(lame_encode_buffer_interleaved, (int (*) (lame_global_flags* gfp, short int pcm[], int num_samples, unsigned char* mp3buf, int mp3buf_size)), libmp3lame);
+
+ dl_sym(lame_encode_buffer_int, (int (*) (lame_global_flags* gfp, const int buffer_l [], const int buffer_r [], const int nsamples, unsigned char* mp3buf, const int mp3buf_size)), libmp3lame);
+
+ dl_sym(lame_encode_buffer_float, (int (*) (lame_global_flags* gfp, const float buffer_l [], const float buffer_r [], const int nsamples, unsigned char* mp3buf, const int mp3buf_size)), libmp3lame);
+
+ dl_sym(lame_get_encoder_delay, (int (*) (lame_global_flags* gfp)), libmp3lame);
+
+ dl_sym(lame_set_in_samplerate, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_num_channels, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_quality, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_mode, (int (*) (lame_global_flags *, MPEG_mode)), libmp3lame);
+
+ dl_sym(lame_set_out_samplerate, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_brate, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_VBR, (int (*) (lame_global_flags *, vbr_mode)), libmp3lame);
+
+ dl_sym(lame_set_VBR_quality, (int (*) (lame_global_flags *, float)), libmp3lame);
+
+ dl_sym(lame_set_VBR_mean_bitrate_kbps, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_bWriteVbrTag, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_set_disable_reservoir, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ dl_sym(lame_init_params, (int (*) (lame_global_flags *)), libmp3lame);
+
+ dl_sym(lame_get_framesize, (int (*) (const lame_global_flags *)), libmp3lame);
+
+ dl_sym(lame_set_lowpassfreq, (int (*) (lame_global_flags *, int)), libmp3lame);
+
+ return 0;
+
+error:
+ av_log(avctx, AV_LOG_FATAL, "libmp3lame: Missing symbols in %s: %s "
+ "mp3lame support disabled\n", MP3LAME_LIB, err);
+ dlclose(libmp3lame);
+ return 1;
+
+}
+#endif
+
#define BUFFER_SIZE (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4+1000) // FIXME: Buffer size to small? Adding 1000 to make up for it.
typedef struct LAMEContext {
@@ -93,6 +232,11 @@ static av_cold int mp3lame_encode_init(A
LAMEContext *s = avctx->priv_data;
int ret;
+#ifdef CONFIG_LIBMP3LAME_DLOPEN
+ if (loadLibMp3Lame(avctx))
+ return -1;
+#endif
+
s->avctx = avctx;
/* initialize LAME and get defaults */
Index: ffmpeg-4.1.3/libavcodec/libopencore-amr.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libopencore-amr.c
+++ ffmpeg-4.1.3/libavcodec/libopencore-amr.c
@@ -29,6 +29,108 @@
#include "audio_frame_queue.h"
#include "internal.h"
+#if CONFIG_LIBOPENCORE_AMRWB_DECODER
+#include <opencore-amrwb/dec_if.h>
+#include <opencore-amrwb/if_rom.h>
+#endif
+
+#ifdef CONFIG_LIBOPENCORE_AMRNB_DLOPEN
+#include <opencore-amrnb/interf_dec.h>
+#include <opencore-amrnb/interf_enc.h>
+
+#include "dlopen.h"
+static void* (*dl_Decoder_Interface_init) (void);
+static void (*dl_Decoder_Interface_exit) (void* state);
+static void (*dl_Decoder_Interface_Decode) (void* state, const unsigned char* in, short* out, int bfi);
+static void* (*dl_Encoder_Interface_init) (int dtx);
+static void (*dl_Encoder_Interface_exit) (void* state);
+static int (*dl_Encoder_Interface_Encode) (void* state, enum Mode mode, const short* speech, unsigned char* out, int forceSpeech);
+
+#define Decoder_Interface_init dl_Decoder_Interface_init
+#define Decoder_Interface_exit dl_Decoder_Interface_exit
+#define Decoder_Interface_Decode dl_Decoder_Interface_Decode
+#define Encoder_Interface_init dl_Encoder_Interface_init
+#define Encoder_Interface_exit dl_Encoder_Interface_exit
+#define Encoder_Interface_Encode dl_Encoder_Interface_Encode
+#define AMRNB_LIB "libopencore-amrnb.so.0"
+
+static int loadLibAMRNB(AVCodecContext *avctx);
+static int loadLibAMRNB(AVCodecContext *avctx) {
+ void *libamrnb = NULL;
+ const char *err = NULL;
+
+ libamrnb = dlopen(AMRNB_LIB, RTLD_LAZY);
+ if ((err = dlerror())) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, opencore-amrnb support will be disabled\n", err, AMRNB_LIB);
+ if (libamrnb)
+ dlclose(libamrnb);
+ return 1;
+ }
+
+
+ dl_sym(Decoder_Interface_init, (void (*)), libamrnb);
+
+ dl_sym(Decoder_Interface_exit, (void (*) (void* state)), libamrnb);
+
+ dl_sym(Decoder_Interface_Decode, (void (*) (void* state, const unsigned char* in, short* out, int bfi)), libamrnb);
+
+ dl_sym(Encoder_Interface_init, (void* (*) (int dtx)), libamrnb);
+
+ dl_sym(Encoder_Interface_exit, (void (*) (void* state)), libamrnb);
+
+ dl_sym(Encoder_Interface_Encode, (int (*) (void* state, enum Mode mode, const short* speech, unsigned char* out, int forceSpeech)), libamrnb);
+
+ return 0;
+
+error:
+ av_log(avctx, AV_LOG_FATAL, "opencore-amrnb: Missing symbols in %s: %s\n"
+ "opencore-amrnb support disabled\n", AMRNB_LIB, err);
+ dlclose(libamrnb);
+ return 1;
+}
+#endif
+
+#ifdef CONFIG_LIBOPENCORE_AMRWB_DLOPEN
+#include "dlopen.h"
+
+static void* (*dl_D_IF_init) (void);
+static void (*dl_D_IF_decode) (void* state, const unsigned char* bits, short* synth, int bfi);
+static void (*dl_D_IF_exit) (void* state);
+
+#define D_IF_init dl_D_IF_init
+#define D_IF_decode dl_D_IF_decode
+#define D_IF_exit dl_D_IF_exit
+#define AMRWB_LIB "libopencore-amrwb.so.0"
+
+static int loadLibAMRWB(AVCodecContext *avctx) {
+ void *libamrwb = NULL;
+ const char *err = NULL;
+
+ libamrwb = dlopen(AMRWB_LIB, RTLD_LAZY);
+ if ((err = dlerror())) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, opencore-amrwb support will be disabled\n", err, AMRWB_LIB);
+ if (libamrwb)
+ dlclose(libamrwb);
+ return 1;
+ }
+
+ dl_sym(D_IF_init, (void (*)), libamrwb);
+
+ dl_sym(D_IF_decode, (void (*) (void* state, const unsigned char* bits, short* synth, int bfi)), libamrwb);
+
+ dl_sym(D_IF_exit, (void (*) (void* state)), libamrwb);
+
+ return 0;
+
+error:
+ av_log(avctx, AV_LOG_FATAL, "opencore-amrwb: Missing symbols in %s: %s\n"
+ "opencore-amrwb support disabled\n", AMRWB_LIB, err);
+ dlclose(libamrwb);
+ return 1;
+}
+#endif
+
+
static int amr_decode_fix_avctx(AVCodecContext *avctx)
{
const int is_amr_wb = 1 + (avctx->codec_id == AV_CODEC_ID_AMR_WB);
@@ -49,9 +151,6 @@ static int amr_decode_fix_avctx(AVCodecC
#if CONFIG_LIBOPENCORE_AMRNB
-#include <opencore-amrnb/interf_dec.h>
-#include <opencore-amrnb/interf_enc.h>
-
typedef struct AMRContext {
AVClass *av_class;
void *dec_state;
@@ -193,6 +292,11 @@ static av_cold int amr_nb_encode_init(AV
{
AMRContext *s = avctx->priv_data;
+#ifdef CONFIG_LIBOPENCORE_AMRNB_DLOPEN
+ if (loadLibAMRNB(avctx))
+ return -1;
+#endif
+
if (avctx->sample_rate != 8000 && avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return AVERROR(ENOSYS);
@@ -303,10 +407,6 @@ AVCodec ff_libopencore_amrnb_encoder = {
/* -----------AMR wideband ------------*/
#if CONFIG_LIBOPENCORE_AMRWB_DECODER
-
-#include <opencore-amrwb/dec_if.h>
-#include <opencore-amrwb/if_rom.h>
-
typedef struct AMRWBContext {
void *state;
} AMRWBContext;
@@ -319,6 +419,11 @@ static av_cold int amr_wb_decode_init(AV
if ((ret = amr_decode_fix_avctx(avctx)) < 0)
return ret;
+#ifdef CONFIG_LIBOPENCORE_AMRWB_DLOPEN
+ if (loadLibAMRWB(avctx))
+ return -1;
+#endif
+
s->state = D_IF_init();
return 0;
Index: ffmpeg-4.1.3/libavcodec/libx264.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libx264.c
+++ ffmpeg-4.1.3/libavcodec/libx264.c
@@ -40,6 +40,120 @@
#include <stdlib.h>
#include <string.h>
+#ifdef CONFIG_LIBX264_DLOPEN
+#include "dlopen.h"
+
+static void (*dl_x264_picture_init) (x264_picture_t *);
+static int (*dl_x264_encoder_encode) (x264_t *, x264_nal_t **, int *, x264_picture_t *, x264_picture_t *);
+static int (*dl_x264_encoder_delayed_frames) (x264_t *);
+static x264_t* (*dl_x264_encoder_open) ( x264_param_t * );
+static int (*dl_x264_encoder_reconfig) ( x264_t *, x264_param_t * );
+static void (*dl_x264_encoder_close) (x264_t *);
+static void (*dl_x264_param_default) (x264_param_t *);
+static int (*dl_x264_param_parse) (x264_param_t *, const char *name, const char *value );
+static int (*dl_x264_param_default_preset) (x264_param_t *, const char *preset, const char *tune);
+static int (*dl_x264_param_apply_profile) (x264_param_t *, const char *profile);
+static void (*dl_x264_param_apply_fastfirstpass) (x264_param_t *);
+static int (*dl_x264_encoder_headers) (x264_t *, x264_nal_t **, int *);
+#define x264_picture_init dl_x264_picture_init
+#define x264_encoder_encode dl_x264_encoder_encode
+#define x264_encoder_delayed_frames dl_x264_encoder_delayed_frames
+#undef x264_encoder_open
+#define x264_encoder_open dl_x264_encoder_open
+#define x264_encoder_reconfig dl_x264_encoder_reconfig
+#define x264_encoder_close dl_x264_encoder_close
+#define x264_param_default dl_x264_param_default
+#define x264_param_apply_profile dl_x264_param_apply_profile
+#define x264_param_apply_fastfirstpass dl_x264_param_apply_fastfirstpass
+#define x264_param_parse dl_x264_param_parse
+#define x264_param_default_preset dl_x264_param_default_preset
+#define x264_encoder_headers dl_x264_encoder_headers
+
+#define X264_BUILD_str num2str(X264_BUILD)
+#define X264_LIB "libx264.so." X264_BUILD_str
+#define x264_encoder_open_str "x264_encoder_open_" X264_BUILD_str
+
+int dl_x264_bit_depth;
+#define x264_bit_depth dl_x264_bit_depth
+
+const x264_level_t x264_levels[] =
+{
+ { 10, 1485, 99, 396, 64, 175, 64, 64, 0, 2, 0, 0, 1 },
+ { 9, 1485, 99, 396, 128, 350, 64, 64, 0, 2, 0, 0, 1 }, /* "1b" */
+ { 11, 3000, 396, 900, 192, 500, 128, 64, 0, 2, 0, 0, 1 },
+ { 12, 6000, 396, 2376, 384, 1000, 128, 64, 0, 2, 0, 0, 1 },
+ { 13, 11880, 396, 2376, 768, 2000, 128, 64, 0, 2, 0, 0, 1 },
+ { 20, 11880, 396, 2376, 2000, 2000, 128, 64, 0, 2, 0, 0, 1 },
+ { 21, 19800, 792, 4752, 4000, 4000, 256, 64, 0, 2, 0, 0, 0 },
+ { 22, 20250, 1620, 8100, 4000, 4000, 256, 64, 0, 2, 0, 0, 0 },
+ { 30, 40500, 1620, 8100, 10000, 10000, 256, 32, 22, 2, 0, 1, 0 },
+ { 31, 108000, 3600, 18000, 14000, 14000, 512, 16, 60, 4, 1, 1, 0 },
+ { 32, 216000, 5120, 20480, 20000, 20000, 512, 16, 60, 4, 1, 1, 0 },
+ { 40, 245760, 8192, 32768, 20000, 25000, 512, 16, 60, 4, 1, 1, 0 },
+ { 41, 245760, 8192, 32768, 50000, 62500, 512, 16, 24, 2, 1, 1, 0 },
+ { 42, 522240, 8704, 34816, 50000, 62500, 512, 16, 24, 2, 1, 1, 1 },
+ { 50, 589824, 22080, 110400, 135000, 135000, 512, 16, 24, 2, 1, 1, 1 },
+ { 51, 983040, 36864, 184320, 240000, 240000, 512, 16, 24, 2, 1, 1, 1 },
+ { 52, 2073600, 36864, 184320, 240000, 240000, 512, 16, 24, 2, 1, 1, 1 },
+ { 0 }
+};
+
+static int loadLibX264(AVCodecContext *avctx);
+static int loadLibX264(AVCodecContext *avctx) {
+ void *libx264 = NULL;
+ const char *err = NULL;
+ int *ptr;
+
+ libx264 = dlopen(X264_LIB, RTLD_LAZY);
+ if ((err = dlerror())) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, x264 support will be disabled\n", err, X264_LIB);
+ if (libx264)
+ dlclose(libx264);
+ return 1;
+ }
+
+
+ dl_sym(x264_picture_init, (void (*) (x264_picture_t *)), libx264);
+
+ dl_sym(x264_encoder_encode, (int (*) (x264_t *, x264_nal_t **, int *, x264_picture_t *, x264_picture_t *)), libx264);
+
+ dl_sym(x264_encoder_delayed_frames, (int (*) (x264_t *)), libx264);
+
+ dl_x264_encoder_open =(x264_t* (*) (x264_param_t *)) dlsym(libx264, x264_encoder_open_str);
+ if ((err = dlerror()))
+ goto error;
+
+ dl_sym(x264_encoder_reconfig, (int (*) (x264_t *, x264_param_t * )), libx264);
+
+ dl_sym(x264_encoder_close, (void (*) (x264_t *)), libx264);
+
+ dl_sym(x264_param_default, (void (*) (x264_param_t *)), libx264);
+
+ dl_sym(x264_param_apply_fastfirstpass, (void (*) (x264_param_t *)), libx264);
+
+ dl_sym(x264_param_parse, (int (*) (x264_param_t *, const char *name, const char *value )), libx264);
+
+ dl_sym(x264_param_default_preset, (int (*) (x264_param_t *, const char *preset, const char *tune)), libx264);
+
+ dl_sym(x264_param_apply_profile, (int (*) (x264_param_t *, const char *profile)), libx264);
+
+ dl_sym(x264_param_apply_fastfirstpass, (void (*) (x264_param_t *)), libx264);
+
+ dl_sym(x264_encoder_headers, (int (*) (x264_t *, x264_nal_t **, int *)), libx264);
+
+ ptr = (int *) dlsym(libx264, "x264_bit_depth");
+ dl_x264_bit_depth = *ptr;
+
+ return 0;
+
+error:
+ av_log(avctx, AV_LOG_FATAL, "libx264: Missing symbols in %s: %s\n"
+ "x264 support disabled\n", X264_LIB, err);
+ dlclose(libx264);
+ return 1;
+}
+#endif
+
typedef struct X264Context {
AVClass *class;
x264_param_t params;
@@ -468,6 +582,11 @@ static av_cold int X264_init(AVCodecCont
if (avctx->global_quality > 0)
av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n");
+#ifdef CONFIG_LIBX264_DLOPEN
+ if (loadLibX264(avctx))
+ return -1;
+#endif
+
#if CONFIG_LIBX262_ENCODER
if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
x4->params.b_mpeg2 = 1;
Index: ffmpeg-4.1.3/libavcodec/libx265.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libx265.c
+++ ffmpeg-4.1.3/libavcodec/libx265.c
@@ -34,6 +34,39 @@
#include "avcodec.h"
#include "internal.h"
+#ifdef CONFIG_LIBX265_DLOPEN
+#include "dlopen.h"
+#define X265_BUILD_str num2str(X265_BUILD)
+#define X265_LIB "libx265.so." X265_BUILD_str
+#undef x265_api_get
+typedef const x265_api* (*x265_api_func)(int);
+x265_api_func dl_x265_api_get = NULL;
+#define x265_api_get dl_x265_api_get
+
+static int loadLibX265();
+static int loadLibX265() {
+ const char *err = NULL;
+ void *libx265 = NULL;
+ int *ptr;
+
+ libx265 = dlopen(X265_LIB, RTLD_LAZY);
+ if ((err = dlerror())) {
+ fprintf(stderr, "%s\n%s is missing, x265 support will be disabled\n", err, X265_LIB);
+ if(libx265)
+ dlclose(libx265);
+ return 1;
+ }
+
+ x265_api_get=(x265_api_func)dlsym(libx265, "x265_api_get_" num2str(X265_BUILD));
+ if(!x265_api_get) {
+ fprintf(stderr, "No x265_api_get_" num2str(X265_BUILD) " in " X265_LIB "\n");
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
typedef struct libx265Context {
const AVClass *class;
@@ -417,6 +450,10 @@ static const enum AVPixelFormat x265_csp
static av_cold void libx265_encode_init_csp(AVCodec *codec)
{
+#ifdef CONFIG_LIBX265_DLOPEN
+ if (loadLibX265())
+ return;
+#endif
if (x265_api_get(12))
codec->pix_fmts = x265_csp_twelve;
else if (x265_api_get(10))
Index: ffmpeg-4.1.3/libavcodec/libxvid.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/libxvid.c
+++ ffmpeg-4.1.3/libavcodec/libxvid.c
@@ -51,6 +51,61 @@
#include <io.h>
#endif
+#ifdef CONFIG_LIBXVID_DLOPEN
+#include "dlopen.h"
+
+static int (*dl_xvid_encore) (void *handle, int opt, void *param1, void *param2);
+static int (*dl_xvid_global) (void *handle, int opt, void *param1, void *param2);
+static int (*dl_xvid_plugin_single) (void *handle, int opt, void *param1, void *param2);
+static int (*dl_xvid_plugin_lumimasking) (void *handle, int opt, void *param1, void *param2);
+static int (*dl_xvid_plugin_ssim) (void *handle, int opt, void *param1, void *param2);
+static int (*dl_xvid_plugin_2pass2) (void *handle, int opt, void *param1, void *param2);
+
+#define xvid_encore dl_xvid_encore
+#define xvid_global dl_xvid_global
+#define xvid_plugin_single dl_xvid_plugin_single
+#define xvid_plugin_lumimasking dl_xvid_plugin_lumimasking
+#define xvid_plugin_ssim dl_xvid_plugin_ssim
+#define xvid_plugin_2pass2 dl_xvid_plugin_2pass2
+#define XVID_LIB "libxvidcore.so.4"
+
+static int loadLibXVID(AVCodecContext *avctx);
+static int loadLibXVID(AVCodecContext *avctx) {
+ void *libxvid = NULL;
+ const char *err = NULL;
+
+ libxvid = dlopen(XVID_LIB, RTLD_LAZY);
+ if ((err = dlerror())) {
+ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, libxvid support will be disabled\n", err, XVID_LIB);
+
+ if (libxvid)
+ dlclose(libxvid);
+ return 1;
+ }
+
+ dl_sym(xvid_encore, (int (*) (void *handle, int opt, void *param1, void *param2)), libxvid);
+
+ dl_sym(xvid_global, (int (*) (void *handle, int opt, void *param1, void *param2)), libxvid);
+
+ dl_sym(xvid_plugin_single, (int (*) (void *handle, int opt, void *param1, void *param2)), libxvid);
+
+ dl_sym(xvid_plugin_lumimasking, (int (*) (void *handle, int opt, void *param1, void *param2)), libxvid);
+
+ dl_sym(xvid_plugin_ssim, (int (*) (void *handle, int opt, void *param1, void *param2)), libxvid);
+
+ dl_sym(xvid_plugin_2pass2, (int (*) (void *handle, int opt, void *param1, void *param2)), libxvid);
+
+ return 0;
+
+error:
+ av_log(avctx, AV_LOG_FATAL, "libxvid: Missing symbols in %s: %s "
+ "libxvid support disabled\n", XVID_LIB, err);
+ dlclose(libxvid);
+
+ return 1;
+}
+#endif
+
/**
* Buffer management macros.
*/
@@ -388,6 +443,11 @@ static av_cold int xvid_encode_init(AVCo
xvid_enc_create_t xvid_enc_create = { 0 };
xvid_enc_plugin_t plugins[4];
+#ifdef CONFIG_LIBXVID_DLOPEN
+ if (loadLibXVID(avctx))
+ return -1;
+#endif
+
x->twopassfd = -1;
/* Bring in VOP flags from ffmpeg command-line */

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Jun 11 11:12:43 UTC 2019 - Ismail Dönmez <idonmez@suse.com>
- Add ffmpeg-4.1-dlopen-faac-mp3lame-opencore-x264-x265-xvid.patch
from OpenMandriva to optionally enable runtime enabling of
fdkaac/lame/x264/x265
- Enable runtime enabling for fdkaac via --enable-libfdk-aac-dlopen
-------------------------------------------------------------------
Tue May 14 11:38:01 UTC 2019 - Martin Liška <mliska@suse.cz>

View File

@ -117,6 +117,8 @@ Patch3: ffmpeg-new-coder-errors.diff
Patch4: ffmpeg-codec-choice.diff
# dav1d added https://patchwork.ffmpeg.org/patch/10843/
Patch6: ffmpeg-avcodec-libdav1d-AV1-decoder-wrapper.patch
# https://github.com/OpenMandrivaAssociation/ffmpeg/blob/master/ffmpeg-4.1-dlopen-faac-mp3lame-opencore-x264-x265-xvid.patch
Patch7: ffmpeg-4.1-dlopen-faac-mp3lame-opencore-x264-x265-xvid.patch
BuildRequires: ladspa-devel
BuildRequires: libgsm-devel
BuildRequires: libmp3lame-devel
@ -668,7 +670,7 @@ LDFLAGS="%_lto_cflags" \
--enable-vaapi \
--enable-vdpau \
%if %{with fdk_aac}
--enable-libfdk_aac \
--enable-libfdk-aac-dlopen \
--enable-nonfree \
%endif
%if %{with opencore}

View File

@ -2,10 +2,10 @@
libavutil/arm/timer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: ffmpeg-3.0.1/libavutil/arm/timer.h
Index: ffmpeg-4.1.3/libavutil/arm/timer.h
===================================================================
--- ffmpeg-3.0.1.orig/libavutil/arm/timer.h
+++ ffmpeg-3.0.1/libavutil/arm/timer.h
--- ffmpeg-4.1.3.orig/libavutil/arm/timer.h
+++ ffmpeg-4.1.3/libavutil/arm/timer.h
@@ -24,7 +24,7 @@
#include <stdint.h>
#include "config.h"

View File

@ -1,7 +1,7 @@
diff --git a/configure b/configure
index 01c3a1011d..e56b925065 100755
--- a/configure
+++ b/configure
Index: ffmpeg-4.1.3/configure
===================================================================
--- ffmpeg-4.1.3.orig/configure
+++ ffmpeg-4.1.3/configure
@@ -226,6 +226,7 @@ External library support:
--enable-libcelt enable CELT decoding via libcelt [no]
--enable-libcdio enable audio CD grabbing with libcdio [no]
@ -18,7 +18,7 @@ index 01c3a1011d..e56b925065 100755
libdc1394
libdrm
libflite
@@ -3088,6 +3090,7 @@ libaom_av1_encoder_select="extract_extradata_bsf"
@@ -3091,6 +3093,7 @@ libaom_av1_encoder_select="extract_extra
libcelt_decoder_deps="libcelt"
libcodec2_decoder_deps="libcodec2"
libcodec2_encoder_deps="libcodec2"
@ -26,7 +26,7 @@ index 01c3a1011d..e56b925065 100755
libdavs2_decoder_deps="libdavs2"
libfdk_aac_decoder_deps="libfdk_aac"
libfdk_aac_encoder_deps="libfdk_aac"
@@ -6064,6 +6067,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 &&
@@ -6069,6 +6072,7 @@ enabled libcelt && require lib
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas
enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2
@ -34,11 +34,11 @@ index 01c3a1011d..e56b925065 100755
enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.5.115" davs2.h davs2_decoder_open
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3e41497e34..8643da8f2b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -956,6 +956,7 @@ OBJS-$(CONFIG_LIBAOM_AV1_ENCODER) += libaomenc.o
Index: ffmpeg-4.1.3/libavcodec/Makefile
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/Makefile
+++ ffmpeg-4.1.3/libavcodec/Makefile
@@ -956,6 +956,7 @@ OBJS-$(CONFIG_LIBAOM_AV1_ENCODER)
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o codec2utils.o
OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o codec2utils.o
@ -46,12 +46,11 @@ index 3e41497e34..8643da8f2b 100644
OBJS-$(CONFIG_LIBDAVS2_DECODER) += libdavs2.o
OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o
OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
new file mode 100644
index 0000000000..873adfda40
Index: ffmpeg-4.1.3/libavcodec/libdav1d.c
===================================================================
--- /dev/null
+++ b/libavcodec/libdav1d.c
@@ -0,0 +1,270 @@
+++ ffmpeg-4.1.3/libavcodec/libdav1d.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2018 Ronald S. Bultje <rsbultje gmail com>
+ * Copyright (c) 2018 James Almer <jamrial gmail com>
@ -76,7 +75,6 @@ index 0000000000..873adfda40
+#include <dav1d/dav1d.h>
+
+#include "libavutil/avassert.h"
+#include "libavutil/fifo.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
@ -87,7 +85,6 @@ index 0000000000..873adfda40
+ AVClass *class;
+ Dav1dContext *c;
+
+ AVFifoBuffer *cache;
+ Dav1dData data;
+ int tile_threads;
+} Libdav1dContext;
@ -104,10 +101,6 @@ index 0000000000..873adfda40
+ s.n_tile_threads = dav1d->tile_threads;
+ s.n_frame_threads = FFMIN(c->thread_count ? c->thread_count : av_cpu_count(), 256);
+
+ dav1d->cache = av_fifo_alloc(8 * sizeof(AVPacket));
+ if (!dav1d->cache)
+ return AVERROR(ENOMEM);
+
+ res = dav1d_open(&dav1d->c, &s);
+ if (res < 0)
+ return AVERROR(ENOMEM);
@ -119,23 +112,10 @@ index 0000000000..873adfda40
+{
+ Libdav1dContext *dav1d = c->priv_data;
+
+ av_fifo_reset(dav1d->cache);
+ dav1d_data_unref(&dav1d->data);
+ dav1d_flush(dav1d->c);
+}
+
+static int libdav1d_fifo_write(void *src, void *dst, int dst_size) {
+ AVPacket *pkt_dst = dst, *pkt_src = src;
+
+ av_assert2(dst_size >= sizeof(AVPacket));
+
+ pkt_src->buf = NULL;
+ av_packet_free_side_data(pkt_src);
+ *pkt_dst = *pkt_src;
+
+ return sizeof(AVPacket);
+}
+
+static void libdav1d_data_free(const uint8_t *data, void *opaque) {
+ AVBufferRef *buf = opaque;
+
@ -169,37 +149,41 @@ index 0000000000..873adfda40
+{
+ Libdav1dContext *dav1d = c->priv_data;
+ Dav1dData *data = &dav1d->data;
+ AVPacket pkt = { 0 };
+ Dav1dPicture p = { 0 };
+ int res;
+
+ if (!data->sz) {
+ AVPacket pkt = { 0 };
+
+ res = ff_decode_get_packet(c, &pkt);
+ if (res < 0 && res != AVERROR_EOF)
+ return res;
+
+ if (pkt.size) {
+ if (!av_fifo_space(dav1d->cache)) {
+ res = av_fifo_grow(dav1d->cache, 8 * sizeof(pkt));
+ if (res < 0) {
+ av_packet_unref(&pkt);
+ return res;
+ }
+ }
+
+ res = dav1d_data_wrap(data, pkt.data, pkt.size, libdav1d_data_free, pkt.buf);
+ if (res < 0) {
+ av_packet_unref(&pkt);
+ return res;
+ }
+
+ av_fifo_generic_write(dav1d->cache, &pkt, sizeof(pkt), libdav1d_fifo_write);
+ } else {
+ data = NULL;
+ data->m.timestamp = pkt.pts;
+ data->m.offset = pkt.pos;
+ data->m.duration = pkt.duration;
+
+ pkt.buf = NULL;
+ av_packet_unref(&pkt);
+ }
+ }
+
+ res = dav1d_decode(dav1d->c, data, &p);
+ res = dav1d_send_data(dav1d->c, data);
+ if (res < 0) {
+ if (res == -EINVAL)
+ res = AVERROR_INVALIDDATA;
+ if (res != -EAGAIN)
+ return res;
+ }
+
+ res = dav1d_get_picture(dav1d->c, &p);
+ if (res < 0) {
+ if (res == -EINVAL)
+ res = AVERROR_INVALIDDATA;
@ -211,8 +195,6 @@ index 0000000000..873adfda40
+
+ av_assert0(p.data[0] != NULL);
+
+ av_fifo_generic_read(dav1d->cache, &pkt, sizeof(pkt), NULL);
+
+ frame->buf[0] = av_buffer_create(NULL, 0, libdav1d_frame_free,
+ p.ref, AV_BUFFER_FLAG_READONLY);
+ if (!frame->buf[0]) {
@ -237,7 +219,7 @@ index 0000000000..873adfda40
+ return res;
+ }
+
+ switch (p.p.chr) {
+ switch (p.seq_hdr->chr) {
+ case DAV1D_CHR_VERTICAL:
+ frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT;
+ break;
@ -245,25 +227,25 @@ index 0000000000..873adfda40
+ frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
+ break;
+ }
+ frame->colorspace = c->colorspace = (enum AVColorSpace) p.p.mtrx;
+ frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p.p.pri;
+ frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p.p.trc;
+ frame->color_range = c->color_range = p.p.fullrange ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
+ frame->colorspace = c->colorspace = (enum AVColorSpace) p.seq_hdr->mtrx;
+ frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p.seq_hdr->pri;
+ frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p.seq_hdr->trc;
+ frame->color_range = c->color_range = p.seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
+
+ // match timestamps and packet size
+ frame->pts = frame->best_effort_timestamp = pkt.pts;
+ frame->pts = frame->best_effort_timestamp = p.m.timestamp;
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
+ frame->pkt_pts = pkt.pts;
+ frame->pkt_pts = p.m.timestamp;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ frame->pkt_dts = pkt.dts;
+ frame->pkt_pos = pkt.pos;
+ frame->pkt_size = pkt.size;
+ frame->pkt_duration = pkt.duration;
+ frame->key_frame = p.p.type == DAV1D_FRAME_TYPE_KEY;
+ frame->pkt_dts = p.m.timestamp;
+ frame->pkt_pos = p.m.offset;
+ frame->pkt_size = p.m.size;
+ frame->pkt_duration = p.m.duration;
+ frame->key_frame = p.frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
+
+ switch (p.p.type) {
+ switch (p.frame_hdr->frame_type) {
+ case DAV1D_FRAME_TYPE_KEY:
+ case DAV1D_FRAME_TYPE_INTRA:
+ frame->pict_type = AV_PICTURE_TYPE_I;
@ -285,7 +267,6 @@ index 0000000000..873adfda40
+{
+ Libdav1dContext *dav1d = c->priv_data;
+
+ av_fifo_freep(&dav1d->cache);
+ dav1d_data_unref(&dav1d->data);
+ dav1d_close(&dav1d->c);
+
@ -322,220 +303,11 @@ index 0000000000..873adfda40
+ .priv_class = &libdav1d_class,
+ .wrapper_name = "libdav1d",
+};
From 752659327d4ac73640781376d214a26765f971f4 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Wed, 14 Nov 2018 10:05:25 -0300
Subject: [PATCH] avcodec/libdav1d: fix build after a recent API break
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/libdav1d.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 873adfda403..b19aee4e9ed 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -140,12 +140,18 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
}
av_fifo_generic_write(dav1d->cache, &pkt, sizeof(pkt), libdav1d_fifo_write);
- } else {
- data = NULL;
}
}
- res = dav1d_decode(dav1d->c, data, &p);
+ res = dav1d_send_data(dav1d->c, data);
+ if (res < 0) {
+ if (res == -EINVAL)
+ res = AVERROR_INVALIDDATA;
+ if (res != -EAGAIN)
+ return res;
+ }
+
+ res = dav1d_get_picture(dav1d->c, &p);
if (res < 0) {
if (res == -EINVAL)
res = AVERROR_INVALIDDATA;
From cc25529420e3c559fcb4c7a993f112983da7d397 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Sun, 25 Nov 2018 17:28:53 -0300
Subject: [PATCH] avcodec/libdav1d: update the API usage after upstream changes
The color fields were moved to another struct, and a way to propagate
timestamps and other input metadata was introduced, so the packet fifo
can be removed.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/libdav1d.c | 66 ++++++++++++++-----------------------------
1 file changed, 21 insertions(+), 45 deletions(-)
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index b19aee4e9ed..d927f11a9e9 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -22,7 +22,6 @@
#include <dav1d/dav1d.h>
#include "libavutil/avassert.h"
-#include "libavutil/fifo.h"
#include "libavutil/opt.h"
#include "avcodec.h"
@@ -33,7 +32,6 @@ typedef struct Libdav1dContext {
AVClass *class;
Dav1dContext *c;
- AVFifoBuffer *cache;
Dav1dData data;
int tile_threads;
} Libdav1dContext;
@@ -50,10 +48,6 @@ static av_cold int libdav1d_init(AVCodecContext *c)
s.n_tile_threads = dav1d->tile_threads;
s.n_frame_threads = FFMIN(c->thread_count ? c->thread_count : av_cpu_count(), 256);
- dav1d->cache = av_fifo_alloc(8 * sizeof(AVPacket));
- if (!dav1d->cache)
- return AVERROR(ENOMEM);
-
res = dav1d_open(&dav1d->c, &s);
if (res < 0)
return AVERROR(ENOMEM);
@@ -65,23 +59,10 @@ static void libdav1d_flush(AVCodecContext *c)
{
Libdav1dContext *dav1d = c->priv_data;
- av_fifo_reset(dav1d->cache);
dav1d_data_unref(&dav1d->data);
dav1d_flush(dav1d->c);
}
-static int libdav1d_fifo_write(void *src, void *dst, int dst_size) {
- AVPacket *pkt_dst = dst, *pkt_src = src;
-
- av_assert2(dst_size >= sizeof(AVPacket));
-
- pkt_src->buf = NULL;
- av_packet_free_side_data(pkt_src);
- *pkt_dst = *pkt_src;
-
- return sizeof(AVPacket);
-}
-
static void libdav1d_data_free(const uint8_t *data, void *opaque) {
AVBufferRef *buf = opaque;
@@ -115,31 +96,29 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
{
Libdav1dContext *dav1d = c->priv_data;
Dav1dData *data = &dav1d->data;
- AVPacket pkt = { 0 };
Dav1dPicture p = { 0 };
int res;
if (!data->sz) {
+ AVPacket pkt = { 0 };
+
res = ff_decode_get_packet(c, &pkt);
if (res < 0 && res != AVERROR_EOF)
return res;
if (pkt.size) {
- if (!av_fifo_space(dav1d->cache)) {
- res = av_fifo_grow(dav1d->cache, 8 * sizeof(pkt));
- if (res < 0) {
- av_packet_unref(&pkt);
- return res;
- }
- }
-
res = dav1d_data_wrap(data, pkt.data, pkt.size, libdav1d_data_free, pkt.buf);
if (res < 0) {
av_packet_unref(&pkt);
return res;
}
- av_fifo_generic_write(dav1d->cache, &pkt, sizeof(pkt), libdav1d_fifo_write);
+ data->m.timestamp = pkt.pts;
+ data->m.offset = pkt.pos;
+ data->m.duration = pkt.duration;
+
+ pkt.buf = NULL;
+ av_packet_unref(&pkt);
}
}
@@ -163,8 +142,6 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
av_assert0(p.data[0] != NULL);
- av_fifo_generic_read(dav1d->cache, &pkt, sizeof(pkt), NULL);
-
frame->buf[0] = av_buffer_create(NULL, 0, libdav1d_frame_free,
p.ref, AV_BUFFER_FLAG_READONLY);
if (!frame->buf[0]) {
@@ -189,7 +166,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
return res;
}
- switch (p.p.chr) {
+ switch (p.seq_hdr->chr) {
case DAV1D_CHR_VERTICAL:
frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT;
break;
@@ -197,25 +174,25 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
break;
}
- frame->colorspace = c->colorspace = (enum AVColorSpace) p.p.mtrx;
- frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p.p.pri;
- frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p.p.trc;
- frame->color_range = c->color_range = p.p.fullrange ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
+ frame->colorspace = c->colorspace = (enum AVColorSpace) p.seq_hdr->mtrx;
+ frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p.seq_hdr->pri;
+ frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p.seq_hdr->trc;
+ frame->color_range = c->color_range = p.seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
// match timestamps and packet size
- frame->pts = frame->best_effort_timestamp = pkt.pts;
+ frame->pts = frame->best_effort_timestamp = p.m.timestamp;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
- frame->pkt_pts = pkt.pts;
+ frame->pkt_pts = p.m.timestamp;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- frame->pkt_dts = pkt.dts;
- frame->pkt_pos = pkt.pos;
- frame->pkt_size = pkt.size;
- frame->pkt_duration = pkt.duration;
- frame->key_frame = p.p.type == DAV1D_FRAME_TYPE_KEY;
+ frame->pkt_dts = p.m.timestamp;
+ frame->pkt_pos = p.m.offset;
+ frame->pkt_size = p.m.size;
+ frame->pkt_duration = p.m.duration;
+ frame->key_frame = p.frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
- switch (p.p.type) {
+ switch (p.frame_hdr->frame_type) {
case DAV1D_FRAME_TYPE_KEY:
case DAV1D_FRAME_TYPE_INTRA:
frame->pict_type = AV_PICTURE_TYPE_I;
@@ -237,7 +214,6 @@ static av_cold int libdav1d_close(AVCodecContext *c)
{
Libdav1dContext *dav1d = c->priv_data;
- av_fifo_freep(&dav1d->cache);
dav1d_data_unref(&dav1d->data);
dav1d_close(&dav1d->c);
--- orig-ffmpeg-4.1.1/libavcodec/allcodecs.c 2019-02-09 21:56:02.000000000 +0100
+++ ffmpeg-4.1.1/libavcodec/allcodecs.c 2019-03-18 23:27:28.701284908 +0100
@@ -671,6 +671,7 @@
Index: ffmpeg-4.1.3/libavcodec/allcodecs.c
===================================================================
--- ffmpeg-4.1.3.orig/libavcodec/allcodecs.c
+++ ffmpeg-4.1.3/libavcodec/allcodecs.c
@@ -671,6 +671,7 @@ extern AVCodec ff_pcm_mulaw_at_encoder;
extern AVCodec ff_pcm_mulaw_at_decoder;
extern AVCodec ff_qdmc_at_decoder;
extern AVCodec ff_qdm2_at_decoder;
@ -543,4 +315,3 @@ index b19aee4e9ed..d927f11a9e9 100644
extern AVCodec ff_libaom_av1_decoder;
extern AVCodec ff_libaom_av1_encoder;
extern AVCodec ff_libcelt_decoder;

View File

@ -11,10 +11,10 @@ reduced codec selection list.
libavformat/matroskaenc.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
Index: ffmpeg-4.1/libavformat/matroskaenc.c
Index: ffmpeg-4.1.3/libavformat/matroskaenc.c
===================================================================
--- ffmpeg-4.1.orig/libavformat/matroskaenc.c
+++ ffmpeg-4.1/libavformat/matroskaenc.c
--- ffmpeg-4.1.3.orig/libavformat/matroskaenc.c
+++ ffmpeg-4.1.3/libavformat/matroskaenc.c
@@ -2807,16 +2807,24 @@ static const AVClass matroska_class = {
.version = LIBAVUTIL_VERSION_INT,
};

View File

@ -10,10 +10,10 @@ Improve the error messages a bit to say what's really going on
fftools/ffmpeg_opt.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
Index: ffmpeg-4.1.1/fftools/ffmpeg.c
Index: ffmpeg-4.1.3/fftools/ffmpeg.c
===================================================================
--- ffmpeg-4.1.1.orig/fftools/ffmpeg.c 2019-02-09 21:56:07.000000000 +0100
+++ ffmpeg-4.1.1/fftools/ffmpeg.c 2019-03-01 09:04:20.287182857 +0100
--- ffmpeg-4.1.3.orig/fftools/ffmpeg.c
+++ ffmpeg-4.1.3/fftools/ffmpeg.c
@@ -2906,7 +2906,7 @@ static int init_input_stream(int ist_ind
if (ist->decoding_needed) {
AVCodec *codec = ist->dec;
@ -23,10 +23,10 @@ Index: ffmpeg-4.1.1/fftools/ffmpeg.c
avcodec_get_name(ist->dec_ctx->codec_id), ist->file_index, ist->st->index);
return AVERROR(EINVAL);
}
Index: ffmpeg-4.1.1/fftools/ffmpeg_filter.c
Index: ffmpeg-4.1.3/fftools/ffmpeg_filter.c
===================================================================
--- ffmpeg-4.1.1.orig/fftools/ffmpeg_filter.c 2019-02-09 21:56:02.000000000 +0100
+++ ffmpeg-4.1.1/fftools/ffmpeg_filter.c 2019-03-01 09:04:20.287182857 +0100
--- ffmpeg-4.1.3.orig/fftools/ffmpeg_filter.c
+++ ffmpeg-4.1.3/fftools/ffmpeg_filter.c
@@ -973,7 +973,7 @@ static int configure_input_filter(Filter
{
if (!ifilter->ist->dec) {
@ -45,10 +45,10 @@ Index: ffmpeg-4.1.1/fftools/ffmpeg_filter.c
avcodec_get_name(ost->st->codecpar->codec_id), ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto fail;
Index: ffmpeg-4.1.1/fftools/ffmpeg_opt.c
Index: ffmpeg-4.1.3/fftools/ffmpeg_opt.c
===================================================================
--- ffmpeg-4.1.1.orig/fftools/ffmpeg_opt.c 2019-02-09 21:56:02.000000000 +0100
+++ ffmpeg-4.1.1/fftools/ffmpeg_opt.c 2019-03-01 09:04:20.287182857 +0100
--- ffmpeg-4.1.3.orig/fftools/ffmpeg_opt.c
+++ ffmpeg-4.1.3/fftools/ffmpeg_opt.c
@@ -1306,7 +1306,7 @@ static int choose_encoder(OptionsContext
if (!ost->enc) {
av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for "