diff mbox series

[FFmpeg-devel,1/2] avutil/hwcontext_vulkan: cuda doesn't belong to valid_sw_formats

Message ID tencent_C2D8A7D0AA8093021C4E8B83263B9082A606@qq.com
State Accepted
Commit 63078b45999d116945841146576d914cc0389fe2
Headers show
Series [FFmpeg-devel,1/2] avutil/hwcontext_vulkan: cuda doesn't belong to valid_sw_formats | 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

Zhao Zhili Oct. 27, 2023, 3:37 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

Move it to transfer_get_formats.
---
 libavutil/hwcontext_vulkan.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

Philip Langdale Oct. 27, 2023, 4:48 p.m. UTC | #1
On Fri, 27 Oct 2023 23:37:00 +0800
Zhao Zhili <quinkblack@foxmail.com> wrote:

> From: Zhao Zhili <zhilizhao@tencent.com>
> 
> Move it to transfer_get_formats.
> ---
>  libavutil/hwcontext_vulkan.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/libavutil/hwcontext_vulkan.c
> b/libavutil/hwcontext_vulkan.c index 8dd40cb66f..8481427b42 100644
> --- a/libavutil/hwcontext_vulkan.c
> +++ b/libavutil/hwcontext_vulkan.c
> @@ -1664,11 +1664,6 @@ static int
> vulkan_frames_get_constraints(AVHWDeviceContext *ctx, NULL, NULL,
> NULL, NULL, 0, 0) >= 0; }
>  
> -#if CONFIG_CUDA
> -    if (p->dev_is_nvidia)
> -        count++;
> -#endif
> -
>      constraints->valid_sw_formats = av_malloc_array(count + 1,
>                                                      sizeof(enum
> AVPixelFormat)); if (!constraints->valid_sw_formats)
> @@ -1684,10 +1679,6 @@ static int
> vulkan_frames_get_constraints(AVHWDeviceContext *ctx, }
>      }
>  
> -#if CONFIG_CUDA
> -    if (p->dev_is_nvidia)
> -        constraints->valid_sw_formats[count++] = AV_PIX_FMT_CUDA;
> -#endif
>      constraints->valid_sw_formats[count++] = AV_PIX_FMT_NONE;
>  
>      constraints->min_width  = 1;
> @@ -2416,12 +2407,22 @@ static int
> vulkan_transfer_get_formats(AVHWFramesContext *hwfc, enum
> AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
>  {
> -    enum AVPixelFormat *fmts = av_malloc_array(2, sizeof(*fmts));
> +    enum AVPixelFormat *fmts;
> +    int n = 2;
> +
> +#if CONFIG_CUDA
> +    n++;
> +#endif
> +    fmts = av_malloc_array(n, sizeof(*fmts));
>      if (!fmts)
>          return AVERROR(ENOMEM);
>  
> -    fmts[0] = hwfc->sw_format;
> -    fmts[1] = AV_PIX_FMT_NONE;
> +    n = 0;
> +    fmts[n++] = hwfc->sw_format;
> +#if CONFIG_CUDA
> +    fmts[n++] = AV_PIX_FMT_CUDA;
> +#endif
> +    fmts[n++] = AV_PIX_FMT_NONE;
>  
>      *formats = fmts;
>      return 0;

LGTM. Thanks!


--phil
Lynne Oct. 29, 2023, 6:12 a.m. UTC | #2
Oct 27, 2023, 09:37 by quinkblack@foxmail.com:

> From: Zhao Zhili <zhilizhao@tencent.com>
>
> Move it to transfer_get_formats.
>

Could you backport this, along with the other two patches to the v6.1 branch too?
Thanks
Zhao Zhili Oct. 29, 2023, 8:55 a.m. UTC | #3
> 在 2023年10月29日,下午2:12,Lynne <dev@lynne.ee> 写道:
> 
> Oct 27, 2023, 09:37 by quinkblack@foxmail.com:
> 
>> From: Zhao Zhili <zhilizhao@tencent.com>
>> 
>> Move it to transfer_get_formats.
>> 
> 
> Could you backport this, along with the other two patches to the v6.1 branch too?

Of course, done.

> Thanks
> _______________________________________________
> 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/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 8dd40cb66f..8481427b42 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1664,11 +1664,6 @@  static int vulkan_frames_get_constraints(AVHWDeviceContext *ctx,
                                     NULL, NULL, NULL, NULL, 0, 0) >= 0;
     }
 
-#if CONFIG_CUDA
-    if (p->dev_is_nvidia)
-        count++;
-#endif
-
     constraints->valid_sw_formats = av_malloc_array(count + 1,
                                                     sizeof(enum AVPixelFormat));
     if (!constraints->valid_sw_formats)
@@ -1684,10 +1679,6 @@  static int vulkan_frames_get_constraints(AVHWDeviceContext *ctx,
         }
     }
 
-#if CONFIG_CUDA
-    if (p->dev_is_nvidia)
-        constraints->valid_sw_formats[count++] = AV_PIX_FMT_CUDA;
-#endif
     constraints->valid_sw_formats[count++] = AV_PIX_FMT_NONE;
 
     constraints->min_width  = 1;
@@ -2416,12 +2407,22 @@  static int vulkan_transfer_get_formats(AVHWFramesContext *hwfc,
                                        enum AVHWFrameTransferDirection dir,
                                        enum AVPixelFormat **formats)
 {
-    enum AVPixelFormat *fmts = av_malloc_array(2, sizeof(*fmts));
+    enum AVPixelFormat *fmts;
+    int n = 2;
+
+#if CONFIG_CUDA
+    n++;
+#endif
+    fmts = av_malloc_array(n, sizeof(*fmts));
     if (!fmts)
         return AVERROR(ENOMEM);
 
-    fmts[0] = hwfc->sw_format;
-    fmts[1] = AV_PIX_FMT_NONE;
+    n = 0;
+    fmts[n++] = hwfc->sw_format;
+#if CONFIG_CUDA
+    fmts[n++] = AV_PIX_FMT_CUDA;
+#endif
+    fmts[n++] = AV_PIX_FMT_NONE;
 
     *formats = fmts;
     return 0;