Skip to content

Bit-exact improvements to CCSO module - #5429

Merged
urvangjoshi merged 4 commits into
AOMediaCodec:av2-encfrom
dikshasingh-sys:ccso_simd_1
Sep 24, 2026
Merged

urvangjoshi merged 4 commits into
AOMediaCodec:av2-encfrom
dikshasingh-sys:ccso_simd_1

Conversation

@dikshasingh-sys

Copy link
Copy Markdown

Test results (RA)
Anchor: commit d229da8
A1 - 17 frames
A2 - 33 frames

+-------+-------+----------------------+----------------------+
| Speed | Class | Encoder Instruction  | Encode Time          |
|       |       | Count Reduction (%)  | Reduction (%)        |
+-------+-------+----------------------+----------------------+
|   1   |  A2   |                 1.19 |                 1.78 |
|       |  A1   |                 1.84 |                 7.56 |
+-------+-------+----------------------+----------------------+

This change is verified to be bit-exact for all presets.

@dikshasingh-sys

Copy link
Copy Markdown
Author

@yunqingwang1 @urvangjoshi
/cc @vikasprasad10 @harishdm @ranjit-tulabandu @cherma-a @deepa-kg @RemyaPrakasan @ram-mohan

Please review.

Note: Each commit in this PR is logically independent and has its own commit message. Please do not squash them.

Comment thread av2/encoder/pickccso.c Outdated
The table look-up in ccso_filter_block_hbd_with_buf_avx2() is
vectorized using multiple shuffle/blend instructions.

Speed (C/AVX2 time):

ccso_block_size | No. of bands | parent | optimized
----------------|--------------|--------|----------
256x256         | 1            | 10.19x | 47.80x
256x256         | 2            | 10.12x | 41.78x
256x256         | 4            | 10.09x | 35.18x
256x256         | 8            | 10.09x | 26.34x
----------------|--------------|--------|----------
128x128         | 1            | 8.42x  | 26.66x
128x128         | 2            | 7.86x  | 22.82x
128x128         | 4            | 7.83x  | 20.98x
128x128         | 8            | 7.84x  | 17.06x
The table look-up in ccso_filter_block_hbd_wo_buf_avx2() is
optimized using multiple 'shuffle' instructions instead of
'gather' instruction.

Speed test results(C/AVX2 time) are as follows:

ccso_block_size |No. of bands | parent | optimized
----------------|-------------|--------|----------
256x256         | 1           | 9.43x  | 13.46x
256x256         | 2           | 6.01x  | 12.55x
256x256         | 4           | 6.00x  | 10.88x
256x256         | 8           | 5.97x  | 8.39x
----------------|-------------|--------|----------
128x128         | 1           | 6.33x  | 8.43x
128x128         | 2           | 4.73x  | 7.84x
128x128         | 4           | 4.70x  | 7.03x
128x128         | 8           | 4.61x  | 5.94x

The function ccso_derive_src_block_avx2() is optimized
via simplification of the edge index derivation.

Speed test results:

ccso_block_size | edge_clf | parent | optimized
----------------|----------|--------|----------
256x256         | 0        | 14.05x | 17.56x
256x256         | 1        | 13.57x | 14.56x
----------------|----------|--------|----------
128x128         | 0        | 7.88x  | 8.19x
128x128         | 1        | 6.69x  | 7.06x
The AVX2 implementation of compute_distortion_block() is optimized via
- Use 16-bit subtraction to calculate the difference between source and
  reconstructed pixels
- Defer the horizontal addition within SIMD registers to every nth row
  based on bit-depth and processing unit size

Performance impact (C/AVX2 time):

Unit size  | Parent | Optimized
-----------|--------|----------
256x256    | 2.11x  | 6.41x
128x128    | 2.00x  | 5.75x
64x64      | 1.90x  | 5.42x
32x32      | 1.77x  | 3.37x
When BRU is disabled, call compute_distortion_block() for every
CCSO filter unit instead of processing individual SBs. This change is
bit-exact.
@urvangjoshi
urvangjoshi merged commit c69de19 into AOMediaCodec:av2-enc Sep 24, 2026
98 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.

3 participants