diff mbox series

[FFmpeg-devel,2/3] avcodec/x86: disable hevc 12b luma deblock

Message ID 20240221111003.185240-2-jdek@itanimul.li
State New
Headers show
Series [FFmpeg-devel,1/3] checkasm/hevc_deblock: add luma and chroma full | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

J. Dekker Feb. 21, 2024, 11:10 a.m. UTC
Over/underflow in some cases.

Signed-off-by: J. Dekker <jdek@itanimul.li>
---
 libavcodec/x86/hevcdsp_init.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt Feb. 23, 2024, 3:14 a.m. UTC | #1
J. Dekker:
> Over/underflow in some cases.
> 
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
>  libavcodec/x86/hevcdsp_init.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
> index 31e81eb11f..11cb1b3bfd 100644
> --- a/libavcodec/x86/hevcdsp_init.c
> +++ b/libavcodec/x86/hevcdsp_init.c
> @@ -1205,10 +1205,11 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
>          if (EXTERNAL_SSE2(cpu_flags)) {
>              c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2;
>              c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2;
> -            if (ARCH_X86_64) {
> -                c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
> -                c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
> -            }
> +            // FIXME: 12-bit luma deblock over/underflows in some cases
> +            // if (ARCH_X86_64) {
> +            //     c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
> +            //     c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
> +            // }
>              SAO_BAND_INIT(12, sse2);
>              SAO_EDGE_INIT(12, sse2);
>  

If you disable them here, you should also ensure that they are not
assembled at all.

- Andreas
Nuo Mi Feb. 23, 2024, 12:45 p.m. UTC | #2
On Wed, Feb 21, 2024 at 7:10 PM J. Dekker <jdek@itanimul.li> wrote:

> Over/underflow in some cases.
>
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
>  libavcodec/x86/hevcdsp_init.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
> index 31e81eb11f..11cb1b3bfd 100644
> --- a/libavcodec/x86/hevcdsp_init.c
> +++ b/libavcodec/x86/hevcdsp_init.c
> @@ -1205,10 +1205,11 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const
> int bit_depth)
>          if (EXTERNAL_SSE2(cpu_flags)) {
>              c->hevc_v_loop_filter_chroma =
> ff_hevc_v_loop_filter_chroma_12_sse2;
>              c->hevc_h_loop_filter_chroma =
> ff_hevc_h_loop_filter_chroma_12_sse2;
> -            if (ARCH_X86_64) {
> -                c->hevc_v_loop_filter_luma =
> ff_hevc_v_loop_filter_luma_12_sse2;
> -                c->hevc_h_loop_filter_luma =
> ff_hevc_h_loop_filter_luma_12_sse2;
> -            }
> +            // FIXME: 12-bit luma deblock over/underflows in some cases
> +            // if (ARCH_X86_64) {
> +            //     c->hevc_v_loop_filter_luma =
> ff_hevc_v_loop_filter_luma_12_sse2;
> +            //     c->hevc_h_loop_filter_luma =
> ff_hevc_h_loop_filter_luma_12_sse2;
> +            // }
>              SAO_BAND_INIT(12, sse2);
>              SAO_EDGE_INIT(12, sse2);
>
Hi Dekker,
VVC will utilize this function as well.
Could you please share the HEVC clip or data that caused the overflow?
We'll make efforts to address it during the VVC porting

Thank you.

>
> --
> 2.43.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
J. Dekker Feb. 24, 2024, 9:49 a.m. UTC | #3
Nuo Mi <nuomi2021@gmail.com> writes:

> On Wed, Feb 21, 2024 at 7:10 PM J. Dekker <jdek@itanimul.li> wrote:
>
>> Over/underflow in some cases.
>>
>> Signed-off-by: J. Dekker <jdek@itanimul.li>
>> ---
>>  libavcodec/x86/hevcdsp_init.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
>> index 31e81eb11f..11cb1b3bfd 100644
>> --- a/libavcodec/x86/hevcdsp_init.c
>> +++ b/libavcodec/x86/hevcdsp_init.c
>> @@ -1205,10 +1205,11 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const
>> int bit_depth)
>>          if (EXTERNAL_SSE2(cpu_flags)) {
>>              c->hevc_v_loop_filter_chroma =
>> ff_hevc_v_loop_filter_chroma_12_sse2;
>>              c->hevc_h_loop_filter_chroma =
>> ff_hevc_h_loop_filter_chroma_12_sse2;
>> -            if (ARCH_X86_64) {
>> -                c->hevc_v_loop_filter_luma =
>> ff_hevc_v_loop_filter_luma_12_sse2;
>> -                c->hevc_h_loop_filter_luma =
>> ff_hevc_h_loop_filter_luma_12_sse2;
>> -            }
>> +            // FIXME: 12-bit luma deblock over/underflows in some cases
>> +            // if (ARCH_X86_64) {
>> +            //     c->hevc_v_loop_filter_luma =
>> ff_hevc_v_loop_filter_luma_12_sse2;
>> +            //     c->hevc_h_loop_filter_luma =
>> ff_hevc_h_loop_filter_luma_12_sse2;
>> +            // }
>>              SAO_BAND_INIT(12, sse2);
>>              SAO_EDGE_INIT(12, sse2);
>>
> Hi Dekker,
> VVC will utilize this function as well.
> Could you please share the HEVC clip or data that caused the overflow?
> We'll make efforts to address it during the VVC porting
>

You can just run ./tests/checkasm/checkasm --test=hevc_deblock to
find a failing case. My guess is that delta0 overflows before the right
shift, see the ARM64 asm which specfically widens this calculation on 12
bit variant but I'm not 100%, I don't know x86 asm.
J. Dekker Feb. 24, 2024, 9:54 a.m. UTC | #4
Andreas Rheinhardt <andreas.rheinhardt@outlook.com> writes:
> J. Dekker:
>>              SAO_BAND_INIT(12, sse2);
>>              SAO_EDGE_INIT(12, sse2);
>>  
>
> If you disable them here, you should also ensure that they are not
> assembled at all.
>
> - Andreas

Sure, will do on push if no other things to resolve in the latest set.
Martin Storsjö Feb. 24, 2024, 10:46 a.m. UTC | #5
On Sat, 24 Feb 2024, J. Dekker wrote:

>
> Nuo Mi <nuomi2021@gmail.com> writes:
>
>> On Wed, Feb 21, 2024 at 7:10 PM J. Dekker <jdek@itanimul.li> wrote:
>>
>>> Over/underflow in some cases.
>>>
>>> Signed-off-by: J. Dekker <jdek@itanimul.li>
>>> ---
>>>  libavcodec/x86/hevcdsp_init.c | 9 +++++----
>>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
>>> index 31e81eb11f..11cb1b3bfd 100644
>>> --- a/libavcodec/x86/hevcdsp_init.c
>>> +++ b/libavcodec/x86/hevcdsp_init.c
>>> @@ -1205,10 +1205,11 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const
>>> int bit_depth)
>>>          if (EXTERNAL_SSE2(cpu_flags)) {
>>>              c->hevc_v_loop_filter_chroma =
>>> ff_hevc_v_loop_filter_chroma_12_sse2;
>>>              c->hevc_h_loop_filter_chroma =
>>> ff_hevc_h_loop_filter_chroma_12_sse2;
>>> -            if (ARCH_X86_64) {
>>> -                c->hevc_v_loop_filter_luma =
>>> ff_hevc_v_loop_filter_luma_12_sse2;
>>> -                c->hevc_h_loop_filter_luma =
>>> ff_hevc_h_loop_filter_luma_12_sse2;
>>> -            }
>>> +            // FIXME: 12-bit luma deblock over/underflows in some cases
>>> +            // if (ARCH_X86_64) {
>>> +            //     c->hevc_v_loop_filter_luma =
>>> ff_hevc_v_loop_filter_luma_12_sse2;
>>> +            //     c->hevc_h_loop_filter_luma =
>>> ff_hevc_h_loop_filter_luma_12_sse2;
>>> +            // }
>>>              SAO_BAND_INIT(12, sse2);
>>>              SAO_EDGE_INIT(12, sse2);
>>>
>> Hi Dekker,
>> VVC will utilize this function as well.
>> Could you please share the HEVC clip or data that caused the overflow?
>> We'll make efforts to address it during the VVC porting
>>
>
> You can just run ./tests/checkasm/checkasm --test=hevc_deblock to
> find a failing case.

To clarify, this is with the new checkasm test added in this patchset, not 
currently in git master - otherwise fate would be failing for everybody on 
x86.

> My guess is that delta0 overflows before the right
> shift, see the ARM64 asm which specfically widens this calculation on 12
> bit variant but I'm not 100%, I don't know x86 asm.

Are you sure the input is within valid range? It's always possible that 
checkasm produces inputs that the real decoder wouldn't - but it's also 
possible that this is a real decoder bug that just hasn't been triggered 
by any other test yet.

// Martin
J. Dekker Feb. 24, 2024, 6:32 p.m. UTC | #6
Martin Storsjö <martin@martin.st> writes:
> [...]
>
> Are you sure the input is within valid range? It's always possible that
> checkasm produces inputs that the real decoder wouldn't - but it's also
> possible that this is a real decoder bug that just hasn't been triggered by any
> other test yet.
>
> // Martin

The checkasm was just written to just to trigger all the theoretical
edgecases. I know there is a decent range of values which pass the d0 +
d3 < beta check and overflow in (9 * (q0 - p0) - 3 * (q1 - p1) + 8) for
int16_t. I'm not 100% sure that these values can be output by the
decoder, and even if so they're rare.
diff mbox series

Patch

diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
index 31e81eb11f..11cb1b3bfd 100644
--- a/libavcodec/x86/hevcdsp_init.c
+++ b/libavcodec/x86/hevcdsp_init.c
@@ -1205,10 +1205,11 @@  void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
         if (EXTERNAL_SSE2(cpu_flags)) {
             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2;
             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2;
-            if (ARCH_X86_64) {
-                c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
-                c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
-            }
+            // FIXME: 12-bit luma deblock over/underflows in some cases
+            // if (ARCH_X86_64) {
+            //     c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
+            //     c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
+            // }
             SAO_BAND_INIT(12, sse2);
             SAO_EDGE_INIT(12, sse2);