David Staessens | 4f491087 | 2019-10-28 03:18:51 | [diff] [blame] | 1 | # Using the Video Encode Accelerator Unittests Manually |
| 2 | |
| 3 | The VEAtest (or `video_encode_accelerator_unittest`) is a set of unit tests that |
| 4 | embeds the Chrome video encoding stack without requiring the whole browser, |
| 5 | meaning they can work in a headless environment. It includes a variety of tests |
| 6 | to validate the encoding stack with h264, vp8 and vp9. |
| 7 | |
| 8 | Running this test manually can be very useful when bringing up a new codec, or |
| 9 | in order to make sure that new code does not break hardware encoding. This |
| 10 | document is a walk though the prerequisites for running this program, as well |
| 11 | as the most common options. |
| 12 | |
| 13 | ## Prerequisites |
| 14 | |
| 15 | The required kernel drivers should be loaded, and there should exist a |
| 16 | `/dev/video-enc0` symbolic link pointing to the encoder device node (e.g. |
| 17 | `/dev/video-enc0` → `/dev/video0`). |
| 18 | |
| 19 | The unittests can be built by specifying the `video_encode_accelerator_unittest` |
| 20 | target to `ninja`. If you are building for an ARM board that is not yet |
| 21 | supported by the |
| 22 | [simplechrome](https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md) |
| 23 | workflow, use `arm-generic` as the board. It should work across all ARM targets. |
| 24 | |
| 25 | For unlisted Intel boards, any other Intel target (preferably with the same |
| 26 | chipset) should be usable with libva. AMD targets can use `amd64-generic`. |
| 27 | |
| 28 | ## Basic VEA usage |
| 29 | |
| 30 | The VEA test takes raw YUV files in I420 format as input and produces e.g. an |
| 31 | H.264 Annex-B byte stream. Sample raw YUV files can be found at the following |
| 32 | locations: |
| 33 | |
| 34 | * [1080 Crowd YUV](http://commondatastorage.googleapis.com/chromiumos-test-assets-public/crowd/crowd1080-96f60dd6ff87ba8b129301a0f36efc58.yuv) |
| 35 | * [320x180 Bear YUV](http://commondatastorage.googleapis.com/chromiumos-test-assets-public/bear/bear-320x180-c60a86c52ba93fa7c5ae4bb3156dfc2a.yuv) |
| 36 | |
| 37 | It is recommended to rename these files after downloading them to e.g. |
| 38 | `crowd1080.yuv` and `bear-320x180.yuv`. |
| 39 | |
| 40 | The VEA can then be tested as follows: |
| 41 | |
| 42 | ./video_encode_accelerator_unittest --single-process-tests --disable_flush --gtest_filter=SimpleEncode/VideoEncodeAcceleratorTest.TestSimpleEncode/0 --test_stream_data=bear-320x180.yuv:320:180:1:bear.mp4:100000:30 |
| 43 | |
| 44 | for the `bear` file, and |
| 45 | |
| 46 | ./video_encode_accelerator_unittest --single-process-tests --disable_flush --gtest_filter=SimpleEncode/VideoEncodeAcceleratorTest.TestSimpleEncode/0 --test_stream_data=crowd1080.yuv:1920:1080:1:crowd.mp4:4000000:30 |
| 47 | |
| 48 | for the larger `crowd` file. These commands will put the encoded output into |
| 49 | `bear.mp4` and `crowd.mp4` respectively. They can then be copied on the host and |
| 50 | played with `mplayer -fps 25`. |
| 51 | |
| 52 | ## Test filtering options |
| 53 | |
| 54 | `./video_encode_accelerator_unittest --help` will list all valid options. |
| 55 | |
| 56 | The list of available tests can be retrieved using the `--gtest_list_tests` |
| 57 | option. |
| 58 | |
| 59 | By default, all tests are run, which can be a bit too much, especially when |
| 60 | bringing up a new codec. The `--gtest_filter` option can be used to specify a |
| 61 | pattern of test names to run. |
| 62 | |
| 63 | ## Verbosity options |
| 64 | |
| 65 | The `--vmodule` options allows to specify a set of source files that should be |
| 66 | more verbose about what they are doing. For basic usage, a useful set of vmodule |
| 67 | options could be: |
| 68 | |
| 69 | --vmodule=*/media/gpu/*=4 |
| 70 | |
| 71 | ## Source code |
| 72 | |
| 73 | The VEAtest's source code can be consulted here: [https://cs.chromium.org/chromium/src/media/gpu/video_encode_accelerator_unittest.cc](https://cs.chromium.org/chromium/src/media/gpu/video_encode_accelerator_unittest.cc). |
| 74 | |
| 75 | V4L2 support: [https://cs.chromium.org/chromium/src/media/gpu/v4l2/](https://cs.chromium.org/chromium/src/media/gpu/v4l2/). |
| 76 | |
| 77 | VAAPI support: [https://cs.chromium.org/chromium/src/media/gpu/vaapi/](https://cs.chromium.org/chromium/src/media/gpu/vaapi/). |