Skip to content

Add superblock source SAD speed feature for RTC partitioning - #5367

Draft
jianj-g wants to merge 1 commit into
AOMediaCodec:av2-encfrom
jianj-g:rtc-source-sad
Draft

Add superblock source SAD speed feature for RTC partitioning#5367
jianj-g wants to merge 1 commit into
AOMediaCodec:av2-encfrom
jianj-g:rtc-source-sad

Conversation

@jianj-g

@jianj-g jianj-g commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Computes superblock source SAD (between current source and collocated previous source block) and incorporates it into variance-based partitioning (VBP) for real-time (RTC) encoding mode (speed >= 6).

Key changes:

  1. Superblock source SAD metrics:

    • Added SOURCE_SAD classification enum (kZeroSad, kVeryLowSad, kLowSad, kMedSad, kHighSad) and tracking fields in MACROBLOCK.
    • Gated under sf->rt_sf.source_metrics_sb (enabled at speed >= 6).
    • Computed per-SB source SAD in encode_rd_sb via cpi->fn_ptr[sb_size].sdf and normalized to 64x64 scale.
  2. Variance-based partition tuning:

    • Early exit fast path for static superblocks (source_sad == 0 && y_sad == 0), directly selecting the whole superblock size without evaluating sub-block variance quadtrees.
    • Scaled partition split thresholds (thresholds[1]..thresholds[4]) for low-motion superblocks (source_sad_level <= kLowSad) to favor larger blocks.
    • Adjusted low-resolution QP transition bounds in tune_thresh_based_on_resolution when source_sad_level <= kLowSad.
    • Guarded 16x16 and 32x32 variance-difference forced splits with (source_sad_level > kLowSad).

STATS_CHANGED for RTC mode

TAG=agy
CONV=9425edb0-f25c-4ea7-b0c5-9c5c7ed895c0

…ioning

Computes superblock source SAD (between current source and collocated
previous source block) and incorporates it into variance-based
partitioning (VBP) for real-time (RTC) encoding mode (speed >= 6).

Key changes:
1. Superblock source SAD metrics:
   - Added SOURCE_SAD classification enum (kZeroSad, kVeryLowSad,
     kLowSad, kMedSad, kHighSad) and tracking fields in MACROBLOCK.
   - Gated under sf->rt_sf.source_metrics_sb (enabled at speed >= 6).
   - Computed per-SB source SAD in encode_rd_sb via cpi->fn_ptr[sb_size].sdf
     and normalized to 64x64 scale.

2. Variance-based partition tuning:
   - Early exit fast path for static superblocks (source_sad == 0 && y_sad == 0),
     directly selecting the whole superblock size without evaluating sub-block
     variance quadtrees.
   - Scaled partition split thresholds (thresholds[1]..thresholds[4]) for
     low-motion superblocks (source_sad_level <= kLowSad) to favor larger blocks.
   - Adjusted low-resolution QP transition bounds in
     tune_thresh_based_on_resolution when source_sad_level <= kLowSad.
   - Guarded 16x16 and 32x32 variance-difference forced splits with
     (source_sad_level > kLowSad).

STATS_CHANGED for RTC mode

TAG=agy
CONV=9425edb0-f25c-4ea7-b0c5-9c5c7ed895c0
@jianj-g
jianj-g marked this pull request as draft September 3, 2026 23:37
@jianj-g
jianj-g requested a review from marpan-max September 3, 2026 23:37
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.

2 participants