Higher level goal:
Expose all settings available in VAAPI driver and limit parameters to supported ranges.
Details on implementation:
vainfo is an example of source code that shows the codecs and ranges for each parameter (for each codec).
This is the simplest way to check the supported codecs and to check each parameter what range of values can be used.
The story becomes complicated because we are using ffmpeg as an intermediate layer for transcoding ... so you might get into limitations where the driver is exposing a feature but ffmpeg didn't implemented that feature (or is implemented only in newer ffmpeg versions). For now, let's assume that all features from driver are available in ffmpeg.
vainfo is generating two set of outputs: simple (codecs and profiles) and full (where are dumped also all features/parameters ranges).
What was implemented:
First step was to detect the codecs available (from vainfo 'simple') and detect the maximum number of b-frames and quality.
Also ui and uilp are two variables that hide or expose features based in availability in vaapi driver for normal or low power codecs.
Challenge:
The codecs are implemented in tvh as 4 categories: h264, hevc, vp8 and vp9.
The UI (web page) has the ability to switch between h264 and h264 low_power by checking/unchecking 'low_power'. This is a very flexible but very complicated to implement ... why: because vaapi is considering h264 and h264_low_power as two different codecs; so, have two different set of constrains. It will be very complicated to change the constrains (on-the-fly) on the web UI based on a selection of the checkbox low_power.
Posible improvements:
Separate the codecs from 4 into 8 (from beginning): h264, hevc, vp8, vp9, h264_low_power, hevc_low_power, vp8_low_power and vp9_low_power.
This will hardcode the value of 'low_power' (will be grayed out) to unchecked for regular codecs and checked for low_power --> you might see this as a regression but will allow us to load the constrains for all parameters when UI is built. You can always instantiate two separate codecs, one for normal and one low_power codecs.
Implement also rc_mode constrains based in vaapi driver.
Separate codec settings into: Basic, Advanced and Expert --> this is subjective so we should discuss on the forum where we draw the lines.
Let me know if you agree with this path or you think is the wrong direction.