diff options
author | Cheng Chen <chengchen@google.com> | 2022-12-02 18:04:32 -0800 |
---|---|---|
committer | Cheng Chen <chengchen@google.com> | 2022-12-07 14:13:06 -0800 |
commit | 5887bd234e5468be69f8e6e714623a152efeaf93 (patch) | |
tree | 3c407acea81b9bdd8a37142fc2958bc1d6c47c5f /vpx | |
parent | 2a8a25cf447914515dd7c27030f39b1cc06234f3 (diff) | |
download | libvpx-5887bd234e5468be69f8e6e714623a152efeaf93.tar libvpx-5887bd234e5468be69f8e6e714623a152efeaf93.tar.gz libvpx-5887bd234e5468be69f8e6e714623a152efeaf93.tar.bz2 libvpx-5887bd234e5468be69f8e6e714623a152efeaf93.zip |
L2E: Add a new interface to control rdmult
Allow external model to control frame rdmult.
A function is called per frame to get the value of rdmult from
the external model.
The external rdmult will overwrite libvpx's default rdmult unless
a reserved value is selected.
A unit test is added to test when the default rdmult value is set.
Change-Id: I2f17a036c188de66dc00709beef4bf2ed86a919a
Diffstat (limited to 'vpx')
-rw-r--r-- | vpx/vpx_ext_ratectrl.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/vpx/vpx_ext_ratectrl.h b/vpx/vpx_ext_ratectrl.h index 95b883413..3c5fc8cfc 100644 --- a/vpx/vpx_ext_ratectrl.h +++ b/vpx/vpx_ext_ratectrl.h @@ -25,20 +25,26 @@ extern "C" { * types, removing or reassigning enums, adding/removing/rearranging * fields to structures. */ -#define VPX_EXT_RATECTRL_ABI_VERSION (5) +#define VPX_EXT_RATECTRL_ABI_VERSION (6) /*!\brief The control type of the inference API. * In VPX_RC_QP mode, the external rate control model determines the * quantization parameter (QP) for each frame. * In VPX_RC_GOP mode, the external rate control model determines the * group of picture (GOP) of the video sequence. + * In VPX_RC_RDMULT mode, the external rate control model determines the + * rate-distortion multiplier (rdmult) for the current frame. * In VPX_RC_GOP_QP mode, the external rate control model determines * both the QP and the GOP. + * In VPX_RC_GOP_QP_RDMULT mode, the external rate control model determines + * the QP, GOP and the rdmult. */ typedef enum vpx_rc_type { VPX_RC_QP = 1 << 0, VPX_RC_GOP = 1 << 1, - VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP + VPX_RC_RDMULT = 1 << 2, + VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP, + VPX_RC_GOP_QP_RDMULT = VPX_RC_QP | VPX_RC_GOP | VPX_RC_RDMULT } vpx_rc_type_t; /*!\brief Abstract rate control model handler @@ -55,6 +61,13 @@ typedef void *vpx_rc_model_t; */ #define VPX_DEFAULT_Q -1 +/*!\brief A reserved value for the rdmult. + * If the external rate control model returns this value, + * the encoder will use the default rdmult selected by libvpx's rate control + * system. + */ +#define VPX_DEFAULT_RDMULT -1 + /*!\brief Encode frame decision made by the external rate control model * * The encoder will receive the decision from the external rate control model @@ -432,6 +445,19 @@ typedef vpx_rc_status_t (*vpx_rc_get_gop_decision_cb_fn_t)( vpx_rc_model_t rate_ctrl_model, const vpx_rc_gop_info_t *gop_info, vpx_rc_gop_decision_t *gop_decision); +/*!\brief Get the frame rdmult from the external rate control model. + * + * This callback is invoked by the encoder to get rdmult from + * the external rate control model. + * + * \param[in] rate_ctrl_model rate control model + * \param[in] frame_info information collected from the encoder + * \param[out] rdmult frame rate-distortion multiplier from the model + */ +typedef vpx_rc_status_t (*vpx_rc_get_frame_rdmult_cb_fn_t)( + vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info, + int *rdmult); + /*!\brief Delete the external rate control model callback prototype * * This callback is invoked by the encoder to delete the external rate control @@ -474,6 +500,10 @@ typedef struct vpx_rc_funcs { */ vpx_rc_get_gop_decision_cb_fn_t get_gop_decision; /*! + * Get rdmult for the frame from the external rate control model. + */ + vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult; + /*! * Delete the external rate control model. */ vpx_rc_delete_model_cb_fn_t delete_model; |