Repository navigation
rtc: Update and improve cyclic refresh (aq-mode=3) for AV2 - #5580
Merged
Merged
Conversation
jianj-g
force-pushed
the
rtc-aq-mode-3
branch
from
October 20, 2026 17:59
b3ecc04 to
a28b3e4
Compare
jianj-g
marked this pull request as draft
October 20, 2026 21:43
jianj-g
force-pushed
the
rtc-aq-mode-3
branch
from
October 21, 2026 23:02
a28b3e4 to
1b30a1e
Compare
marpan-max
reviewed
Oct 22, 2026
marpan-max
approved these changes
Oct 22, 2026
jianj-g
force-pushed
the
rtc-aq-mode-3
branch
2 times, most recently
from
October 23, 2026 20:46
364bfc0 to
aa16b9f
Compare
marpan-max
approved these changes
Oct 23, 2026
jianj-g
marked this pull request as ready for review
October 23, 2026 21:36
Fix existing segmentation and quantizer state synchronization issues in cyclic refresh (CYCLIC_REFRESH_AQ / aq-mode=3) and adapt its core parameters, 1-pass CBR rate control, and variance-based partitioning to AV2: - Remove unused last_coded_q_map allocation and fix the out-of-bounds write on keyframes in av2_cyclic_refresh_setup(). - Adapt compute_deltaq(), qp_thresh, qp_max_thresh, and thresh_dist_sb to AV2's logarithmic qindex scale and bit-depth offset (MAXQ_FOR_GIVEN_BIT_DEPTH), and scale rate/distortion thresholds in candidate_refresh_aq() for BLOCK_128X128 and BLOCK_256X256 superblocks. - Update segment_id on skip_txfm, propagate segment_id to cur_frame->seg_map, enc_seg.map, and cr->map, and re-initialize plane quantizers inside av2_cyclic_refresh_update_segment(). - Add av2_cyclic_reset_segment_skip() in encode_b() when skip_txfm is finalized after encode_superblock(), and accumulate per-thread cyclic refresh counters (actual_num_seg1_blocks, actual_num_seg2_blocks, cnt_zeromv) across worker threads. - Enable CYCLIC_REFRESH_AQ in encode_with_recode_loop(), dynamically adapt cyclic refresh percentage and delta-q in av2_cyclic_refresh_postencode(), and integrate cyclic refresh with 1-pass CBR rate control in ratectrl.c. - Use segment-adjusted qindex in av2_choose_var_based_partitioning() when cyclic refresh segmentation is enabled so boosted superblocks are not over-merged by high-Q threshold relaxations. - Add unit tests in aq_segment_test.cc, rtc_test.cc, and rtc_datarate_test.cc covering aq-mode=3 across RTC speeds, superblock sizes (64x64, 128x128, 256x256, dynamic), screen content, row-MT, and CBR rate targeting.
urvangjoshi
force-pushed
the
rtc-aq-mode-3
branch
from
October 23, 2026 22:16
aa16b9f to
e76b842
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix existing segmentation and quantizer state synchronization issues in
cyclic refresh (CYCLIC_REFRESH_AQ / aq-mode=3) and adapt its core
parameters, 1-pass CBR rate control, and variance-based partitioning to
AV2:
write on keyframes in av2_cyclic_refresh_setup().
to AV2's logarithmic qindex scale and bit-depth offset
(MAXQ_FOR_GIVEN_BIT_DEPTH), and scale rate/distortion thresholds in
candidate_refresh_aq() for BLOCK_128X128 and BLOCK_256X256 superblocks.
cur_frame->seg_map, enc_seg.map, and cr->map, and re-initialize plane
quantizers inside av2_cyclic_refresh_update_segment().
finalized after encode_superblock(), and accumulate per-thread cyclic
refresh counters (actual_num_seg1_blocks, actual_num_seg2_blocks,
cnt_zeromv) across worker threads.
adapt cyclic refresh percentage and delta-q in
av2_cyclic_refresh_postencode(), and integrate cyclic refresh with
1-pass CBR rate control in ratectrl.c.
when cyclic refresh segmentation is enabled so boosted superblocks are
not over-merged by high-Q threshold relaxations.
rtc_datarate_test.cc covering aq-mode=3 across RTC speeds, superblock
sizes (64x64, 128x128, 256x256, dynamic), screen content, row-MT, and
CBR rate targeting.
5.6% bdrate gain / 8.8% speed up on RTC test set compared with aq mode 0
on speed 6.