Alexandre Courbot | 2cad5de | 2018-11-08 09:13:29 | [diff] [blame] | 1 | # Using the Video Decode/Encode Accelerator Unittests Manually |
| 2 | |
| 3 | VDAtest (or `video_decode_accelerator_unittest`) and VEAtest (or |
| 4 | `video_encode_accelerator_unittest`) are unit tests that embeds the Chrome video |
| 5 | decoding/encoding stack without requiring the whole browser, meaning they can |
| 6 | work in a headless environment. They includes a variety of tests to validate the |
| 7 | decoding and encoding stacks with h264, vp8 and vp9. |
| 8 | |
| 9 | Running these tests manually can be very useful when bringing up a new codec, or |
| 10 | in order to make sure that new code does not break hardware decoding and/or |
| 11 | encoding. This document is a walk though the prerequisites for running these |
| 12 | programs, as well as their most common options. |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | The required kernel drivers should be loaded, and there should exist a |
| 17 | `/dev/video-dec0` symbolic link pointing to the decoder device node (e.g. |
| 18 | `/dev/video-dec0` → `/dev/video0`). Similarly, a `/dev/video-enc0` symbolic |
| 19 | link should point to the encoder device node. |
| 20 | |
| 21 | The unittests can be built by specifying the `video_decode_accelerator_unittest` |
| 22 | and `video_encode_accelerator_unittest` targets to `ninja`. If you are building |
| 23 | for an ARM board that is not yet supported by the |
| 24 | [simplechrome](https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md) |
| 25 | workflow, use `arm-generic` as the board. It should work across all ARM targets. |
| 26 | |
| 27 | For unlisted Intel boards, any other Intel target (preferably with the same |
| 28 | chipset) should be usable with libva. AMD targets can use `amd64-generic`. |
| 29 | |
| 30 | ## Basic VDA usage |
| 31 | |
| 32 | The `media/test/data` folder in Chromium's source tree contains files with |
| 33 | encoded video data (`test-25fps.h264`, `test-25fps.vp8` and `test-25fps.vp9`). |
| 34 | Each of these files also has a `.md5` counterpart, which contains the md5 |
| 35 | checksums of valid thumbnails. |
| 36 | |
| 37 | Running the VDAtest can be done as follows: |
| 38 | |
| 39 | ./video_decode_accelerator_unittest --disable_rendering --single-process-tests --test_video_data=test_video |
| 40 | |
| 41 | Where test_video is of the form |
| 42 | |
| 43 | filename:width:height:numframes:numfragments:minFPSwithRender:minFPSnoRender:profile |
| 44 | |
| 45 | The correct value of test_video for each test file follows: |
| 46 | |
| 47 | * __H264__: `test-25fps.h264:320:240:250:258:35:150:1` |
| 48 | * __VP8__: `test-25fps.vp8:320:240:250:250:35:150:11` |
| 49 | * __VP9__: `test-25fps.vp9:320:240:250:250:35:150:12` |
| 50 | |
| 51 | So in order to run all h264 tests, one would invoke |
| 52 | |
| 53 | ./video_decode_accelerator_unittest --disable_rendering --single-process-tests --test_video_data=test-25fps.h264:320:240:250:258:35:150:1 |
| 54 | |
| 55 | ## Test filtering options |
| 56 | |
| 57 | `./video_decode_accelerator_unittest --help` will list all valid options. |
| 58 | |
| 59 | The list of available tests can be retrieved using the `--gtest_list_tests` |
| 60 | option. |
| 61 | |
| 62 | By default, all tests are run, which can be a bit too much, especially when |
| 63 | bringing up a new codec. The `--gtest_filter` option can be used to specify a |
| 64 | pattern of test names to run. For instance, to only run the |
| 65 | `TestDecodeTimeMedian` test, one can specify |
| 66 | `--gtest_filter="*TestDecodeTimeMedian*"`. |
| 67 | |
| 68 | So the complete command line to test vp9 decoding with the |
| 69 | `TestDecodeTimeMedian` test only (a good starting point for bringup) would be |
| 70 | |
| 71 | ./video_decode_accelerator_unittest --disable_rendering --single-process-tests --test_video_data=test-25fps.vp9:320:240:250:250:35:150:12 --gtest_filter="*TestDecodeTimeMedian*" |
| 72 | |
| 73 | ## Verbosity options |
| 74 | |
| 75 | The `--vmodule` options allows to specify a set of source files that should be |
| 76 | more verbose about what they are doing. For basic usage, a useful set of vmodule |
| 77 | options could be: |
| 78 | |
| 79 | --vmodule=*/media/gpu/*=4 |
| 80 | |
| 81 | ## Testing performance |
| 82 | |
| 83 | Use the `--disable_rendering --rendering_fps=0 --gtest_filter="DecodeVariations/*/0"` |
| 84 | options to max the decoder output and measure its performance. |
| 85 | |
| 86 | ## Testing parallel decoding |
| 87 | |
| 88 | Use `--gtest_filter="ResourceExhaustion*/0"` to run 3 decoders in parallel, and |
| 89 | `--gtest_filter="ResourceExhaustion*/1"` to run 4 decoders in parallel. |
| 90 | |
| 91 | ## Wrap-up |
| 92 | |
| 93 | Using all these options together, we can invoke VDAtest in the following way for |
| 94 | a verbose H264 decoding test: |
| 95 | |
| 96 | ./video_decode_accelerator_unittest --single-process-tests --disable_rendering --gtest_filter="*TestDecodeTimeMedian*" --vmodule=*/media/gpu/*=4 --test_video_data=test-25fps.h264:320:240:250:258:35:150:1 |
| 97 | |
| 98 | ## Basic VEA usage |
| 99 | |
| 100 | The VEA works in a similar fashion to the VDA, taking raw YUV files in I420 |
| 101 | format as input and producing e.g. a H.264 Annex-B byte stream. Sample raw YUV |
| 102 | files can be found at the following locations: |
| 103 | |
| 104 | * [1080 Crowd YUV](http://commondatastorage.googleapis.com/chromiumos-test-assets-public/crowd/crowd1080-96f60dd6ff87ba8b129301a0f36efc58.yuv) |
| 105 | * [320x180 Bear YUV](http://commondatastorage.googleapis.com/chromiumos-test-assets-public/bear/bear-320x180-c60a86c52ba93fa7c5ae4bb3156dfc2a.yuv) |
| 106 | |
| 107 | It is recommended to rename these files after downloading them to e.g. |
| 108 | `crowd1080.yuv` and `bear-320x180.yuv`. |
| 109 | |
| 110 | The VEA can then be tested as follows: |
| 111 | |
| 112 | ./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 |
| 113 | |
| 114 | for the `bear` file, and |
| 115 | |
| 116 | ./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 |
| 117 | |
| 118 | for the larger `crowd` file. These commands will put the encoded output into |
| 119 | `bear.mp4` and `crowd.mp4` respectively. They can then be copied on the host and |
| 120 | played with `mplayer -fps 25`. |
| 121 | |
| 122 | ## Source code |
| 123 | |
| 124 | The VDAtest's source code can be consulted here: [https://cs.chromium.org/chromium/src/media/gpu/video_decode_accelerator_unittest.cc](https://cs.chromium.org/chromium/src/media/gpu/video_decode_accelerator_unittest.cc). |
| 125 | |
| 126 | V4L2 support: [https://cs.chromium.org/chromium/src/media/gpu/v4l2/](https://cs.chromium.org/chromium/src/media/gpu/v4l2/). |
| 127 | |
| 128 | VAAPI support: [https://cs.chromium.org/chromium/src/media/gpu/vaapi/](https://cs.chromium.org/chromium/src/media/gpu/vaapi/). |