WebM Codec SDK
vpx_ext_ratectrl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 The WebM project authors. All Rights Reserved.
3  *
4  * Use of this source code is governed by a BSD-style license
5  * that can be found in the LICENSE file in the root of the source
6  * tree. An additional intellectual property rights grant can be found
7  * in the file PATENTS. All contributing project authors may
8  * be found in the AUTHORS file in the root of the source tree.
9  */
10 
15 #ifndef VPX_VPX_VPX_EXT_RATECTRL_H_
16 #define VPX_VPX_VPX_EXT_RATECTRL_H_
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "./vpx_integer.h"
23 #include "./vpx_tpl.h"
24 
33 #define VPX_EXT_RATECTRL_ABI_VERSION (7 + VPX_TPL_ABI_VERSION)
34 
37 #define VPX_RC_MAX_STATIC_GF_GROUP_LENGTH 250
38 
43 #define VPX_RC_MAX_REF_FRAMES 4
44 
50 typedef enum vpx_rc_type {
60  VPX_RC_QP = 1 << 0,
65  VPX_RC_GOP = 1 << 1,
70  VPX_RC_RDMULT = 1 << 2,
80 
83 typedef enum vpx_ext_rc_mode {
84  VPX_RC_QMODE = 0,
85  VPX_RC_VBR = 1,
86  VPX_RC_CQ = 2,
88 
92  VPX_RC_INVALID_UPDATE_TYPE = -1,
93  VPX_RC_KF_UPDATE = 0,
94  VPX_RC_LF_UPDATE = 1,
95  VPX_RC_GF_UPDATE = 2,
96  VPX_RC_ARF_UPDATE = 3,
97  VPX_RC_OVERLAY_UPDATE = 4,
98  VPX_RC_MID_OVERLAY_UPDATE = 5,
99  VPX_RC_USE_BUF_FRAME = 6,
101 
106 typedef enum vpx_rc_ref_name {
107  VPX_RC_INVALID_REF_FRAME = -1,
108  VPX_RC_INTRA_FRAME = 0,
109  VPX_RC_LAST_FRAME = 1,
110  VPX_RC_GOLDEN_FRAME = 2,
111  VPX_RC_ALTREF_FRAME = 3,
113 
119 typedef void *vpx_rc_model_t;
120 
126 #define VPX_DEFAULT_Q -1
127 
133 #define VPX_DEFAULT_RDMULT -1
134 
138 typedef struct sb_parameters {
139  int q_index;
140  int rdmult;
141 } sb_params;
142 
149  int q_index;
150  int rdmult;
159 
166 typedef struct vpx_rc_encodeframe_info {
191  int gop_size;
197 
204  int64_t bit_count;
207 
210 typedef enum vpx_rc_status {
211  VPX_RC_OK = 0,
212  VPX_RC_ERROR = 1,
214 
219 typedef struct vpx_rc_frame_stats {
224  double frame;
230  double weight;
234  double intra_error;
238  double coded_error;
250  double pcnt_inter;
254  double pcnt_motion;
265  double pcnt_neutral;
308  double MVr;
312  double mvr_abs;
316  double MVc;
320  double mvc_abs;
324  double MVrv;
328  double MVcv;
338  double duration;
343  double count;
347  double new_mv_count;
349 
352 typedef struct vpx_rc_firstpass_stats {
364 
367 typedef struct vpx_rc_config {
388  int base_qp;
390 
393 typedef struct vpx_rc_ref_frame {
406 
410 typedef struct vpx_rc_gop_decision {
425 
433 
444  void *priv, const vpx_rc_config_t *ratectrl_config,
445  vpx_rc_model_t *rate_ctrl_model_ptr);
446 
457  vpx_rc_model_t rate_ctrl_model,
458  const vpx_rc_firstpass_stats_t *first_pass_stats);
459 
470  vpx_rc_model_t rate_ctrl_model, const VpxTplGopStats *tpl_gop_stats);
471 
482  vpx_rc_model_t rate_ctrl_model, const int frame_gop_index,
483  vpx_rc_encodeframe_decision_t *frame_decision);
484 
494  vpx_rc_model_t rate_ctrl_model,
495  const vpx_rc_encodeframe_result_t *encode_frame_result);
496 
506  vpx_rc_model_t rate_ctrl_model,
507  vpx_rc_key_frame_decision_t *key_frame_decision);
508 
518  vpx_rc_model_t rate_ctrl_model, vpx_rc_gop_decision_t *gop_decision);
519 
530  vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info,
531  int *rdmult);
532 
541  vpx_rc_model_t rate_ctrl_model);
542 
549 typedef struct vpx_rc_funcs {
590 
594  const char *rate_ctrl_log_path;
598  void *priv;
600 
601 #ifdef __cplusplus
602 } // extern "C"
603 #endif
604 
605 #endif // VPX_VPX_VPX_EXT_RATECTRL_H_
int actual_encoding_qindex
Definition: vpx_ext_ratectrl.h:205
vpx_ext_rc_mode
The rate control mode for the external rate control model.
Definition: vpx_ext_ratectrl.h:83
int max_gf_interval
Definition: vpx_ext_ratectrl.h:371
int show_frame_count
Definition: vpx_ext_ratectrl.h:370
double inactive_zone_cols
Definition: vpx_ext_ratectrl.h:304
Frame coding result.
Definition: vpx_ext_ratectrl.h:203
double mvc_abs
Definition: vpx_ext_ratectrl.h:320
int ref_frame_coding_indexes[3]
Definition: vpx_ext_ratectrl.h:181
struct vpx_rc_encodeframe_info vpx_rc_encodeframe_info_t
Information for the frame to be encoded.
struct vpx_rc_frame_stats vpx_rc_frame_stats_t
First pass frame stats This is a mirror of vp9&#39;s FIRSTPASS_STATS except that spatial_layer_id is omit...
The decision made by the external rate control model to set the key frame location and the show frame...
Definition: vpx_ext_ratectrl.h:429
The decision made by the external rate control model to set the group of picture. ...
Definition: vpx_ext_ratectrl.h:410
int num_frames
Definition: vpx_ext_ratectrl.h:362
double coded_error
Definition: vpx_ext_ratectrl.h:238
vpx_rc_ref_frame_t ref_frame_list[250+2]
Definition: vpx_ext_ratectrl.h:423
struct vpx_rc_encodeframe_decision vpx_rc_encodeframe_decision_t
Encode frame decision made by the external rate control model.
vpx_rc_delete_model_cb_fn_t delete_model
Definition: vpx_ext_ratectrl.h:589
int frame_height
Definition: vpx_ext_ratectrl.h:369
int delta_q_uv
Definition: vpx_ext_ratectrl.h:151
enum vpx_rc_status vpx_rc_status_t
Status returned by rate control callback functions.
int gop_index
Definition: vpx_ext_ratectrl.h:180
enum vpx_ext_rc_mode vpx_ext_rc_mode_t
The rate control mode for the external rate control model.
vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats
Definition: vpx_ext_ratectrl.h:561
Control what ref frame to use and its index.
Definition: vpx_ext_ratectrl.h:393
vpx_rc_status_t(* vpx_rc_update_encodeframe_result_cb_fn_t)(vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_result_t *encode_frame_result)
Update encode frame result callback prototype.
Definition: vpx_ext_ratectrl.h:493
double mvr_abs
Definition: vpx_ext_ratectrl.h:312
enum vpx_rc_ref_name vpx_rc_ref_name_t
Name for the ref frames returned by the external RC.
double pcnt_second_ref
Definition: vpx_ext_ratectrl.h:260
double MVrv
Definition: vpx_ext_ratectrl.h:324
First pass frame stats This is a mirror of vp9&#39;s FIRSTPASS_STATS except that spatial_layer_id is omit...
Definition: vpx_ext_ratectrl.h:219
int frame_rate_num
Definition: vpx_ext_ratectrl.h:377
int show_index
Definition: vpx_ext_ratectrl.h:175
struct vpx_rc_funcs vpx_rc_funcs_t
Callback function set for external rate control.
Callback function set for external rate control.
Definition: vpx_ext_ratectrl.h:549
vpx_rc_get_gop_decision_cb_fn_t get_gop_decision
Definition: vpx_ext_ratectrl.h:581
int use_key_frame
Definition: vpx_ext_ratectrl.h:413
double intra_error
Definition: vpx_ext_ratectrl.h:234
int key_frame_group_size
Definition: vpx_ext_ratectrl.h:431
#define VPX_RC_MAX_REF_FRAMES
Max number of ref frames returned by the external RC.
Definition: vpx_ext_ratectrl.h:43
double pcnt_intra_low
Definition: vpx_ext_ratectrl.h:273
double intra_smooth_pct
Definition: vpx_ext_ratectrl.h:296
vpx_rc_status_t(* vpx_rc_send_firstpass_stats_cb_fn_t)(vpx_rc_model_t rate_ctrl_model, const vpx_rc_firstpass_stats_t *first_pass_stats)
Send first pass stats to the external rate control model callback prototype.
Definition: vpx_ext_ratectrl.h:456
vpx_rc_create_model_cb_fn_t create_model
Definition: vpx_ext_ratectrl.h:557
int min_gf_interval
Definition: vpx_ext_ratectrl.h:372
Definition: vpx_ext_ratectrl.h:65
vpx_rc_status_t(* vpx_rc_create_model_cb_fn_t)(void *priv, const vpx_rc_config_t *ratectrl_config, vpx_rc_model_t *rate_ctrl_model_ptr)
Create an external rate control model callback prototype.
Definition: vpx_ext_ratectrl.h:443
int max_base_q_index
Definition: vpx_ext_ratectrl.h:387
double pcnt_motion
Definition: vpx_ext_ratectrl.h:254
double MVcv
Definition: vpx_ext_ratectrl.h:328
sb_params * sb_params_list
Definition: vpx_ext_ratectrl.h:157
Definition: vpx_ext_ratectrl.h:70
vpx_rc_ref_name
Name for the ref frames returned by the external RC.
Definition: vpx_ext_ratectrl.h:106
vpx_rc_status_t(* vpx_rc_delete_model_cb_fn_t)(vpx_rc_model_t rate_ctrl_model)
Delete the external rate control model callback prototype.
Definition: vpx_ext_ratectrl.h:540
double new_mv_count
Definition: vpx_ext_ratectrl.h:347
vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision
Definition: vpx_ext_ratectrl.h:569
void * vpx_rc_model_t
Abstract rate control model handler.
Definition: vpx_ext_ratectrl.h:119
struct vpx_rc_ref_frame vpx_rc_ref_frame_t
Control what ref frame to use and its index.
int frame_type
Definition: vpx_ext_ratectrl.h:174
Encode config sent to external rate control model.
Definition: vpx_ext_ratectrl.h:367
Definition: vpx_ext_ratectrl.h:78
struct vpx_rc_firstpass_stats vpx_rc_firstpass_stats_t
Collection of first pass frame stats.
double frame_noise_energy
Definition: vpx_ext_ratectrl.h:246
int base_qp
Definition: vpx_ext_ratectrl.h:388
Definition: vpx_ext_ratectrl.h:60
double sr_coded_error
Definition: vpx_ext_ratectrl.h:242
vpx_rc_frame_update_type
Corresponds to FRAME_UPDATE_TYPE defined in vp9_firstpass.h.
Definition: vpx_ext_ratectrl.h:91
struct vpx_rc_config vpx_rc_config_t
Encode config sent to external rate control model.
vpx_rc_get_key_frame_decision_cb_fn_t get_key_frame_decision
Definition: vpx_ext_ratectrl.h:577
double pcnt_neutral
Definition: vpx_ext_ratectrl.h:265
const char * rate_ctrl_log_path
Definition: vpx_ext_ratectrl.h:594
double mv_in_out_count
Definition: vpx_ext_ratectrl.h:334
vpx_rc_status_t(* vpx_rc_get_encodeframe_decision_cb_fn_t)(vpx_rc_model_t rate_ctrl_model, const int frame_gop_index, vpx_rc_encodeframe_decision_t *frame_decision)
Receive encode frame decision callback prototype.
Definition: vpx_ext_ratectrl.h:481
vpx_rc_type_t rc_type
Definition: vpx_ext_ratectrl.h:553
struct sb_parameters sb_params
Superblock quantization parameters Store the superblock quantization parameters.
Encode frame decision made by the external rate control model.
Definition: vpx_ext_ratectrl.h:148
int q_index
Definition: vpx_ext_ratectrl.h:149
double intra_skip_pct
Definition: vpx_ext_ratectrl.h:289
double pcnt_inter
Definition: vpx_ext_ratectrl.h:250
Information for the frame to be encoded.
Definition: vpx_ext_ratectrl.h:166
int64_t bit_count
Definition: vpx_ext_ratectrl.h:204
vpx_rc_frame_stats_t * frame_stats
Definition: vpx_ext_ratectrl.h:358
int ref_frame_valid_list[3]
Definition: vpx_ext_ratectrl.h:187
int target_bitrate_kbps
Definition: vpx_ext_ratectrl.h:376
double duration
Definition: vpx_ext_ratectrl.h:338
int use_alt_ref
Definition: vpx_ext_ratectrl.h:195
vpx_rc_type
The type of the external rate control.
Definition: vpx_ext_ratectrl.h:50
double count
Definition: vpx_ext_ratectrl.h:343
vpx_ext_rc_mode_t rc_mode
Definition: vpx_ext_ratectrl.h:383
int undershoot_percent
Definition: vpx_ext_ratectrl.h:385
Collection of first pass frame stats.
Definition: vpx_ext_ratectrl.h:352
#define VPX_RC_MAX_STATIC_GF_GROUP_LENGTH
Corresponds to MAX_STATIC_GF_GROUP_LENGTH defined in vp9_ratectrl.h.
Definition: vpx_ext_ratectrl.h:37
int q_index
Definition: vpx_ext_ratectrl.h:139
struct vpx_rc_encodeframe_result vpx_rc_encodeframe_result_t
Frame coding result.
int overshoot_percent
Definition: vpx_ext_ratectrl.h:384
int frame_width
Definition: vpx_ext_ratectrl.h:368
int gop_coding_frames
Definition: vpx_ext_ratectrl.h:411
Superblock quantization parameters Store the superblock quantization parameters.
Definition: vpx_ext_ratectrl.h:138
int coding_index
Definition: vpx_ext_ratectrl.h:176
Definition: vpx_ext_ratectrl.h:55
struct vpx_rc_gop_decision vpx_rc_gop_decision_t
The decision made by the external rate control model to set the group of picture. ...
int rdmult
Definition: vpx_ext_ratectrl.h:140
double inactive_zone_rows
Definition: vpx_ext_ratectrl.h:300
Definition: vpx_ext_ratectrl.h:74
enum vpx_rc_type vpx_rc_type_t
The type of the external rate control.
int min_base_q_index
Definition: vpx_ext_ratectrl.h:386
void * priv
Definition: vpx_ext_ratectrl.h:598
vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult
Definition: vpx_ext_ratectrl.h:585
struct vpx_rc_key_frame_decision vpx_rc_key_frame_decision_t
The decision made by the external rate control model to set the key frame location and the show frame...
vpx_rc_status_t(* vpx_rc_get_key_frame_decision_cb_fn_t)(vpx_rc_model_t rate_ctrl_model, vpx_rc_key_frame_decision_t *key_frame_decision)
Get the key frame decision from the external rate control model.
Definition: vpx_ext_ratectrl.h:505
double MVc
Definition: vpx_ext_ratectrl.h:316
vpx_rc_status
Status returned by rate control callback functions.
Definition: vpx_ext_ratectrl.h:210
int gop_size
Definition: vpx_ext_ratectrl.h:191
enum vpx_rc_frame_update_type vpx_rc_frame_update_type_t
Corresponds to FRAME_UPDATE_TYPE defined in vp9_firstpass.h.
int index[4]
Definition: vpx_ext_ratectrl.h:398
int update_ref_index[250+2]
Definition: vpx_ext_ratectrl.h:421
int key_frame_show_index
Definition: vpx_ext_ratectrl.h:430
vpx_rc_status_t(* vpx_rc_send_tpl_gop_stats_cb_fn_t)(vpx_rc_model_t rate_ctrl_model, const VpxTplGopStats *tpl_gop_stats)
Send TPL stats for the current GOP to the external rate control model callback prototype.
Definition: vpx_ext_ratectrl.h:469
double MVr
Definition: vpx_ext_ratectrl.h:308
double weight
Definition: vpx_ext_ratectrl.h:230
vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats
Definition: vpx_ext_ratectrl.h:565
vpx_rc_ref_name_t name[4]
Definition: vpx_ext_ratectrl.h:404
int use_alt_ref
Definition: vpx_ext_ratectrl.h:412
vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result
Definition: vpx_ext_ratectrl.h:573
int frame_rate_den
Definition: vpx_ext_ratectrl.h:378
Temporal dependency model stats for each GOP before propagation.
Definition: vpx_tpl.h:60
double frame
Definition: vpx_ext_ratectrl.h:224
double pcnt_intra_high
Definition: vpx_ext_ratectrl.h:281
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)
Get the frame rdmult from the external rate control model.
Definition: vpx_ext_ratectrl.h:529
vpx_rc_frame_update_type_t update_type[250+2]
Definition: vpx_ext_ratectrl.h:419
vpx_rc_status_t(* vpx_rc_get_gop_decision_cb_fn_t)(vpx_rc_model_t rate_ctrl_model, vpx_rc_gop_decision_t *gop_decision)
Get the GOP structure from the external rate control model.
Definition: vpx_ext_ratectrl.h:517
int rdmult
Definition: vpx_ext_ratectrl.h:150
Describes the TPL stats descriptor and associated operations.