diff options
author | Jerome Jiang <jianj@google.com> | 2024-05-09 12:33:19 -0400 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2024-05-09 15:19:35 -0400 |
commit | e934e355157bf56d80e64c37b9b3c96f68734fad (patch) | |
tree | 02d860eea35f2649e7fd494b66cbe8eba84514b0 | |
parent | 8433fe6393986c844502be1f5a83a9f26531c360 (diff) | |
download | libvpx-e934e355157bf56d80e64c37b9b3c96f68734fad.tar.gz |
vp9 rc: also run tpl for GOPs without ARF
Tested with ffmpeg integration end to end test.
Bug: b/338393251
Change-Id: I4048036d35f8ab64c07305b838d091f765f64a8d
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 38b030a44..e8bc40983 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -6330,6 +6330,25 @@ void vp9_init_encode_frame_result(ENCODE_FRAME_RESULT *encode_frame_result) { #endif // CONFIG_RATE_CTRL } +// Returns if TPL stats need to be calculated. +static INLINE int should_run_tpl(VP9_COMP *cpi, int gf_group_index) { + RATE_CONTROL *const rc = &cpi->rc; + if (!cpi->sf.enable_tpl_model) return 0; + // If there is an ARF for this GOP, TPL stats is always calculated. + if (gf_group_index == 1 && + cpi->twopass.gf_group.update_type[gf_group_index] == ARF_UPDATE) + return 1; + // If this GOP doesn't have an ARF, TPL stats is still calculated, only when + // external rate control is used. + if (cpi->ext_ratectrl.ready && + cpi->ext_ratectrl.funcs.send_tpl_gop_stats != NULL && + rc->frames_till_gf_update_due == rc->baseline_gf_interval && + cpi->twopass.gf_group.update_type[1] != ARF_UPDATE) { + return 1; + } + return 0; +} + int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, size_t *size, uint8_t *dest, size_t dest_size, int64_t *time_stamp, int64_t *time_end, int flush, @@ -6590,9 +6609,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, #if CONFIG_COLLECT_COMPONENT_TIMING start_timing(cpi, setup_tpl_stats_time); #endif - if (gf_group_index == 1 && - cpi->twopass.gf_group.update_type[gf_group_index] == ARF_UPDATE && - cpi->sf.enable_tpl_model) { + if (should_run_tpl(cpi, gf_group_index)) { vp9_init_tpl_buffer(cpi); vp9_estimate_tpl_qp_gop(cpi); vp9_setup_tpl_stats(cpi); |