Skip to content

Commit

Permalink
svt-av1-psy 916cabd and aom-psy101 9af04512
Browse files Browse the repository at this point in the history
  • Loading branch information
Uranite committed Dec 12, 2024
1 parent 8410769 commit 4159f90
Show file tree
Hide file tree
Showing 9 changed files with 454 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
default: false
required: false
schedule:
- cron: '0 12 * * *'
- cron: '0 17 * * *'

env:
DOCKER_BUILDKIT: 1
Expand All @@ -31,7 +31,7 @@ jobs:
steps:
- name: Repo Check
run: |
if [[ "$GITHUB_REPOSITORY" != "BtbN/FFmpeg-Builds" ]]; then
if [[ "$GITHUB_REPOSITORY" != "Uranite/FFmpeg-Builds" ]]; then
echo "When forking this repository to make your own builds, you have to adjust this check."
echo "When doing so make sure to randomize the scheduled cron time above, in order to spread out the various build times as much as possible."
echo "This has been put in place due to the enormous amounts of traffic hundreds/thousands of parallel builds can cause on external infrastructure."
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
fail-fast: false
matrix:
target: [win64,linux64,linuxarm64]
variant: [gpl,lgpl,gpl 5.1,gpl 6.1,gpl 7.1,lgpl 5.1,lgpl 6.1,lgpl 7.1,gpl-shared,lgpl-shared,gpl-shared 5.1,gpl-shared 6.1,gpl-shared 7.1,lgpl-shared 5.1,lgpl-shared 6.1,lgpl-shared 7.1]
variant: [gpl,gpl 7.0,gpl 7.1,gpl-shared,gpl-shared 7.0,gpl-shared 7.1]
steps:
- name: Free Disk-Space
run: df -h && sudo apt-get clean && docker system prune -a -f && sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc && df -h
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
fail-fast: false
matrix:
target: [win64,linux64,linuxarm64]
variant: [gpl,lgpl,gpl 5.1,gpl 6.1,gpl 7.1,lgpl 5.1,lgpl 6.1,lgpl 7.1,gpl-shared,lgpl-shared,gpl-shared 5.1,gpl-shared 6.1,gpl-shared 7.1,lgpl-shared 5.1,lgpl-shared 6.1,lgpl-shared 7.1]
variant: [gpl,gpl 7.0,gpl 7.1,gpl-shared,gpl-shared 7.0,gpl-shared 7.1]
steps:
- name: Free Disk-Space
run: df -h && sudo apt-get clean && docker system prune -a -f && sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc && df -h
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FFmpeg Static Auto-Builds
# FFmpeg Static Auto-Builds (Fork with svt-av1-psy and aom-psy101)

Static Windows (x86_64) and Linux (x86_64) Builds of ffmpeg master and latest release branch.
Static Windows (x86_64) and Linux (x86_64) Builds of ffmpeg master and latest release branch, featuring svt-av1-psy and aom-psy101.

Windows builds are targetting Windows 7 and newer, provided UCRT is installed.
The minimum supported version is Windows 10 22H2, no guarantees on anything older.
Expand Down
22 changes: 21 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ cat <<EOF >"$BUILD_SCRIPT"
git clone --filter=blob:none --branch='$GIT_BRANCH' '$FFMPEG_REPO' ffmpeg
cd ffmpeg
# Extract the version from GIT_BRANCH
BRANCH_VERSION=\$(echo '$GIT_BRANCH' | grep -oP 'release/\K\d+\.\d+' || echo 'master')
if [ -d "/patches/ffmpeg/\$BRANCH_VERSION" ]; then
for patch in /patches/ffmpeg/\$BRANCH_VERSION/*.patch; do
[ -f "\$patch" ] || continue
git apply "\$patch"
done
elif [ -d "/patches/ffmpeg" ]; then
for patch in /patches/ffmpeg/*.patch; do
[ -f "\$patch" ] || continue
git apply "\$patch"
done
fi
./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS \$FF_CONFIGURE \
--extra-cflags="\$FF_CFLAGS" --extra-cxxflags="\$FF_CXXFLAGS" --extra-libs="\$FF_LIBS" \
--extra-ldflags="\$FF_LDFLAGS" --extra-ldexeflags="\$FF_LDEXEFLAGS" \
Expand All @@ -46,7 +61,12 @@ EOF

[[ -t 1 ]] && TTY_ARG="-t" || TTY_ARG=""

docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v "$PWD/ffbuild":/ffbuild -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh
PATCHES_MOUNT=""
if [ -d "patches/ffmpeg" ]; then
PATCHES_MOUNT="-v $PWD/patches:/patches"
fi

docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v "$PWD/ffbuild":/ffbuild $PATCHES_MOUNT -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh

mkdir -p artifacts
ARTIFACTS_PATH="$PWD/artifacts"
Expand Down
69 changes: 69 additions & 0 deletions patches/ffmpeg/7.0/psy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 8fa42d590b..b6486e67c9 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -65,7 +65,8 @@ typedef struct SvtContext {
// User options.
AVDictionary *svtav1_opts;
int enc_mode;
- int crf;
+ float crf;
+ uint8_t extended_crf_qindex_offset;
int qp;
} SvtContext;

@@ -201,6 +202,7 @@ static void handle_side_data(AVCodecContext *avctx,
}
}

+#define MAX_QP_VALUE 63
static int config_enc_params(EbSvtAv1EncConfiguration *param,
AVCodecContext *avctx)
{
@@ -209,7 +211,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
AVDictionaryEntry *en = NULL;

// Update param from options
- if (svt_enc->enc_mode >= -1)
+ if (svt_enc->enc_mode >= -3)
param->enc_mode = svt_enc->enc_mode;

if (avctx->bit_rate) {
@@ -229,7 +231,16 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
FFMAX(avctx->bit_rate, avctx->rc_max_rate);

if (svt_enc->crf > 0) {
- param->qp = svt_enc->crf;
+ float crf_value;
+ uint32_t extended_q_index;
+
+ crf_value = svt_enc->crf;
+ param->qp = FFMIN(MAX_QP_VALUE, (int)crf_value);
+
+ // Calculate the quarter-step offset
+ extended_q_index = (uint32_t)(crf_value * 4);
+ param->extended_crf_qindex_offset = extended_q_index - param->qp * 4;
+
param->rate_control_mode = 0;
} else if (svt_enc->qp > 0) {
param->qp = svt_enc->qp;
@@ -657,7 +668,7 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "preset", "Encoding preset",
- OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -2 }, -2, MAX_ENC_PRESET, VE },
+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -4 }, -4, MAX_ENC_PRESET, VE },

FF_AV1_PROFILE_OPTS

@@ -689,8 +700,8 @@ static const AVOption options[] = {
{ LEVEL("7.3", 73) },
#undef LEVEL

- { "crf", "Constant Rate Factor value", OFFSET(crf),
- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
+ { "crf", "Constant Rate Factor value (can use quarter-step increments)",
+ OFFSET(crf), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, 70, VE },
{ "qp", "Initial Quantizer level value", OFFSET(qp),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, 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 },
71 changes: 71 additions & 0 deletions patches/ffmpeg/7.1/psy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 79b28eb4df..24ce54a0c4 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -69,7 +69,8 @@ typedef struct SvtContext {
// User options.
AVDictionary *svtav1_opts;
int enc_mode;
- int crf;
+ float crf;
+ uint8_t extended_crf_qindex_offset;
int qp;
} SvtContext;

@@ -205,6 +206,7 @@ static void handle_side_data(AVCodecContext *avctx,
}
}

+#define MAX_QP_VALUE 63
static int config_enc_params(EbSvtAv1EncConfiguration *param,
AVCodecContext *avctx)
{
@@ -213,7 +215,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
const AVDictionaryEntry av_unused *en = NULL;

// Update param from options
- if (svt_enc->enc_mode >= -1)
+ if (svt_enc->enc_mode >= -3)
param->enc_mode = svt_enc->enc_mode;

if (avctx->bit_rate) {
@@ -233,8 +235,17 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
FFMAX(avctx->bit_rate, avctx->rc_max_rate);

if (svt_enc->crf > 0) {
- param->qp = svt_enc->crf;
- param->rate_control_mode = 0;
+ float crf_value;
+ uint32_t extended_q_index;
+
+ crf_value = svt_enc->crf;
+ param->qp = FFMIN(MAX_QP_VALUE, (int)crf_value);
+
+ // Calculate the quarter-step offset
+ extended_q_index = (uint32_t)(crf_value * 4);
+ param->extended_crf_qindex_offset = extended_q_index - param->qp * 4;
+
+ param->rate_control_mode = 0;
} else if (svt_enc->qp > 0) {
param->qp = svt_enc->qp;
param->rate_control_mode = 0;
@@ -694,7 +705,7 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "preset", "Encoding preset",
- OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -2 }, -2, MAX_ENC_PRESET, VE },
+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -4 }, -4, MAX_ENC_PRESET, VE },

FF_AV1_PROFILE_OPTS

@@ -726,8 +737,8 @@ static const AVOption options[] = {
{ LEVEL("7.3", 73) },
#undef LEVEL

- { "crf", "Constant Rate Factor value", OFFSET(crf),
- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
+ { "crf", "Constant Rate Factor value (can use quarter-step increments)",
+ OFFSET(crf), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, 70, VE },
{ "qp", "Initial Quantizer level value", OFFSET(qp),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, 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 },
71 changes: 71 additions & 0 deletions patches/ffmpeg/psy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 79b28eb4df..24ce54a0c4 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -69,7 +69,8 @@ typedef struct SvtContext {
// User options.
AVDictionary *svtav1_opts;
int enc_mode;
- int crf;
+ float crf;
+ uint8_t extended_crf_qindex_offset;
int qp;
} SvtContext;

@@ -205,6 +206,7 @@ static void handle_side_data(AVCodecContext *avctx,
}
}

+#define MAX_QP_VALUE 63
static int config_enc_params(EbSvtAv1EncConfiguration *param,
AVCodecContext *avctx)
{
@@ -213,7 +215,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
const AVDictionaryEntry av_unused *en = NULL;

// Update param from options
- if (svt_enc->enc_mode >= -1)
+ if (svt_enc->enc_mode >= -3)
param->enc_mode = svt_enc->enc_mode;

if (avctx->bit_rate) {
@@ -233,8 +235,17 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
FFMAX(avctx->bit_rate, avctx->rc_max_rate);

if (svt_enc->crf > 0) {
- param->qp = svt_enc->crf;
- param->rate_control_mode = 0;
+ float crf_value;
+ uint32_t extended_q_index;
+
+ crf_value = svt_enc->crf;
+ param->qp = FFMIN(MAX_QP_VALUE, (int)crf_value);
+
+ // Calculate the quarter-step offset
+ extended_q_index = (uint32_t)(crf_value * 4);
+ param->extended_crf_qindex_offset = extended_q_index - param->qp * 4;
+
+ param->rate_control_mode = 0;
} else if (svt_enc->qp > 0) {
param->qp = svt_enc->qp;
param->rate_control_mode = 0;
@@ -694,7 +705,7 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "preset", "Encoding preset",
- OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -2 }, -2, MAX_ENC_PRESET, VE },
+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -4 }, -4, MAX_ENC_PRESET, VE },

FF_AV1_PROFILE_OPTS

@@ -726,8 +737,8 @@ static const AVOption options[] = {
{ LEVEL("7.3", 73) },
#undef LEVEL

- { "crf", "Constant Rate Factor value", OFFSET(crf),
- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
+ { "crf", "Constant Rate Factor value (can use quarter-step increments)",
+ OFFSET(crf), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, 70, VE },
{ "qp", "Initial Quantizer level value", OFFSET(qp),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, 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 },
4 changes: 2 additions & 2 deletions scripts.d/50-aom.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SCRIPT_REPO="https://aomedia.googlesource.com/aom"
SCRIPT_COMMIT="37c5c4e6aa461b264642505a089503fa78f0bae3"
SCRIPT_REPO="https://gitlab.com/damian101/aom-psy101.git"
SCRIPT_COMMIT="9af04512e8c1da7f6bcafd6d89aadc37caa3f08e"

ffbuild_enabled() {
[[ $TARGET == winarm64 ]] && return -1
Expand Down
4 changes: 2 additions & 2 deletions scripts.d/50-svtav1.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SCRIPT_REPO="https://gitlab.com/AOMediaCodec/SVT-AV1.git"
SCRIPT_COMMIT="c642bb04462b25d0d3881494a4e2a5487460722b"
SCRIPT_REPO="https://github.com/gianni-rosato/svt-av1-psy.git"
SCRIPT_COMMIT="916cabd50bbaba3728def160f0b8aa9cb418aa5c"

ffbuild_enabled() {
[[ $TARGET == win32 ]] && return -1
Expand Down
Loading

0 comments on commit 4159f90

Please sign in to comment.