Skip to content

Commit

Permalink
svt-av1-psy v2.2.1-B and aom-psy101 df18b42
Browse files Browse the repository at this point in the history
  • Loading branch information
Uranite committed Oct 10, 2024
1 parent fcc6136 commit 715a839
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 9 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.1,gpl-shared,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.1,gpl-shared,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
14 changes: 13 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ cat <<EOF >"$BUILD_SCRIPT"
git clone --filter=blob:none --branch='$GIT_BRANCH' '$FFMPEG_REPO' ffmpeg
cd ffmpeg
if [ -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 +53,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
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
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="a42ea198de1e1438f5ee462bd599d082c924bc35"
SCRIPT_REPO="https://gitlab.com/damian101/aom-psy101.git"
SCRIPT_COMMIT="df18b42d03624f5c9fac2ef9211a66413b8dd88e"

ffbuild_enabled() {
[[ $TARGET == winarm64 ]] && return -1
Expand Down
4 changes: 2 additions & 2 deletions scripts.d/50-svtav1.sh
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="13a54d08f161bd1ff21a6259b8ed54b279691d6e"
SCRIPT_REPO="https://github.com/gianni-rosato/svt-av1-psy.git"
SCRIPT_COMMIT="954f7266bf07d526d701de314534395af3c4b90b"

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

0 comments on commit 715a839

Please sign in to comment.