I want to use vp9 encoder to encode video with alpha channel (argb -> webm, through ffmpeg) in real time (less than 30ms/frame), but I found that even if the -deadline realtime -speed 8 parameter is added, the speed is improved Still not obvious.
After that, I used
# perf record -e cpu-clock -g
to test the following three instructions:
1.ffmpeg -f rawvideo -pix_fmt argb -s 720x1280 -i input.rgba -pix_fmt yuva420p -threads 2 -deadline realtime -speed 8 output.webm
2.ffmpeg -f rawvideo -pix_fmt argb -s 720x1280 -i input.rgba -pix_fmt yuv420p -threads 2 -deadline realtime -speed 8 output.webm
3.ffmpeg -f rawvideo -pix_fmt argb -s 720x1280 -i input.rgba -pix_fmt yuv420p -threads 2 output.webm
I found that when I added the -deadline realtime -speed 8 attribute, the normal (ie yuv420p) would not call the vp9_diamond_search_sad_avx() and vp9_optimize_b() functions. But when I encode a video with an alpha channel (ie yuva420p), the above two functions will still be called.
I observed the source code of libvpx-vp9 and found that difference were generated when the vp9_encode_sb_row() function judged if cpi->sf.use_nonrd_pick_mode (line 5832 in vp9_encodeframe.c). cpi->sf.use_nonrd_pick_mode is set to 1 when speed>=5, so encode_nonrd_sb_row() is called in vp9_encode_sb_row(). Otherwise, encode_rd_sb_row() will be called, and finally vp9_optimize_b() and vp9_diamond_search_sad_avx() will be called.
So my guess is that the encoding of the alpha channel may not be processed for the -deadline and -speed parameters. Attached is the result I obtained through perf
Thanks for reading