Skip to content

Commit

Permalink
Update psy.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Uranite committed Oct 4, 2024
1 parent 5b19409 commit 9268e01
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,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 @@ -229,7 +229,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
33 changes: 22 additions & 11 deletions patches/ffmpeg/psy.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 79b28eb..dca9b99 100644
index 79b28eb..3db3c93 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -69,7 +69,8 @@ typedef struct SvtContext {
Expand All @@ -12,7 +12,15 @@ index 79b28eb..dca9b99 100644
int qp;
} SvtContext;

@@ -213,7 +214,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
@@ -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
Expand All @@ -21,40 +29,43 @@ index 79b28eb..dca9b99 100644
param->enc_mode = svt_enc->enc_mode;

if (avctx->bit_rate) {
@@ -233,8 +234,15 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
@@ -233,8 +235,18 @@ 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 = 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
+ uint32_t extended_q_index = (uint32_t)(crf_value * 4);
+ extended_q_index = (uint32_t)(crf_value * 4);
+ param->extended_crf_qindex_offset = extended_q_index - param->qp * 4;
+
+
+ param->rate_control_mode = 0;
+ param->enable_adaptive_quantization = 2;
} else if (svt_enc->qp > 0) {
param->qp = svt_enc->qp;
param->rate_control_mode = 0;
@@ -694,7 +702,7 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
@@ -694,7 +706,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 = -2 }, -3, MAX_ENC_PRESET, VE },
+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -4 }, -4, MAX_ENC_PRESET, VE },

FF_AV1_PROFILE_OPTS

@@ -726,8 +734,8 @@ static const AVOption options[] = {
@@ -726,8 +738,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)",
+ { "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 },
Expand Down

0 comments on commit 9268e01

Please sign in to comment.