ffvvc / FFmpeg

VVC Decoder for ffmpeg
Other
48 stars 12 forks source link

Merge no_{p,q} with max_len_{p,q} #249

Closed stone-d-chen closed 3 months ago

stone-d-chen commented 4 months ago

Hi @nuomi2021,

It might be helpful to merge together no_{p,q} and maxlen{p,q} so that no_{p,q} = 1 means maxlen{p,q} = 1 since they convey similar information.

no_{p,q} is used to skip deblocking operations

https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/vvc/filter_template.c#L495-L503

For chroma, maxlen{p,q} = 0 when

https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/vvc/filter.c#L730-L733

and this prevents deblocking calculations

https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/vvc/filter_template.c#L707-L711

Instead if

          if (!max_len_p && !max_len_q) // both zero which we guarantee happens in max_filter_length_chroma
              continue;

and if only one of maxlen{p,q} = 0, we treat that as no_{p,q} and skip.

This would free up two registers in the asm which would make implementing the more complicated logic easier.

I need to do more research on Luma but I think this works for Luma as well.

nuomi2021 commented 4 months ago

but if max_len_p == 0 and max_len_q == 3, it will introduce problem for this line https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/vvc/filter_template.c#L713

This would free up two registers in the asm which would make implementing the more complicated logic easier.

can we use tricks like this: https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/x86/h264_deblock.asm#L483-L496 r4 was used before, but we can use r4m to get the value back from the memory. so you do not need reserve register for no_q and no_q

stone-d-chen commented 4 months ago

but if max_len_p == 0 and max_len_q == 3, it will introduce problem for this line

Oh yeah... can't believe I missed that....

https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/vvc/filter_template.c#L713

This would free up two registers in the asm which would make implementing the more complicated logic easier.

can we use tricks like this:

https://github.com/ffvvc/FFmpeg/blob/459f88331b69820effea62402b6f33e0aae56fd2/libavcodec/x86/h264_deblock.asm#L483-L496

r4 was used before, but we can use r4m to get the value back from the memory. so you do not need reserve register for no_q and no_q

Hm yeah I guess no_q and no_q aren't reused so it's okay to clobber them.