Skip to content

Run the CCSO search sample passes on the worker threads - #5616

Open
chengchen-google wants to merge 1 commit into
AOMediaCodec:av2-encfrom
chengchen-google:s19-0001
Open

chengchen-google wants to merge 1 commit into
AOMediaCodec:av2-encfrom
chengchen-google:s19-0001

Conversation

@chengchen-google

Copy link
Copy Markdown
Contributor

The CCSO search evaluates up to 116 filter candidates per plane. For each candidate it classifies every luma sample of the frame, accumulates the per class error statistics, and for every trained filter copies the reconstructed plane, filters it and computes the per filter unit distortion.

These full frame passes run on the main thread while the tile worker threads wait.

This commit proposes to process these passes with multi-thread. It process the frame filter row by row, each writes only its own samples of the classification and reconstruction buffers. It splits the plane evenly across the encoder worker threads.

The new speed feature enable_ccso_mt is introduced. It is off with one thread and on for multi-threads.

Results on RA A1 (17 frames), A2 (33 frames) show a significant encoder speed up (~20%) for A1 at speed 1. The speed up is less for A2 because A1 uses 4 threads. The more threads, the higher speed up is expected.

Also, after speed 2, the CCSO search is optimized and the number of searches is significantly reduced. Therefore the speed up for speed 2 and above is less.

Full results:

+-------+-------+-------+-------+-------+-------+-------+-------+
| Speed | Class |     Y |    Cb |    Cr |  wAvg | Enc%  |  Dec% |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   1   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  79.4 | 101.7 |
|   1   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  95.7 |  97.8 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   2   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  98.5 |  99.2 |
|   2   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  98.6 | 101.1 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   3   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  98.6 |  95.5 |
|   3   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  98.6 |  96.9 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   4   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  98.3 | 101.7 |
|   4   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  99.1 | 101.3 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   5   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  97.8 | 100.0 |
|   5   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  99.3 |  97.5 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   6   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  97.0 |  99.1 |
|   6   | A2    | +0.00 | +0.00 | +0.00 | +0.00 | 100.1 | 103.6 |
+-------+-------+-------+-------+-------+-------+-------+-------+

This is a bit-exact change.

We also add a unit test test/encoder_frame_mt_test.cc. It encodes a clip with 1, 2, 3 and 4 threads and checks that the compressed frames and the decoded frames are identical.

The CCSO search evaluates up to 116 filter candidates per plane.
For each candidate it classifies every luma sample of the frame,
accumulates the per class error statistics, and for every trained
filter copies the reconstructed plane, filters it and computes
the per filter unit distortion.

These full frame passes run on the main thread while the tile worker
threads wait.

This commit proposes to process these passes with multi-thread.
It process the frame filter row by row, each writes only its own
samples of the classification and reconstruction buffers. It splits
the plane evenly across the encoder worker threads.

The new speed feature enable_ccso_mt is introduced. It is off with
one thread and on for multi-threads.

Results on RA A1 (17 frames), A2 (33 frames) show a significant
encoder speed up (~20%) for A1 at speed 1. The speed up is less
for A2 because A1 uses 4 threads. The more threads, the higher
speed up is expected.

Also, after speed 2, the CCSO search is optimized and the number of
searches is significantly reduced. Therefore the speed up for speed
2 and above is less.

Full results:
+-------+-------+-------+-------+-------+-------+-------+-------+
| Speed | Class |     Y |    Cb |    Cr |  wAvg | Enc%  |  Dec% |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   1   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  79.4 | 101.7 |
|   1   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  95.7 |  97.8 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   2   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  98.5 |  99.2 |
|   2   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  98.6 | 101.1 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   3   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  98.6 |  95.5 |
|   3   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  98.6 |  96.9 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   4   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  98.3 | 101.7 |
|   4   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  99.1 | 101.3 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   5   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  97.8 | 100.0 |
|   5   | A2    | +0.00 | +0.00 | +0.00 | +0.00 |  99.3 |  97.5 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   6   | A1    | +0.00 | +0.00 | +0.00 | +0.00 |  97.0 |  99.1 |
|   6   | A2    | +0.00 | +0.00 | +0.00 | +0.00 | 100.1 | 103.6 |
+-------+-------+-------+-------+-------+-------+-------+-------+

This is a bit-exact change.

We also add a unit test test/encoder_frame_mt_test.cc.
It encodes a clip with 1, 2, 3 and 4 threads and checks that the
compressed frames and the decoded frames are identical.

Change-Id: I4a5db90932afc67b29f72315b2ee060ceca01daa
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