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#include "./vpx_tpl.h"
20
29#define VPX_EXT_RATECTRL_ABI_VERSION (7)
30
43 typedef enum vpx_rc_type {
44 VPX_RC_QP = 1 << 0,
45 VPX_RC_GOP = 1 << 1,
46 VPX_RC_RDMULT = 1 << 2,
47 VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP,
48 VPX_RC_GOP_QP_RDMULT = VPX_RC_QP | VPX_RC_GOP | VPX_RC_RDMULT
49} vpx_rc_type_t;
50
53 typedef enum vpx_ext_rc_mode {
54 VPX_RC_QMODE = 0,
55 VPX_RC_VBR = 1,
56 VPX_RC_CQ = 2,
57} vpx_ext_rc_mode_t;
58
64 typedef void *vpx_rc_model_t;
65
71#define VPX_DEFAULT_Q -1
72
78#define VPX_DEFAULT_RDMULT -1
79
92 typedef struct vpx_rc_encodeframe_decision {
93 int q_index;
94 int max_frame_size;
95} vpx_rc_encodeframe_decision_t;
96
103 typedef struct vpx_rc_encodeframe_info {
111 int frame_type;
112 int show_index;
113 int coding_index;
117 int gop_index;
118 int ref_frame_coding_indexes[3];
124 int ref_frame_valid_list[3];
128 int gop_size;
132 int use_alt_ref;
133} vpx_rc_encodeframe_info_t;
134
140 typedef struct vpx_rc_encodeframe_result {
141 int64_t sse;
142 int64_t bit_count;
143 int64_t pixel_count;
144 int actual_encoding_qindex;
145} vpx_rc_encodeframe_result_t;
146
149 typedef enum vpx_rc_status {
150 VPX_RC_OK = 0,
151 VPX_RC_ERROR = 1,
152} vpx_rc_status_t;
153
158 typedef struct vpx_rc_frame_stats {
163 double frame;
169 double weight;
173 double intra_error;
177 double coded_error;
181 double sr_coded_error;
185 double frame_noise_energy;
189 double pcnt_inter;
193 double pcnt_motion;
199 double pcnt_second_ref;
204 double pcnt_neutral;
212 double pcnt_intra_low;
220 double pcnt_intra_high;
228 double intra_skip_pct;
235 double intra_smooth_pct;
239 double inactive_zone_rows;
243 double inactive_zone_cols;
247 double MVr;
251 double mvr_abs;
255 double MVc;
259 double mvc_abs;
263 double MVrv;
267 double MVcv;
273 double mv_in_out_count;
277 double duration;
282 double count;
286 double new_mv_count;
287} vpx_rc_frame_stats_t;
288
291 typedef struct vpx_rc_firstpass_stats {
297 vpx_rc_frame_stats_t *frame_stats;
301 int num_frames;
302} vpx_rc_firstpass_stats_t;
303
306 typedef struct vpx_rc_config {
307 int frame_width;
308 int frame_height;
309 int show_frame_count;
310 int max_gf_interval;
311 int min_gf_interval;
315 int target_bitrate_kbps;
316 int frame_rate_num;
317 int frame_rate_den;
322 vpx_ext_rc_mode_t rc_mode;
323 int overshoot_percent;
324 int undershoot_percent;
325} vpx_rc_config_t;
326
330 typedef struct vpx_rc_gop_info {
338 int min_gf_interval;
342 int max_gf_interval;
347 int active_min_gf_interval;
352 int active_max_gf_interval;
358 int allow_alt_ref;
362 int is_key_frame;
366 int last_gop_use_alt_ref;
371 int frames_since_key;
376 int frames_to_key;
380 int lag_in_frames;
385 int show_index;
389 int coding_index;
394 int gop_global_index;
395} vpx_rc_gop_info_t;
396
400 typedef struct vpx_rc_gop_decision {
401 int gop_coding_frames;
402 int use_alt_ref;
403} vpx_rc_gop_decision_t;
404
414 typedef vpx_rc_status_t (*vpx_rc_create_model_cb_fn_t)(
415 void *priv, const vpx_rc_config_t *ratectrl_config,
416 vpx_rc_model_t *rate_ctrl_model_ptr);
417
427 typedef vpx_rc_status_t (*vpx_rc_send_firstpass_stats_cb_fn_t)(
428 vpx_rc_model_t rate_ctrl_model,
429 const vpx_rc_firstpass_stats_t *first_pass_stats);
430
440 typedef vpx_rc_status_t (*vpx_rc_send_tpl_gop_stats_cb_fn_t)(
441 vpx_rc_model_t rate_ctrl_model, const VpxTplGopStats *tpl_gop_stats);
442
452 typedef vpx_rc_status_t (*vpx_rc_get_encodeframe_decision_cb_fn_t)(
453 vpx_rc_model_t rate_ctrl_model,
454 const vpx_rc_encodeframe_info_t *encode_frame_info,
455 vpx_rc_encodeframe_decision_t *frame_decision);
456
465 typedef vpx_rc_status_t (*vpx_rc_update_encodeframe_result_cb_fn_t)(
466 vpx_rc_model_t rate_ctrl_model,
467 const vpx_rc_encodeframe_result_t *encode_frame_result);
468
478 typedef vpx_rc_status_t (*vpx_rc_get_gop_decision_cb_fn_t)(
479 vpx_rc_model_t rate_ctrl_model, const vpx_rc_gop_info_t *gop_info,
480 vpx_rc_gop_decision_t *gop_decision);
481
491 typedef vpx_rc_status_t (*vpx_rc_get_frame_rdmult_cb_fn_t)(
492 vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info,
493 int *rdmult);
494
502 typedef vpx_rc_status_t (*vpx_rc_delete_model_cb_fn_t)(
503 vpx_rc_model_t rate_ctrl_model);
504
511 typedef struct vpx_rc_funcs {
515 vpx_rc_type_t rc_type;
519 vpx_rc_create_model_cb_fn_t create_model;
523 vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats;
527 vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats;
531 vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision;
535 vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result;
539 vpx_rc_get_gop_decision_cb_fn_t get_gop_decision;
543 vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult;
547 vpx_rc_delete_model_cb_fn_t delete_model;
551 void *priv;
552} vpx_rc_funcs_t;
553
554#ifdef __cplusplus
555} // extern "C"
556#endif
557
558#endif // VPX_VPX_VPX_EXT_RATECTRL_H_
VpxTplGopStats
Temporal dependency model stats for each GOP before propagation.
Definition vpx_tpl.h:59
vpx_rc_config
Encode config sent to external rate control model.
Definition vpx_ext_ratectrl.h:306
vpx_rc_config::frame_height
int frame_height
Definition vpx_ext_ratectrl.h:308
vpx_rc_config::frame_width
int frame_width
Definition vpx_ext_ratectrl.h:307
vpx_rc_config::show_frame_count
int show_frame_count
Definition vpx_ext_ratectrl.h:309
vpx_rc_config::overshoot_percent
int overshoot_percent
Definition vpx_ext_ratectrl.h:323
vpx_rc_config::max_gf_interval
int max_gf_interval
Definition vpx_ext_ratectrl.h:310
vpx_rc_config::undershoot_percent
int undershoot_percent
Definition vpx_ext_ratectrl.h:324
vpx_rc_config::target_bitrate_kbps
int target_bitrate_kbps
Definition vpx_ext_ratectrl.h:315
vpx_rc_config::rc_mode
vpx_ext_rc_mode_t rc_mode
Definition vpx_ext_ratectrl.h:322
vpx_rc_config::frame_rate_num
int frame_rate_num
Definition vpx_ext_ratectrl.h:316
vpx_rc_config::min_gf_interval
int min_gf_interval
Definition vpx_ext_ratectrl.h:311
vpx_rc_config::frame_rate_den
int frame_rate_den
Definition vpx_ext_ratectrl.h:317
vpx_rc_encodeframe_decision
Encode frame decision made by the external rate control model.
Definition vpx_ext_ratectrl.h:92
vpx_rc_encodeframe_decision::q_index
int q_index
Definition vpx_ext_ratectrl.h:93
vpx_rc_encodeframe_decision::max_frame_size
int max_frame_size
Definition vpx_ext_ratectrl.h:94
vpx_rc_encodeframe_info
Information for the frame to be encoded.
Definition vpx_ext_ratectrl.h:103
vpx_rc_encodeframe_info::show_index
int show_index
Definition vpx_ext_ratectrl.h:112
vpx_rc_encodeframe_info::coding_index
int coding_index
Definition vpx_ext_ratectrl.h:113
vpx_rc_encodeframe_info::ref_frame_coding_indexes
int ref_frame_coding_indexes[3]
Definition vpx_ext_ratectrl.h:118
vpx_rc_encodeframe_info::ref_frame_valid_list
int ref_frame_valid_list[3]
Definition vpx_ext_ratectrl.h:124
vpx_rc_encodeframe_info::gop_index
int gop_index
Definition vpx_ext_ratectrl.h:117
vpx_rc_encodeframe_info::frame_type
int frame_type
Definition vpx_ext_ratectrl.h:111
vpx_rc_encodeframe_info::use_alt_ref
int use_alt_ref
Definition vpx_ext_ratectrl.h:132
vpx_rc_encodeframe_info::gop_size
int gop_size
Definition vpx_ext_ratectrl.h:128
vpx_rc_encodeframe_result
Frame coding result.
Definition vpx_ext_ratectrl.h:140
vpx_rc_encodeframe_result::actual_encoding_qindex
int actual_encoding_qindex
Definition vpx_ext_ratectrl.h:144
vpx_rc_encodeframe_result::sse
int64_t sse
Definition vpx_ext_ratectrl.h:141
vpx_rc_encodeframe_result::pixel_count
int64_t pixel_count
Definition vpx_ext_ratectrl.h:143
vpx_rc_encodeframe_result::bit_count
int64_t bit_count
Definition vpx_ext_ratectrl.h:142
vpx_rc_firstpass_stats
Collection of first pass frame stats.
Definition vpx_ext_ratectrl.h:291
vpx_rc_firstpass_stats::frame_stats
vpx_rc_frame_stats_t * frame_stats
Definition vpx_ext_ratectrl.h:297
vpx_rc_firstpass_stats::num_frames
int num_frames
Definition vpx_ext_ratectrl.h:301
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:158
vpx_rc_frame_stats::mvr_abs
double mvr_abs
Definition vpx_ext_ratectrl.h:251
vpx_rc_frame_stats::duration
double duration
Definition vpx_ext_ratectrl.h:277
vpx_rc_frame_stats::pcnt_intra_low
double pcnt_intra_low
Definition vpx_ext_ratectrl.h:212
vpx_rc_frame_stats::inactive_zone_cols
double inactive_zone_cols
Definition vpx_ext_ratectrl.h:243
vpx_rc_frame_stats::weight
double weight
Definition vpx_ext_ratectrl.h:169
vpx_rc_frame_stats::MVr
double MVr
Definition vpx_ext_ratectrl.h:247
vpx_rc_frame_stats::mv_in_out_count
double mv_in_out_count
Definition vpx_ext_ratectrl.h:273
vpx_rc_frame_stats::inactive_zone_rows
double inactive_zone_rows
Definition vpx_ext_ratectrl.h:239
vpx_rc_frame_stats::frame
double frame
Definition vpx_ext_ratectrl.h:163
vpx_rc_frame_stats::new_mv_count
double new_mv_count
Definition vpx_ext_ratectrl.h:286
vpx_rc_frame_stats::intra_error
double intra_error
Definition vpx_ext_ratectrl.h:173
vpx_rc_frame_stats::frame_noise_energy
double frame_noise_energy
Definition vpx_ext_ratectrl.h:185
vpx_rc_frame_stats::pcnt_neutral
double pcnt_neutral
Definition vpx_ext_ratectrl.h:204
vpx_rc_frame_stats::MVc
double MVc
Definition vpx_ext_ratectrl.h:255
vpx_rc_frame_stats::mvc_abs
double mvc_abs
Definition vpx_ext_ratectrl.h:259
vpx_rc_frame_stats::intra_smooth_pct
double intra_smooth_pct
Definition vpx_ext_ratectrl.h:235
vpx_rc_frame_stats::MVrv
double MVrv
Definition vpx_ext_ratectrl.h:263
vpx_rc_frame_stats::pcnt_motion
double pcnt_motion
Definition vpx_ext_ratectrl.h:193
vpx_rc_frame_stats::MVcv
double MVcv
Definition vpx_ext_ratectrl.h:267
vpx_rc_frame_stats::pcnt_intra_high
double pcnt_intra_high
Definition vpx_ext_ratectrl.h:220
vpx_rc_frame_stats::count
double count
Definition vpx_ext_ratectrl.h:282
vpx_rc_frame_stats::pcnt_inter
double pcnt_inter
Definition vpx_ext_ratectrl.h:189
vpx_rc_frame_stats::intra_skip_pct
double intra_skip_pct
Definition vpx_ext_ratectrl.h:228
vpx_rc_frame_stats::sr_coded_error
double sr_coded_error
Definition vpx_ext_ratectrl.h:181
vpx_rc_frame_stats::pcnt_second_ref
double pcnt_second_ref
Definition vpx_ext_ratectrl.h:199
vpx_rc_frame_stats::coded_error
double coded_error
Definition vpx_ext_ratectrl.h:177
vpx_rc_funcs
Callback function set for external rate control.
Definition vpx_ext_ratectrl.h:511
vpx_rc_funcs::send_firstpass_stats
vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats
Definition vpx_ext_ratectrl.h:523
vpx_rc_funcs::get_encodeframe_decision
vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision
Definition vpx_ext_ratectrl.h:531
vpx_rc_funcs::create_model
vpx_rc_create_model_cb_fn_t create_model
Definition vpx_ext_ratectrl.h:519
vpx_rc_funcs::send_tpl_gop_stats
vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats
Definition vpx_ext_ratectrl.h:527
vpx_rc_funcs::get_gop_decision
vpx_rc_get_gop_decision_cb_fn_t get_gop_decision
Definition vpx_ext_ratectrl.h:539
vpx_rc_funcs::rc_type
vpx_rc_type_t rc_type
Definition vpx_ext_ratectrl.h:515
vpx_rc_funcs::priv
void * priv
Definition vpx_ext_ratectrl.h:551
vpx_rc_funcs::update_encodeframe_result
vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result
Definition vpx_ext_ratectrl.h:535
vpx_rc_funcs::delete_model
vpx_rc_delete_model_cb_fn_t delete_model
Definition vpx_ext_ratectrl.h:547
vpx_rc_funcs::get_frame_rdmult
vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult
Definition vpx_ext_ratectrl.h:543
vpx_rc_gop_decision
The decision made by the external rate control model to set the group of picture.
Definition vpx_ext_ratectrl.h:400
vpx_rc_gop_decision::use_alt_ref
int use_alt_ref
Definition vpx_ext_ratectrl.h:402
vpx_rc_gop_decision::gop_coding_frames
int gop_coding_frames
Definition vpx_ext_ratectrl.h:401
vpx_rc_gop_info
Information passed to the external rate control model to help make GOP decisions.
Definition vpx_ext_ratectrl.h:330
vpx_rc_gop_info::active_min_gf_interval
int active_min_gf_interval
Definition vpx_ext_ratectrl.h:347
vpx_rc_gop_info::show_index
int show_index
Definition vpx_ext_ratectrl.h:385
vpx_rc_gop_info::frames_since_key
int frames_since_key
Definition vpx_ext_ratectrl.h:371
vpx_rc_gop_info::allow_alt_ref
int allow_alt_ref
Definition vpx_ext_ratectrl.h:358
vpx_rc_gop_info::is_key_frame
int is_key_frame
Definition vpx_ext_ratectrl.h:362
vpx_rc_gop_info::active_max_gf_interval
int active_max_gf_interval
Definition vpx_ext_ratectrl.h:352
vpx_rc_gop_info::max_gf_interval
int max_gf_interval
Definition vpx_ext_ratectrl.h:342
vpx_rc_gop_info::min_gf_interval
int min_gf_interval
Definition vpx_ext_ratectrl.h:338
vpx_rc_gop_info::last_gop_use_alt_ref
int last_gop_use_alt_ref
Definition vpx_ext_ratectrl.h:366
vpx_rc_gop_info::frames_to_key
int frames_to_key
Definition vpx_ext_ratectrl.h:376
vpx_rc_gop_info::coding_index
int coding_index
Definition vpx_ext_ratectrl.h:389
vpx_rc_gop_info::lag_in_frames
int lag_in_frames
Definition vpx_ext_ratectrl.h:380
vpx_rc_gop_info::gop_global_index
int gop_global_index
Definition vpx_ext_ratectrl.h:394
vpx_tpl.h
Describes the TPL stats descriptor and associated operations.