diff mbox series

[FFmpeg-devel] swscale/x86/input: add AVX2 optimized RGB24 to YUV functions

Message ID 20240604190742.1742-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] swscale/x86/input: add AVX2 optimized RGB24 to YUV functions | 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

James Almer June 4, 2024, 7:07 p.m. UTC
rgb24_to_uv_8_c: 39.3
rgb24_to_uv_8_sse2: 14.3
rgb24_to_uv_8_ssse3: 13.3
rgb24_to_uv_8_avx: 12.8
rgb24_to_uv_8_avx2: 14.3
rgb24_to_uv_128_c: 582.8
rgb24_to_uv_128_sse2: 127.3
rgb24_to_uv_128_ssse3: 107.3
rgb24_to_uv_128_avx: 111.3
rgb24_to_uv_128_avx2: 62.3
rgb24_to_uv_1080_c: 4981.3
rgb24_to_uv_1080_sse2: 1048.3
rgb24_to_uv_1080_ssse3: 876.8
rgb24_to_uv_1080_avx: 887.8
rgb24_to_uv_1080_avx2: 492.3
rgb24_to_uv_1280_c: 5906.8
rgb24_to_uv_1280_sse2: 1263.3
rgb24_to_uv_1280_ssse3: 1048.3
rgb24_to_uv_1280_avx: 1045.8
rgb24_to_uv_1280_avx2: 579.8
rgb24_to_uv_1920_c: 8665.3
rgb24_to_uv_1920_sse2: 1888.8
rgb24_to_uv_1920_ssse3: 1571.8
rgb24_to_uv_1920_avx: 1558.8
rgb24_to_uv_1920_avx2: 869.3
rgb24_to_y_8_c: 20.3
rgb24_to_y_8_sse2: 11.8
rgb24_to_y_8_ssse3: 10.3
rgb24_to_y_8_avx: 10.3
rgb24_to_y_8_avx2: 10.8
rgb24_to_y_128_c: 284.8
rgb24_to_y_128_sse2: 83.3
rgb24_to_y_128_ssse3: 66.8
rgb24_to_y_128_avx: 64.8
rgb24_to_y_128_avx2: 39.3
rgb24_to_y_1080_c: 2451.3
rgb24_to_y_1080_sse2: 696.3
rgb24_to_y_1080_ssse3: 516.8
rgb24_to_y_1080_avx: 518.8
rgb24_to_y_1080_avx2: 301.8
rgb24_to_y_1280_c: 2892.8
rgb24_to_y_1280_sse2: 816.8
rgb24_to_y_1280_ssse3: 623.3
rgb24_to_y_1280_avx: 616.3
rgb24_to_y_1280_avx2: 350.8
rgb24_to_y_1920_c: 4338.8
rgb24_to_y_1920_sse2: 1210.8
rgb24_to_y_1920_ssse3: 928.3
rgb24_to_y_1920_avx: 920.3
rgb24_to_y_1920_avx2: 534.8

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libswscale/x86/input.asm | 49 ++++++++++++++++++++++++++++++++++++----
 libswscale/x86/swscale.c |  7 ++++++
 2 files changed, 51 insertions(+), 5 deletions(-)

Comments

Andreas Rheinhardt June 4, 2024, 7:25 p.m. UTC | #1
James Almer:
> rgb24_to_uv_8_c: 39.3
> rgb24_to_uv_8_sse2: 14.3
> rgb24_to_uv_8_ssse3: 13.3
> rgb24_to_uv_8_avx: 12.8
> rgb24_to_uv_8_avx2: 14.3

Worse than avx and ssse3

> rgb24_to_uv_128_c: 582.8
> rgb24_to_uv_128_sse2: 127.3
> rgb24_to_uv_128_ssse3: 107.3
> rgb24_to_uv_128_avx: 111.3

Worse than ssse3

> rgb24_to_uv_128_avx2: 62.3
> rgb24_to_uv_1080_c: 4981.3
> rgb24_to_uv_1080_sse2: 1048.3
> rgb24_to_uv_1080_ssse3: 876.8
> rgb24_to_uv_1080_avx: 887.8

Worse than ssse3

> rgb24_to_uv_1080_avx2: 492.3
> rgb24_to_uv_1280_c: 5906.8
> rgb24_to_uv_1280_sse2: 1263.3
> rgb24_to_uv_1280_ssse3: 1048.3
> rgb24_to_uv_1280_avx: 1045.8

Not really better than ssse3

> rgb24_to_uv_1280_avx2: 579.8
> rgb24_to_uv_1920_c: 8665.3
> rgb24_to_uv_1920_sse2: 1888.8
> rgb24_to_uv_1920_ssse3: 1571.8
> rgb24_to_uv_1920_avx: 1558.8

Not really better than ssse3

> rgb24_to_uv_1920_avx2: 869.3
> rgb24_to_y_8_c: 20.3
> rgb24_to_y_8_sse2: 11.8
> rgb24_to_y_8_ssse3: 10.3
> rgb24_to_y_8_avx: 10.3

Not better than ssse3

> rgb24_to_y_8_avx2: 10.8

Worse than ssse3

> rgb24_to_y_128_c: 284.8
> rgb24_to_y_128_sse2: 83.3
> rgb24_to_y_128_ssse3: 66.8
> rgb24_to_y_128_avx: 64.8

Not really better than ssse3

> rgb24_to_y_128_avx2: 39.3
> rgb24_to_y_1080_c: 2451.3
> rgb24_to_y_1080_sse2: 696.3
> rgb24_to_y_1080_ssse3: 516.8
> rgb24_to_y_1080_avx: 518.8

Worse than ssse3

> rgb24_to_y_1080_avx2: 301.8
> rgb24_to_y_1280_c: 2892.8
> rgb24_to_y_1280_sse2: 816.8
> rgb24_to_y_1280_ssse3: 623.3
> rgb24_to_y_1280_avx: 616.3

Not really better than ssse3

> rgb24_to_y_1280_avx2: 350.8
> rgb24_to_y_1920_c: 4338.8
> rgb24_to_y_1920_sse2: 1210.8
> rgb24_to_y_1920_ssse3: 928.3
> rgb24_to_y_1920_avx: 920.3

Not really better than ssse3

> rgb24_to_y_1920_avx2: 534.8
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libswscale/x86/input.asm | 49 ++++++++++++++++++++++++++++++++++++----
>  libswscale/x86/swscale.c |  7 ++++++
>  2 files changed, 51 insertions(+), 5 deletions(-)
> 
> diff --git a/libswscale/x86/input.asm b/libswscale/x86/input.asm
> index a197183f1f..e79fe11405 100644
> --- a/libswscale/x86/input.asm
> +++ b/libswscale/x86/input.asm
> @@ -23,7 +23,7 @@
>  
>  %include "libavutil/x86/x86util.asm"
>  
> -SECTION_RODATA
> +SECTION_RODATA 32
>  
>  %define RY 0x20DE
>  %define GY 0x4087
> @@ -90,8 +90,12 @@ rgb_UVrnd:       times 4 dd 0x400100       ; 128.5 << 15
>  ; rgba_Vcoeff_ag:  times 4 dw 0,  GV
>  
>  shuf_rgb_12x4:   db 0, 0x80, 1, 0x80,  2, 0x80,  3, 0x80, \
> +                    6, 0x80, 7, 0x80,  8, 0x80,  9, 0x80, \
> +                    0, 0x80, 1, 0x80,  2, 0x80,  3, 0x80, \
>                      6, 0x80, 7, 0x80,  8, 0x80,  9, 0x80
>  shuf_rgb_3x56:   db 2, 0x80, 3, 0x80,  4, 0x80,  5, 0x80, \
> +                    8, 0x80, 9, 0x80, 10, 0x80, 11, 0x80, \
> +                    2, 0x80, 3, 0x80,  4, 0x80,  5, 0x80, \
>                      8, 0x80, 9, 0x80, 10, 0x80, 11, 0x80
>  pd_65535f:     times 8 dd 65535.0
>  pb_pack_shuffle16le:    db  0,  1,  4,  5, \
> @@ -134,8 +138,13 @@ SECTION .text
>  %macro RGB24_TO_Y_FN 2-3
>  cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, table
>  %if ARCH_X86_64
> +%if mmsize == 32
> +    vbroadcasti128 m8, [%2_Ycoeff_12x4]
> +    vbroadcasti128 m9, [%2_Ycoeff_3x56]
> +%else
>      mova           m8, [%2_Ycoeff_12x4]
>      mova           m9, [%2_Ycoeff_3x56]
> +%endif
>  %define coeff1 m8
>  %define coeff2 m9
>  %else ; x86-32
> @@ -165,11 +174,19 @@ cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, table
>  %if notcpuflag(ssse3)
>      pxor           m7, m7
>  %endif ; !cpuflag(ssse3)
> +%if mmsize == 32
> +    vbroadcasti128 m4, [rgb_Yrnd]
> +%else
>      mova           m4, [rgb_Yrnd]
> +%endif
>  .loop:
>  %if cpuflag(ssse3)
> -    movu           m0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
> -    movu           m2, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
> +    movu          xm0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
> +    movu          xm2, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
> +%if mmsize == 32
> +    vinserti128    m0, m0, [srcq+24], 1
> +    vinserti128    m2, m2, [srcq+36], 1
> +%endif
>      pshufb         m1, m0, shuf_rgb2      ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
>      pshufb         m0, shuf_rgb1          ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
>      pshufb         m3, m2, shuf_rgb2      ; (word) { R4, B5, G5, R5, R6, B7, G7, R7 }
> @@ -216,10 +233,17 @@ cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, table
>  %macro RGB24_TO_UV_FN 2-3
>  cglobal %2 %+ 24ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table
>  %if ARCH_X86_64
> +%if mmsize == 32
> +    vbroadcasti128  m8, [%2_Ucoeff_12x4]
> +    vbroadcasti128  m9, [%2_Ucoeff_3x56]
> +    vbroadcasti128 m10, [%2_Vcoeff_12x4]
> +    vbroadcasti128 m11, [%2_Vcoeff_3x56]
> +%else
>      mova           m8, [%2_Ucoeff_12x4]
>      mova           m9, [%2_Ucoeff_3x56]
>      mova          m10, [%2_Vcoeff_12x4]
>      mova          m11, [%2_Vcoeff_3x56]
> +%endif
>  %define coeffU1 m8
>  %define coeffU2 m9
>  %define coeffV1 m10
> @@ -253,14 +277,22 @@ cglobal %2 %+ 24ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table
>      add         dstUq, wq
>      add         dstVq, wq
>      neg            wq
> +%if mmsize == 32
> +    vbroadcasti128 m6, [rgb_UVrnd]
> +%else
>      mova           m6, [rgb_UVrnd]
> +%endif
>  %if notcpuflag(ssse3)
>      pxor           m7, m7
>  %endif
>  .loop:
>  %if cpuflag(ssse3)
> -    movu           m0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
> -    movu           m4, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
> +    movu          xm0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
> +    movu          xm4, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
> +%if mmsize == 32
> +    vinserti128    m0, m0, [srcq+24], 1
> +    vinserti128    m4, m4, [srcq+36], 1
> +%endif
>      pshufb         m1, m0, shuf_rgb2      ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
>      pshufb         m0, shuf_rgb1          ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
>  %else ; !cpuflag(ssse3)
> @@ -337,6 +369,13 @@ INIT_XMM avx
>  RGB24_FUNCS 11, 13
>  %endif
>  
> +%if ARCH_X86_64
> +%if HAVE_AVX2_EXTERNAL
> +INIT_YMM avx2
> +RGB24_FUNCS 11, 13
> +%endif
> +%endif
> +
>  ; %1 = nr. of XMM registers
>  ; %2-5 = rgba, bgra, argb or abgr (in individual characters)
>  %macro RGB32_TO_Y_FN 5-6
> diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
> index fff8bb4396..1438c077e6 100644
> --- a/libswscale/x86/swscale.c
> +++ b/libswscale/x86/swscale.c
> @@ -321,6 +321,8 @@ void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
>  INPUT_FUNCS(sse2);
>  INPUT_FUNCS(ssse3);
>  INPUT_FUNCS(avx);
> +INPUT_FUNC(rgb24, avx2);
> +INPUT_FUNC(bgr24, avx2);
>  
>  #if ARCH_X86_64
>  #define YUV2NV_DECL(fmt, opt) \
> @@ -634,6 +636,11 @@ switch(c->dstBpc){ \
>      }
>  
>      if (EXTERNAL_AVX2_FAST(cpu_flags)) {
> +        if (ARCH_X86_64)
> +            switch (c->srcFormat) {
> +            case_rgb(rgb24, RGB24, avx2);
> +            case_rgb(bgr24, BGR24, avx2);
> +            }
>          switch (c->dstFormat) {
>          case AV_PIX_FMT_NV12:
>          case AV_PIX_FMT_NV24:
James Almer June 4, 2024, 7:30 p.m. UTC | #2
On 6/4/2024 4:25 PM, Andreas Rheinhardt wrote:
> James Almer:
>> rgb24_to_uv_8_c: 39.3
>> rgb24_to_uv_8_sse2: 14.3
>> rgb24_to_uv_8_ssse3: 13.3
>> rgb24_to_uv_8_avx: 12.8
>> rgb24_to_uv_8_avx2: 14.3
> 
> Worse than avx and ssse3

Can't be disabled for small sizes.

> 
>> rgb24_to_uv_128_c: 582.8
>> rgb24_to_uv_128_sse2: 127.3
>> rgb24_to_uv_128_ssse3: 107.3
>> rgb24_to_uv_128_avx: 111.3
> 
> Worse than ssse3

I know, but it's not related to this patch.
Same for all the comments below.
Andreas Rheinhardt June 4, 2024, 7:32 p.m. UTC | #3
James Almer:
> On 6/4/2024 4:25 PM, Andreas Rheinhardt wrote:
>> James Almer:
>>> rgb24_to_uv_8_c: 39.3
>>> rgb24_to_uv_8_sse2: 14.3
>>> rgb24_to_uv_8_ssse3: 13.3
>>> rgb24_to_uv_8_avx: 12.8
>>> rgb24_to_uv_8_avx2: 14.3
>>
>> Worse than avx and ssse3
> 
> Can't be disabled for small sizes.
> 

Why can't this be disabled?

>>
>>> rgb24_to_uv_128_c: 582.8
>>> rgb24_to_uv_128_sse2: 127.3
>>> rgb24_to_uv_128_ssse3: 107.3
>>> rgb24_to_uv_128_avx: 111.3
>>
>> Worse than ssse3
> 
> I know, but it's not related to this patch.
> Same for all the comments below.
James Almer June 4, 2024, 7:37 p.m. UTC | #4
On 6/4/2024 4:32 PM, Andreas Rheinhardt wrote:
> James Almer:
>> On 6/4/2024 4:25 PM, Andreas Rheinhardt wrote:
>>> James Almer:
>>>> rgb24_to_uv_8_c: 39.3
>>>> rgb24_to_uv_8_sse2: 14.3
>>>> rgb24_to_uv_8_ssse3: 13.3
>>>> rgb24_to_uv_8_avx: 12.8
>>>> rgb24_to_uv_8_avx2: 14.3
>>>
>>> Worse than avx and ssse3
>>
>> Can't be disabled for small sizes.
>>
> 
> Why can't this be disabled?

The function pointer is for all sizes. And adding a check + jmp in the 
assembly is not going to be better. Also, this being for 8 pixel wide 
buffers, it's not going to be anyone's bottleneck.

> 
>>>
>>>> rgb24_to_uv_128_c: 582.8
>>>> rgb24_to_uv_128_sse2: 127.3
>>>> rgb24_to_uv_128_ssse3: 107.3
>>>> rgb24_to_uv_128_avx: 111.3
>>>
>>> Worse than ssse3
>>
>> I know, but it's not related to this patch.
>> Same for all the comments below.
> 
> _______________________________________________
> 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".
diff mbox series

Patch

diff --git a/libswscale/x86/input.asm b/libswscale/x86/input.asm
index a197183f1f..e79fe11405 100644
--- a/libswscale/x86/input.asm
+++ b/libswscale/x86/input.asm
@@ -23,7 +23,7 @@ 
 
 %include "libavutil/x86/x86util.asm"
 
-SECTION_RODATA
+SECTION_RODATA 32
 
 %define RY 0x20DE
 %define GY 0x4087
@@ -90,8 +90,12 @@  rgb_UVrnd:       times 4 dd 0x400100       ; 128.5 << 15
 ; rgba_Vcoeff_ag:  times 4 dw 0,  GV
 
 shuf_rgb_12x4:   db 0, 0x80, 1, 0x80,  2, 0x80,  3, 0x80, \
+                    6, 0x80, 7, 0x80,  8, 0x80,  9, 0x80, \
+                    0, 0x80, 1, 0x80,  2, 0x80,  3, 0x80, \
                     6, 0x80, 7, 0x80,  8, 0x80,  9, 0x80
 shuf_rgb_3x56:   db 2, 0x80, 3, 0x80,  4, 0x80,  5, 0x80, \
+                    8, 0x80, 9, 0x80, 10, 0x80, 11, 0x80, \
+                    2, 0x80, 3, 0x80,  4, 0x80,  5, 0x80, \
                     8, 0x80, 9, 0x80, 10, 0x80, 11, 0x80
 pd_65535f:     times 8 dd 65535.0
 pb_pack_shuffle16le:    db  0,  1,  4,  5, \
@@ -134,8 +138,13 @@  SECTION .text
 %macro RGB24_TO_Y_FN 2-3
 cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, table
 %if ARCH_X86_64
+%if mmsize == 32
+    vbroadcasti128 m8, [%2_Ycoeff_12x4]
+    vbroadcasti128 m9, [%2_Ycoeff_3x56]
+%else
     mova           m8, [%2_Ycoeff_12x4]
     mova           m9, [%2_Ycoeff_3x56]
+%endif
 %define coeff1 m8
 %define coeff2 m9
 %else ; x86-32
@@ -165,11 +174,19 @@  cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, table
 %if notcpuflag(ssse3)
     pxor           m7, m7
 %endif ; !cpuflag(ssse3)
+%if mmsize == 32
+    vbroadcasti128 m4, [rgb_Yrnd]
+%else
     mova           m4, [rgb_Yrnd]
+%endif
 .loop:
 %if cpuflag(ssse3)
-    movu           m0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
-    movu           m2, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
+    movu          xm0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
+    movu          xm2, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
+%if mmsize == 32
+    vinserti128    m0, m0, [srcq+24], 1
+    vinserti128    m2, m2, [srcq+36], 1
+%endif
     pshufb         m1, m0, shuf_rgb2      ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
     pshufb         m0, shuf_rgb1          ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
     pshufb         m3, m2, shuf_rgb2      ; (word) { R4, B5, G5, R5, R6, B7, G7, R7 }
@@ -216,10 +233,17 @@  cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, table
 %macro RGB24_TO_UV_FN 2-3
 cglobal %2 %+ 24ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table
 %if ARCH_X86_64
+%if mmsize == 32
+    vbroadcasti128  m8, [%2_Ucoeff_12x4]
+    vbroadcasti128  m9, [%2_Ucoeff_3x56]
+    vbroadcasti128 m10, [%2_Vcoeff_12x4]
+    vbroadcasti128 m11, [%2_Vcoeff_3x56]
+%else
     mova           m8, [%2_Ucoeff_12x4]
     mova           m9, [%2_Ucoeff_3x56]
     mova          m10, [%2_Vcoeff_12x4]
     mova          m11, [%2_Vcoeff_3x56]
+%endif
 %define coeffU1 m8
 %define coeffU2 m9
 %define coeffV1 m10
@@ -253,14 +277,22 @@  cglobal %2 %+ 24ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table
     add         dstUq, wq
     add         dstVq, wq
     neg            wq
+%if mmsize == 32
+    vbroadcasti128 m6, [rgb_UVrnd]
+%else
     mova           m6, [rgb_UVrnd]
+%endif
 %if notcpuflag(ssse3)
     pxor           m7, m7
 %endif
 .loop:
 %if cpuflag(ssse3)
-    movu           m0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
-    movu           m4, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
+    movu          xm0, [srcq+0]           ; (byte) { Bx, Gx, Rx }[0-3]
+    movu          xm4, [srcq+12]          ; (byte) { Bx, Gx, Rx }[4-7]
+%if mmsize == 32
+    vinserti128    m0, m0, [srcq+24], 1
+    vinserti128    m4, m4, [srcq+36], 1
+%endif
     pshufb         m1, m0, shuf_rgb2      ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
     pshufb         m0, shuf_rgb1          ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
 %else ; !cpuflag(ssse3)
@@ -337,6 +369,13 @@  INIT_XMM avx
 RGB24_FUNCS 11, 13
 %endif
 
+%if ARCH_X86_64
+%if HAVE_AVX2_EXTERNAL
+INIT_YMM avx2
+RGB24_FUNCS 11, 13
+%endif
+%endif
+
 ; %1 = nr. of XMM registers
 ; %2-5 = rgba, bgra, argb or abgr (in individual characters)
 %macro RGB32_TO_Y_FN 5-6
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index fff8bb4396..1438c077e6 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -321,6 +321,8 @@  void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
 INPUT_FUNCS(sse2);
 INPUT_FUNCS(ssse3);
 INPUT_FUNCS(avx);
+INPUT_FUNC(rgb24, avx2);
+INPUT_FUNC(bgr24, avx2);
 
 #if ARCH_X86_64
 #define YUV2NV_DECL(fmt, opt) \
@@ -634,6 +636,11 @@  switch(c->dstBpc){ \
     }
 
     if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+        if (ARCH_X86_64)
+            switch (c->srcFormat) {
+            case_rgb(rgb24, RGB24, avx2);
+            case_rgb(bgr24, BGR24, avx2);
+            }
         switch (c->dstFormat) {
         case AV_PIX_FMT_NV12:
         case AV_PIX_FMT_NV24: