Follow vaapi_h264 style, enable the VBR mode.
Unified · Split
| @@ -1185,13 +1185,15 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) · 1184 unmodified lines | ||
| 1185 | 1185 | "%d / %d / %d for IDR- / P- / B-frames.\n", |
| 1186 | 1186 | priv->fixed_qp_idr, priv->fixed_qp_p, priv->fixed_qp_b); |
| 1187 | 1187 | |
| 1188 | − } else if (ctx->va_rc_mode == VA_RC_CBR) { | |
| 1188 | + } else if (ctx->va_rc_mode == VA_RC_CBR || | |
| 1189 | + ctx->va_rc_mode == VA_RC_VBR) { | |
| 1189 | 1190 | // These still need to be set for pic_init_qp/slice_qp_delta. |
| 1190 | 1191 | priv->fixed_qp_idr = 30; |
| 1191 | 1192 | priv->fixed_qp_p = 30; |
| 1192 | 1193 | priv->fixed_qp_b = 30; |
| 1193 | 1194 | |
| 1194 | − av_log(avctx, AV_LOG_DEBUG, "Using constant-bitrate = %"PRId64" bps.\n", | |
| 1195 | + av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n", | |
| 1196 | + ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable", | |
| 1195 | 1197 | avctx->bit_rate); |
| 1196 | 1198 | |
| 1197 | 1199 | } else { |
| @@ -1251,9 +1253,12 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) · 53 unmodified lines | ||
| 1251 | 1253 | } |
| 1252 | 1254 | ctx->va_entrypoint = VAEntrypointEncSlice; |
| 1253 | 1255 | |
| 1254 | − if (avctx->bit_rate > 0) | |
| 1255 | − ctx->va_rc_mode = VA_RC_CBR; | |
| 1256 | − else | |
| 1256 | + if (avctx->bit_rate > 0) { | |
| 1257 | + if (avctx->rc_max_rate == avctx->bit_rate) | |
| 1258 | + ctx->va_rc_mode = VA_RC_CBR; | |
| 1259 | + else | |
| 1260 | + ctx->va_rc_mode = VA_RC_VBR; | |
| 1261 | + } else | |
| 1257 | 1262 | ctx->va_rc_mode = VA_RC_CQP; |
| 1258 | 1263 | |
| 1259 | 1264 | ctx->va_packed_headers = |