update fadecomp patch

This commit is contained in:
odrling 2021-05-08 03:37:41 +02:00
parent 9916ccd755
commit 92ab27d27d
2 changed files with 40 additions and 68 deletions

View File

@ -1,22 +1,8 @@
From 43e589ef727752f459ee1dec5bc8d274c3c2db42 Mon Sep 17 00:00:00 2001
From: DJATOM <djatom@beatrice-raws.org>
Date: Tue, 26 Jan 2021 01:47:09 +0200
Subject: [PATCH] Add --fade-compensate option
Allocates more bitrate on fades
---
common/base.c | 5 +++++
encoder/encoder.c | 5 +++++
encoder/slicetype.c | 4 ++--
x264.c | 3 +++
x264.h | 1 +
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/common/base.c b/common/base.c
index 7a230ade..e1baeeb5 100644
index 5b35a2e3..9d572c90 100644
--- a/common/base.c
+++ b/common/base.c
@@ -1322,6 +1322,8 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha
@@ -1334,6 +1334,8 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha
p->rc.i_aq_mode = atoi(value);
OPT("aq-strength")
p->rc.f_aq_strength = atof(value);
@ -25,7 +11,7 @@ index 7a230ade..e1baeeb5 100644
OPT("pass")
{
int pass = x264_clip3( atoi(value), 0, 3 );
@@ -1460,7 +1462,10 @@ char *x264_param2string( x264_param_t *p, int b_res )
@@ -1442,7 +1444,10 @@ char *x264_param2string( x264_param_t *p, int b_res )
s += sprintf( s, " subme=%d", p->analyse.i_subpel_refine );
s += sprintf( s, " psy=%d", p->analyse.b_psy );
if( p->analyse.b_psy )
@ -37,10 +23,10 @@ index 7a230ade..e1baeeb5 100644
s += sprintf( s, " me_range=%d", p->analyse.i_me_range );
s += sprintf( s, " chroma_me=%d", p->analyse.b_chroma_me );
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 266e91ec..ca5f39c9 100644
index b946cddf..9e43ad7c 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1154,10 +1154,15 @@ static int validate_parameters( x264_t *h, int b_open )
@@ -1189,10 +1189,15 @@ static int validate_parameters( x264_t *h, int b_open )
x264_log( h, X264_LOG_WARNING, "--tune %s should be used if attempting to benchmark %s!\n", s, s );
}
@ -57,10 +43,10 @@ index 266e91ec..ca5f39c9 100644
h->param.analyse.f_psy_rd = x264_clip3f( h->param.analyse.f_psy_rd, 0, 10 );
h->param.analyse.f_psy_trellis = x264_clip3f( h->param.analyse.f_psy_trellis, 0, 10 );
diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index b2e0e335..0972cc75 100644
index 0315ba6b..527287a8 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -460,7 +460,7 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
@@ -459,7 +459,7 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
else
SET_WEIGHT( weights[plane], 1, minscale, mindenom, minoff );
@ -69,7 +55,7 @@ index b2e0e335..0972cc75 100644
fenc->f_weighted_cost_delta[i_delta_index] = (float)minscore / origscore;
}
@@ -1032,7 +1032,7 @@ static void macroblock_tree_finish( x264_t *h, x264_frame_t *frame, float averag
@@ -1031,7 +1031,7 @@ static void macroblock_tree_finish( x264_t *h, x264_frame_t *frame, float averag
int fps_factor = round( CLIP_DURATION(average_duration) / CLIP_DURATION(frame->f_duration) * 256 / MBTREE_PRECISION );
float weightdelta = 0.0;
if( ref0_distance && frame->f_weighted_cost_delta[ref0_distance-1] > 0 )
@ -79,10 +65,10 @@ index b2e0e335..0972cc75 100644
/* Allow the strength to be adjusted via qcompress, since the two
* concepts are very similar. */
diff --git a/x264.c b/x264.c
index a12fa099..9dbd9831 100644
index 4765973a..e06d622d 100644
--- a/x264.c
+++ b/x264.c
@@ -812,6 +812,8 @@ static void help( x264_param_t *defaults, int longhelp )
@@ -751,6 +751,8 @@ static void help( x264_param_t *defaults, int longhelp )
" - 3: Auto-variance AQ with bias to dark scenes\n", defaults->rc.i_aq_mode );
H1( " --aq-strength <float> Reduces blocking and blurring in flat and\n"
" textured areas. [%.1f]\n", defaults->rc.f_aq_strength );
@ -91,19 +77,19 @@ index a12fa099..9dbd9831 100644
H1( "\n" );
H0( " -p, --pass <integer> Enable multipass ratecontrol\n"
" - 1: First pass, creates stats file\n"
@@ -1160,6 +1162,7 @@ static struct option long_options[] =
{ "no-dct-decimate", no_argument, NULL, 0 },
{ "aq-strength", required_argument, NULL, 0 },
{ "aq-mode", required_argument, NULL, 0 },
+ { "fade-compensate", required_argument, NULL, 0 },
{ "deadzone-inter", required_argument, NULL, 0 },
{ "deadzone-intra", required_argument, NULL, 0 },
{ "level", required_argument, NULL, 0 },
@@ -1092,6 +1094,7 @@ static struct option long_options[] =
{ "no-dct-decimate", no_argument, NULL, 0 },
{ "aq-strength", required_argument, NULL, 0 },
{ "aq-mode", required_argument, NULL, 0 },
+ { "fade-compensate", required_argument, NULL, 0 },
{ "deadzone-inter", required_argument, NULL, 0 },
{ "deadzone-intra", required_argument, NULL, 0 },
{ "level", required_argument, NULL, 0 },
diff --git a/x264.h b/x264.h
index 8689aa03..18abda8e 100644
index d9644b6f..a2aeb769 100644
--- a/x264.h
+++ b/x264.h
@@ -469,6 +469,7 @@ typedef struct x264_param_t
@@ -454,6 +454,7 @@ typedef struct x264_param_t
int i_aq_mode; /* psy adaptive QP. (X264_AQ_*) */
float f_aq_strength;

View File

@ -1,22 +1,8 @@
From 43e589ef727752f459ee1dec5bc8d274c3c2db42 Mon Sep 17 00:00:00 2001
From: DJATOM <djatom@beatrice-raws.org>
Date: Tue, 26 Jan 2021 01:47:09 +0200
Subject: [PATCH] Add --fade-compensate option
Allocates more bitrate on fades
---
common/base.c | 5 +++++
encoder/encoder.c | 5 +++++
encoder/slicetype.c | 4 ++--
x264.c | 3 +++
x264.h | 1 +
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/common/base.c b/common/base.c
index 7a230ade..e1baeeb5 100644
index 5b35a2e3..9d572c90 100644
--- a/common/base.c
+++ b/common/base.c
@@ -1322,6 +1322,8 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha
@@ -1334,6 +1334,8 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha
p->rc.i_aq_mode = atoi(value);
OPT("aq-strength")
p->rc.f_aq_strength = atof(value);
@ -25,7 +11,7 @@ index 7a230ade..e1baeeb5 100644
OPT("pass")
{
int pass = x264_clip3( atoi(value), 0, 3 );
@@ -1460,7 +1462,10 @@ char *x264_param2string( x264_param_t *p, int b_res )
@@ -1442,7 +1444,10 @@ char *x264_param2string( x264_param_t *p, int b_res )
s += sprintf( s, " subme=%d", p->analyse.i_subpel_refine );
s += sprintf( s, " psy=%d", p->analyse.b_psy );
if( p->analyse.b_psy )
@ -37,10 +23,10 @@ index 7a230ade..e1baeeb5 100644
s += sprintf( s, " me_range=%d", p->analyse.i_me_range );
s += sprintf( s, " chroma_me=%d", p->analyse.b_chroma_me );
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 266e91ec..ca5f39c9 100644
index b946cddf..9e43ad7c 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1154,10 +1154,15 @@ static int validate_parameters( x264_t *h, int b_open )
@@ -1189,10 +1189,15 @@ static int validate_parameters( x264_t *h, int b_open )
x264_log( h, X264_LOG_WARNING, "--tune %s should be used if attempting to benchmark %s!\n", s, s );
}
@ -57,10 +43,10 @@ index 266e91ec..ca5f39c9 100644
h->param.analyse.f_psy_rd = x264_clip3f( h->param.analyse.f_psy_rd, 0, 10 );
h->param.analyse.f_psy_trellis = x264_clip3f( h->param.analyse.f_psy_trellis, 0, 10 );
diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index b2e0e335..0972cc75 100644
index 0315ba6b..527287a8 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -460,7 +460,7 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
@@ -459,7 +459,7 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
else
SET_WEIGHT( weights[plane], 1, minscale, mindenom, minoff );
@ -69,7 +55,7 @@ index b2e0e335..0972cc75 100644
fenc->f_weighted_cost_delta[i_delta_index] = (float)minscore / origscore;
}
@@ -1032,7 +1032,7 @@ static void macroblock_tree_finish( x264_t *h, x264_frame_t *frame, float averag
@@ -1031,7 +1031,7 @@ static void macroblock_tree_finish( x264_t *h, x264_frame_t *frame, float averag
int fps_factor = round( CLIP_DURATION(average_duration) / CLIP_DURATION(frame->f_duration) * 256 / MBTREE_PRECISION );
float weightdelta = 0.0;
if( ref0_distance && frame->f_weighted_cost_delta[ref0_distance-1] > 0 )
@ -79,10 +65,10 @@ index b2e0e335..0972cc75 100644
/* Allow the strength to be adjusted via qcompress, since the two
* concepts are very similar. */
diff --git a/x264.c b/x264.c
index a12fa099..9dbd9831 100644
index 4765973a..e06d622d 100644
--- a/x264.c
+++ b/x264.c
@@ -812,6 +812,8 @@ static void help( x264_param_t *defaults, int longhelp )
@@ -751,6 +751,8 @@ static void help( x264_param_t *defaults, int longhelp )
" - 3: Auto-variance AQ with bias to dark scenes\n", defaults->rc.i_aq_mode );
H1( " --aq-strength <float> Reduces blocking and blurring in flat and\n"
" textured areas. [%.1f]\n", defaults->rc.f_aq_strength );
@ -91,19 +77,19 @@ index a12fa099..9dbd9831 100644
H1( "\n" );
H0( " -p, --pass <integer> Enable multipass ratecontrol\n"
" - 1: First pass, creates stats file\n"
@@ -1160,6 +1162,7 @@ static struct option long_options[] =
{ "no-dct-decimate", no_argument, NULL, 0 },
{ "aq-strength", required_argument, NULL, 0 },
{ "aq-mode", required_argument, NULL, 0 },
+ { "fade-compensate", required_argument, NULL, 0 },
{ "deadzone-inter", required_argument, NULL, 0 },
{ "deadzone-intra", required_argument, NULL, 0 },
{ "level", required_argument, NULL, 0 },
@@ -1092,6 +1094,7 @@ static struct option long_options[] =
{ "no-dct-decimate", no_argument, NULL, 0 },
{ "aq-strength", required_argument, NULL, 0 },
{ "aq-mode", required_argument, NULL, 0 },
+ { "fade-compensate", required_argument, NULL, 0 },
{ "deadzone-inter", required_argument, NULL, 0 },
{ "deadzone-intra", required_argument, NULL, 0 },
{ "level", required_argument, NULL, 0 },
diff --git a/x264.h b/x264.h
index 8689aa03..18abda8e 100644
index d9644b6f..a2aeb769 100644
--- a/x264.h
+++ b/x264.h
@@ -469,6 +469,7 @@ typedef struct x264_param_t
@@ -454,6 +454,7 @@ typedef struct x264_param_t
int i_aq_mode; /* psy adaptive QP. (X264_AQ_*) */
float f_aq_strength;