forked from BtbN/FFmpeg-Builds
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
svt-av1-psy 916cabd and aom-psy101 9af04512
- Loading branch information
Showing
9 changed files
with
454 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.