Commit 01775730 authored by Sumit Agarwal's avatar Sumit Agarwal Committed by Timo Rothenpieler

avcodec/nvenc: add weighted prediction support

Signed-off-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
parent 18a659d1
...@@ -298,6 +298,12 @@ static int nvenc_check_capabilities(AVCodecContext *avctx) ...@@ -298,6 +298,12 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
return AVERROR(ENOSYS); return AVERROR(ENOSYS);
} }
ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_WEIGHTED_PREDICTION);
if (ctx->weighted_pred > 0 && ret <= 0) {
av_log (avctx, AV_LOG_VERBOSE, "Weighted Prediction not supported\n");
return AVERROR(ENOSYS);
}
return 0; return 0;
} }
...@@ -1032,6 +1038,9 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) ...@@ -1032,6 +1038,9 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enableEncodeAsync = 0;
ctx->init_encode_params.enablePTD = 1; ctx->init_encode_params.enablePTD = 1;
if (ctx->weighted_pred == 1)
ctx->init_encode_params.enableWeightedPrediction = 1;
if (ctx->bluray_compat) { if (ctx->bluray_compat) {
ctx->aud = 1; ctx->aud = 1;
avctx->refs = FFMIN(FFMAX(avctx->refs, 0), 6); avctx->refs = FFMIN(FFMAX(avctx->refs, 0), 6);
......
...@@ -161,6 +161,7 @@ typedef struct NvencContext ...@@ -161,6 +161,7 @@ typedef struct NvencContext
int init_qp_b; int init_qp_b;
int init_qp_i; int init_qp_i;
int cqp; int cqp;
int weighted_pred;
} NvencContext; } NvencContext;
int ff_nvenc_encode_init(AVCodecContext *avctx); int ff_nvenc_encode_init(AVCodecContext *avctx);
......
...@@ -117,6 +117,8 @@ static const AVOption options[] = { ...@@ -117,6 +117,8 @@ static const AVOption options[] = {
{ "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE }, { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "qp", "Constant quantization parameter rate control method", { "qp", "Constant quantization parameter rate control method",
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE }, OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "weighted_pred","Set 1 to enable weighted prediction",
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL } { NULL }
}; };
......
...@@ -114,6 +114,8 @@ static const AVOption options[] = { ...@@ -114,6 +114,8 @@ static const AVOption options[] = {
{ "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE }, { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "qp", "Constant quantization parameter rate control method", { "qp", "Constant quantization parameter rate control method",
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE }, OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "weighted_pred","Set 1 to enable weighted prediction",
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL } { NULL }
}; };
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 95 #define LIBAVCODEC_VERSION_MINOR 95
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment