radeonsi/vcn: Add support for H264 B-frames
What does this MR do and why?
radeonsi/vcn: Add support for H264 B-frames
It seems to work correctly, tested with both ffmpeg and gstreamer and the video quality is noticeable better. On big buck bunny 1080@60 sample encoded with CBR at 6mbit bitrate VMAF score goes up from 90.673581 (P-frames only) to 93.081015 (3 B-frames + preencode).
Tested with 6700XT and 7900XTX.
Draft because there are still isues I need to fix or get help with.
Frontend:
- B-pyramid/depth/hierarchy is not supported and there doesn't seem to be VA capability flag for this so it will have to detect that the application is trying to use B-frames as reference and return error
- Bitstream parser for packed headers seems buggy, especially with gstreamer (emulation prevention bytes not present in bitstream?)
Driver:
- I haven't figured out what extra size in dpb is needed with
b_picture_enabled == 1
, and it doesn't seem to be static as the "hang threshold" changes with input size :)
Example:
# 3 b-frames, quality + preencode, 6mbit CBR
ffmpeg -hide_banner -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i input.mp4 -c:v h264_vaapi -rc_mode CBR -compression_level 13 -b:v 6M -rc_init_occupancy 6M -bufsize 6M -maxrate 6M -bf 3 -y /tmp/out.mp4
# VMAF
ffmpeg -i /tmp/out.mp4 -i ~/input.mp4 -lavfi libvmaf -f null –
Edited by David Rosca