Skip to content

rtc: Reuse pc_tree in non-RD partition search - #5284

Merged
yeqing-wu merged 1 commit into
AOMediaCodec:av2-encfrom
jianj-g:rtc-reuse-pc-tree
Aug 20, 2026
Merged

rtc: Reuse pc_tree in non-RD partition search#5284
yeqing-wu merged 1 commit into
AOMediaCodec:av2-encfrom
jianj-g:rtc-reuse-pc-tree

Conversation

@jianj-g

@jianj-g jianj-g commented Aug 18, 2026

Copy link
Copy Markdown

Pre-allocate and reuse the partition context tree (pc_root / PC_TREE) per thread in real-time non-RD partition search instead of allocating and freeing nodes for every superblock.

  • Add pc_root to ThreadData and pre-allocate once per thread/frame.
  • Add av2_reset_pmc to reset PICK_MODE_CONTEXT state on node reuse.
  • In av2_nonrd_use_partition, lazily allocate child pc_tree nodes and reset existing PMC nodes across superblocks.

This change is bitexact for RTC with 2.5% speed up for QVGA and 1.5% speed up for VGA and HD on speed 6.

Comment thread av2/encoder/context_tree.c
Comment thread av2/encoder/ethread.c
Comment thread av2/encoder/ethread.c
Comment thread av2/encoder/encodeframe.c Outdated
@jianj-g
jianj-g force-pushed the rtc-reuse-pc-tree branch 2 times, most recently from 0283c08 to 2dd3567 Compare August 19, 2026 19:40
Comment thread av2/encoder/encodeframe.c
@jianj-g
jianj-g force-pushed the rtc-reuse-pc-tree branch from 2dd3567 to 706fb93 Compare August 19, 2026 19:58
@yeqing-wu
yeqing-wu enabled auto-merge (squash) August 19, 2026 21:04
Pre-allocate and reuse the partition context tree (pc_root / PC_TREE)
per thread in real-time non-RD partition search instead of allocating
and freeing nodes for every superblock.

- Add pc_root to ThreadData and pre-allocate once per thread/frame.
- Add av2_reset_pmc to reset PICK_MODE_CONTEXT state on node reuse.
- In av2_nonrd_use_partition, lazily allocate child pc_tree nodes and
  reset existing PMC nodes across superblocks.

This does not change the bitstream for RTC.
@jianj-g
jianj-g force-pushed the rtc-reuse-pc-tree branch from 706fb93 to 9a7d6f8 Compare August 20, 2026 15:19
@yeqing-wu
yeqing-wu merged commit bb4bd78 into AOMediaCodec:av2-enc Aug 20, 2026
109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants