Skip to content

Extend two-pass partition search to key/intra frames - #5525

Merged
yeqing-wu merged 1 commit into
AOMediaCodec:av2-encfrom
chengchen-google:s3-kf-twopass-v3
Oct 16, 2026
Merged

yeqing-wu merged 1 commit into
AOMediaCodec:av2-encfrom
chengchen-google:s3-kf-twopass-v3

Conversation

@chengchen-google

Copy link
Copy Markdown
Contributor

Enable fast two-pass (dry + wet) superblock partition search on intra-only/key frames in GOOD mode for speeds 1-6, controlled by part_sf.intra_two_pass_partition_search and resolution-/speed-adaptive part_sf.intra_two_pass_max_qindex (using 8-bit-equivalent qindex):

  • Dry pass (SB_DRY_PASS): search luma partition tree down to BLOCK_16X16 (re-splitting unsplit blocks up to 32x32 in the wet pass for qindex_8b < 150 in RA / 210 in AI), cap TX partition sweep to NONE + SPLIT, and skip chroma SDP, IntraBC, FSC, secondary MRL lines, palette, and DIP.
  • Wet pass (SB_WET_PASS): evaluate PARTITION_NONE on >= 32x32 blocks that the dry pass split (try_none_with_forced_split), reuse luma PARTITION_NONE for chroma when luma sub-blocks are >= bsize, and keep full intra mode search at wet-pass leaf blocks.

CTC Random Access performance (17f on A1, 33f on A2-A5), Anchor is 24ff468:

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  1      A1       0.10%           4.65%    46.6
  1      A2       0.01%           0.80%   111.2

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  2      A1       0.08%           3.00%    39.0
  2      A2       0.01%           0.25%    44.7

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  3      A1       0.06%           2.83%    46.7
  3      A2       0.00%           0.13%    48.9

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  4      A1       0.34%           8.17%    23.8
  4      A2       0.27%           6.01%    22.3

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  5      A1       0.71%          12.83%    18.1
  5      A2       0.27%           8.89%    32.9

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  6      A1       0.22%           4.56%    20.7
  6      A2       0.14%           1.92%    13.7

STATS_CHANGED

@yeqing-wu yeqing-wu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @chengchen-google, thanks for supporting the two-pass partition into key/intra frame. I’ve also implemented this, but I haven’t achieved a good tradeoff, and I don’t have time to tune it. It’s great to see you implement this and speed up the encoder.

Comment thread av2/encoder/encodeframe.c Outdated
Comment thread av2/encoder/encodeframe.c Outdated
Comment thread av2/encoder/partition_search.c
Comment thread av2/encoder/encodeframe.c Outdated
Comment thread av2/encoder/speed_features.c Outdated
Comment thread av2/encoder/encodeframe_utils.h Outdated

@yeqing-wu yeqing-wu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@leolzhao
leolzhao self-requested a review October 14, 2026 22:56

@leolzhao leolzhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MR looks good to me. Please rebase the code and fix the conflicts.

@yeqing-wu
yeqing-wu enabled auto-merge (rebase) October 14, 2026 23:38
@yeqing-wu

Copy link
Copy Markdown
Contributor

@chengchen-google, there is an error because of documentation, please address it.

@chengchen-google
chengchen-google force-pushed the s3-kf-twopass-v3 branch 2 times, most recently from ce9bfab to 99f2a09 Compare October 15, 2026 17:03
@urvangjoshi

Copy link
Copy Markdown
Contributor

@chengchen-google : looks like there is a conflict again. Could you rebase one more time?

@chengchen-google

Copy link
Copy Markdown
Contributor Author

@chengchen-google : looks like there is a conflict again. Could you rebase one more time?

Done.

Enable fast two-pass (dry + wet) superblock partition search on
intra-only/key frames in GOOD mode for speeds 1-6, controlled by
part_sf.intra_two_pass_partition_search and resolution-/speed-adaptive
part_sf.intra_two_pass_max_qindex (using 8-bit-equivalent qindex):

- Dry pass (SB_DRY_PASS): search luma partition tree down to
  BLOCK_16X16 (re-splitting unsplit blocks up to 32x32 in the wet pass
  for qindex_8b < 150 in RA / 210 in AI), cap TX partition sweep to
  NONE + SPLIT, and skip chroma SDP, IntraBC, FSC, secondary MRL lines,
  palette, and DIP.
- Wet pass (SB_WET_PASS): evaluate PARTITION_NONE on >= 32x32 blocks
  that the dry pass split (try_none_with_forced_split), reuse luma
  PARTITION_NONE for chroma when luma sub-blocks are >= bsize, and
  keep full intra mode search at wet-pass leaf blocks.

CTC Random Access performance (17f on A1, 33f on A2-A5),
Anchor is 24ff468:

```
Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  1      A1       0.10%           4.65%    46.6
  1      A2       0.01%           0.80%   111.2

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  2      A1       0.08%           3.00%    39.0
  2      A2       0.01%           0.25%    44.7

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  3      A1       0.06%           2.83%    46.7
  3      A2       0.00%           0.13%    48.9

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  4      A1       0.34%           8.17%    23.8
  4      A2       0.27%           6.01%    22.3

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  5      A1       0.71%          12.83%    18.1
  5      A2       0.27%           8.89%    32.9

Speed    Set     BD-Rate (YUV)   Speedup   Ratio
  6      A1       0.22%           4.56%    20.7
  6      A2       0.14%           1.92%    13.7
```

STATS_CHANGED

Change-Id: I2eacb7ed813b59b7cafab55c73bd56a501362404
@chengchen-google
chengchen-google force-pushed the s3-kf-twopass-v3 branch 2 times, most recently from e84915b to 2c1ba33 Compare October 16, 2026 17:02
@yeqing-wu
yeqing-wu merged commit b140e72 into AOMediaCodec:av2-enc Oct 16, 2026
107 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.

5 participants