PR #23812 opened by Diego de Souza (ddesouza)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23812
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23812.patch

PR #23564 introduced CUARRAY support but referenced CUDA array formats and
dynamic-loader entries that are only available in newer nv-codec-headers.

FFmpeg's configure checks still accept older ffnvcodec versions, causing build
failures on the MSYS2 FATE builders:

- https://fate.ffmpeg.org/report.cgi?time=20260714195752&slot=msys2-clang64
- https://fate.ffmpeg.org/report.cgi?slot=msys2-clangarm64&time=20260714200439
- https://fate.ffmpeg.org/report.cgi?slot=msys2-mingw64&time=20260714195755
- https://fate.ffmpeg.org/report.cgi?slot=msys2-ucrt64&time=20260714200701

This patch adds a configure probe for the complete CUDA array header surface
used by the implementation. When unavailable, it:

- disables the CUARRAY NVDEC hwaccels;
- compiles out CUARRAY-specific CUDA, NVDEC/CUVID, and NVENC code;
- stops advertising CUARRAY through the CUDA hardware context;
- preserves ordinary CUDA, NVDEC, NVENC, and hwupload_cuda support.

The public CUARRAY API and ABI remain unchanged.

Testing performed on a Linux NVIDIA GPU system:

- nv-codec-headers 13.0 (`33a9ede8d9914299d9262539c576a15bd0a19621`)
  - configuration and compilation passed;
  - `HAVE_FFNVCODEC_CUARRAY=0`;
  - ordinary NVDEC/NVENC components remained enabled;
  - all CUARRAY NVDEC hwaccels were disabled.

- nv-codec-headers 13.1
  - configuration and compilation passed;
  - `HAVE_FFNVCODEC_CUARRAY=1`;
  - all CUARRAY NVDEC hwaccels were enabled;
  - H.264 8-bit 4:2:0 transcodes passed through:
    - NVDEC CUARRAY safe-copy;
    - NVDEC CUARRAY zero-copy (`+unsafe_output`);
    - CUVID CUARRAY safe-copy;
    - CUVID CUARRAY zero-copy.

Follow-up to #23564.


>From b734da8a4085155427785b5b322675c40e1466e9 Mon Sep 17 00:00:00 2001
From: Diego de Souza <[email protected]>
Date: Wed, 15 Jul 2026 01:20:28 +0200
Subject: [PATCH] configure: gate CUARRAY support on ffnvcodec capabilities

The CUARRAY implementation unconditionally references CUDA array
formats and dynamic-loader entries added in nv-codec-headers 13.1.
This breaks builds with older ffnvcodec versions that configure
still accepts.

Probe for the complete CUARRAY header support and use the result
to disable only CUARRAY hwaccels and code paths. Ordinary CUDA,
NVDEC, NVENC, and hwupload_cuda remain available with older headers.

Signed-off-by: Diego de Souza <[email protected]>
---
 configure                  | 49 +++++++++++++++++++++-----
 libavcodec/cuviddec.c      |  1 +
 libavcodec/nvdec.h         |  3 +-
 libavcodec/nvenc.h         |  2 ++
 libavutil/hwcontext_cuda.c | 70 ++++++++++++++++++++++++++++++++++++--
 5 files changed, 113 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index c715098795..46d7bf2785 100755
--- a/configure
+++ b/configure
@@ -2714,6 +2714,7 @@ HAVE_LIST="
     $THREADS_LIST
     $TOOLCHAIN_FEATURES
     $TYPES_LIST
+    ffnvcodec_cuarray
     gzip
     ioctl_posix
     libdrm_getfb2
@@ -3417,7 +3418,7 @@ av1_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_AV1"
 av1_dxva2_hwaccel_select="av1_decoder"
 av1_nvdec_hwaccel_deps="nvdec CUVIDAV1PICPARAMS"
 av1_nvdec_hwaccel_select="av1_decoder"
-av1_nvdec_cuarray_hwaccel_deps="nvdec CUVIDAV1PICPARAMS"
+av1_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray CUVIDAV1PICPARAMS"
 av1_nvdec_cuarray_hwaccel_select="av1_decoder"
 av1_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferAV1_bit_depth_idx"
 av1_vaapi_hwaccel_select="av1_decoder"
@@ -3445,7 +3446,7 @@ h264_dxva2_hwaccel_deps="dxva2"
 h264_dxva2_hwaccel_select="h264_decoder"
 h264_nvdec_hwaccel_deps="nvdec"
 h264_nvdec_hwaccel_select="h264_decoder"
-h264_nvdec_cuarray_hwaccel_deps="nvdec"
+h264_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 h264_nvdec_cuarray_hwaccel_select="h264_decoder"
 h264_vaapi_hwaccel_deps="vaapi"
 h264_vaapi_hwaccel_select="h264_decoder"
@@ -3465,7 +3466,7 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
 hevc_dxva2_hwaccel_select="hevc_decoder"
 hevc_nvdec_hwaccel_deps="nvdec"
 hevc_nvdec_hwaccel_select="hevc_decoder"
-hevc_nvdec_cuarray_hwaccel_deps="nvdec"
+hevc_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 hevc_nvdec_cuarray_hwaccel_select="hevc_decoder"
 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
 hevc_vaapi_hwaccel_select="hevc_decoder"
@@ -3481,7 +3482,7 @@ mjpeg_vaapi_hwaccel_deps="vaapi"
 mjpeg_vaapi_hwaccel_select="mjpeg_decoder"
 mpeg1_nvdec_hwaccel_deps="nvdec"
 mpeg1_nvdec_hwaccel_select="mpeg1video_decoder"
-mpeg1_nvdec_cuarray_hwaccel_deps="nvdec"
+mpeg1_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 mpeg1_nvdec_cuarray_hwaccel_select="mpeg1video_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
@@ -3497,7 +3498,7 @@ mpeg2_dxva2_hwaccel_deps="dxva2"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
 mpeg2_nvdec_hwaccel_deps="nvdec"
 mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
-mpeg2_nvdec_cuarray_hwaccel_deps="nvdec"
+mpeg2_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 mpeg2_nvdec_cuarray_hwaccel_select="mpeg2video_decoder"
 mpeg2_vaapi_hwaccel_deps="vaapi"
 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
@@ -3507,7 +3508,7 @@ mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
 mpeg4_nvdec_hwaccel_deps="nvdec"
 mpeg4_nvdec_hwaccel_select="mpeg4_decoder"
-mpeg4_nvdec_cuarray_hwaccel_deps="nvdec"
+mpeg4_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 mpeg4_nvdec_cuarray_hwaccel_select="mpeg4_decoder"
 mpeg4_vaapi_hwaccel_deps="vaapi"
 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
@@ -3533,7 +3534,7 @@ vc1_dxva2_hwaccel_deps="dxva2"
 vc1_dxva2_hwaccel_select="vc1_decoder"
 vc1_nvdec_hwaccel_deps="nvdec"
 vc1_nvdec_hwaccel_select="vc1_decoder"
-vc1_nvdec_cuarray_hwaccel_deps="nvdec"
+vc1_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 vc1_nvdec_cuarray_hwaccel_select="vc1_decoder"
 vc1_vaapi_hwaccel_deps="vaapi"
 vc1_vaapi_hwaccel_select="vc1_decoder"
@@ -3541,7 +3542,7 @@ vc1_vdpau_hwaccel_deps="vdpau"
 vc1_vdpau_hwaccel_select="vc1_decoder"
 vp8_nvdec_hwaccel_deps="nvdec"
 vp8_nvdec_hwaccel_select="vp8_decoder"
-vp8_nvdec_cuarray_hwaccel_deps="nvdec"
+vp8_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 vp8_nvdec_cuarray_hwaccel_select="vp8_decoder"
 vp8_vaapi_hwaccel_deps="vaapi"
 vp8_vaapi_hwaccel_select="vp8_decoder"
@@ -3555,7 +3556,7 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9"
 vp9_dxva2_hwaccel_select="vp9_decoder"
 vp9_nvdec_hwaccel_deps="nvdec"
 vp9_nvdec_hwaccel_select="vp9_decoder"
-vp9_nvdec_cuarray_hwaccel_deps="nvdec"
+vp9_nvdec_cuarray_hwaccel_deps="nvdec ffnvcodec_cuarray"
 vp9_nvdec_cuarray_hwaccel_select="vp9_decoder"
 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth"
 vp9_vaapi_hwaccel_select="vp9_decoder"
@@ -7237,6 +7238,36 @@ if ! disabled ffnvcodec; then
       check_pkg_config ffnvcodec "ffnvcodec >= 11.1.5.3 ffnvcodec < 12.0" 
"$ffnv_hdr_list" ""
 fi
 
+if enabled ffnvcodec; then
+    check_cc ffnvcodec_cuarray "ffnvcodec/dynlink_loader.h" \
+        "CUarray_format formats[] = {
+             CU_AD_FORMAT_NV12,
+             CU_AD_FORMAT_P016,
+             CU_AD_FORMAT_NV16,
+             CU_AD_FORMAT_P216,
+             CU_AD_FORMAT_YUV444_8BIT_SEMIPLANAR,
+             CU_AD_FORMAT_YUV444_16BIT_SEMIPLANAR,
+             CU_AD_FORMAT_UINT8_PLANAR_420,
+             CU_AD_FORMAT_UINT8_PLANAR_422,
+             CU_AD_FORMAT_UINT8_PLANAR_444,
+             CU_AD_FORMAT_UINT16_PLANAR_420,
+             CU_AD_FORMAT_UINT16_PLANAR_422,
+             CU_AD_FORMAT_UINT16_PLANAR_444,
+         };
+         unsigned int flags = CUDA_ARRAY3D_SURFACE_LDST |
+                              CUDA_ARRAY3D_VIDEO_ENCODE_DECODE;
+         CUresult result = CUDA_ERROR_INVALID_VALUE;
+         CudaFunctions funcs = { 0 };
+         funcs.cuArray3DCreate = 0;
+         funcs.cuArrayDestroy = 0;
+         funcs.cuArray3DGetDescriptor = 0;
+         funcs.cuArrayGetPlane = 0;
+         (void)formats;
+         (void)flags;
+         (void)result;
+         (void)funcs"
+fi
+
 check_cpp_condition winrt windows.h 
"!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"
 
 if ! disabled w32threads && ! enabled pthreads; then
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 3c8faae3c8..f5d65c2c45 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "config_components.h"
 
 #include <stdatomic.h>
diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h
index 756192acd2..6d6267bcbd 100644
--- a/libavcodec/nvdec.h
+++ b/libavcodec/nvdec.h
@@ -47,7 +47,8 @@
 #endif
 
 // SDK 13.1 compile time feature checks
-#if NVDECAPI_CHECK_VERSION(13, 1)
+#if NVDECAPI_CHECK_VERSION(13, 1) && defined(HAVE_FFNVCODEC_CUARRAY) && \
+    HAVE_FFNVCODEC_CUARRAY
 #define NVDEC_HAVE_OPAQUE_OUTPUT_SUPPORT
 #endif
 
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index acde2a42c1..6d033b61f6 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -78,8 +78,10 @@ typedef void ID3D11Device;
 #if NVENCAPI_CHECK_VERSION(13, 1)
 #define NVENC_NEW_COUNTING_TYPE
 #define NVENC_HAVE_AV1_HGOP_SUPPORT
+#if defined(HAVE_FFNVCODEC_CUARRAY) && HAVE_FFNVCODEC_CUARRAY
 #define NVENC_HAVE_CUDA_ARRAY_INPUT_SUPPORT
 #endif
+#endif
 
 typedef struct NvencSurface
 {
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 61fbf52885..e9d725caeb 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -78,8 +78,10 @@ static const enum AVPixelFormat supported_formats[] = {
 
 #define CHECK_CU(x) FF_CUDA_CHECK_DL(device_ctx, cu, x)
 
+#if HAVE_FFNVCODEC_CUARRAY
 static CUarray_format cuda_array_format_for_pix_fmt(enum AVPixelFormat fmt);
 static unsigned int cuda_array_numchannels_for_pix_fmt(enum AVPixelFormat fmt);
+#endif
 
 static int cuda_frames_get_constraints(AVHWDeviceContext *ctx,
                                        const void *hwconfig,
@@ -89,15 +91,22 @@ static int cuda_frames_get_constraints(AVHWDeviceContext 
*ctx,
     enum AVPixelFormat req_fmt = config ? config->hw_format : AV_PIX_FMT_NONE;
     int i, nb_sw_formats = 0;
 
+#if !HAVE_FFNVCODEC_CUARRAY
+    if (req_fmt == AV_PIX_FMT_CUARRAY)
+        return AVERROR(ENOSYS);
+#endif
+
     constraints->valid_sw_formats = 
av_malloc_array(FF_ARRAY_ELEMS(supported_formats) + 1,
                                                     
sizeof(*constraints->valid_sw_formats));
     if (!constraints->valid_sw_formats)
         return AVERROR(ENOMEM);
 
     for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) {
+#if HAVE_FFNVCODEC_CUARRAY
         if (req_fmt == AV_PIX_FMT_CUARRAY &&
             !cuda_array_format_for_pix_fmt(supported_formats[i]))
             continue;
+#endif
         constraints->valid_sw_formats[nb_sw_formats++] = supported_formats[i];
     }
     constraints->valid_sw_formats[nb_sw_formats] = AV_PIX_FMT_NONE;
@@ -110,13 +119,21 @@ static int cuda_frames_get_constraints(AVHWDeviceContext 
*ctx,
         constraints->valid_hw_formats[0] = req_fmt;
         constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE;
     } else {
+#if HAVE_FFNVCODEC_CUARRAY
         constraints->valid_hw_formats = av_malloc_array(3, 
sizeof(*constraints->valid_hw_formats));
+#else
+        constraints->valid_hw_formats = av_malloc_array(2, 
sizeof(*constraints->valid_hw_formats));
+#endif
         if (!constraints->valid_hw_formats)
             return AVERROR(ENOMEM);
 
         constraints->valid_hw_formats[0] = AV_PIX_FMT_CUDA;
+#if HAVE_FFNVCODEC_CUARRAY
         constraints->valid_hw_formats[1] = AV_PIX_FMT_CUARRAY;
         constraints->valid_hw_formats[2] = AV_PIX_FMT_NONE;
+#else
+        constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE;
+#endif
     }
 
     return 0;
@@ -133,13 +150,17 @@ static void cuda_buffer_free(void *opaque, uint8_t *data)
 
     CHECK_CU(cu->cuCtxPushCurrent(hwctx->cuda_ctx));
 
+#if HAVE_FFNVCODEC_CUARRAY
     if (ctx->format == AV_PIX_FMT_CUARRAY) {
         AVCUDAArrayFrameDescriptor *desc = (AVCUDAArrayFrameDescriptor*)data;
         CHECK_CU(cu->cuArrayDestroy(desc->array));
         av_free(desc);
     } else {
+#endif
         CHECK_CU(cu->cuMemFree((CUdeviceptr)data));
+#if HAVE_FFNVCODEC_CUARRAY
     }
+#endif
 
     CHECK_CU(cu->cuCtxPopCurrent(&dummy));
 }
@@ -161,6 +182,7 @@ static AVBufferRef *cuda_pool_alloc(void *opaque, size_t 
size)
     if (err < 0)
         return NULL;
 
+#if HAVE_FFNVCODEC_CUARRAY
     if (ctx->format == AV_PIX_FMT_CUARRAY) {
         AVCUDAArrayFrameDescriptor *desc = av_mallocz(sizeof(*desc));
         if (!desc)
@@ -193,6 +215,7 @@ static AVBufferRef *cuda_pool_alloc(void *opaque, size_t 
size)
 
         goto done;
     }
+#endif
 
     err = CHECK_CU(cu->cuMemAlloc(&data, size));
     if (err < 0)
@@ -213,6 +236,7 @@ done:
 
 static void cuda_frames_uninit(AVHWFramesContext *ctx)
 {
+#if HAVE_FFNVCODEC_CUARRAY
     AVHWDeviceContext *device_ctx = ctx->device_ctx;
     AVCUDADeviceContext    *hwctx = device_ctx->hwctx;
     CUDAFramesContext       *priv = ctx->hwctx;
@@ -232,8 +256,12 @@ static void cuda_frames_uninit(AVHWFramesContext *ctx)
         av_freep(&priv->p.cuarray_surfaces);
         priv->p.cuarray_num_surfaces = 0;
     }
+#else
+    (void)ctx;
+#endif
 }
 
+#if HAVE_FFNVCODEC_CUARRAY
 static CUarray_format cuda_array_format_for_pix_fmt(enum AVPixelFormat fmt)
 {
     switch (fmt) {
@@ -276,6 +304,7 @@ static unsigned int cuda_array_numchannels_for_pix_fmt(enum 
AVPixelFormat fmt)
     default:                   return 3;
     }
 }
+#endif
 
 static int cuda_frames_init(AVHWFramesContext *ctx)
 {
@@ -285,7 +314,9 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
     CudaFunctions             *cu = hwctx->internal->cuda_dl;
     int err, i;
 
+#if HAVE_FFNVCODEC_CUARRAY
     CUcontext dummy;
+#endif
 
     for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) {
         if (ctx->sw_format == supported_formats[i])
@@ -297,10 +328,18 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
         return AVERROR(ENOSYS);
     }
 
+#if HAVE_FFNVCODEC_CUARRAY
     if (ctx->format == AV_PIX_FMT_CUARRAY && !cu->cuArrayGetPlane) {
         av_log(ctx, AV_LOG_ERROR, "cuArrayGetPlane not available, update your 
driver\n");
         return AVERROR(ENOSYS);
     }
+#else
+    if (ctx->format == AV_PIX_FMT_CUARRAY) {
+        av_log(ctx, AV_LOG_ERROR,
+               "CUarray frames require compatible ffnvcodec headers\n");
+        return AVERROR(ENOSYS);
+    }
+#endif
 
     err = CHECK_CU(cu->cuDeviceGetAttribute(&priv->tex_alignment,
                                             14 /* 
CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT */,
@@ -318,6 +357,7 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
 
     av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, &priv->shift_width, 
&priv->shift_height);
 
+#if HAVE_FFNVCODEC_CUARRAY
     if (ctx->format == AV_PIX_FMT_CUARRAY) {
         if (!priv->p.cuarray_desc.Width)
             priv->p.cuarray_desc.Width = ctx->width;
@@ -371,6 +411,7 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
         av_log(ctx, AV_LOG_DEBUG, "allocated %d CUarray surfaces (%zux%zu)\n",
                priv->p.cuarray_num_surfaces, priv->p.cuarray_desc.Width, 
priv->p.cuarray_desc.Height);
     }
+#endif
 
     if (!ctx->pool) {
         int size = av_image_get_buffer_size(ctx->sw_format, ctx->width, 
ctx->height, priv->tex_alignment);
@@ -396,18 +437,23 @@ fail:
 
 static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
 {
+#if HAVE_FFNVCODEC_CUARRAY
     AVHWDeviceContext *device_ctx = ctx->device_ctx;
     AVCUDADeviceContext    *hwctx = device_ctx->hwctx;
+#endif
     CUDAFramesContext       *priv = ctx->hwctx;
+#if HAVE_FFNVCODEC_CUARRAY
     CudaFunctions             *cu = hwctx->internal->cuda_dl;
 
     CUcontext dummy;
+#endif
     int res;
 
     frame->buf[0] = av_buffer_pool_get(ctx->pool);
     if (!frame->buf[0])
         return AVERROR(ENOMEM);
 
+#if HAVE_FFNVCODEC_CUARRAY
     if (ctx->format == AV_PIX_FMT_CUARRAY) {
         AVCUDAArrayFrameDescriptor *desc = 
(AVCUDAArrayFrameDescriptor*)frame->buf[0]->data;
         if (!desc) {
@@ -460,7 +506,9 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame 
*frame)
         res = CHECK_CU(cu->cuCtxPopCurrent(&dummy));
         if (res < 0)
             return res;
-    } else {
+    } else
+#endif
+    if (ctx->format == AV_PIX_FMT_CUDA) {
         res = av_image_fill_arrays(frame->data, frame->linesize, 
frame->buf[0]->data,
                                    ctx->sw_format, ctx->width, ctx->height, 
priv->tex_alignment);
         if (res < 0)
@@ -481,9 +529,11 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame 
*frame)
 
     return 0;
 
+#if HAVE_FFNVCODEC_CUARRAY
 fail:
     CHECK_CU(cu->cuCtxPopCurrent(&dummy));
     return res;
+#endif
 }
 
 static enum AVPixelFormat cuda_frame_hw_format(const AVFrame *frame)
@@ -525,6 +575,10 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
     {
         enum AVPixelFormat src_fmt = cuda_frame_hw_format(src);
         enum AVPixelFormat dst_fmt = cuda_frame_hw_format(dst);
+#if !HAVE_FFNVCODEC_CUARRAY
+        if (src_fmt == AV_PIX_FMT_CUARRAY || dst_fmt == AV_PIX_FMT_CUARRAY)
+            return AVERROR(ENOSYS);
+#endif
         if ((src_fmt != AV_PIX_FMT_NONE &&
              src_fmt != AV_PIX_FMT_CUDA && src_fmt != AV_PIX_FMT_CUARRAY) ||
             (dst_fmt != AV_PIX_FMT_NONE &&
@@ -555,8 +609,10 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
      *     subset of the planes.
      */
     for (i = 0; i < FF_ARRAY_ELEMS(src->data) && src->linesize[i]; i++) {
+#if HAVE_FFNVCODEC_CUARRAY
         int src_is_nonplanar_cuarray = 0;
         int dst_is_nonplanar_cuarray = 0;
+#endif
 
         CUDA_MEMCPY2D cpy = {
             .srcPitch      = src->linesize[i],
@@ -568,6 +624,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
         if (src->format == AV_PIX_FMT_CUDA) {
             cpy.srcMemoryType = CU_MEMORYTYPE_DEVICE;
             cpy.srcDevice     = (CUdeviceptr)src->data[i];
+#if HAVE_FFNVCODEC_CUARRAY
         } else if (src->format == AV_PIX_FMT_CUARRAY) {
             CUarray array;
             CUresult cures = cu->cuArrayGetPlane(&array, 
(CUarray)src->data[0], i);
@@ -583,6 +640,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
 
             cpy.srcMemoryType = CU_MEMORYTYPE_ARRAY;
             cpy.srcArray      = array;
+#endif
         } else {
             cpy.srcMemoryType = CU_MEMORYTYPE_HOST;
             cpy.srcHost       = src->data[i];
@@ -591,6 +649,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
         if (dst->format == AV_PIX_FMT_CUDA) {
             cpy.dstMemoryType = CU_MEMORYTYPE_DEVICE;
             cpy.dstDevice     = (CUdeviceptr)dst->data[i];
+#if HAVE_FFNVCODEC_CUARRAY
         } else if (dst->format == AV_PIX_FMT_CUARRAY) {
             CUarray array;
             CUresult cures = cu->cuArrayGetPlane(&array, 
(CUarray)dst->data[0], i);
@@ -606,6 +665,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
 
             cpy.dstMemoryType = CU_MEMORYTYPE_ARRAY;
             cpy.dstArray      = array;
+#endif
         } else {
             cpy.dstMemoryType = CU_MEMORYTYPE_HOST;
             cpy.dstHost       = dst->data[i];
@@ -615,8 +675,10 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
         if (ret < 0)
             goto exit;
 
+#if HAVE_FFNVCODEC_CUARRAY
         if (src_is_nonplanar_cuarray || dst_is_nonplanar_cuarray)
             break;
+#endif
     }
 
     if (!dst->hw_frames_ctx) {
@@ -925,5 +987,9 @@ const HWContextType ff_hwcontext_type_cuda = {
     .transfer_data_to     = cuda_transfer_data,
     .transfer_data_from   = cuda_transfer_data,
 
-    .pix_fmts             = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, 
AV_PIX_FMT_CUARRAY, AV_PIX_FMT_NONE },
+    .pix_fmts             = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA,
+#if HAVE_FFNVCODEC_CUARRAY
+                                                         AV_PIX_FMT_CUARRAY,
+#endif
+                                                         AV_PIX_FMT_NONE },
 };
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to