summaryrefslogtreecommitdiff
path: root/libavcodec/qsvenc.c
diff options
context:
space:
mode:
authorYue Heng <yue.heng@intel.com>2022-05-25 21:13:41 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2022-06-06 13:56:10 +0800
commit11912f65ef5ad12db938e404eafc855af1bc3859 (patch)
treed178b8c9e6559ad9f4c2f4316f0a30a0b5fec09d /libavcodec/qsvenc.c
parente8381691813a4f10a280169a782a716568e57614 (diff)
downloadffmpeg-11912f65ef5ad12db938e404eafc855af1bc3859.tar.gz
libavcodec/qsvenc: Add min/max QP control options for I/P/B frame
To do more accurate QP control, add min/max QP control on I/P/B frame separately to qsv encoder. qmax and qmin still work but newly-added options have higher priority. Signed-off-by: Yue Heng <yue.heng@intel.com> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r--libavcodec/qsvenc.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2b3b06767d..03e9e5523d 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -828,8 +828,13 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
if (q->b_strategy >= 0)
q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
- if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) {
- av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but invalid, please make sure min <= max\n");
+ if ((avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) ||
+ (q->max_qp_i >= 0 && q->min_qp_i >= 0 && q->min_qp_i > q->max_qp_i) ||
+ (q->max_qp_p >= 0 && q->min_qp_p >= 0 && q->min_qp_p > q->max_qp_p) ||
+ (q->max_qp_b >= 0 && q->min_qp_b >= 0 && q->min_qp_b > q->max_qp_b)) {
+ av_log(avctx, AV_LOG_ERROR,
+ "qmin and or qmax are set but invalid,"
+ " please make sure min <= max\n");
return AVERROR(EINVAL);
}
if (avctx->qmin >= 0) {
@@ -840,6 +845,18 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax;
q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
}
+ if (q->min_qp_i >= 0)
+ q->extco2.MinQPI = q->min_qp_i > 51 ? 51 : q->min_qp_i;
+ if (q->max_qp_i >= 0)
+ q->extco2.MaxQPI = q->max_qp_i > 51 ? 51 : q->max_qp_i;
+ if (q->min_qp_p >= 0)
+ q->extco2.MinQPP = q->min_qp_p > 51 ? 51 : q->min_qp_p;
+ if (q->max_qp_p >= 0)
+ q->extco2.MaxQPP = q->max_qp_p > 51 ? 51 : q->max_qp_p;
+ if (q->min_qp_b >= 0)
+ q->extco2.MinQPB = q->min_qp_b > 51 ? 51 : q->min_qp_b;
+ if (q->max_qp_b >= 0)
+ q->extco2.MaxQPB = q->max_qp_b > 51 ? 51 : q->max_qp_b;
if (q->mbbrc >= 0)
q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;