multimedia/ffmpeg: fork 4.* into a pinned port

Mainly for leaf consumers: applications but not plugins or libraries.
Otherwise, indirectly mixing different versions of ffmpeg libraries at
runtime can lead to crashes.

To use simply add the following before <bsd.port.mk> or <bsd.port.pre.mk>

  .include "${.CURDIR:H:H}/multimedia/ffmpeg4/override.mk"

PR:		261302
Inspired by:	c717faa5c7
This commit is contained in:
Jan Beich
2023-03-17 20:59:23 +00:00
parent 1d6031f987
commit f0dadc529f
17 changed files with 2497 additions and 0 deletions
+1
View File
@@ -60,6 +60,7 @@
SUBDIR += ffaudioconverter
SUBDIR += ffdec
SUBDIR += ffmpeg
SUBDIR += ffmpeg4
SUBDIR += ffmpegthumbnailer
SUBDIR += ffms2
SUBDIR += ffnvcodec-headers
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
TIMESTAMP = 1665342284
SHA256 (ffmpeg-4.4.3.tar.xz) = 6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
SIZE (ffmpeg-4.4.3.tar.xz) = 9566020
SHA256 (0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch) = 376ea23e9d876390fbca936c80cb437bb9daa6232ff65df0ea91673e18b739ff
SIZE (0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch) = 24259
SHA256 (0002-doc-Add-libsvt_hevc-encoder-docs.patch) = d16589efc4be2602a9f436e9938cfee0cc7b5ccd7a4a6b41c0c9a59ae0859fda
SIZE (0002-doc-Add-libsvt_hevc-encoder-docs.patch) = 5336
SHA256 (master-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch) = b7d722dfce20b73e9d5c73d55ffe041bbdc92a3c4a5c5d766b6b3040671b4052
SIZE (master-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch) = 33497
+26
View File
@@ -0,0 +1,26 @@
--- configure.orig 2022-10-09 19:04:43 UTC
+++ configure
@@ -3784,13 +3784,7 @@ host_os=$target_os_default
host_os=$target_os_default
# machine
-if test "$target_os_default" = aix; then
- arch_default=$(uname -p)
- strip_default="strip -X32_64"
- nm_default="nm -g -X32_64"
-else
- arch_default=$(uname -m)
-fi
+arch_default=$(uname -p)
cpu="generic"
intrinsics="none"
@@ -6758,7 +6752,7 @@ if enabled x86; then
if enabled x86; then
case $target_os in
- mingw32*|mingw64*|win32|win64|linux|cygwin*)
+ freebsd|mingw32*|mingw64*|win32|win64|linux|cygwin*)
;;
*)
disable ffnvcodec cuvid nvdec nvenc
@@ -0,0 +1,11 @@
--- doc/Makefile.orig 2015-06-19 20:44:35 UTC
+++ doc/Makefile
@@ -145,7 +145,7 @@ install-html: $(HTMLPAGES)
endif
ifdef CONFIG_MANPAGES
-install-progs-$(CONFIG_DOC): install-man
+#install-progs-$(CONFIG_DOC): install-man
install-man: $(MANPAGES)
$(Q)mkdir -p "$(MANDIR)/man1"
@@ -0,0 +1,18 @@
- ioctl() prototype on BSDs follows Version 7 AT&T UNIX
--- libavdevice/v4l2.c.orig 2019-04-21 04:37:17 UTC
+++ libavdevice/v4l2.c
@@ -95,10 +95,10 @@ struct video_data {
int (*open_f)(const char *file, int oflag, ...);
int (*close_f)(int fd);
int (*dup_f)(int fd);
-#ifdef __GLIBC__
- int (*ioctl_f)(int fd, unsigned long int request, ...);
-#else
+#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
int (*ioctl_f)(int fd, int request, ...);
+#else
+ int (*ioctl_f)(int fd, unsigned long int request, ...);
#endif
ssize_t (*read_f)(int fd, void *buffer, size_t n);
void *(*mmap_f)(void *start, size_t length, int prot, int flags, int fd, int64_t offset);
@@ -0,0 +1,51 @@
Partially revert https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/8b78eb312de9
until graphics/lensfun is updated to a version that contains
https://github.com/lensfun/lensfun/commit/b135e05d729d
--- libavfilter/vf_lensfun.c.orig 2021-04-08 21:28:40 UTC
+++ libavfilter/vf_lensfun.c
@@ -222,20 +222,39 @@ static int config_props(AVFilterLink *inlink)
if (!lensfun->modifier) {
if (lensfun->camera && lensfun->lens) {
- lensfun->modifier = lf_modifier_create(lensfun->lens,
+ lensfun->modifier = lf_modifier_create(
+#if (LF_VERSION > 0x35F00)
+ lensfun->lens,
lensfun->focal_length,
+#endif
lensfun->camera->CropFactor,
inlink->w,
inlink->h, LF_PF_U8, lensfun->reverse);
if (lensfun->mode & VIGNETTING)
- lf_modifier_enable_vignetting_correction(lensfun->modifier, lensfun->aperture, lensfun->focus_distance);
+ lf_modifier_enable_vignetting_correction(lensfun->modifier,
+#if (LF_VERSION <= 0x35F00)
+ lensfun->lens, lensfun->focal_length,
+#endif
+ lensfun->aperture, lensfun->focus_distance);
if (lensfun->mode & GEOMETRY_DISTORTION) {
- lf_modifier_enable_distortion_correction(lensfun->modifier);
- lf_modifier_enable_projection_transform(lensfun->modifier, lensfun->target_geometry);
+ lf_modifier_enable_distortion_correction(lensfun->modifier,
+#if (LF_VERSION <= 0x35F00)
+ lensfun->lens, lensfun->focal_length
+#endif
+ );
+ lf_modifier_enable_projection_transform(lensfun->modifier,
+#if (LF_VERSION <= 0x35F00)
+ lensfun->lens, lensfun->focal_length,
+#endif
+ lensfun->target_geometry);
lf_modifier_enable_scaling(lensfun->modifier, lensfun->scale);
}
if (lensfun->mode & SUBPIXEL_DISTORTION)
- lf_modifier_enable_tca_correction(lensfun->modifier);
+ lf_modifier_enable_tca_correction(lensfun->modifier,
+#if (LF_VERSION <= 0x35F00)
+ lensfun->lens, lensfun->focal_length
+#endif
+ );
} else {
// lensfun->camera and lensfun->lens should have been initialized
return AVERROR_BUG;
@@ -0,0 +1,44 @@
--- libavformat/rtsp.c.orig 2016-10-27 16:17:40 UTC
+++ libavformat/rtsp.c
@@ -1614,7 +1614,12 @@ int ff_rtsp_make_setup_request(AVFormatC
}
if (ttl > 0)
snprintf(optbuf, sizeof(optbuf), "?ttl=%d", ttl);
- getnameinfo((struct sockaddr*) &addr, sizeof(addr),
+ getnameinfo((struct sockaddr*) &addr,
+#if HAVE_STRUCT_SOCKADDR_SA_LEN
+ ((struct sockaddr*) &addr)->sa_len,
+#else
+ sizeof(addr),
+#endif
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
ff_url_join(url, sizeof(url), "rtp", NULL, namebuf,
port, "%s", optbuf);
@@ -1830,8 +1835,13 @@ redirect:
goto fail;
}
if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) {
- getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host),
- NULL, 0, NI_NUMERICHOST);
+ getnameinfo((struct sockaddr*) &peer,
+#if HAVE_STRUCT_SOCKADDR_SA_LEN
+ ((struct sockaddr*) &peer)->sa_len,
+#else
+ peer_len,
+#endif
+ host, sizeof(host), NULL, 0, NI_NUMERICHOST);
}
/* request options supported by the server; this also detects server
@@ -2310,7 +2320,11 @@ static int sdp_read_header(AVFormatConte
AVDictionary *opts = map_to_opts(rt);
err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip,
+#if HAVE_STRUCT_SOCKADDR_SA_LEN
+ ((struct sockaddr*) &rtsp_st->sdp_ip)->sa_len,
+#else
sizeof(rtsp_st->sdp_ip),
+#endif
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
if (err) {
av_log(s, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(err));
@@ -0,0 +1,13 @@
--- libavutil/common.h.orig 2015-06-19 20:44:53 UTC
+++ libavutil/common.h
@@ -49,6 +49,10 @@
# define AV_NE(be, le) (le)
#endif
+#ifndef UINT64_C
+#define UINT64_C(c) (c ## UL)
+#endif
+
//rounded division & shift
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
/* assume b>0 */
@@ -0,0 +1,11 @@
--- libavutil/x86/asm.h.orig 2015-06-19 20:44:54 UTC
+++ libavutil/x86/asm.h
@@ -71,7 +71,7 @@ typedef int32_t x86_reg;
typedef int x86_reg;
#endif
-#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
+#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE && !defined(__clang__)))
#define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
#if ARCH_X86_64 && defined(PIC)
@@ -0,0 +1,24 @@
drm-kmod doesn't expose uAPI yet, so bundle like Mesa
--- libavutil/hwcontext_drm.c.orig 2022-07-22 17:58:39 UTC
+++ libavutil/hwcontext_drm.c
@@ -28,6 +28,19 @@
#if HAVE_LINUX_DMA_BUF_H
#include <linux/dma-buf.h>
#include <sys/ioctl.h>
+#else // BSDs
+#undef HAVE_LINUX_DMA_BUF_H
+#define HAVE_LINUX_DMA_BUF_H 1
+#include <sys/ioctl.h>
+struct dma_buf_sync {
+ uint64_t flags;
+};
+#define DMA_BUF_BASE 'b'
+#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
+#define DMA_BUF_SYNC_READ (1 << 0)
+#define DMA_BUF_SYNC_WRITE (2 << 0)
+#define DMA_BUF_SYNC_START (0 << 2)
+#define DMA_BUF_SYNC_END (1 << 2)
#endif
#include <drm.h>
@@ -0,0 +1,15 @@
Error:
libswscale/ppc/yuv2rgb_altivec.c:288:36: error: redeclaration of 'vec_xl' must have the 'overloadable' attribute
static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr)
--- libswscale/ppc/yuv2rgb_altivec.c.orig 2021-04-08 21:28:40 UTC
+++ libswscale/ppc/yuv2rgb_altivec.c
@@ -284,7 +284,7 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector s
* ------------------------------------------------------------------------------
*/
-#if !HAVE_VSX
+#if !HAVE_VSX && !defined(__clang__)
static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr)
{
const vector unsigned char *v_addr = (const vector unsigned char *) (addr + offset);
+437
View File
@@ -0,0 +1,437 @@
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/04b89e8ae33b
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/64e2fb3f9d89
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0463f5d6d56d
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/c5f314309067
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/c33b4048859a
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/a2b090da7932
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/1dddb930aaf0
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/4e47ebf38b97
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/50bc87263576
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/d794b36a7788
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/6fd1533057ff
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/ded0334d214f
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/70887d44ffa3
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/fe100bc556d7
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/fb70e0611bd7
--- configure.orig 2021-10-24 20:47:11 UTC
+++ configure
@@ -6430,7 +6430,7 @@ enabled libsrt && require_pkg_config libsrt
enabled libssh && require_pkg_config libssh libssh libssh/sftp.h sftp_init
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.8.4" EbSvtAv1Enc.h svt_av1_enc_init_handle
+enabled libsvtav1 && require_pkg_config libsvtav1 "SvtAv1Enc >= 0.9.0" EbSvtAv1Enc.h svt_av1_enc_init_handle
enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h TF_Version -ltensorflow
enabled libtesseract && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
--- doc/encoders.texi.orig 2021-10-24 20:47:07 UTC
+++ doc/encoders.texi
@@ -1754,28 +1754,15 @@ Set the operating point tier.
@item tier
Set the operating point tier.
-@item rc
-Set the rate control mode to use.
-
-Possible modes:
-@table @option
-@item cqp
-Constant quantizer: use fixed values of qindex (dependent on the frame type)
-throughout the stream. This mode is the default.
-
-@item vbr
-Variable bitrate: use a target bitrate for the whole stream.
-
-@item cvbr
-Constrained variable bitrate: use a target bitrate for each GOP.
-@end table
-
@item qmax
Set the maximum quantizer to use when using a bitrate mode.
@item qmin
Set the minimum quantizer to use when using a bitrate mode.
+@item crf
+Constant rate factor value used in crf rate control mode (0-63).
+
@item qp
Set the quantizer used in cqp rate control mode (0-63).
@@ -1786,14 +1773,18 @@ Set number of frames to look ahead (0-120).
Set number of frames to look ahead (0-120).
@item preset
-Set the quality-speed tradeoff, in the range 0 to 8. Higher values are
-faster but lower quality. Defaults to 8 (highest speed).
+Set the quality-speed tradeoff, in the range 0 to 13. Higher values are
+faster but lower quality.
@item tile_rows
Set log2 of the number of rows of tiles to use (0-6).
@item tile_columns
Set log2 of the number of columns of tiles to use (0-4).
+
+@item svtav1-params
+Set SVT-AV1 options using a list of @var{key}=@var{value} pairs separated
+by ":". See the SVT-AV1 encoder user guide for a list of accepted parameters.
@end table
--- libavcodec/libsvtav1.c.orig 2021-10-24 20:47:07 UTC
+++ libavcodec/libsvtav1.c
@@ -60,17 +60,20 @@ typedef struct SvtContext {
EOS_STATUS eos_flag;
// User options.
+ AVDictionary *svtav1_opts;
+#if FF_API_SVTAV1_OPTS
int hierarchical_level;
int la_depth;
- int enc_mode;
- int rc_mode;
int scd;
- int qp;
int tier;
int tile_columns;
int tile_rows;
+#endif
+ int enc_mode;
+ int crf;
+ int qp;
} SvtContext;
static const struct {
@@ -151,11 +154,126 @@ static int config_enc_params(EbSvtAv1EncConfiguration
{
SvtContext *svt_enc = avctx->priv_data;
const AVPixFmtDescriptor *desc;
+ AVDictionaryEntry *en = NULL;
+ // Update param from options
+#if FF_API_SVTAV1_OPTS
+ param->hierarchical_levels = svt_enc->hierarchical_level;
+ param->tier = svt_enc->tier;
+ param->scene_change_detection = svt_enc->scd;
+ param->tile_columns = svt_enc->tile_columns;
+ param->tile_rows = svt_enc->tile_rows;
+
+ if (svt_enc->la_depth >= 0)
+ param->look_ahead_distance = svt_enc->la_depth;
+#endif
+
+ if (svt_enc->enc_mode >= 0)
+ param->enc_mode = svt_enc->enc_mode;
+
+ if (avctx->bit_rate) {
+ param->target_bit_rate = avctx->bit_rate;
+ if (avctx->rc_max_rate != avctx->bit_rate)
+ param->rate_control_mode = 1;
+ else
+ param->rate_control_mode = 2;
+
+ param->max_qp_allowed = avctx->qmax;
+ param->min_qp_allowed = avctx->qmin;
+ }
+ param->max_bit_rate = avctx->rc_max_rate;
+ param->vbv_bufsize = avctx->rc_buffer_size;
+
+ if (svt_enc->crf > 0) {
+ param->qp = svt_enc->crf;
+ param->rate_control_mode = 0;
+ } else if (svt_enc->qp > 0) {
+ param->qp = svt_enc->qp;
+ param->rate_control_mode = 0;
+ param->enable_adaptive_quantization = 0;
+ }
+
+ desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ param->color_primaries = avctx->color_primaries;
+ param->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ?
+ AVCOL_SPC_RGB : avctx->colorspace;
+ param->transfer_characteristics = avctx->color_trc;
+
+ if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED)
+ param->color_range = avctx->color_range == AVCOL_RANGE_JPEG;
+ else
+ param->color_range = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
+
+#if SVT_AV1_CHECK_VERSION(1, 0, 0)
+ if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) {
+ const char *name =
+ av_chroma_location_name(avctx->chroma_sample_location);
+
+ switch (avctx->chroma_sample_location) {
+ case AVCHROMA_LOC_LEFT:
+ param->chroma_sample_position = EB_CSP_VERTICAL;
+ break;
+ case AVCHROMA_LOC_TOPLEFT:
+ param->chroma_sample_position = EB_CSP_COLOCATED;
+ break;
+ default:
+ if (!name)
+ break;
+
+ av_log(avctx, AV_LOG_WARNING,
+ "Specified chroma sample location %s is unsupported "
+ "on the AV1 bit stream level. Usage of a container that "
+ "allows passing this information - such as Matroska - "
+ "is recommended.\n",
+ name);
+ break;
+ }
+ }
+#endif
+
+ if (avctx->profile != FF_PROFILE_UNKNOWN)
+ param->profile = avctx->profile;
+
+ if (avctx->level != FF_LEVEL_UNKNOWN)
+ param->level = avctx->level;
+
+ if (avctx->gop_size > 0)
+ param->intra_period_length = avctx->gop_size - 1;
+
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
+ param->frame_rate_numerator = avctx->framerate.num;
+ param->frame_rate_denominator = avctx->framerate.den;
+ } else {
+ param->frame_rate_numerator = avctx->time_base.den;
+ param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
+ }
+
+ /* 2 = IDR, closed GOP, 1 = CRA, open GOP */
+ param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1;
+
+#if SVT_AV1_CHECK_VERSION(0, 9, 1)
+ while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
+ EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value);
+ if (ret != EB_ErrorNone) {
+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
+ av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value);
+ if (avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR(EINVAL);
+ }
+ }
+#else
+ if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
+ av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 "
+ "headers >= 0.9.1.\n");
+ if (avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR(ENOSYS);
+ }
+#endif
+
param->source_width = avctx->width;
param->source_height = avctx->height;
- desc = av_pix_fmt_desc_get(avctx->pix_fmt);
param->encoder_bit_depth = desc->comp[0].depth;
if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1)
@@ -169,12 +287,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration
return AVERROR(EINVAL);
}
- if (avctx->profile != FF_PROFILE_UNKNOWN)
- param->profile = avctx->profile;
-
- if (avctx->level != FF_LEVEL_UNKNOWN)
- param->level = avctx->level;
-
if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10)
&& param->profile != FF_PROFILE_AV1_PROFESSIONAL ) {
av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n");
@@ -184,40 +296,21 @@ static int config_enc_params(EbSvtAv1EncConfiguration
param->profile = FF_PROFILE_AV1_HIGH;
}
- // Update param from options
- param->hierarchical_levels = svt_enc->hierarchical_level;
- param->enc_mode = svt_enc->enc_mode;
- param->tier = svt_enc->tier;
- param->rate_control_mode = svt_enc->rc_mode;
- param->scene_change_detection = svt_enc->scd;
- param->qp = svt_enc->qp;
+ avctx->bit_rate = param->rate_control_mode > 0 ?
+ param->target_bit_rate : 0;
+ avctx->rc_max_rate = param->max_bit_rate;
+ avctx->rc_buffer_size = param->vbv_bufsize;
- param->target_bit_rate = avctx->bit_rate;
+ if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
+ AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);
+ if (!cpb_props)
+ return AVERROR(ENOMEM);
- if (avctx->gop_size > 0)
- param->intra_period_length = avctx->gop_size - 1;
-
- if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
- param->frame_rate_numerator = avctx->framerate.num;
- param->frame_rate_denominator = avctx->framerate.den;
- } else {
- param->frame_rate_numerator = avctx->time_base.den;
- param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
+ cpb_props->buffer_size = avctx->rc_buffer_size;
+ cpb_props->max_bitrate = avctx->rc_max_rate;
+ cpb_props->avg_bitrate = avctx->bit_rate;
}
- if (param->rate_control_mode) {
- param->max_qp_allowed = avctx->qmax;
- param->min_qp_allowed = avctx->qmin;
- }
-
- param->intra_refresh_type = 2; /* Real keyframes only */
-
- if (svt_enc->la_depth >= 0)
- param->look_ahead_distance = svt_enc->la_depth;
-
- param->tile_columns = svt_enc->tile_columns;
- param->tile_rows = svt_enc->tile_rows;
-
return 0;
}
@@ -330,11 +423,8 @@ static int eb_send_frame(AVCodecContext *avctx, const
if (svt_enc->eos_flag == EOS_SENT)
return 0;
- headerPtrLast.n_alloc_len = 0;
- headerPtrLast.n_filled_len = 0;
- headerPtrLast.n_tick_count = 0;
- headerPtrLast.p_app_private = NULL;
- headerPtrLast.p_buffer = NULL;
+ memset(&headerPtrLast, 0, sizeof(headerPtrLast));
+ headerPtrLast.pic_type = EB_AV1_INVALID_PICTURE;
headerPtrLast.flags = EB_BUFFERFLAG_EOS;
svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);
@@ -350,6 +440,16 @@ static int eb_send_frame(AVCodecContext *avctx, const
headerPtr->p_app_private = NULL;
headerPtr->pts = frame->pts;
+ switch (frame->pict_type) {
+ case AV_PICTURE_TYPE_I:
+ headerPtr->pic_type = EB_AV1_KEY_PICTURE;
+ break;
+ default:
+ // Actually means auto, or default.
+ headerPtr->pic_type = EB_AV1_INVALID_PICTURE;
+ break;
+ }
+
svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr);
return 0;
@@ -472,21 +572,22 @@ static const AVOption options[] = {
#define OFFSET(x) offsetof(SvtContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "hielevel", "Hierarchical prediction levels setting", OFFSET(hierarchical_level),
- AV_OPT_TYPE_INT, { .i64 = 4 }, 3, 4, VE , "hielevel"},
+#if FF_API_SVTAV1_OPTS
+ { "hielevel", "Hierarchical prediction levels setting (Deprecated, use svtav1-params)", OFFSET(hierarchical_level),
+ AV_OPT_TYPE_INT, { .i64 = 4 }, 3, 4, VE | AV_OPT_FLAG_DEPRECATED , "hielevel"},
{ "3level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "hielevel" },
{ "4level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, INT_MIN, INT_MAX, VE, "hielevel" },
- { "la_depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
- AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE },
+ { "la_depth", "Look ahead distance [0, 120] (Deprecated, use svtav1-params)", OFFSET(la_depth),
+ AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE | AV_OPT_FLAG_DEPRECATED },
- { "preset", "Encoding preset [0, 8]",
- OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = MAX_ENC_PRESET }, 0, MAX_ENC_PRESET, VE },
-
- { "tier", "Set operating point tier", OFFSET(tier),
- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" },
+ { "tier", "Set operating point tier (Deprecated, use svtav1-params)", OFFSET(tier),
+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED, "tier" },
{ "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" },
{ "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "tier" },
+#endif
+ { "preset", "Encoding preset",
+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, MAX_ENC_PRESET, VE },
FF_AV1_PROFILE_OPTS
@@ -518,21 +619,20 @@ static const AVOption options[] = {
{ LEVEL("7.3", 73) },
#undef LEVEL
- { "rc", "Bit rate control mode", OFFSET(rc_mode),
- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"},
- { "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" },
- { "vbr", "Variable Bit Rate, use a target bitrate for the entire stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "rc" },
- { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 }, INT_MIN, INT_MAX, VE, "rc" },
+ { "crf", "Constant Rate Factor value", OFFSET(crf),
+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
+ { "qp", "Initial Quantizer level value", OFFSET(qp),
+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
+#if FF_API_SVTAV1_OPTS
+ { "sc_detection", "Scene change detection (Deprecated, use svtav1-params)", OFFSET(scd),
+ AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED },
- { "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp),
- AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
+ { "tile_columns", "Log2 of number of tile columns to use (Deprecated, use svtav1-params)", OFFSET(tile_columns), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, VE | AV_OPT_FLAG_DEPRECATED },
+ { "tile_rows", "Log2 of number of tile rows to use (Deprecated, use svtav1-params)", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 6, VE | AV_OPT_FLAG_DEPRECATED },
+#endif
- { "sc_detection", "Scene change detection", OFFSET(scd),
- AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
- { "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
- { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
-
{NULL},
};
@@ -544,9 +644,10 @@ static const AVCodecDefault eb_enc_defaults[] = {
};
static const AVCodecDefault eb_enc_defaults[] = {
- { "b", "7M" },
+ { "b", "0" },
+ { "flags", "+cgop" },
{ "g", "-1" },
- { "qmin", "0" },
+ { "qmin", "1" },
{ "qmax", "63" },
{ NULL },
};
@@ -561,12 +662,11 @@ AVCodec ff_libsvtav1_encoder = {
.receive_packet = eb_receive_packet,
.close = eb_enc_close,
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
- .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV420P10,
AV_PIX_FMT_NONE },
.priv_class = &class,
.defaults = eb_enc_defaults,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.wrapper_name = "libsvtav1",
};
--- libavcodec/version.h.orig 2021-10-24 20:47:07 UTC
+++ libavcodec/version.h
@@ -168,5 +168,8 @@
#ifndef FF_API_INIT_PACKET
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
#endif
+#ifndef FF_API_SVTAV1_OPTS
+#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
+#endif
#endif /* AVCODEC_VERSION_H */
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
FF_SUFFIX= 4
BUILD_DEPENDS:= ${BUILD_DEPENDS:S/ffmpeg/&${FF_SUFFIX}/g}
LIB_DEPENDS:= ${LIB_DEPENDS:S/ffmpeg$/&${FF_SUFFIX}/}
USES+= localbase # -isystem
CONFIGURE_ENV+= PKG_CONFIG_PATH="${LOCALBASE}/ffmpeg${FF_SUFFIX}/libdata/pkgconfig"
MAKE_ENV+= PKG_CONFIG_PATH="${LOCALBASE}/ffmpeg${FF_SUFFIX}/libdata/pkgconfig"
+3
View File
@@ -0,0 +1,3 @@
FFmpeg is a complete, cross-platform solution to record, convert and stream
audio and video. It includes libavcodec - the leading audio/video codec
library.
+220
View File
@@ -0,0 +1,220 @@
bin/ffmpeg
%%SDL%%bin/ffplay
bin/ffprobe
include/libavcodec/ac3_parser.h
include/libavcodec/adts_parser.h
include/libavcodec/avcodec.h
include/libavcodec/avdct.h
include/libavcodec/avfft.h
include/libavcodec/bsf.h
include/libavcodec/codec.h
include/libavcodec/codec_desc.h
include/libavcodec/codec_id.h
include/libavcodec/codec_par.h
include/libavcodec/d3d11va.h
include/libavcodec/dirac.h
include/libavcodec/dv_profile.h
include/libavcodec/dxva2.h
include/libavcodec/jni.h
include/libavcodec/mediacodec.h
include/libavcodec/packet.h
include/libavcodec/qsv.h
include/libavcodec/vaapi.h
include/libavcodec/vdpau.h
include/libavcodec/version.h
include/libavcodec/videotoolbox.h
include/libavcodec/vorbis_parser.h
include/libavcodec/xvmc.h
include/libavdevice/avdevice.h
include/libavdevice/version.h
include/libavfilter/avfilter.h
include/libavfilter/buffersink.h
include/libavfilter/buffersrc.h
include/libavfilter/version.h
include/libavformat/avformat.h
include/libavformat/avio.h
include/libavformat/version.h
include/libavresample/avresample.h
include/libavresample/version.h
include/libavutil/adler32.h
include/libavutil/aes.h
include/libavutil/aes_ctr.h
include/libavutil/attributes.h
include/libavutil/audio_fifo.h
include/libavutil/avassert.h
include/libavutil/avconfig.h
include/libavutil/avstring.h
include/libavutil/avutil.h
include/libavutil/base64.h
include/libavutil/blowfish.h
include/libavutil/bprint.h
include/libavutil/bswap.h
include/libavutil/buffer.h
include/libavutil/camellia.h
include/libavutil/cast5.h
include/libavutil/channel_layout.h
include/libavutil/common.h
include/libavutil/cpu.h
include/libavutil/crc.h
include/libavutil/des.h
include/libavutil/dict.h
include/libavutil/display.h
include/libavutil/dovi_meta.h
include/libavutil/downmix_info.h
include/libavutil/encryption_info.h
include/libavutil/error.h
include/libavutil/eval.h
include/libavutil/ffversion.h
include/libavutil/fifo.h
include/libavutil/file.h
include/libavutil/film_grain_params.h
include/libavutil/frame.h
include/libavutil/hash.h
include/libavutil/hdr_dynamic_metadata.h
include/libavutil/hmac.h
include/libavutil/hwcontext.h
include/libavutil/hwcontext_cuda.h
include/libavutil/hwcontext_d3d11va.h
include/libavutil/hwcontext_drm.h
include/libavutil/hwcontext_dxva2.h
include/libavutil/hwcontext_mediacodec.h
include/libavutil/hwcontext_opencl.h
include/libavutil/hwcontext_qsv.h
include/libavutil/hwcontext_vaapi.h
include/libavutil/hwcontext_vdpau.h
include/libavutil/hwcontext_videotoolbox.h
include/libavutil/hwcontext_vulkan.h
include/libavutil/imgutils.h
include/libavutil/intfloat.h
include/libavutil/intreadwrite.h
include/libavutil/lfg.h
include/libavutil/log.h
include/libavutil/lzo.h
include/libavutil/macros.h
include/libavutil/mastering_display_metadata.h
include/libavutil/mathematics.h
include/libavutil/md5.h
include/libavutil/mem.h
include/libavutil/motion_vector.h
include/libavutil/murmur3.h
include/libavutil/opt.h
include/libavutil/parseutils.h
include/libavutil/pixdesc.h
include/libavutil/pixelutils.h
include/libavutil/pixfmt.h
include/libavutil/random_seed.h
include/libavutil/rational.h
include/libavutil/rc4.h
include/libavutil/replaygain.h
include/libavutil/ripemd.h
include/libavutil/samplefmt.h
include/libavutil/sha.h
include/libavutil/sha512.h
include/libavutil/spherical.h
include/libavutil/stereo3d.h
include/libavutil/tea.h
include/libavutil/threadmessage.h
include/libavutil/time.h
include/libavutil/timecode.h
include/libavutil/timestamp.h
include/libavutil/tree.h
include/libavutil/twofish.h
include/libavutil/tx.h
include/libavutil/version.h
include/libavutil/video_enc_params.h
include/libavutil/xtea.h
include/libpostproc/postprocess.h
include/libpostproc/version.h
include/libswresample/swresample.h
include/libswresample/version.h
include/libswscale/swscale.h
include/libswscale/version.h
lib/libavcodec.so
lib/libavcodec.so.58
lib/libavcodec.so.58.134.100
lib/libavdevice.so
lib/libavdevice.so.58
lib/libavdevice.so.58.13.100
lib/libavfilter.so
lib/libavfilter.so.7
lib/libavfilter.so.7.110.100
lib/libavformat.so
lib/libavformat.so.58
lib/libavformat.so.58.76.100
lib/libavresample.so
lib/libavresample.so.4
lib/libavresample.so.4.0.0
lib/libavutil.so
lib/libavutil.so.56
lib/libavutil.so.56.70.100
lib/libpostproc.so
lib/libpostproc.so.55
lib/libpostproc.so.55.9.100
lib/libswresample.so
lib/libswresample.so.3
lib/libswresample.so.3.9.100
lib/libswscale.so
lib/libswscale.so.5
lib/libswscale.so.5.9.100
libdata/pkgconfig/libavcodec.pc
libdata/pkgconfig/libavdevice.pc
libdata/pkgconfig/libavfilter.pc
libdata/pkgconfig/libavformat.pc
libdata/pkgconfig/libavresample.pc
libdata/pkgconfig/libavutil.pc
libdata/pkgconfig/libpostproc.pc
libdata/pkgconfig/libswresample.pc
libdata/pkgconfig/libswscale.pc
man/man1/ffmpeg-all.1.gz
man/man1/ffmpeg-bitstream-filters.1.gz
man/man1/ffmpeg-codecs.1.gz
man/man1/ffmpeg-devices.1.gz
man/man1/ffmpeg-filters.1.gz
man/man1/ffmpeg-formats.1.gz
man/man1/ffmpeg-protocols.1.gz
man/man1/ffmpeg-resampler.1.gz
man/man1/ffmpeg-scaler.1.gz
man/man1/ffmpeg-utils.1.gz
man/man1/ffmpeg.1.gz
%%SDL%%man/man1/ffplay-all.1.gz
%%SDL%%man/man1/ffplay.1.gz
man/man1/ffprobe-all.1.gz
man/man1/ffprobe.1.gz
man/man3/libavcodec.3.gz
man/man3/libavdevice.3.gz
man/man3/libavfilter.3.gz
man/man3/libavformat.3.gz
man/man3/libavutil.3.gz
man/man3/libswresample.3.gz
man/man3/libswscale.3.gz
%%DATADIR%%/examples/Makefile
%%DATADIR%%/examples/README
%%DATADIR%%/examples/avio_list_dir.c
%%DATADIR%%/examples/avio_reading.c
%%DATADIR%%/examples/decode_audio.c
%%DATADIR%%/examples/decode_video.c
%%DATADIR%%/examples/demuxing_decoding.c
%%DATADIR%%/examples/encode_audio.c
%%DATADIR%%/examples/encode_video.c
%%DATADIR%%/examples/extract_mvs.c
%%DATADIR%%/examples/filter_audio.c
%%DATADIR%%/examples/filtering_audio.c
%%DATADIR%%/examples/filtering_video.c
%%DATADIR%%/examples/http_multiclient.c
%%DATADIR%%/examples/hw_decode.c
%%DATADIR%%/examples/metadata.c
%%DATADIR%%/examples/muxing.c
%%DATADIR%%/examples/qsvdec.c
%%DATADIR%%/examples/remuxing.c
%%DATADIR%%/examples/resampling_audio.c
%%DATADIR%%/examples/scaling_video.c
%%DATADIR%%/examples/transcode_aac.c
%%DATADIR%%/examples/transcoding.c
%%DATADIR%%/examples/vaapi_encode.c
%%DATADIR%%/examples/vaapi_transcode.c
%%DATADIR%%/ffprobe.xsd
%%DATADIR%%/libvpx-1080p.ffpreset
%%DATADIR%%/libvpx-1080p50_60.ffpreset
%%DATADIR%%/libvpx-360p.ffpreset
%%DATADIR%%/libvpx-720p.ffpreset
%%DATADIR%%/libvpx-720p50_60.ffpreset