Skip to content

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

Merged
urvangjoshi merged 1 commit into
AOMediaCodec:av2-encfrom
jianj-g:rtc-source-sad
Sep 18, 2026
Merged

urvangjoshi merged 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:

rtc_derf: 0.019% bdrate loss, 0.3% speed up
rtc: -0.38% bdrate gain, 3.4% speed up
rtc_screen: -5.8% bdrate gain, 3.2% speed up

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
@jianj-g
jianj-g force-pushed the rtc-source-sad branch 3 times, most recently from dad1133 to 040d4af Compare September 17, 2026 18:45
@jianj-g
jianj-g marked this pull request as ready for review September 17, 2026 20:52
@jianj-g
jianj-g requested a review from urvangjoshi September 17, 2026 21:09
…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, including area-normalized visible-region
     SAD calculation for border superblocks.

2. Variance-based partition tuning:
   - Early exit fast path for static superblocks (source_sad == 0 && y_sad == 0,
     or y_sad < block_width * block_height * 2 for screen content), directly
     selecting the whole superblock size without evaluating sub-block quadtrees.
   - Resolution- and content-adaptive quant_base and partition threshold scaling
     (thresholds[1]..thresholds[4]) for low-motion superblocks across <= 240p,
     288p, and > 288p resolutions as well as screen content.

Benchmark results (9-QP constant-QP sweep, speed 6):
- rtc (28 clips):       Overall PSNR BD-rate: -1.26%, Speedup: +6.13%
- rtc_derf (20 clips):  Overall PSNR BD-rate: +0.13%, Speedup: +1.84%
- rtc_screen (9 clips): Overall PSNR BD-rate: -4.42%, Speedup: +18.04%

STATS_CHANGED for RTC mode

TAG=agy
CONV=64216da8-b0fa-4a3a-9988-d7f9322228c1
@urvangjoshi
urvangjoshi merged commit 30ada81 into AOMediaCodec:av2-enc Sep 18, 2026
8 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