intel / cartwheel-ffmpeg

Intel developer staging area for unmerged upstream patch contributions to FFmpeg
GNU Lesser General Public License v2.1
84 stars 31 forks source link

[VAAPI AV1 Encode] Encoder doesn't check VAConfigAttribEncMaxRefFrames #278

Open sivileri opened 9 months ago

sivileri commented 9 months ago

On official ffmpeg (with the upstreamed AV1 encode patch), the encoder seems to be generating bitstreams using always 2 reference frames set to LAST/GOLDEN for P, even when VAConfigAttribEncMaxRefFrames.L0 reports a lower limit (e.g max 1 L0 reference frame).

@feiwan1 Is this something that could be checked so only the LAST reference is used for P when VAConfigAttribEncMaxRefFrames.L0 = 1 ? This affects the vaon12 VA driver which has encode AV1 support over different hardware abstracted through D3D12 reporting different support for VAConfigAttribEncMaxRefFrames.

Thanks!

sivileri commented 9 months ago

Actually, looks like this also affects other codecs like H264/HEVC encoding with VAAPI, could we add such check for those as well?

feiwan1 commented 9 months ago

OK, I will add the max ref frames check. BTW, 2 refs for P frame is only avaliable for AV1. Other codecs still use one ref for P frame.

sivileri commented 9 months ago

Thanks @feiwan1 ! For B frames in AV1, vaon12 is also reporting the L1 limit in the upper 16 bits of VAConfigAttribEncMaxRefFrames, right now looks like encoding B uses 2 references, could also the max references check be staged in the B case in case in the future there are more references used in B frame, so they're always under the L1 limit of VAConfigAttribEncMaxRefFrames too ?

feiwan1 commented 9 months ago

Thanks @feiwan1 ! For B frames in AV1, vaon12 is also reporting the L1 limit in the upper 16 bits of VAConfigAttribEncMaxRefFrames, right now looks like encoding B uses 2 references, could also the max references check be staged in the B case in case in the future there are more references used in B frame, so they're always under the L1 limit of VAConfigAttribEncMaxRefFrames too ?

Sure, both L0 and L1 should be checked.