WebM Codec SDK

vpx_ext_ratectrl.h
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
11#ifndef VPX_VPX_VPX_EXT_RATECTRL_H_
12#define VPX_VPX_VPX_EXT_RATECTRL_H_
13
14#ifdef __cplusplus
15 extern "C" {
16#endif
17
18#include "./vpx_integer.h"
19
28#define VPX_EXT_RATECTRL_ABI_VERSION (6)
29
42 typedef enum vpx_rc_type {
43 VPX_RC_QP = 1 << 0,
44 VPX_RC_GOP = 1 << 1,
45 VPX_RC_RDMULT = 1 << 2,
46 VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP,
47 VPX_RC_GOP_QP_RDMULT = VPX_RC_QP | VPX_RC_GOP | VPX_RC_RDMULT
48} vpx_rc_type_t;
49
55 typedef void *vpx_rc_model_t;
56
62#define VPX_DEFAULT_Q -1
63
69#define VPX_DEFAULT_RDMULT -1
70
83 typedef struct vpx_rc_encodeframe_decision {
84 int q_index;
85 int max_frame_size;
86} vpx_rc_encodeframe_decision_t;
87
94 typedef struct vpx_rc_encodeframe_info {
102 int frame_type;
103 int show_index;
104 int coding_index;
108 int gop_index;
109 int ref_frame_coding_indexes[3];
115 int ref_frame_valid_list[3];
119 int gop_size;
123 int use_alt_ref;
124} vpx_rc_encodeframe_info_t;
125
131 typedef struct vpx_rc_encodeframe_result {
132 int64_t sse;
133 int64_t bit_count;
134 int64_t pixel_count;
135 int actual_encoding_qindex;
136} vpx_rc_encodeframe_result_t;
137
140 typedef enum vpx_rc_status {
141 VPX_RC_OK = 0,
142 VPX_RC_ERROR = 1,
143} vpx_rc_status_t;
144
149 typedef struct vpx_rc_frame_stats {
154 double frame;
160 double weight;
164 double intra_error;
168 double coded_error;
172 double sr_coded_error;
176 double frame_noise_energy;
180 double pcnt_inter;
184 double pcnt_motion;
190 double pcnt_second_ref;
195 double pcnt_neutral;
203 double pcnt_intra_low;
211 double pcnt_intra_high;
219 double intra_skip_pct;
226 double intra_smooth_pct;
230 double inactive_zone_rows;
234 double inactive_zone_cols;
238 double MVr;
242 double mvr_abs;
246 double MVc;
250 double mvc_abs;
254 double MVrv;
258 double MVcv;
264 double mv_in_out_count;
268 double duration;
273 double count;
274} vpx_rc_frame_stats_t;
275
278 typedef struct vpx_rc_firstpass_stats {
284 vpx_rc_frame_stats_t *frame_stats;
288 int num_frames;
289} vpx_rc_firstpass_stats_t;
290
293 typedef struct vpx_rc_config {
294 int frame_width;
295 int frame_height;
296 int show_frame_count;
300 int target_bitrate_kbps;
301 int frame_rate_num;
302 int frame_rate_den;
303} vpx_rc_config_t;
304
308 typedef struct vpx_rc_gop_info {
316 int min_gf_interval;
320 int max_gf_interval;
325 int active_min_gf_interval;
330 int active_max_gf_interval;
336 int allow_alt_ref;
340 int is_key_frame;
344 int last_gop_use_alt_ref;
349 int frames_since_key;
354 int frames_to_key;
358 int lag_in_frames;
363 int show_index;
367 int coding_index;
372 int gop_global_index;
373} vpx_rc_gop_info_t;
374
378 typedef struct vpx_rc_gop_decision {
379 int gop_coding_frames;
380 int use_alt_ref;
381} vpx_rc_gop_decision_t;
382
392 typedef vpx_rc_status_t (*vpx_rc_create_model_cb_fn_t)(
393 void *priv, const vpx_rc_config_t *ratectrl_config,
394 vpx_rc_model_t *rate_ctrl_model_pt);
395
405 typedef vpx_rc_status_t (*vpx_rc_send_firstpass_stats_cb_fn_t)(
406 vpx_rc_model_t rate_ctrl_model,
407 const vpx_rc_firstpass_stats_t *first_pass_stats);
408
418 typedef vpx_rc_status_t (*vpx_rc_get_encodeframe_decision_cb_fn_t)(
419 vpx_rc_model_t rate_ctrl_model,
420 const vpx_rc_encodeframe_info_t *encode_frame_info,
421 vpx_rc_encodeframe_decision_t *frame_decision);
422
431 typedef vpx_rc_status_t (*vpx_rc_update_encodeframe_result_cb_fn_t)(
432 vpx_rc_model_t rate_ctrl_model,
433 const vpx_rc_encodeframe_result_t *encode_frame_result);
434
444 typedef vpx_rc_status_t (*vpx_rc_get_gop_decision_cb_fn_t)(
445 vpx_rc_model_t rate_ctrl_model, const vpx_rc_gop_info_t *gop_info,
446 vpx_rc_gop_decision_t *gop_decision);
447
457 typedef vpx_rc_status_t (*vpx_rc_get_frame_rdmult_cb_fn_t)(
458 vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info,
459 int *rdmult);
460
468 typedef vpx_rc_status_t (*vpx_rc_delete_model_cb_fn_t)(
469 vpx_rc_model_t rate_ctrl_model);
470
477 typedef struct vpx_rc_funcs {
481 vpx_rc_type_t rc_type;
485 vpx_rc_create_model_cb_fn_t create_model;
489 vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats;
493 vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision;
497 vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result;
501 vpx_rc_get_gop_decision_cb_fn_t get_gop_decision;
505 vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult;
509 vpx_rc_delete_model_cb_fn_t delete_model;
513 void *priv;
514} vpx_rc_funcs_t;
515
516#ifdef __cplusplus
517} // extern "C"
518#endif
519
520#endif // VPX_VPX_VPX_EXT_RATECTRL_H_
vpx_rc_config
Encode config sent to external rate control model.
Definition vpx_ext_ratectrl.h:293
vpx_rc_config::frame_height
int frame_height
Definition vpx_ext_ratectrl.h:295
vpx_rc_config::frame_width
int frame_width
Definition vpx_ext_ratectrl.h:294
vpx_rc_config::show_frame_count
int show_frame_count
Definition vpx_ext_ratectrl.h:296
vpx_rc_config::target_bitrate_kbps
int target_bitrate_kbps
Definition vpx_ext_ratectrl.h:300
vpx_rc_config::frame_rate_num
int frame_rate_num
Definition vpx_ext_ratectrl.h:301
vpx_rc_config::frame_rate_den
int frame_rate_den
Definition vpx_ext_ratectrl.h:302
vpx_rc_encodeframe_decision
Encode frame decision made by the external rate control model.
Definition vpx_ext_ratectrl.h:83
vpx_rc_encodeframe_decision::q_index
int q_index
Definition vpx_ext_ratectrl.h:84
vpx_rc_encodeframe_decision::max_frame_size
int max_frame_size
Definition vpx_ext_ratectrl.h:85
vpx_rc_encodeframe_info
Information for the frame to be encoded.
Definition vpx_ext_ratectrl.h:94
vpx_rc_encodeframe_info::show_index
int show_index
Definition vpx_ext_ratectrl.h:103
vpx_rc_encodeframe_info::coding_index
int coding_index
Definition vpx_ext_ratectrl.h:104
vpx_rc_encodeframe_info::ref_frame_coding_indexes
int ref_frame_coding_indexes[3]
Definition vpx_ext_ratectrl.h:109
vpx_rc_encodeframe_info::ref_frame_valid_list
int ref_frame_valid_list[3]
Definition vpx_ext_ratectrl.h:115
vpx_rc_encodeframe_info::gop_index
int gop_index
Definition vpx_ext_ratectrl.h:108
vpx_rc_encodeframe_info::frame_type
int frame_type
Definition vpx_ext_ratectrl.h:102
vpx_rc_encodeframe_info::use_alt_ref
int use_alt_ref
Definition vpx_ext_ratectrl.h:123
vpx_rc_encodeframe_info::gop_size
int gop_size
Definition vpx_ext_ratectrl.h:119
vpx_rc_encodeframe_result
Frame coding result.
Definition vpx_ext_ratectrl.h:131
vpx_rc_encodeframe_result::actual_encoding_qindex
int actual_encoding_qindex
Definition vpx_ext_ratectrl.h:135
vpx_rc_encodeframe_result::sse
int64_t sse
Definition vpx_ext_ratectrl.h:132
vpx_rc_encodeframe_result::pixel_count
int64_t pixel_count
Definition vpx_ext_ratectrl.h:134
vpx_rc_encodeframe_result::bit_count
int64_t bit_count
Definition vpx_ext_ratectrl.h:133
vpx_rc_firstpass_stats
Collection of first pass frame stats.
Definition vpx_ext_ratectrl.h:278
vpx_rc_firstpass_stats::frame_stats
vpx_rc_frame_stats_t * frame_stats
Definition vpx_ext_ratectrl.h:284
vpx_rc_firstpass_stats::num_frames
int num_frames
Definition vpx_ext_ratectrl.h:288
vpx_rc_frame_stats
First pass frame stats This is a mirror of vp9's FIRSTPASS_STATS except that spatial_layer_id is omit...
Definition vpx_ext_ratectrl.h:149
vpx_rc_frame_stats::mvr_abs
double mvr_abs
Definition vpx_ext_ratectrl.h:242
vpx_rc_frame_stats::duration
double duration
Definition vpx_ext_ratectrl.h:268
vpx_rc_frame_stats::pcnt_intra_low
double pcnt_intra_low
Definition vpx_ext_ratectrl.h:203
vpx_rc_frame_stats::inactive_zone_cols
double inactive_zone_cols
Definition vpx_ext_ratectrl.h:234
vpx_rc_frame_stats::weight
double weight
Definition vpx_ext_ratectrl.h:160
vpx_rc_frame_stats::MVr
double MVr
Definition vpx_ext_ratectrl.h:238
vpx_rc_frame_stats::mv_in_out_count
double mv_in_out_count
Definition vpx_ext_ratectrl.h:264
vpx_rc_frame_stats::inactive_zone_rows
double inactive_zone_rows
Definition vpx_ext_ratectrl.h:230
vpx_rc_frame_stats::frame
double frame
Definition vpx_ext_ratectrl.h:154
vpx_rc_frame_stats::intra_error
double intra_error
Definition vpx_ext_ratectrl.h:164
vpx_rc_frame_stats::frame_noise_energy
double frame_noise_energy
Definition vpx_ext_ratectrl.h:176
vpx_rc_frame_stats::pcnt_neutral
double pcnt_neutral
Definition vpx_ext_ratectrl.h:195
vpx_rc_frame_stats::MVc
double MVc
Definition vpx_ext_ratectrl.h:246
vpx_rc_frame_stats::mvc_abs
double mvc_abs
Definition vpx_ext_ratectrl.h:250
vpx_rc_frame_stats::intra_smooth_pct
double intra_smooth_pct
Definition vpx_ext_ratectrl.h:226
vpx_rc_frame_stats::MVrv
double MVrv
Definition vpx_ext_ratectrl.h:254
vpx_rc_frame_stats::pcnt_motion
double pcnt_motion
Definition vpx_ext_ratectrl.h:184
vpx_rc_frame_stats::MVcv
double MVcv
Definition vpx_ext_ratectrl.h:258
vpx_rc_frame_stats::pcnt_intra_high
double pcnt_intra_high
Definition vpx_ext_ratectrl.h:211
vpx_rc_frame_stats::count
double count
Definition vpx_ext_ratectrl.h:273
vpx_rc_frame_stats::pcnt_inter
double pcnt_inter
Definition vpx_ext_ratectrl.h:180
vpx_rc_frame_stats::intra_skip_pct
double intra_skip_pct
Definition vpx_ext_ratectrl.h:219
vpx_rc_frame_stats::sr_coded_error
double sr_coded_error
Definition vpx_ext_ratectrl.h:172
vpx_rc_frame_stats::pcnt_second_ref
double pcnt_second_ref
Definition vpx_ext_ratectrl.h:190
vpx_rc_frame_stats::coded_error
double coded_error
Definition vpx_ext_ratectrl.h:168
vpx_rc_funcs
Callback function set for external rate control.
Definition vpx_ext_ratectrl.h:477
vpx_rc_funcs::send_firstpass_stats
vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats
Definition vpx_ext_ratectrl.h:489
vpx_rc_funcs::get_encodeframe_decision
vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision
Definition vpx_ext_ratectrl.h:493
vpx_rc_funcs::create_model
vpx_rc_create_model_cb_fn_t create_model
Definition vpx_ext_ratectrl.h:485
vpx_rc_funcs::get_gop_decision
vpx_rc_get_gop_decision_cb_fn_t get_gop_decision
Definition vpx_ext_ratectrl.h:501
vpx_rc_funcs::rc_type
vpx_rc_type_t rc_type
Definition vpx_ext_ratectrl.h:481
vpx_rc_funcs::priv
void * priv
Definition vpx_ext_ratectrl.h:513
vpx_rc_funcs::update_encodeframe_result
vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result
Definition vpx_ext_ratectrl.h:497
vpx_rc_funcs::delete_model
vpx_rc_delete_model_cb_fn_t delete_model
Definition vpx_ext_ratectrl.h:509
vpx_rc_funcs::get_frame_rdmult
vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult
Definition vpx_ext_ratectrl.h:505
vpx_rc_gop_decision
The decision made by the external rate control model to set the group of picture.
Definition vpx_ext_ratectrl.h:378
vpx_rc_gop_decision::use_alt_ref
int use_alt_ref
Definition vpx_ext_ratectrl.h:380
vpx_rc_gop_decision::gop_coding_frames
int gop_coding_frames
Definition vpx_ext_ratectrl.h:379
vpx_rc_gop_info
Information passed to the external rate control model to help make GOP decisions.
Definition vpx_ext_ratectrl.h:308
vpx_rc_gop_info::active_min_gf_interval
int active_min_gf_interval
Definition vpx_ext_ratectrl.h:325
vpx_rc_gop_info::show_index
int show_index
Definition vpx_ext_ratectrl.h:363
vpx_rc_gop_info::frames_since_key
int frames_since_key
Definition vpx_ext_ratectrl.h:349
vpx_rc_gop_info::allow_alt_ref
int allow_alt_ref
Definition vpx_ext_ratectrl.h:336
vpx_rc_gop_info::is_key_frame
int is_key_frame
Definition vpx_ext_ratectrl.h:340
vpx_rc_gop_info::active_max_gf_interval
int active_max_gf_interval
Definition vpx_ext_ratectrl.h:330
vpx_rc_gop_info::max_gf_interval
int max_gf_interval
Definition vpx_ext_ratectrl.h:320
vpx_rc_gop_info::min_gf_interval
int min_gf_interval
Definition vpx_ext_ratectrl.h:316
vpx_rc_gop_info::last_gop_use_alt_ref
int last_gop_use_alt_ref
Definition vpx_ext_ratectrl.h:344
vpx_rc_gop_info::frames_to_key
int frames_to_key
Definition vpx_ext_ratectrl.h:354
vpx_rc_gop_info::coding_index
int coding_index
Definition vpx_ext_ratectrl.h:367
vpx_rc_gop_info::lag_in_frames
int lag_in_frames
Definition vpx_ext_ratectrl.h:358
vpx_rc_gop_info::gop_global_index
int gop_global_index
Definition vpx_ext_ratectrl.h:372